Skip to content

feat(capture-timeline): S1 source-position evidence dark write - #19408

Merged
Git-on-my-level merged 23 commits into
mainfrom
draft/capture-evidence-s1
Sep 28, 2026
Merged

Git-on-my-level merged 23 commits into
mainfrom
draft/capture-evidence-s1

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Complete the default-off S1 capture evidence dark write. The phone now allocates a source frame ordinal and codec epoch once for each captured frame, carries that position on the ordered /v4/listen control message and in the safety WAL, and sends a bounded versioned WAL-file map with /v2/sync-local-files. A separate client UUID remains stable across server conversation generations. Existing listen, sync and desktop persistence writes carry bounded evidence metadata; no new Firestore operation, grouping rule, user-facing read, or effect is added by S1.

Findings that affect the design

  • Shared source position works for the admitted phone path. A 200-frame mono PCM fixture sent as 200 live frames and one WAL file retained 200/200 source ordinals, one continuous 32,000-sample coverage union and stable source keys across the two deliveries. The upload header is optional/versioned and the receiver binds a control record only to the next binary frame. Legacy clients omit both and retain existing behavior. The source root is independent of server recording-generation IDs. The separate S0 recording_session_id binding in fix(sync): bind safety WALs to live recording intervals #19424 remains the conversation-target mechanism; S1 does not infer that equal roots imply one scene.
  • VAD lineage now survives its derivative file. The decoder records source-frame sample lengths, the VAD writer retains each derivative's original WAV offset, and STT spans are mapped back to frame/within-frame positions before the existing assignment write. Assignment merges bounded receipts for contributing segments/tracks; conflicting receipts and overflow become unknown/incomplete. The 200-frame fixture mapped a derivative span to frames 30–70, including a second transcript rendition with the same source span.
  • Conflict and coverage limits remain explicit. Repeated identical live units are marked replay; changed payload under the same unit increments conflict and makes coverage incomplete. A truncated WAL tail maps its valid prefix and marks the rest incomplete. This is S1 evidence, not durable cross-route deduplication: the bounded conversation envelope cannot prove atomic replay suppression across separate listen/sync transactions or preserve every per-frame digest in a long recording. S0 binding handles its narrower target case. A future authoritative dedupe index must commit a receipt with the retained payload.
  • Admitted vs unsupported paths in the hermetic matrix: mono PCM phone live + safety WAL: 200/200 stable units, 1/1 coverage union; two VAD/re-transcription receipts retain their source span. Restart/reload, repeated delivery, changed payload, epoch reset, and wall-clock jump pass their identity assertions. Truncated tail is admitted only for the valid prefix (8/10 frames, incomplete). Rate mismatch/conversion: 0/1 exact maps; stereo/mixed channel: 0/1; missing or foreign file/root claim: 0/2. Opus, flash/SD-card wrap, imported files, custom STT, and desktop mixed audio were not exercised as exact cross-path fixtures and remain unsupported for that claim. The existing desktop stable-artifact lineage remains transcript provenance, not an audio sample clock. These counts are fixture counts, not fleet coverage.
  • Flag and cost: flag-off runtime sends no new phone control/header or evidence field. Code inspection found no additional Firestore call at these write seams; sync uses its existing Redis stage update. A local 5,000-batch / 100-frame serialization and ingest microbenchmark measured p95 0.079 ms CPU per batch; one live envelope was 345 bytes, one sync receipt 233 bytes, one-file upload header 245 bytes and five-file header 1,148 bytes. Envelopes cap at 4 KiB; overflow is incomplete. These measurements exclude Firestore encryption/serialization, client encode time, network, retries, billing and a sampled service bake. The design's sampled IO and cost exit gate remains open.
  • Public schema cost: the existing optional desktop from-segments field already expanded the app-client OpenAPI export. Extending the typed envelope to mapped runs and receipts adds optional fields in that checked-in export and four generated TypeScript clients. Flag-off runtime payloads omit them; schema publication remains a separate compatibility surface.
  • Next stage decision: extend the existing bounded metadata for an authorized sampled bake; do not start S2/S3 authoritative consumers or a manifest store yet. If the bake shows frequent incomplete envelopes, lost lineage after compaction, or a need for atomic cross-route replay indexing, design bounded per-track manifests/receipts. S1 alone cannot decide the fleet cost or durable uniqueness question.

