Repository navigation
fix: Read Hermes state schema through the logical export seam - #5064
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 59 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 (4)
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 |
…ty (#5065) ## Summary `devtools gate patterns` is **red on master**, blocking every PR opened since, including ones that touch neither implicated file. This restores it and makes the baselines honest. ## Problem Two PRs, each green on its own, red once both had landed: - **#5056** (error paths) added `logger = logging.getLogger(__name__)` to `polylogue/sources/retained_acquisition.py` for the ZIP-member-skip warning. - **#5059** (structured logging) recorded the `legacy-stdlib-logger` ratchet baseline at 23 entries. Neither PR's CI ever saw the other's change. After both merged, master scanned 24 matches against a 23-entry baseline, so the gate reported a new match and set `blocking: true`. PRs #5061, #5062, #5063 and #5064 all failed for this inherited reason. Separately, the baselines carried **22 stale entries** whose sites no longer exist — several naming `polylogue/storage/repair.py`, a file deleted some time ago. ## Solution Convert the one blocking site to a structured event, `source.zip.members_refused`. No new allowlist field was needed: `path` and `skipped` are already registered, and the refused-member list rides in `error_detail`, the single existing quarantined field. Prune the 22 stale entries. Pruning **shrinks** the ratchet, which is the permitted direction; adding an entry to silence the gate is the forbidden one. ## Verification ``` devtools gate patterns -> blocking: false, new_matches: 0, stale_matches: 0 ``` Baselines now match the scan exactly in both directions. Before this change the same command reported 1 new match and 22 stale entries. No test asserts on the old warning text, so no test changes were required. ## Note for the ratchet's owner — not addressed here A structural gap surfaced while fixing this. `legacy-stdlib-logger` matches `logging.getLogger(...)`, but the form most of the tree actually uses is the `polylogue.logging.get_logger` wrapper, which the rule does not match. A concurrent conversion of 90 prose sites across `daemon/cli.py` and `daemon/http.py` therefore eliminated **zero** baseline entries — the gate meant to enforce "no legacy logging" is blind to the dominant legacy form. Widening the existing rule would grow its baseline by roughly 140 modules, which the ratchet forbids. The coherent route is a second rule with its own baseline at the true remaining count: a new ratchet may start wherever reality is, while an existing one may only shrink. That is a deliberate decision and belongs in its own change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Problem: `test_rebuild_lease_excludes_competing_process` and `TestRebuildLeaseStatus::test_reports_held_by_a_separate_live_process` failed on clean master, isolated and inside the full tests/unit/storage run. Evidence: Python 3.14 made `forkserver` the default multiprocessing start method on Linux, so the *first* `Process.start()` in a pytest session pays a full fresh-interpreter bring-up before the child body runs. Measured in this harness with a temporary probe: 4.41s on an idle host (free-threaded build), against a 5s `ready.wait(5)` deadline. Every later start reuses the running forkserver and returns in milliseconds, which is why only whichever of the two ran first failed -- inserting a throwaway `Process.start()` ahead of them made both pass untouched. Solution: the deadline is a liveness bound, not a latency assertion. Both tests assert that a lease held by a separate process excludes this one; nothing is weakened by waiting longer for that process to exist. Hoist it to a named constant with the cause recorded, and give the child's hold the same budget so it cannot release before the parent inspects the lock. No product change. Anti-vacuity verified by reverting, not asserted: changing `_open_lock_fd`'s `fcntl.flock(fd, lock_type | LOCK_NB)` to `LOCK_SH` turns `test_rebuild_lease_excludes_competing_process` red (receipt .cache/verify/runs/20260914T094213Z-focused-test-1950366-eede6632). Verification: devtools test tests/unit/storage/test_index_generation.py -- PASSED (20260914T093731Z-focused-test-1935974-f2387ec5). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Problem: three tests in tests/unit/storage/test_hermes_artifact_inspection.py failed on clean master, and behind two of them sat a live product defect. Evidence: #5040 (f84dd3b) made ingest refuse Hermes SQLite page images -- replay (`sources.revision_backfill._parse_one`) already refused them, and admitting them on ingest would mint a second source authority for content the archive holds under its logical revision. Retained Hermes material is therefore the member's canonical logical export, never a page image. The tests still built page images and asserted `supported_parseable` / `session_document`: stale assertions of behaviour that is deliberately gone. Rebuilding them on exports exposed the defect: `artifacts/inspection._hermes_state_db_schema_version` still read through `open_readonly_connection`, a plain read-only SQLite open. An export is not a SQLite database, so it returned no version and every retained Hermes state observation resolved to `unsupported_parseable` with `resolved_package_version=None` -- a durable artifact observation that misreports supported material as unsupported, and it does not announce itself. `looks_like_state_db_path` and `hermes_state._connect_readonly` were both moved onto `open_logical_source` by #4798; this one reader was left behind. Solution: read through `open_logical_source`, the same seam, which serves a live database and a retained export alike. Tests: the two stale cases now retain the export `write_logical_export` produces under `member_export_scope` -- the production acquisition route -- and assert the v16 and v17 package resolution. Two cases added for what the page image now means: it is refused as session content (`recognized_unparsed` / `binary_database`), and inspecting a retained WAL-mode page image still leaves the blob namespace pristine. Anti-vacuity, each verified by reverting: - export tests: restore `open_readonly_connection` and both go red as `unsupported_parseable` (observed at 20260914T093533Z-focused-test-1930511). - refusal test: drop the `is_declared_logical_export` gate in `raw_payload/decode.py` and the page image is claimed as `session_document` again (20260914T094013Z-focused-test-1944868). - namespace test: drop that gate *and* pass `sqlite_immutable=False` and `<hash>-wal`/`<hash>-shm` appear beside the blob (20260914T094100Z-focused-test-1947117). Either revert alone leaves it green. SCHEMA CLOSURE: `polylogue/storage/artifacts/inspection.py` is IN the derived schema-identity closure and this edit MOVES the index identity (ffced4154e582ec5e9d1e126fb45a07beb5214b3c6e8b60b44badf256d007e8f -> 764f42c74c300d1db97ae67a090bac78947d4be462601738383b308288e878f9; ops identity unchanged). It must land before a fresh rebuild starts, never during one. Verification: devtools test tests/unit/storage/test_hermes_artifact_inspection.py tests/unit/storage/test_index_generation.py -- PASSED (20260914T093731Z-focused-test-1935974-f2387ec5). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Widening `except sqlite3.Error:` to also catch `LogicalExportError` and `OSError` removed a baselined `sqlite-error-default` match, so the ratchet reported its entry as stale. Pruning shrinks the baseline, which is the permitted direction. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
f1599f6 to
64050b6
Compare
…events (#5072) ## Summary All 34 remaining daemon modules converted to structured events. **Zero legacy loggers remain anywhere in `polylogue/daemon/` outside `cli.py`/`http.py`**, which landed separately in #5067. Ratchet baseline 23 → 20 — exactly the three eliminated. Largest: `judgment_automation` 23 sites, `convergence_stages` 17, `metrics` 12, `status` 11, `embedding_backlog` 11, `write_coordinator` 10, `derivation` 8. A dead logger in `backup.py` was removed outright. ## What this makes legible ``` INFO daemon.stage.executed duration_ms=0.0 outcome=ok path=claude-code/a.jsonl stage=acquire WARNI daemon.stage.execute.degraded attempts=44 calls=40 gaps=2 outcome=degraded path=claude-code/a.jsonl reason=unresolved_workflow_gaps runs=12 stage=claude_workflow WARNI daemon.stage.drained action=batch attempted=3 confirmed=1 debt=1 failed=2 outcome=degraded payload_failures=0 reason=transport_failures rejected=0 remaining=2 transport_failures=2 ``` The old code logged `gaps=2` inside an **INFO** sentence — a degraded stage reported at the same level as a healthy one. And prose collapsed transport failures, payload failures and rejections into a single line; they now have separate counted lanes with a reason naming the dominant one. `convergence_stages.py` carries `make_default_convergence_stages`, the stage list that drives the entire from-scratch rebuild, so this is the module that decides whether a multi-hour build's degradation is visible without reading source. ## `propagate()` — verified, not assumed `BoundedComputeAdapter.__init__` builds the `ThreadPoolExecutor` eagerly and `_run_task` submits a bare closure. Measured with the pool pre-warmed: bare submit → `{}`, wrapped → `{'run_id': 'rebuild01'}`. Added at both `operation_runtime.py` submit sites. ## Fields 46 new, all count/token/identifier/duration/flag; three registered but never emitted were dropped. `error_detail` remains the only `text`-kind field, asserted by its pinning test. One deliberate omission: a failed Apprise `add()` used to interpolate the notification URL with `%r`, and those URLs embed tokens. The **position** is logged instead of the URL. ## Verification ``` devtools test tests/unit/daemon -> PASSED 2233/2233, exit 0 (429s) devtools verify --quick -> exit 0, all 15 gates devtools gate layering -> exit 0 devtools gate patterns -> passed, 20 matches, 0 prunable devtools render all --check -> exit 0, "out of sync" -> 0 ``` The tip was checked before **and** after that run (`3b342d756`, clean both times), because a green belonging to a different tree than the one reported has already bitten this campaign twice today in both directions. The count is 2233 rather than an earlier 2230 because the rebase brought three more daemon tests in with #5063/#5064 — both numbers are real measurements of different trees. Seven tests pinned the old prose through `caplog` or subprocess stderr; each now asserts on the event and its fields and names its anti-vacuity condition. The raw-authority-cache test is strictly stronger than before: it now requires the first pass to report `degraded` with cohorts pending and the second `ok`, a distinction a single INFO line could not express. ## Landing order `polylogue/daemon/write_coordinator.py` and `polylogue/logging_fields.py` are **IN** the derived-schema closure; the other 35 changed files are `out`. The index identity moves, ops does not. **This must land before a from-scratch rebuild starts, never during one** — encountered for real during development, where editing mid-run produced 133 `SchemaSkewError` failures because the seeded-artifact cache keys on `derived_schema_identity`. Note `write_coordinator.py` now carries both #5062's lease-delegation imports and this change's event imports, so both feed the index identity. The interim identity hashes measured during development are superseded by each rebase; only the finally-landed identity is worth recording. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…5104) ## Summary Three tests still built a Hermes SQLite **page image** and asserted the pre-#5040 marker route. They are retargeted onto the production acquisition shape -- the declared member's canonical **logical export** -- which is what the gate now admits. ## Which merged PR moved the ground PR #5040 (`f84dd3b0c`, "Refuse Hermes page images on ingest") added the `is_declared_logical_export` gate at `archive/raw_payload/decode.py:587`. A page image is no longer admitted as session content, because the replay route (`sources.revision_backfill._parse_one`) already refuses one and admitting it on ingest would mint a second source authority for content the archive holds under its logical revision. PR #5064 (`3ad255e25`) already rewrote the equivalent *storage* tests onto `write_logical_export` + `member_export_scope`. These three were missed by that pass; this follows the same precedent. ## Solution Build the retained material with `write_logical_export(db, handle, scope=member_export_scope(db), immutable=True)` and pass the export as the payload with `source_path` naming the declared `state.db`. The assertions are unchanged in substance: the marker route still fires, the artifact is still a `SESSION_DOCUMENT`, and the payload still equals `hermes_state.marker_payload(...)`. `tests/unit/sources/test_parsers_local_agent.py` grows one helper, `_write_hermes_state_export`, shared by both marker tests. ## Verification ``` devtools test tests/unit/core/test_raw_payload_decode.py \ tests/unit/sources/test_parsers_local_agent.py \ tests/unit/cli/test_archive_query.py tests/unit/cli/test_daemon_client.py \ tests/unit/infra/test_archive_templates.py \ tests/unit/insights/test_delegation_work_evidence_materializer.py \ tests/unit/cli/test_status.py -> receipt 20260914T163857Z-focused-test-3135387-125edb44 248 passed / 249 collected; the three tests in this PR all green devtools verify --quick -> exit 0, 15/15 gates ``` The one failure in that receipt was `tests/unit/cli/test_status.py`, a separate group with its own PR; it is green there. ## Anti-vacuity | Test | Mutation that makes it red | |---|---| | `..._still_recognizes_genuine_hermes_state_db` | drop the member header (`scope=None`): the bytes stop binding to `state.db`, the artifact comes back `BINARY_DATABASE` | | `..._envelope_uses_marker` | same; the provider falls back off `Provider.HERMES` | | `..._default_keeps_live_marker_semantics` | flip the `sqlite_immutable` default to True: the marker gains an `sqlite_immutable` key | ## Residuals Test-only change; no product code touched, so the derived schema identity does not move. The full corpus was not re-run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
polylogue-7lhl5reported 33 red tests acrosstests/unit/daemonandtests/unit/storage. 31 of the 33 were already fixed by PRs #5024-#5051 that landed between the bead's measurement commit (3faacef23) and current master — verified cluster by cluster in source, not assumed. Reproducing at head gave 5 failed / 5538 passed, in two new clusters, both in storage. This fixes both, one of which is a real product defect.Problem
A durable artifact observation was misreporting supported material as unsupported.
PR #5040 made ingest refuse Hermes SQLite page images, because replay already refused them and admitting one would mint a second source authority for content the archive holds under its logical revision. The three failing tests still built page images and asserted
supported_parseable, so the stale half was straightforward.Rebuilding them on the current contract exposed the real defect:
storage/artifacts/inspection.py::_hermes_state_db_schema_versionstill read throughopen_readonly_connection, a plain SQLite open. A logical export is not a SQLite file, so it returned no version — and every retained Hermes state observation resolved tounsupported_parseablewithresolved_package_version=None, silently.looks_like_state_db_pathandhermes_state._connect_readonlywere both moved ontoopen_logical_sourceby #4798. This one reader was left behind.Second cluster: environment, not product. Python 3.14 made
forkserverthe default start method on Linux, so the firstProcess.start()in a pytest session pays a fresh-interpreter bring-up — measured at 4.41 s with a temporary probe, against aready.wait(5)deadline. Only whichever of the two lease tests ran first failed; inserting a throwawayProcess.start()ahead of them made both pass untouched. The deadline is a liveness bound, not a latency assertion, so it is now a named 60 s constant with the cause recorded. The lease itself is correct and unchanged.Solution
Read the Hermes state schema version through
open_logical_source, the same seam its siblings already use. Tests rewritten onto the production acquisition route (write_logical_export+member_export_scope), plus two added: a page image is refused (recognized_unparsed/binary_database), and inspecting a retained WAL-mode page image leaves the blob namespace pristine.Verification
Anti-vacuity verified by reverting, with a receipt for each:
open_readonly_connectionunsupported_parseable)is_declared_logical_exportgatesqlite_immutable=False-wal/-shm; either alone stays greentest_rebuild_lease_excludes_competing_processLOCK_EX->LOCK_SHLanding order
devtools schema closure polylogue/storage/artifacts/inspection.py-> IN. Both identities were computed rather than inferred: the index identity moves,ffced415…->764f42c7…; ops unchanged. Must land before a from-scratch rebuild starts, never during one.Residuals
devtools gate atlasis red with 124 BLOCKs — identically at the base commit and at this tip. Inherited doc-staleness indocs/atlas/storage.mdagainstblob_gc.py,blob_publication.py, andarchive_tiers/{source,bootstrap,archive_tiers_specs}.py. Nothing in this branch is among them, and atlas is not part ofverify --quick, so it is a separate inherited item — one a full pre-builddevtools verifywill also surface.The full corpus was not re-run.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK