Skip to content

test(sync): check phone custody over every batch unit state - #24340

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/invariantcensus
Nov 2, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/invariantcensus

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Why

#24335 found three durable_status branches that told phones completed while batch units were still held. Released phones read completed as permission to mark the WAL synced and later age-delete their only independent copy. Each branch was found by reading code, about 12 days after it shipped (lane artifactmissing; risk review E4). A golden per branch would not catch a fourth.

What

Tests only. No runtime change.

  • Backend property test (backend/tests/unit/test_batch_pipeline_custody_property.py). It enumerates every per-unit job state:

    It covers one-unit uploads and unordered two-unit pairs (durable_status has no order dependence), beside every ledger shape (as admitted, partial, completed with held_audio, valid completed) and both settings of BATCH_PIPELINE_HELD_TERMINAL_STATUS_ENABLED. It asserts the answer is completed only when every unit is committed with no recovery or operator work owed.

  • Shared fixture (backend/tests/fixtures/custody_status_shapes.json). It pins every (status, reason_code, poll_after_ms) the sweep produces, split into resolved and unresolved. A new backend answer fails the backend test until it is added there.

  • Phone test (app/test/unit/custody_status_shapes_test.dart). It replays each unresolved answer through syncJobTerminalPolicy and real LocalWalSyncImpl reconciliation, and checks that a 14-day-old WAL is never acknowledged, never marked synced and never age-evicted. Only the resolved completed answer may acknowledge.

  • A one-paragraph pointer in CONTRACT.md and a kind:none mobile changelog fragment.

Assumption, stated in the test: a valid completed ledger is the projection's own all-units receipt, and is authoritative over job rows (test_status_is_durable_and_completed_result_is_authoritative). It is paired only with all-terminal units. If projection ever wrote completed early, this test would not see it; that needs its own projection-side property.

Fail-first evidence

Verification (layer: local unit tests, this head)

  • backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_batch_pipeline_custody_property.py, via bin/omi-heavy, nice 19: 3 passed. CPU time is about 0.4 s per sweep, under the 1.0 s guard; the sweep is cached between tests.
  • flutter test test/unit/custody_status_shapes_test.dart test/unit/held_partial_custody_test.dart test/unit/sync_job_terminal_policy_test.dart: 18 passed.

Deploy: none (tests only).

Product invariants: INV-DATA-1.

🤖 Generated with Claude Code

#24335 found three durable_status branches that answered `completed`
while units were still held, each caught by reading code, about 12 days
after it shipped. One golden per branch would not catch the fourth.

The new backend property test enumerates every per-unit job state
(in flight, committed, committed-but-held, each quarantine recovery
state, open operator intents) for one- and two-unit uploads, beside
every ledger shape and both held-terminal kill-switch settings, and
asserts `completed` only when every unit is terminal. Against the
pre-#24335 intake.py it fails with 282 (switch on) and 266 (switch off)
unresolved uploads answering `completed`.

Every answer it can produce is pinned in a shared fixture. The phone
test replays each unresolved answer through syncJobTerminalPolicy and
real WAL reconciliation, and checks that 14-day-old bytes survive. A new
backend answer therefore cannot reach phones without that check; adding
the old `completed/batch_unit_held` answer makes the phone test fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T04:28:24.561025Z
We couldn’t complete this review. Comment @codex review to try again.
aa3ab22 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@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.

All reported issues were addressed across 5 files

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

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

Luna r1 (P2): the reachable silence_disposition operator intent was not
enumerated. Add it, and sweep unordered two-unit pairs, since
durable_status has no order dependence; CPU stays about 0.4 s per sweep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 0302a15 into main Nov 2, 2026
72 of 74 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/invariantcensus branch November 2, 2026 05:40
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