Skip to content

fix(storage): Refuse a usage-rollup publication that retired nothing - #5440

Merged
Sinity merged 1 commit into
masterfrom
work/wave-p
Sep 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
work/wave-p

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

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 base 5204d0e9e; 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_rollup reported success after deleting nothing

Its retirement branch returned True unconditionally. 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 rowcount is 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 retire immediately before the FAILED, rather than inferred from reading.

2. Stale test — ..._parks_operation_recovery_on_audit_schema_mismatch

The test wrote PRAGMA user_version = 1 to manufacture a mismatch. b56699c80 (#5275, "Fresh schema floor") set ARCHIVE_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_replay

RawObservationDerivation.publish began pinning its membership read through open_operation_read in 3faacef23 (#5023). That read captures the view from archive.archive_root and archive.index_db_path, which the test's FakeArchive never grew. Both were added to the double, not loosened in the production read. pin_operation_snapshot stays absent because operation_context.py explicitly declares that minimal-double path.

Verification

devtools verify --quick                          ->  PASSED
devtools test tests/unit/daemon/test_daemon_cli.py  ->  107 passed, 0 failed
devtools test <rollup derivation + 2 convergence suites>  ->  PASSED

All three mutations executed and refuted:

  • restore the retirement branch -> all four watcher params red: session_usage_rollup ... FAILED ... 'publish reported success but the required output remains missing', assert 1 == 0
  • replace the durable_schema_mismatch gate with False -> AssertionError: Expected 'mock' to not have been called. Called 1 times.
  • drop the writer lease across replay -> assert [0] == [1], proving that adding archive_root to FakeArchive did not weaken what that test proves

Two 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.py is IN the closure. Index identity be8d4619aff05… -> 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.db still kills daemon startup with DurableChangeTrainError escaping into the BaseException shutdown 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

…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
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 12 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 068ebfc4-4154-4299-8b31-42038723d7fd

📥 Commits

Reviewing files that changed from the base of the PR and between a7498d5 and 189581e.

📒 Files selected for processing (2)
  • polylogue/storage/derived/session/usage_rollup.py
  • tests/unit/daemon/test_daemon_cli.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 21:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

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 ✅ Completed 2026-09-22T21:44:47.385457Z 189581e PR opened
🔒 Security Review ✅ Completed 2026-09-22T21:45:10.286219Z 189581e 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 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: 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".

Comment thread tests/unit/daemon/test_daemon_cli.py Resolved
@Sinity
Sinity merged commit eab6e85 into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the work/wave-p branch September 22, 2026 21:51
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

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