Repository navigation
feat(maintenance): add source-conservation and population-coverage gates - #4685
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 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: c3724283ca
ℹ️ 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".
Add the `source-conservation` verify-archive declaration: every acquired source item types into exactly one term citing its rule, and every index session, message, block, and attachment ref traces back to a raw row. Phantom sessions (polylogue-b508) are reported by lineage and never deleted. A source file that is gone while the archive still retains its raw payload bytes is typed accounting (`source_missing`); only genuine byte loss (`source_lost`) blocks, alongside unexplained, unclassified, orphan, and phantom terms. Add `devtools gate population-coverage`: every origin, detector route, and artifact kind is declared and witnessed. Coverage comes from the declarations, so a stored `recognized_unparsed` support status is not itself a declaration, and the gate evaluates a source inventory only when `--archive-root` names one - its result never depends on ambient machine state. `planner-stats` now covers the documented set including `session_links`, and the coherent fixture ANALYZEs the whole index tier. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
c372428 to
7900e50
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7900e502c6
ℹ️ 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".
…4697) ## Summary Restores the archive verification registry to green on seeded fixtures. Two merged PRs each left one declaration non-green, and 16 corpus tests assert the whole registry at a single seam (`tests/infra/convergence_harness.py:371`), so both surfaced as the same failure. ## Problem Corpus run on master 754553b (`/realm/tmp/work/corpus-2026-09-05c.log`): ``` AssertionError: archive verification registry is not green: [('planner-stats', 'warning', 'sqlite_stat1 missing coverage for: session_links (polylogue-l3tk class)', ...), ('source-conservation', 'error', '5 raw item(s), 0 hook event(s), 4 index session(s); revision_superseded=1; attachment_unreferenced=1!', ...)] ``` **source-conservation.** #4692 (917e793) stopped dropping an attachment whose owning message is ambiguous and began retaining it as a typed unowned row (`ref_count` 0, deliberately excluded from the ref-count sweep). It has no `attachment_refs` row, so `source-conservation` counted it under `attachment_unreferenced`, which blocks. A deliberate, explained retention was reported as archive corruption. **planner-stats.** #4685 (0fa2a9a) added `session_links` to the verified covered set. The empty-table exemption added by #4692 is working correctly — the warning fires because `session_links` is *populated* and un-ANALYZEd. The production rebuild route (`rebuild_index.py`) did ANALYZE it; the test archive builders ANALYZEd a separately hand-copied list (`tests/infra/convergence_harness.py`, `tests/infra/schema_inference.py`) that still read `blocks, messages, action_pairs`. One route drifted from the verified set with nothing to catch it. ## Solution **source-conservation** splits the ref-less attachment population on `ref_count`, which is the discriminator the writer already establishes: - `ref_count = 0` — inserted unreferenced and kept out of the sweep, so it never had a ref: the new non-blocking `attachment_unowned` term. - `ref_count != 0` — refreshed while refs existed, then lost them without the sweep running. This is exactly the state `refresh_and_sweep_attachment_rows` documents as unreachable from every read path; it stays `attachment_unreferenced` and keeps blocking. No schema change: adding a marker column to the index tier would have forced an `INDEX_SCHEMA_VERSION` bump, regenerated schema-disposition artifacts, and a rebuild plan, to record a fact two existing columns already determine. **planner-stats** moves the covered set to one constant, `PLANNER_STATS_COVERED_TABLES` in `polylogue/storage/sqlite/maintenance.py`, with an `analyze_planner_stats_tables()` helper. The verification check, the rebuild replay, and both test builders now read it, so a table added to the verified set cannot go uncovered on a single route. `rebuild_index` still ANALYZEs `sessions` in addition, for its session-scoped replay lookups. ## Verification Red-first, measured against the same fixtures with the pre-fix modules loaded side by side: ``` === owner-ambiguous (ref_count=0) === OLD: blocking_count=1 ... attachment_unreferenced=1! NEW: blocking_count=0 ... attachment_unowned=1 === stale ref_count (ref_count=2) === OLD: blocking_count=1 ... attachment_unreferenced=1! NEW: blocking_count=1 ... attachment_unreferenced=1! ``` ``` OLD builder ANALYZE set : warning missing=['session_links'] NEW builder ANALYZE seam: ok missing=[] ``` The `ref_count=2` row is the control: the split does not disable the blocking term, it only stops it claiming the explained case. Four new tests, each naming its anti-vacuity condition: `4 passed, 3 warnings in 13.81s`. `.venv/bin/python -m devtools verify --quick` — exit 0, all 13 gates ok, no `out of sync`. `ruff check` / `ruff format --check` clean across `polylogue/` and `tests/`; `mypy` clean on the changed production modules. ## Residuals - The 13-file affected-set run (the previously-red convergence/property/reindex files) is still queued behind an unrelated full `verify` on the host's single pytest slot. Both non-green terms that produced the assertion are proven resolved above, but those 16 tests have not yet been observed green in one run; I will post the result on this PR when it lands. - `test_convergence_builder_analyze_covers_every_verified_table` imports the builder's private `_analyze_registry_tables` deliberately: asserting against a restatement of the table list would not catch a builder reverting to a hand-copied one. - Unrelated, found while researching: CLAUDE.md and `docs/internals.md` still point at `polylogue/storage/sqlite/lifecycle.py` and the delta-class lifecycle mechanism, deleted in #4666 (879a995). Wants its own sweep. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid Co-authored-by: Claude Fable 5.1 <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
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
Adds two verification instruments: the
source-conservationverify-archivedeclaration (polylogue-bx26w, with the phantom-session term for polylogue-b508)
and
devtools gate population-coverage(polylogue-rrxe4.1).Problem
Nothing accounted for the whole acquired population.
source-index-coveragereasons over logical heads, so a raw row that is neither a head nor an error
could vanish from every ledger, and no check asked the reverse question: does
every index session, message, block, and attachment ref trace back to a raw
row it is entitled to come from? Against the live archive that gap hides real
material — sessions materialized from declared non-session artifacts
(polylogue-b508 phantoms) are indistinguishable from real ones by row shape.
Separately, no gate asserted that every origin, detector route, and artifact
kind observed in a source inventory is actually declared and witnessed.
Solution
source-conservationtypes every acquired source item — eachraw_sessionsrow, hook event, and history sidecar — into exactly one term that cites the
rule explaining it, and traces every index row back to its owner. Only
unexplained terms block:
unexplained,unclassified_shape,source_lost,orphans, and phantoms. Phantoms are reported by lineage and never deleted.
A source file that no longer exists on disk is not by itself a loss. When the
archive still retains the raw payload bytes the content is conserved, so that
is typed accounting (
source_missing); only a vanished file whose bytes arealso gone (
source_lost) blocks. This is what makes the check usable as theacceptance instrument for a rebuilt archive, where 12,717 rows are
source-missing by ordinary export rotation.
population-coveragederives coverage from the declarations. A storedrecognized_unparsedsupport status is a row value, not a declaration, so itno longer confers coverage on a kind that no
OriginSpecrule claims. Thegate evaluates a source inventory only when
--archive-rootnames one; itpreviously defaulted to the operator's configured archive, which made a repo
gate's verdict depend on ambient machine state.
Two fixes fall out of the fixture work:
planner-statsnow covers the setdocs/maintenance.mdand CLAUDE.md already documented (session_linkswasmissing from the code's tuple while
action_pairswas never ANALYZEd by thecoherent fixture, so the check warned on every seeding), and the coherent
fixture ANALYZEs the whole index tier.
Verification
.venv/bin/python -m devtools test tests/unit/maintenance/test_source_conservation.py tests/unit/devtools/test_verify_population_coverage.py tests/unit/maintenance/test_archive_verification.py.venv/bin/python -m devtools verify --quick— all 13 gates ok, noout of sync..venv/bin/python -m devtools gate population-coverage—Population coverage: PASS.Against the live archive, the forward direction accounts for all 43,124 raw
rows: 20,206 materialized, 8,153 revision-superseded, 12,717 source-missing,
1,140 non-session, 483 pending, 323 sidecar artifacts, 68 parse failures, and
34 unexplained. Reverse: 23,496 sessions, of which 5,072 are phantoms by
lineage, plus 1,858 unreferenced attachments.
Each changed test names its anti-vacuity condition:
test_deleted_source_file_retypes_the_raw_as_source_missingis vacuouswithout the on-disk probe (the raw stays
materialized);test_deleted_source_file_without_retained_bytes_trips_source_conservationis vacuous without the retained-bytes join (byte loss reads as the
non-blocking term);
test_removed_artifact_rule_turns_its_kind_uncoveredisvacuous if coverage is read off the stored support status rather than the
declarations.
Residuals
The 34 unexplained raws and 5,072 phantoms are reported, not resolved — that
is the point of the instrument, and closing them is separate work.
Run against the live archive,
population-coverage --archive-rootreports twouncovered constructs,
aistudio-drive/unknown/decode_failed(15) andaistudio-drive/unknown/unknown(2). Both predate this change and want theirown bead.
source-conservationstats every distinct source path once per run. That isbounded by distinct paths rather than raw rows, but it is real I/O on a cold
cache; callers that must not touch the filesystem can pass
probe_filesystem=False.Beads: polylogue-bx26w, polylogue-rrxe4.1, polylogue-b508
🤖 Generated with Claude Code
https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid