Skip to content

feat(sync): fill a closed record's missing retained tail from the owner's WAL (dark) - #24889

Merged
Git-on-my-level merged 15 commits into
mainfrom
claude/project-thread-cqxm31
Nov 8, 2026
Merged

Git-on-my-level merged 15 commits into
mainfrom
claude/project-thread-cqxm31

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

About 300 closed recordings are stuck in a circular wait. Their server-retained audio is empty or ends before finished_at, so admission refuses on every pass (retained capture (tail) not durable yet, about 16.2k retries from 20:56Z to 21:48Z on 2026-11-07) and the obligation has no TTL. Meanwhile the owner's phone still holds that audio, but its WAL upload gets record_jobs_missing (503) and keeps it.

This PR adds fill_closed_record_gap (backend/utils/batch_pipeline/record_gap_fill.py). It runs in registered_record_response's if not jobs: branch and writes the WAL's missing span as new retained objects, then returns the same 503 as before. The drain's next normal pass admits the record. Admission, validate_record_tail, barriers, the drain and projection are unchanged.

It ships dark: RECORD_GAP_FILL=off and RECORD_GAP_FILL_PERCENT=0 (uid-hashed cohort). This implements lead2's approved design (4965ba / 6aadfb) with conditions (a) to (d):

  • (a) Closed for at least 5 minutes. The fill needs finished_at and the row's updated_at to be at least 300s old (skipped_recent otherwise). On "not durable yet" vs eventual consistency: GCS object listing is strongly consistent; the gate waits 300s after the last row write; and the stuck records were refused on every 60s retry for the whole 52-minute window, so this is a missing tail, not listing lag.
  • (b) Pusher race, and who wins. Fill objects are lossless PCM16 at chunks/{uid}/{cid}/{start:.6f}.bin (.enc for enhanced protection). Every other chunks/ writer uses 3-decimal names, so no writer can address a fill object and a fill can't address theirs. The write is create-only with no overwrite fallback. A collision ends the fill, because an existing key doesn't prove it covers the span; a later upload continues from the new retained end.
    • A late pusher write creates its own object. The fill object's bytes and generation never change; the tests assert this through upload_audio_chunk, including its overwrite fallback.
    • In admission's walk, the object listed first owns overlapping frames. A later-starting pusher object only adds frames past the fill. One starting at the same instant lists first, so the server's own audio stays authoritative for the frames it carries.
    • A fill never starts before the retained end, so at write time it never overlaps retained audio.
  • (c) Counter before any ramp. omi_record_gap_fill_total{outcome}, plus event=sync_record_gap_fill outcome=… record=<16 hex> seconds_bucket=…. Logs carry no uid, conversation id, audio or error text.
  • (d) Phase 2 left out. audio_coverage_unproven is untouched.

The other gates, all required. These run on the database pool before any audio is read:

  • an owner-context match (checked earlier in the function);
  • no record jobs;
  • require_record_audio_barrier passes, and the record is not partial, deleted, discarded or sync-disabled;
  • the check_privacy fence, checked first;
  • a registered record_pending job for this record, so the drain will retry admission. A record that registration refused is never filled.
  • a 10-minute Redis marker per (record, WAL) on a client bounded to 0.5s. A Redis error lets the attempt through and is recorded with record_fallback.

Then, on the storage pool, admission's own retained walk must end more than 0.1s short of finished_at.

What gets written is clipped to [retained end, finished_at + 1s]. When nothing is retained it starts at started_at - 1s, and without a valid start there is no fill. It is capped at 3600s per request, in objects of at most 300s.

The fill must also be contiguous with the audio already held. Its first sample must be within 0.1s of the retained end (or within 1s of the start when nothing is retained), and it stops at the first WAL hole longer than 0.1s. Each WAL file is decoded on its own, because the shared decoder joins files up to 30s apart with silence, which would hide a hole. Admission checks only the final end, and batches can arrive out of order (the phone sends live recordings newest first), so a fill that skipped ahead could let a record admit with a hole.

Scope (lead2 bf6d91, option C). For a closed recording, the phone sends that recording's oldest pending 300s batch first, and after each record_capture_pending 503 it sends the same batch again. Only a gap that starts inside that first 300s window can recover; a record whose gap starts later stays stuck, as it does today. Two ways to widen this are out of scope here. One is releasing WALs once the server holds a byte-exact durable copy, a custody decision that is David's. The other is a client change to move past waiting batches, which would ride the app train.

Playback reads fill objects in both modes. The non-strict reader now resolves the listed 6-decimal path at the exact timestamp instead of rebuilding a 3-decimal key, and both modes share one download helper with no net growth in storage.py. The gates read the full conversation row fresh, with its Firestore revision as updated_at, because the serving row can be a field-masked provenance read. The counter label is the closed RecordGapFillOutcome enum, passed through reason_label().

Change note: backend/docs/listen_pusher_pipeline/changes/2026-11-07-record-gap-fill.md. The flag is registered in config/feature-flags.yaml, with its ramp of 1/10/50/100%, at least 30 minutes per step, and lead2's go at each.

Product invariants affected

none

How it was verified

  • pytest tests/unit/test_record_gap_fill.py tests/unit/test_sync_admission_diagnostics.py tests/unit/test_reason_label_enums.py: 88 passed. Every unit file that calls download_audio_chunks_and_merge (28 files) passes.
  • The neighbouring suites (every unit test touching live_upload, the record-wait cache, upload_audio_chunk or list_audio_chunks; 64 files): every file that failed in the combined run passes when run alone, except test_sync_cloud_tasks.py. That file fails the same 12 tests on the base commit in this sandbox, so those failures are cross-file ordering and environment issues, not this change.
  • make preflight: passed, 41 checks.
  • Not verified: anything in dev or prod. The switch stays off until lead2 gives the 1% go.

Tests

backend/tests/unit/test_record_gap_fill.py covers:

  • each gate refusing without a write: switch off or 0%, an open or unclosed capture, live producer tokens, upload failed, partial, a legacy owner, deleted, sync disabled, no finish, recently finished or recently written, a privacy block, no gap, and a retained-walk refusal;
  • the clip: the written bytes are exactly the in-window WAL PCM, and the retained object is untouched;
  • admission's real walk, validate_record_tail and the manifest reader passing after a fill, for standard and enhanced protection;
  • the unchanged _covered proof passing for the same WAL and failing for a different one;
  • create-only collisions and a racing writer, with no overwrite, and a collision with a shorter object stopping the fill;
  • key-space disjointness;
  • the late-pusher race at a later start and at the same start, plus a pusher commit between the retained listing and the create;
  • privacy checked before any retained read, and a missing record_pending job, both writing nothing;
  • contiguity: a WAL that skips ahead writes nothing, and a fill stops at a hole and resumes on a later upload, including a hole between real WAL files decoded by the real decoder;
  • an empty retained set with a missing or invalid start, which never fills;
  • the marker, plus Redis-outage fall-through;
  • log lines and the counter carrying only hashed keys;
  • non-strict playback reading a 6-decimal fill object;
  • the fresh row carrying the Firestore revision into the settle gate, and a missing conversation skipping;
  • the call site keeping the same 503.

UI evidence

UI-Evidence: none -- backend only

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS

…er's WAL (dark)

About 300 closed recordings were stuck: their retained audio is empty or
ends before finished_at, so admission refuses forever, while the phone's
WAL upload gets record_jobs_missing and keeps the audio. In the jobs-missing
branch, write the WAL's missing span as create-only, tagged PCM16 objects at
6-decimal keys no other writer produces, then return the same 503. The
drain's next normal pass admits the record, and the existing byte-exact
coverage proof releases the WAL later.

Off by default (RECORD_GAP_FILL, RECORD_GAP_FILL_PERCENT). Gates: closed
barrier, settled 5 minutes, privacy fence, admission's own retained walk
short of finish, a per-(record, WAL) marker. Counter
omi_record_gap_fill_total{outcome}; logs carry only hashed keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
storage.py is frozen by the line-count ratchet; the create-only writer
lives in record_gap_fill with an injected bucket.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T00:50:37.671635Z 619fb7e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

You’re at about 95% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread config/feature-flags.yaml Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89baa22a1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…y before any audio read

Review follow-ups: privacy and the record_pending obligation are checked
on the database pool before the retained listing; the marker uses a
bounded Redis client; the storage pool only does audio work. Registers
RECORD_GAP_FILL as an ops kill switch.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
…arker fallback

A WAL holding only a later span (newest-first uploads) no longer advances
the retained end past a hole that admission's final-end check would miss.
A Redis marker error is recorded through record_fallback.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS
… create

Also pins that an empty retained set with a missing or invalid start never fills.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 493c57c9b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22bdc4bcdb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ween files

decode_units joins files up to 30 s apart with zero PCM, which hid a real
hole from the contiguity check and could let a record admit across it.
Gap fill now decodes per file in capture order; tests cover the hole and
the contiguous case with the real decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bba17b892

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

A PreconditionFailed only proves the key exists, not that the winning
object covers the planned span. Continuing could write a later tail over a
hole that admission's final-end check would accept. The fill now stops;
the next upload resumes from the new retained end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS

Copy link
Copy Markdown
Member Author

Formatting fails on 1bba17b and on 152fd01 because of one long line in the wal_file test helper. The fix is black-only, sits locally as ef1c1d6, and changes no code. I'm holding it until the in-flight reviews on 152fd01 return so the push doesn't reset them. It will ship in the same push as any review fixes.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 152fd01548

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…sioned row

Non-strict playback rebuilt keys at 3 decimals, so gap-fill objects were
never read; both reader modes now resolve the listed path at the exact
timestamp through one download helper. Gap fill reads its own full
conversation row with the Firestore revision as updated_at, since the
serving row may be a field-masked provenance read without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS

Copy link
Copy Markdown
Member Author

The Backend unit shard 7/8 and Backend unit suite failures on 152fd01 are caused by this PR. test_reason_label_enums.py rejects the gap-fill counter's open outcome label. I fixed it locally in 1dee6a3: the label now uses a closed RecordGapFillOutcome enum and goes through reason_label(). That file passes locally, along with the gap-fill and admission suites. The fix is held for the same single push as the formatting fix, so the reviews running on 152fd01 aren't reset.


Generated by Claude Code

@Git-on-my-level
Git-on-my-level merged commit 0ec6def into main Nov 8, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the claude/project-thread-cqxm31 branch November 8, 2026 01:06
Git-on-my-level added a commit that referenced this pull request Nov 8, 2026
…4943)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

## What changes

Retro P6 adds `batch-pipeline-tuning-disclosure` to the shared manifest
in both local and CI lanes. Numeric capacity assignments and concurrency
environment defaults in the batch config, pipeline source, worker/pusher
charts, and `backend/utils/pusher_*.py` require numeric disclosures in
one PR-body section naming a matched knob: before/after, from/to, or a
nearby numeric arrow (`6 -> 4` or `6 → 4`). A knob with no removed
numeric assignment may instead use `new: <num>` or `initial <num>`.
Newly added literals directly assigned or compared to state-like names,
or passed as state/status/phase/disposition/outcome/reason kwargs, must
name an exit, terminal, dead-letter, re-entry, clear, or recovery path;
literals already anywhere in the merge-base tree are exempt.
`Numbers-waived: <reason>` and `State-exit-waived: <reason>` waive their
respective requirement and echo the reason.

HTML comments, fenced code blocks and inline code are stripped before
validating disclosures, state exits or waivers. Logging arguments and
literals merely near state-related words do not count as new states.

The same single manifest entry runs hermetic regression tests before
checking the body. Only changed lines trigger detection; flags,
comment-only lines, and unchanged context do not count. The detector
deliberately misses indirect/formula tuning: this is a disclosure
ratchet.

David approved this exact manifest and script/test change on
**2026-11-08 at 16:13Z**. No workflow file changed. The change is
limited to `.github/checks-manifest.yaml` and the two P6 files under
`.github/scripts/`.

## Why this check

The retro's #24481 HPA retune is the design precedent; the sweep below
exercises HPA bounds changes such as #24742. Its from/to wording is
supported, but its knob names are only in inline code, which the
requested prose-only rule excludes. Existing product-invariant and
failure-class checks validate different author declarations; neither
detects capacity knobs or new lifecycle literals. This check reuses the
manifest's existing diff/metadata plumbing without changing workflow
wiring or inventing another PR orchestration layer.

## Product invariants affected

none

Failure-Class: none

## Merged-PR false-positive sweep (2026-11-08T20:01:42.025036+00:00)

**200 merged PRs screened; 69 trigger-touching diffs checked; 16 would
fail and 53 would pass.** 14 failing PRs require numeric disclosures; 2
require state declarations (3 state literals total). The prior sweep
reported 18 failures; the refreshed capped corpus also advances its
merge cutoff.

Method: `gh pr list --repo BasedHardware/omi --state merged --search
'merged:>=2026-10-09' --limit 200 --json
number,title,body,mergeCommit,mergedAt,files`, followed by `gh pr diff
<number> --repo BasedHardware/omi` for matching paths. Full paginated
file lists were checked whenever the initial listing reached 100 files.
Each diff was checked against its PR body and reconstructed PR
merge-base: merge-parent merge-base for normal merges;
PR-head/merge-parent merge-base cross-checked with the recorded PR base
for one-parent merges. State candidates use a whole-tree lookup at that
merge-base.

The capped corpus spans **2026-11-04T12:58:21Z through
2026-11-08T19:20:24Z**: a sample within the requested 30-day window, not
full-month coverage. No production reads or GCP tier were used.

The stricter state association passes #24743 (the prior proximity-only
candidate). #24733 and #24729 now pass the expanded numeric wording. The
required inline-code stripping means #24742 still fails: its from/to
numbers are supported, but its matched knob names appear only in inline
code. #24884 and #24725 also fail when their state names are excluded as
inline code. These are explicit effects of the requested prose-only
policy, not claims that those historical PRs omitted all semantic
explanation.

Sample of would-fail PRs:

| PR | Detected change | Missing disclosure |
| --- | --- | --- |
| [#24889](#24889) | Tuning:
`max_count` | Initial/new numeric value naming a matched knob in prose,
before/after disclosure, or Numbers-waived |
| [#24884](#24884) | New state:
`record_barrier_aged` | State literal and exit declaration in prose, or
State-exit-waived (inline code is excluded) |
| [#24799](#24799) | Tuning:
`MIN_STORAGE_PCM_BUDGET_MB` | Initial/new numeric value naming a matched
knob in prose, before/after disclosure, or Numbers-waived |
| [#24742](#24742) | Tuning:
`maxReplicas`, `minReplicas` | Matched knob name in prose alongside the
existing from/to numbers |
| [#24736](#24736) | Tuning:
`PAGE_SIZE` | Initial/new numeric value naming a matched knob in prose,
before/after disclosure, or Numbers-waived |
| [#24725](#24725) | New state:
`marker_retry_overflow`, `marker_write_failed` | State literal and exit
declaration in prose, or State-exit-waived (inline code is excluded) |
| [#24716](#24716) | Tuning:
`limit` | Initial/new numeric value naming a matched knob in prose,
before/after disclosure, or Numbers-waived |
| [#24712](#24712) | Tuning:
`MAX_OWNER_DRAINS` | Numeric before/after, from/to or arrow disclosure
naming a matched knob in prose, or Numbers-waived |
| [#24710](#24710) | Tuning:
`MAX_DELAYED_OWNERS` | Initial/new numeric value naming a matched knob
in prose, before/after disclosure, or Numbers-waived |
| [#24707](#24707) | Tuning:
`MAX_HEAD_REQUEUES` | Numeric before/after, from/to or arrow disclosure
naming a matched knob in prose, or Numbers-waived |

All would-fail PRs: #24889, #24884, #24799, #24742, #24736, #24725,
#24716, #24712, #24710, #24707, #24703, #24697, #24689, #24680, #24643,
#24601.

## Validation

- **26 focused regression tests passed** on head
`1788dd10315e7a709dcaf6150838907638386ad0`, covering fenced/inline
examples, direct state association (including the logging regression),
from/to and arrows, and first-time versus changed numeric values.
- **`make preflight` passed all 14 selected local checks**, including 26
P6 tests and 78 manifest-contract tests, with `OMI_PR_BODY_FILE` and
`BACKEND_UNIT_FILE_BUDGET_SECONDS=900`. The normal bounded pre-push gate
also passed all 14 checks using the final body and the same budget, with
`GOOGLE_APPLICATION_CREDENTIALS` and every `CLOUDSDK_*` variable
removed.
- `scripts/pr-preflight --suggest` required no invariant citations;
`Failure-Class: none` is declared above.
- No workflow file changed; only the manifest and two P6 scripts differ
from the merge base.
- No production reads or GCP tier used. Full-month coverage beyond the
200-PR cap, indirect/formula tuning and product/runtime behavior are not
established by this check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Git-on-my-level added a commit that referenced this pull request Nov 9, 2026
…ined-copy ack (dark) (#24940)

## What changed and why

Follow-up to #24889 (closed-record gap fill, merged dark), built under
lead2's be4c23 after David's custody ruling e11df2 (option A). Two
parts, race fix first:

1. **Admission fence (lead2's hard condition 9d0efb / ca347f A).** The
fill now claims the drain's own lease on the `record_pending` job
(`available_at = now + 600 s`) in the same transaction as the privacy
fence, so `due` and the drain's `claim` skip the row while the fill
writes. A live lease is `skipped_busy`. After the write, one transaction
re-checks privacy and that the job is still `record_pending` under this
exact lease, then releases it; otherwise the outcome is `raced` (new
counter value) and the lease is left to whoever moved the job. Writes
stop on a piece boundary 60 s before the lease ends. Any create
collision is now always `skipped_collision`.
2. **Option A retained-copy ack.** Behind its own switch
`RECORD_RETAINED_ACK` + `RECORD_RETAINED_ACK_PERCENT` (both default
off), a jobs-missing upload whose fill ended `written` /
`skipped_no_gap` / `skipped_no_audio` / `skipped_marker` with a clean
settle gets the existing `covered_response()` 200 if
`record_retained_ack.prove` passes; the shipped phone then marks those
WALs synced and sends the next batch. The proof re-lists `chunks/` and
counts only lossless single-chunk `.bin`/`.enc` objects at 16 kHz in the
private-cloud-sync or derived audio bucket, read pinned to the listed
generation. Every WAL sample must equal the sample at the same capture
time in a counted object, inside `[started_at - 1 s, finished_at + 1
s]`; privacy is re-checked after the read. Everything else keeps today's
503. The WAL is decoded once and shared by the fill and the proof,
because decoding consumes the uploaded files.

**Hard condition:** `RECORD_GAP_FILL` stays off until this merges and
lead2 re-reviews the fence. The ack rides inside the fill entry, so it
is also off until then.

**Bucket lifecycle (read-only check via Coordkit):**
omi-private-cloud-sync only transitions `chunks/**.batch.{enc,bin}` to
Coldline (never counted, and not a delete); the derived bucket has no
rules. The batch-pipeline staging bucket (30-day delete) is never listed
by `list_audio_chunks`, and the proof now explicitly refuses to count
any object outside the two archive buckets.

Change note:
`backend/docs/listen_pusher_pipeline/changes/2026-11-08-record-gap-fill-fence-and-retained-ack.md`.

## Product invariants affected

none

## How it was verified

- `pytest tests/unit/test_record_gap_fill.py
tests/unit/test_sync_admission_diagnostics.py
tests/unit/test_reason_label_enums.py`: 117 passed.
- The 22 unit files that touch `live_upload`, `record_gap_fill`,
`registered_record_response` or `reason_label`: 1265 passed.
`test_sync_capture_time_skew.py` and `test_sync_cloud_tasks.py` fail 12
tests identically on clean `origin/main` (pre-existing, unrelated).
- `make preflight` and `scripts/pr-preflight --pr-body-file`: 40 checks
passed. `scripts/check_feature_flag_registry.py`: OK.
- Hermetic only: nothing here is deployment or live evidence.

## Tests

In `backend/tests/unit/test_record_gap_fill.py`:
- Fence: lease taken and released on the claim clock; a live lease
writes nothing (`skipped_busy`); `live.drain_recordings` run mid-fill
admits nothing and admits after; a job moved mid-fill (state change or
foreign lease) is `raced`, never acked, and its lease is untouched; a
privacy block at the recheck is `raced`.
- Option A: ack after a full fill (counter and log carry only the 16-hex
record key); retry gets the same answer with no new writes; switch off /
0 % keeps the fill outcome and reads nothing; one differing sample is
`skipped_bytes_differ`; a WAL hole the fill stopped at is
`skipped_uncovered`; gate refusals are never proven; privacy block at
the ack recheck is `skipped_privacy`; a replaced object fails the
generation-pinned read (`failed`); enhanced `.enc` fill objects count;
multi-batch walk (batch 1 already held, batch 2 filled) acks both and
admission's tail passes; real decoder on real WAL files; Opus /
`.opus.enc` / batch / raw-live sources never count or get read; WAL
outside the record window is refused before any listing; objects outside
the archive buckets never count; the call site answers the covered 200
when acked and keeps the 503 otherwise.

## UI evidence

UI-Evidence: none -- backend only

## Failure class (fixes)

Failure-Class: none

---
_Generated by [Claude
Code](https://claude.ai/code/session_017CeWy3fepTWkruwXu3wafS)_

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24940?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/24940?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24940&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. -->

## Tuning

Both knobs are new and only bound the dark retained-ack proof
(RECORD_RETAINED_ACK, default off).
- MAX_LOSSLESS_OBJECTS new: 128. Before: 0 pinned reads per upload,
because the proof did not exist. After: at most 128 lossless objects
pinned and read per proof. A larger set refuses the proof and keeps
today's 503.
- max_count new: 4096 on the retained-ack archive listing. Before: 0
listings per upload. After: at most 1 listing of up to 4096 objects per
proof, the same bound the record seal/orphan repair listings use.
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