Skip to content

fix(playback): keep size-gapped probe bytes usable - #447

Closed
randrini wants to merge 1 commit into
mainfrom
fix/size-mismatch-tolerance
Closed

randrini wants to merge 1 commit into
mainfrom
fix/size-mismatch-tolerance

Conversation

@randrini

Copy link
Copy Markdown
Collaborator

Problem

The virtual probe gate treated a served-vs-declared size gap as a hard failure. In this deployment the provider listing and the bytes the storage layer serves differ by a normal margin (one observed row: 4,269,999,999 bytes declared, 3,743,905,729 served). The probe rejected the candidate, refused to persist its inventory, and some starts ended in virtual_source_unavailable or transcode_start_failed. The catalog row kept its declared placeholder, so the versions list and action bar could not show the real tracks.

Rule

Size decides release identity, not usability.

  • A size gap with no contradicting measurement returns Unverified. The probe's tracks and duration are written to the row metadata-only, the file is planned and played, and clients see the measured inventory. The evidence is not cached as authoritative, does not stamp probe_updated_at, and does not pin the candidate.
  • A measured duration that contradicts the catalog runtime beyond the existing 30% tolerance still returns Mismatch.
  • A declared video release whose probe measured audio-only with a measured container also returns Mismatch.
  • Size never produces Mismatch. The 2.0x plausibility ratio now only limits whether a repeated serve can establish identity.

Every acceptance path calls one gate, ClassifyVirtualServedEvidenceForProbe: fresh probe, cache hit, sibling fallback, substitution and persist. The persist seam no longer reclassifies size with a different pin key; it only re-enforces the duration contradiction. That removes the case where one path accepted bytes another refused.

Production trace

For file_id=1215236, the row declared 4,269,999,999 bytes and the probe served 3,743,905,729, about 12% short and inside the normal band. The old classifier required a positive duration proof to keep a size gap usable; when the probe reported no usable duration it returned Mismatch. That armed the wrong-source damper, unpinned the candidate, and rotated to siblings. When no sibling passed, the start failed as virtual_source_unavailable or transcode_start_failed. The old persist gate also refused the inventory, so the row kept its placeholder. A test covers the same 6.33 GB / 5.57 GB and unknown-duration shape.

Tests

  • internal/scanner/virtual_probe_guard_size_test.go: a size gap stays usable and unverified; a duration contradiction rejects; a track-layout contradiction rejects; the read-only and recording entry points agree.
  • internal/api/handlers/playback_virtual_probe_size_mismatch_test.go: a size gap persists metadata-only inventory and resolves a playable source; the second serve stamps it; an implausible gap never admits; sibling fallback now triggers on an identity contradiction, not a size gap; permissive and strict paths agree.
  • The snapshot tests are updated to the new rule.

Verification

  • go build ./...
  • go vet ./internal/api/handlers ./internal/scanner ./internal/playback ./internal/virtuallibrary
  • go test -count=1 ./internal/api/handlers ./internal/playback ./internal/virtuallibrary: handlers and virtuallibrary pass. Two playback failures also fail on a clean worktree at kipsilabs/main: TestOnDemandSubtitleSegmentsDoNotWaitForTheStream, TestServeExtractDiscardsACappedDemuxCopy.
  • go test -race on the new and changed scanner and handler tests.
  • make verify-playback-fixtures: matrix unchanged.
  • make lint-changed BASE_REF=kipsilabs/main in the vips container: 0 issues.

Posted by an AI agent (Muse Spark, OpenCode harness).

Separate release identity from usability in the virtual probe gate. A
served-vs-declared size gap no longer rejects a candidate: the probe's
measured inventory is written metadata-only, planned and played, while
the verdict stays Unverified and never stamps the row or pins the
candidate. Duration or track-layout contradictions still reject as a
different file, and every acceptance path now uses one classification
entry point so the fresh-probe, cache, and persist seams agree.
@randrini

Copy link
Copy Markdown
Collaborator Author

Superseded by #459, which contains this change plus the rest of the playback reliability bundle. Closing to keep the review surface to one PR.

@randrini randrini closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant