Skip to content

Settle fully proved native WAL duplicates - #26135

Merged
Git-on-my-level merged 12 commits into
mainfrom
lane/wal-duplicate-settlement
Nov 23, 2026
Merged

Git-on-my-level merged 12 commits into
mainfrom
lane/wal-duplicate-settlement

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

SCA-3376 phase 2a.

  • Bind the canonical native intake to the immutable source generations and exact admitted sample slices. Compare staged Opus packet digests with the retained frame manifests, then revalidate object metadata and commit duplicate settlement under the Firestore source and privacy conflict set.
  • Require a unique whole-file match for every file. Initially qualify 16 kHz mono WALs and completed, single-target canonical jobs. Reject spans across archive sessions. All incomplete, ambiguous, historical or unqualified evidence stays held.
  • Read existing exact aliases before archive/retention and legacy status redrive, including with admission disabled. Concurrent retries and rebundles keep one file disposition and reuse the original handle. A compact, owner-fenced terminal receipt keeps exact upload and direct handle replay readable during the 45-day alias lifetime, including after the original canonical ledger and job expire.
  • Continue through existing upload coverage after fencing out any late commit, including for final-snapshot read failures. An uncertain commit RPC stays pending for exact replay. Legacy coverage preserves a concurrently committed settlement through a Firestore transaction retry. Phase 1 admission and commit share that record fence, so a competing handoff cannot invalidate an accepted duplicate alias.

Qualification and release

Dark carrier only. The approved Nov 24 sampler remains independent. Phase 2a shadow needs its own exact-window privacy approval, the sampler result, full custody review, and Release preflight and written go-ahead. The read-only bucket check found no lifecycle expiry for either backing prefix. Durable merge admission persists the preserve-or-remove decision. A non-erasure merge of a settled source retains its original proof and canonical handle, and atomically republishes a direct, bounded lineage when the successor merges again. Explicit erasure on either end invalidates replay. Unknown lineage writers defer. Older revisions can bypass the new ordering. Release must prove every serving writer and a compatible rollback target before enabling settlement. No live audio bodies, raw exports, new provider work or direct production writes.

The proposed shadow has one 24-hour window, 480 fleet-wide claims, at most 49,920 Firestore point reads, 9,600 GCS RPCs and 7.5 GiB of manifest downloads on admitted proofs. Slot contenders are separate. Fixed-label begin/commit/rollback attempt and outcome counters track up to 1,920 lifecycle RPCs per approved shadow window. Shadow commit attempts must be zero. Read back would-settle whole bundles/files and I/O before active rollout. Active proof limits are 105 point reads, 20 GCS RPCs and at most one alias, one terminal receipt and 20 file receipt writes. Exact replay uses a read-only view capped at 56 point reads through one verified successor. A direct status miss costs one point read, and a hit costs at most 11 including the privacy snapshot. Fixed-label lookup outcomes inform the Release budget. First settlement adds one donor-row write. Shadow keeps the 104-read per-proof cap. Only Release can enable after the settled preflight, measured active traffic caps, panel SHIP and a recorded inverse.

Release runs the 1%, 10%, 50%, 100% backend-sync ramp as each closed 24-hour check qualifies. Watch custody violations, shadow disagreement, store amplification, latency p99 and request errors. Stop new settlements on any custody violation or missing telemetry. Roll back with the percent at zero and the source gate off, keeping the readers deployed. Phase 2b paid recovery is outside this PR.

Testing

  • Synthetic qualification covers retained-donor lineage, replay, merge/deletion races, the 16/17-donor boundary Firestore lifecycle RPC instrumentation, and exact upload and direct poll replay after canonical TTL with account and conversation purge coverage. Covers packet ambiguity, missing/changed source, erase and concurrent CAS, disabled read-only replay, rebundles, and the original sampler/handoff contracts.
  • Metadata-only preflight, flag registry and exact-head pre-push checks.

Tuning

  • MAX_SLICES new: 128 per native intake attestation. Over-limit input exits to the existing hold path.

  • Initial canonical job limit is 4 and staged WAL limit is 20 files. Each seen source must prove all packet placements within the per-call I/O and two-second budget before committing.

  • MAX_RETAINED_DONORS new: 16. Above this limit, merge admission defers with sources intact.

Line-Count-Exception: backend/utils/sync/assignment.py | 1677 -> 1684 | Keep the seven-line custody guard adjacent to the existing transaction reads and before any sync ancestry rewrite.

Line-Count-Exception: backend/utils/batch_pipeline/intake.py | 1499 -> 1503 | Keep terminal receipt routing at the existing owner-scoped public status boundary, where it can precede the legacy redrive.

Failure-Class: FC-split-mutation-authority

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 23, 2026 16:40
@Git-on-my-level
Git-on-my-level merged commit 4729587 into main Nov 23, 2026
90 of 94 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/wal-duplicate-settlement branch November 23, 2026 17:01
Git-on-my-level added a commit that referenced this pull request Nov 23, 2026
…n red, shard 7) (#26161)

## What changed and why

Main has been red on Backend unit shard 7 since #26135 (`4729587c`).
Every case in `tests/unit/test_merge_validation.py` errors at setup:

```
ImportError: cannot import name 'get_firestore_client' from 'database._client'
```

#26135 added `from database.record_audio import
fence_record_audio_removal` to
`utils/conversations/merge_conversations.py`. That fixture loads the
module against a stubbed `database._client` that carries only `db`, so
the real `database.record_audio` → `pipeline_ledger` chain can't import.
The pure validation functions under test never call the fence, so the
fixture now stubs `database.record_audio` the same way it stubs the
other persistence modules. Test-only; no production code changes.

This blocks the backend roll that carries #26129 (Play Billing server
side), which is needed today for the Android test purchase before the
Google resubmission.

## Verification

From `backend/`, each file in its own process, as CI runs them:
- `tests/unit/test_merge_validation.py`: 50 passed. The unfixed file
gives 50 errors.
- `tests/unit/test_merge_conversations_canonical_delete.py`: 18 passed.
- `tests/unit/test_conversation_smart_merge_flatten.py`: 103 passed.

Rollback: revert this PR.

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26161?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26161?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26161&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 23, 2026
BasedHardware#26135 made merge_conversations import database.record_audio at module
scope. The fixture's database._client stub only carries db, so every
test_merge_validation case errored at setup and Backend unit shard 7
went red on main at 4729587. Stub the fence module like the other
persistence imports; the pure validation surface never calls it.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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