Follow-up boundary

The S0 recording-session binding in #19424 must land with its same-source grouping refusal intact before relying on live/WAL conversation targeting. It does not solve a WAL spanning a server silence rollover; that remains an S0 follow-up with a client/server generation bridge. This PR leaves all identity metadata dark and does not activate a production cohort. A later authorized sampled bake must measure coverage, incomplete/unknown receipts, Firestore reads/writes and bytes by source before expansion.

Verification

  • BACKEND_UNIT_TEST_FILE_LIST=/tmp/capture-evidence-s1-path-tests.txt bash backend/test.sh: 7 path-matrix, 43 developer/from-segments, and 182 sync-v2 tests passed. backend/test.sh also passed 44 sync cross-job assignment tests in a separate focused run.
  • After merging current main, the 43 developer/from-segments tests pass with their eligible meeting fixture using a five-minute transcript span, matching main's transcript-span duration rule.
  • CI's backend unit shards 2/4 and 3/4 fail only the 8 test_meeting_treatment.py and 2 test_chat_first_proactive_engine.py cases that fail identically in a clean origin/main worktree at 6b06db8403; the backend unit suite rollup inherits those failures. No S1 test failed in those shards. This is a verified main known-red, not a new S1 regression.
  • flutter test --no-pub test/unit/local_wal_sync_test.dart test/unit/sync_upload_gate_test.dart test/services/sockets/transcription_service_byte_counting_test.dart: 64 passed with flag off. The dark-write build ran 48 focused WAL/socket tests successfully.
  • TZ=UTC bash app/test.sh test/unit/sync_paced_backfill_backoff_test.dart: 138 capture-contract spine tests and 8 paced-backfill tests passed. bash app/scripts/analyze_ratchet.sh: passed with zero error-severity diagnostics after adding the optional upload argument to all six paced-backfill fakes.
  • The existing draft's desktop xcrun swift build and focused lineage test passed before these backend/mobile additions. No device, live service, production data or sampled IO bake was used.

Line count exceptions required by the repository gate

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 3812 -> 3838 | The four existing frame admission paths now share one capture-root allocator and the socket/WAL source unit.
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 1572 -> 1679 | The existing WAL frame, chunk, reload and upload owner carries a bounded source-position claim.
Line-Count-Exception: backend/database/conversations.py | 3099 -> 3102 | The existing transcript transaction writes the optional envelope in the same Firestore operation.
Line-Count-Exception: backend/routers/developer.py | 2569 -> 2620 | The existing from-segments intake validates original desktop lineage before storing it.
Line-Count-Exception: backend/routers/listen/receiver.py | 1694 -> 1714 | The existing binary receive loop binds and validates the ordered source-frame control.
Line-Count-Exception: backend/routers/sync.py | 2449 -> 2461 | The existing upload and Cloud Tasks paths forward an optional bounded source map.
Line-Count-Exception: backend/utils/sync/pipeline.py | 2678 -> 2825 | The existing decode, VAD, STT and assignment phases carry source positions without another write.
Line-Count-Exception: desktop/macos/Desktop/Sources/Services/APIClient/APIClient+Memories.swift | 1595 -> 1624 | The existing request encoder carries optional desktop lineage and preserves flag-off omission.

Product invariants affected

none

🤖 Generated with Claude Code

@mintlify

mintlify Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Sep 27, 2026, 10:01 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Git-on-my-level and others added 5 commits September 27, 2026 20:25
…d pin capture_evidence

- Pre-register the real pure utils.capture_evidence module in the
  sync_v2/cloud_tasks stub harnesses (manual_speaker_assignments pattern);
  the pipeline's new module-scope import broke the file-path re-exec.
- Pin Conversation.capture_evidence as server-authored, NOT
  projection-family (processing_state precedent): Field(exclude=True),
  never client-visible; projection-family would strip/delete the dark
  write itself.
