Repository navigation
fix(storage): Refuse a usage-rollup publication that retired nothing - #5440
Conversation
…ation tests/unit/daemon/test_daemon_cli.py had six failures on master that predate the current merge wave (identical set at cba0480). Three distinct causes, none of them the same defect. A required session_usage_rollup key whose session row is not yet committed took the retirement branch of publish_session_usage_rollup, which returned True after deleting nothing. The convergence kernel reads "publish accepted, required output still missing" as a broken publication, so a live intake hint naming a session before ingest committed it produced a FAILED key instead of the retryable race it is. Deleting nothing is the discriminator: an excess key always has a binding row to retire, a required one does not. The audit-schema-mismatch test wrote PRAGMA user_version = 1, which stopped being a mismatch when the schema floor was reset (b56699c, #5275); the test kept passing through a gate it no longer exercised. The skew is now derived from the declaration, and backward, because a forward version is refused earlier by the durable change train's forward-admission check -- a different contract. The watcher test asserted one session-scoped pass per admitted version with done == 1. Session scope now carries three ordered domains and one pass converges several, so that count named nothing. It now asserts what canonical derivation owns: the profile domain reaches DONE and no session-scoped key is reported as a broken publication. Its index reads also raced the replace that follows a returning intake pass, and its profile row is sampled across the settle window rather than read once, because publication and withdrawal are a cycle the stopped daemon does not finish. Verification: devtools test tests/unit/daemon/test_daemon_cli.py -> 107 passed (base 5204d0e: 101 passed, 6 failed). Adjacent session derivation/convergence suites: 86 passed. devtools verify --quick passed. Each fix executed against its own mutation: restoring the retirement branch reddens all four watcher params with the broken-publication error; replacing the durable_schema_mismatch gate with False reddens the audit test; dropping the writer lease across replay reddens the lease test at replay_held == [1], so adding archive_root to FakeArchive did not weaken it. usage_rollup.py is IN the derived schema closure: index identity moves be8d4619 -> 0d03d682, so the archive must reconverge. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
|
Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 189581eaa0
ℹ️ 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".
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Repairs the six long-standing failures in
tests/unit/daemon/test_daemon_cli.py, which turned out to have three distinct causes — including one real product defect. 101 passed / 6 failed at base5204d0e9e; 107 passed / 0 failed at head, with no previously-passing test in the file regressed.These six had been re-reported as "inherited reds" by three separate lanes without being owned, so they were costing attention on every run.
1. Product defect —
publish_session_usage_rollupreported success after deleting nothingIts retirement branch returned
Trueunconditionally. A required key — a live intake hint names a session before ingest commits the row — hit that branch, so the convergence kernel saw "publish accepted, required output still missing", which it deliberately classifies as a broken publication, and recorded FAILED.The delete's
rowcountis the honest discriminator: an excess key always has a binding row, a required one does not. No binding row means nothing was retired, so the publication refuses and the key converges on a later pass — which is the retryable race it actually was.Confirmed by instrumenting both branches and observing
DBGBRANCH retireimmediately before the FAILED, rather than inferred from reading.2. Stale test —
..._parks_operation_recovery_on_audit_schema_mismatchThe test wrote
PRAGMA user_version = 1to manufacture a mismatch.b56699c80(#5275, "Fresh schema floor") setARCHIVE_FORMAT_FLOOR_VERSION = 1, and audit's declared version is that floor — so the write became a no-op,durable_tier_schema_mismatch()returned False, and recovery was correctly called. The gate was never broken; the test stopped producing its own premise. The skew is now derived from the declaration and deliberately backward, because a forward version is refused earlier by the durable change train's forward-admission check — a different contract.3. Harness defect —
..._holds_writer_lease_through_replayRawObservationDerivation.publishbegan pinning its membership read throughopen_operation_readin3faacef23(#5023). That read captures the view fromarchive.archive_rootandarchive.index_db_path, which the test'sFakeArchivenever grew. Both were added to the double, not loosened in the production read.pin_operation_snapshotstays absent becauseoperation_context.pyexplicitly declares that minimal-double path.Verification
All three mutations executed and refuted:
session_usage_rollup ... FAILED ... 'publish reported success but the required output remains missing',assert 1 == 0durable_schema_mismatchgate withFalse->AssertionError: Expected 'mock' to not have been called. Called 1 times.assert [0] == [1], proving that addingarchive_roottoFakeArchivedid not weaken what that test provesTwo further issues measured, not guessed
The index read raced the replace that follows a returning intake pass (measured: 1 -> 2 messages at ~200 ms), now a bounded wait plus settle window. And the profile row is published then withdrawn by the quarantined snapshot's replace, with re-derivation never arriving because the test stops driving the daemon — so the row is sampled across the window and required to have been published.
Stated plainly: that assertion no longer proves the row is present in the final settled state. That is not a property a stopped daemon can establish.
Schema identity
polylogue/storage/derived/session/usage_rollup.pyis IN the closure. Index identitybe8d4619aff05…->0d03d682a0c97…. The archive must reconverge, and this must land before any fresh rebuild starts.Residual worth a bead
The durable change train's forward-admission refusal was not changed, so a forward-versioned
audit.dbstill kills daemon startup withDurableChangeTrainErrorescaping into theBaseExceptionshutdown path — arguably the same failure mode polylogue-39pdi was filed against, reachable by a different route. Redefining a durable-migration guard is a product decision beyond a repair lane's authority, so the test was scoped to the contract it names and the gap reported rather than silently widened.🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy