Repository navigation
Mid Cuts v2: /v2/narrate pipeline + NarratedScene contract v1.2.0 - #71
Merged
Merged
Conversation
…igin proxy guard Phase 1 (bucket + security) of Mid Cuts (Small Cuts v2). Surgical, in-place, backward-compatible: every new env var is optional and defaults to today's behavior, so the live macayaven/small-cuts Space is unaffected when unset. - hf_relay.py: SMALL_CUTS_RELAY_READ_TOKEN -> HfFileSystem(token=...) (fixes the latent tokenless read on a private bucket, DESIGN §7 #2); SMALL_CUTS_RELAY_ BUCKET_PRIVATE -> fail-closed boot guard refusing direct-media (cross-origin resolve) URLs against a private bucket, and proxies clip+audio same-origin so Safari can load + seek the video. - postcut.py: SMALL_CUTS_RELAY_WRITE_TOKEN -> HfApi(token=...) (fixes the tokenless write, DESIGN §7 #1). - tests: token isolation (CI mock + gated live cutover gate, verified live against macayaven/mid-cuts — read reads, read cannot write 403); same-origin Range/206 contract (Safari seek); Modal write-token AST contract. verify: ruff check + ruff format --check + pytest -> 336 passed, 2 skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…end interface Phase 2 foundation for /v2/narrate (Mid Cuts), greenfield + importable so it is unit-tested (modal isn't in the CI venv). build_narrated_scene emits a NarratedScene that validates against narrated-scene.schema.json v1.1.0 by construction — real uuid scene_id (§7 #4), only schema keys with provenance under engine{} (§7 #3). publish_scene uploads media before scene.json so a relay globbing uploads/*/scene.json never sees a scene whose media is missing (§7 #6). NarrationBackend is the swappable seam (mock backend included; the Omni backend lives in the Modal app). verify: ruff + pytest -> 344 passed, 2 skipped (8 new narrate_v2 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…bucket Greenfield Phase 2 endpoint (never touches the live macayaven/small-cuts Space). Ports the proven Qwen3-Omni invocation from the phase-0 probe, builds a contract-valid scene via small_cuts.narrate_v2, validates it (format-checked, §6) and publishes media-before-scene.json to the private macayaven/mid-cuts bucket with the write-only token from the "mid-cuts" Modal secret. Bearer is timing-safe + fail-closed (§7 #5); uploads capped at 30 MB / 30 s; scale-to-zero, GPU bounded. CPU ::smoke + GPU ::e2e entrypoints. Adversarially verified (writer/relay round-trip, security, Omni-port fidelity = all clean); applied the format-checker + zero-frame guards it surfaced. modal isn't importable in CI, so config/safety is asserted via AST/source (tests/test_midcuts_narrate_config.py). verify: ruff + pytest -> 351 passed, 2 skipped; CPU smoke green (mock backend -> contract-valid scene). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ontract-change]
Additive/minor, lockstep. Adds optional timed_captions:[{t_start,t_end,text}] (speech-relative,
aligner-produced) to NarratedScene for the viewer CC track + accessibility; bumps schema $id to
1.2.0 and the golden sample. Not in `required`, so existing producers/consumers (emitting 1.1.0,
no captions) still validate — the live Space is unaffected. Ratified by Carlos (DESIGN §6).
Consumers updated in this lockstep series: the v2 writer (small_cuts.narrate_v2) emits the cues,
the viewer renders them via the existing data-sc-cues path + a CC toggle. iOS is inert (it consumes
ControlFrame/SceneAudio, not NarratedScene).
verify: pytest -> 351 passed, 2 skipped (contract golden validates at v1.2.0).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ve timed_captions Adds the writer-side caption support for the v1.2.0 timed_captions field. carrier_cut_index finds where the spoken warm-up carrier ends (normalized char-accumulation match, robust to aligner segmentation + do_sample-varied duration); cues_from_words drops the carrier words and rebases the real narration's aligned word times to the trimmed audio, grouping into ~5-word cues. build_narrated_scene now accepts an optional timed_captions list (omitted when absent → still v1.1.0- shaped). The v2 app will feed the aligner output through these to populate the scene. verify: ruff + pytest -> 355 passed, 2 skipped (4 new caption tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sion-truth guard [contract-change]
Phase 3 of Mid Cuts (Small Cuts v2): complete the additive/minor v1.2.0 bump (lockstep).
- schema: add optional `duration` (authoritative playback = narration/voice-audio length,
NOT clip length) + `keyframe_time` (poster-frame offset, provenance). Tighten
`contract_version` pattern -> enum[1.1.0,1.2.0]. Add an `allOf` if/then "version-truth"
conditional so any scene carrying duration/keyframe_time/timed_captions must stamp 1.2.0
(a producer can no longer emit new fields under the old version).
- narrate_v2: CONTRACT_VERSION 1.1.0 -> 1.2.0; build_narrated_scene emits the two new
optional fields.
- midcuts_narrate (v2 producer): emit duration = len(wav)/sample_rate and keyframe_time.
- tests: golden gains the fields; new version-truth test + a 1.1.0-subset-still-valid test.
- docs: README changelog + contracts CLAUDE.md header.
Legacy v1 producers stay stamped 1.1.0 (they emit only the 1.1.0 subset; engine{} is NOT
1.2.0-only). Panel-reviewed (GLM 5.2 + GPT-5.5); full gate green; adversarial diff review clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Greenfield Mid Cuts (Small Cuts v2) narration pipeline plus the lockstep NarratedScene contract v1.2.0 bump. A user records a ≤30s clip → Modal
/v2/narrateruns Qwen3-Omni (whole-clip, deadpan voice) → builds a contract-validNarratedScene→ publishes to the privatemacayaven/mid-cutsbucket. This is the focused, Safari-fix-free slice of the work (the unrelatedfix/safari-stage-widthviewer commit is intentionally not included).Consolidates the previously-unmerged Mid Cuts Phases 1–3:
mid-cutsread/write tokens, same-origin media proxy + boot guard, token-isolation + Range/206 tests/v2/narratecontract-change)Contract change — NarratedScene v1.2.0 (additive / minor, lockstep)
timed_captions,duration(authoritative playback = narration/voice-audio length, not clip length),keyframe_time(poster-frame offset; provenance).contract_versiontightenedpattern:"^1\."→enum:["1.1.0","1.2.0"].allOfif/then: any scene carrying a 1.2.0-only field must stamp1.2.0— a producer can no longer emit new fields while claiming the old version.1.1.0(they emit only the 1.1.0 subset;engine{}is not 1.2.0-only — the live engine emits it under 1.1.0).Components
docs/contracts/narrated-scene.schema.jsonsrc/small_cuts/narrate_v2.pybuild_narrated_scene, atomicpublish_scene, backend interface + mock)modal_app/midcuts_narrate.py/v2/narrateapp (Bearer-gated, 202 + result), emitsduration/keyframe_timesrc/small_cuts/hf_relay.pydocs/contracts/README.md,CLAUDE.mdtests/*Usage
Test coverage
Local gate green on this branch —
ruff check✓ ·ruff format --check✓ ·pytest✓ (exit 0). Contract-specific: golden-sample validation, version-truth (a 1.2.0 field under a 1.1.0 stamp is rejected; a 1.1.0 subset still validates), writer conformance (real uuids, only-schema keys,engine{}, emits/omits the new optional fields), atomic media-before-scene publish ordering, relay token-isolation, Safari Range/206.Review notes
durationalready meant audio length in existing consumers — defining it as clip length would have been a valid-but-wrong semantic break.source/source_iconin the relay, top-level provenance in oldpostcut.py);build_narrated_scenedefaultsvisibility="public"; alang/locale field for the 10-language selector; real keyframe selection sokeyframe_time≠0.0.🤖 Generated with Claude Code