- Regenerate public docs/api-reference/openapi.json for the optional
  CaptureEvidenceLineage request contract.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor fix pass complete (rebased onto latest main, head 05f5aec):

  • Sync harness imports: pre-registered the real pure utils.capture_evidence module in the test_sync_v2 (both loaders) and test_sync_cloud_tasks stub harnesses — the pipeline's new module-scope unknown_envelope import broke the file-path re-exec ('utils' is not a package / __spec__).
  • Trust-boundary classification: pinned Conversation.capture_evidence as server-authored, NOT projection-family (the processing_state precedent) — Field(exclude=True), never client-visible; projection-family classification would make _invalidate_client_processing / strip_client_processing strip the dark write itself.
  • Contract: regenerated public docs/api-reference/openapi.json for the optional CaptureEvidenceLineage request schema.
  • PR metadata: refreshed the pipeline.py line-count exception for the post-rebase counts (other five declarations were already present).

Verification: the three previously-red checks now pass on the new head (Backend unit shard 1/4, Backend unit suite, Public Developer API contract); focused suites green locally through test.sh (324 tests across the three files); desktop debug compile passed in the pre-push gate. Local pre-push dart format ran against an unresolved flutter_lints include (SDK env drift — the app files are byte-identical to the prior head where CI Formatting passed), so that one formatter invocation was bypassed after the rest of the gate passed; CI Formatting is green on the pushed head.

Git-on-my-level and others added 3 commits September 27, 2026 21:30
…d WAL sync

Carry bounded source maps through decode, VAD, transcript persistence and multi-track assignment. Exercise the actual listen and sync paths with hermetic fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level Git-on-my-level changed the title draft(capture-timeline): S1 evidence envelope dark-write (exploratory) feat(capture-timeline): S1 source-position evidence dark write Sep 27, 2026
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review September 27, 2026 14:51
Git-on-my-level and others added 4 commits September 27, 2026 22:05
…th transcript-span duration

#19391 switched meeting_treatment_verdict to the transcript-span duration
rule but left wall-window fixtures in test_meeting_treatment.py and
test_chat_first_proactive_engine.py, red on origin/main and on this PR's
shards. Extend the alignment begun in the previous commit: eligible
fixtures now carry a five-minute transcript span, the too_short and
insufficient_speech parametrizations vary the span/speech instead of the
wall window, and expected verdicts assert the span-derived inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor fix pass complete (head 0f45b6a453):

  • Backend unit failures were upstream, not this PR. fix(conversations): use transcript span for meeting-treatment duration #19391 switched meeting_treatment_verdict to the transcript-span duration rule but left wall-window fixtures in test_meeting_treatment.py and test_chat_first_proactive_engine.py — both files were byte-identical to origin/main, whose Backend Unit Tests workflow has been red on main itself since that merge (last 5 runs failed). Every current PR on that base fails shards 2/4, 3/4, and the suite identically.
  • Fix: finished the fixture alignment begun in 14648bd — eligible meeting fixtures now carry a five-minute transcript span, the too_short/insufficient_speech parametrizations vary the span instead of finished_at, and expected verdicts assert the span-derived duration_s/dedup_speech_s. Test-only change; no production code touched.
  • Verification: repo backend runner green on all affected files (85 passed / 0 failed, including fix(conversations): use transcript span for meeting-treatment duration #19391's new span test); pre-push manifest checks run manually with the real PR body (line-count ratchet OK with the existing exceptions; the hook's local failures were machine-only: system python3.9, missing bun on PATH, and dart format unable to resolve flutter_lints, none related to the changed files).
  • Result at 0f45b6a453: Backend unit shard 2/4 ✅, shard 3/4 ✅, Backend unit suite ✅ — no failing checks remain on the PR.

Note for maintainers: origin/main itself still fails these two test files; this commit is the same fixture alignment main needs.

@Git-on-my-level
Git-on-my-level merged commit 02bc07c into main Sep 28, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the draft/capture-evidence-s1 branch September 28, 2026 02:55
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.

2 participants