Skip to content

fix(storage): Make the legacy revision-governance marker read-only in fact - #5424

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

Sinity merged 1 commit into
masterfrom
work/wave-d

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

One real fix, plus four schema-shape beads reconciled against head — of which one AC is proven unperformable by executing it, one is already satisfied, and one is deliberately deferred by its own ruling.

Fixed

polylogue/archive/revision_authority.py now splits the full-revision-governance detail markers into WRITABLE_… (1 member) and LEGACY_… (the pre-#3234 spelling), with RETIRED_… as their union. revision_governance.py:2196 narrows the write boundary from the read set to the writable set.

Before this, the declaration's own comment said the legacy spelling was "read-only, never write" and nothing enforced it. A writer could mint it, after which no query could distinguish a durable pre-#3234 row from a new one — which is precisely what makes the compatibility branch unretireable after the rebuild.

Anti-vacuity executed: reverting the guard to the read vocabulary gives Failed: DID NOT RAISE ValueError at test_revision_replay.py:1675. The opposite direction is pinned too — the writable marker must still apply, so a blanket refusal cannot pass.

cuxz.11 — already satisfied, plus a real gap nobody had named

The dispatch said "nothing is done". Three of its four claims were wrong, and the lane refuted each at base 9ef655cb8:

  • AC1 was already satisfied — write.py:6519 if policy_values != last_agent_policy: emits a row only on genuine change, landed in refactor(storage): Trim dead derived-schema columns and render the embeddings tier from specs #5309, with a comment naming this bead.
  • PRIMARY KEY(session_id, position) is not the forbidden grain — position is the offset where a retained interval starts, so the PK constrains interval starts, not per-message rows.
  • The "100%-NULL index" is partial — WHERE source_message_id IS NOT NULL at index.py:1002 and again at runtime_indexes.py:18. A NULL column costs zero index entries. The 100%-NULL census is historical, exactly as the 2026-09-07 note cautioned.

What was missing is the append path: _last_agent_policy_values now reads the highest-position stored row so an appended chunk compares against stored state. No test covered it, and live sessions are appended to many times.

Mutation (return None): Left contains one more item: (1, 'on-request', 'read-only', 'restricted').

AC4 (row count against the 402,869 baseline) is READY-AT-BUILD — a live-archive measurement, nothing in code blocks it.

3szyi AC2 — proven unperformable, by executing it

The AC asks for durable CHECK constraints generated from Python enum owners. A PolylogueStrEnum carrying audit.destructive_class's six members was injected into archive_tiers/source.py and the real gate run:

Enum-derived membership CHECKs found in durable tiers: 1
  audit: destructive_class matches _TempDestructiveClass
GATE_EXIT=1

Reverted → exit 0. Doing what the AC mandates makes devtools verify red. gate durable-enum-checks refuses exactly this construct, because it pins an enum's evolution into a tier that only moves by numbered migration.

42 of the 54 hand-written lists are on durable tiers. The correct durable remedy is delete-and-validate-at-the-write-boundary (require_vocabulary), not generate. Exactly one durable list has an enum owner today (source.outcome_code), and it is an explicit grandfathered pre-policy waiver.

Census measured with the gate's own classifier so it matches enforced policy: 54 typed value lists (source 26, audit 13, ops 7, user 3, specs 3, index 2 — the index pair are partial-INDEX predicates, not CHECKs). The bead's own raw grep of 76 counts f-string-rendered lists too.

The 12 non-durable lists have zero exact Python owners and are narrow storage-local vocabularies — their correct disposition is AC4 (STORAGE_LOCAL with a stated reason), a small real change nobody has made.

a7xr.27 — deferred by its own ruling, and three records disagree on the counts

The sequencing note exists: label timing:post-reindex, with a 2026-08-24 ruling that this is "worthwhile substrate completion but is not required to reconstruct the archive correctly." Nothing in this wave needed a tier's spec adoption, so nothing was landed.

Re-measured at head, and the bead, its own scoping note, and the dispatch each carry a different wrong count:

tier CREATE TABLE spec-rendered
index 36 35
embeddings 5 5 — fully adopted
source 32 0
ops 17 0
user 17 0
audit 14 0
bootstrap 0 0

So 80 hand-written across five tiers — not 89 (bead), not ~86 (dispatch), not 84 (its scoping). Embeddings is not "6/5 un-adopted"; the sixth match was a comment saying it is adopted. bootstrap.py has zero CREATE TABLE.

Also corrected: the scoping's claim that #5290 emptied the migration directories is false — migrations/source/002 and migrations/user/002 both exist with .train.json sidecars. Only migrations/audit/ is bare, so the audit tier's route is declared-but-unexercised.

Verification

command exit
devtools verify --quick at base 0, 25/25
devtools verify --quick at rebased head 0, 25/25 (durable-enum-checks, schema-manifest, schema-closure all ok)
devtools render all --check 0, out of sync = 0
test_revision_replay.py + test_archive_write.py 0
downstream consumers (169 tests) 1 non-passing — inherited

Inherited red proven at base in a detached checkout: test_owned_nonempty_generation_refuses_cold_build_deferral, identical nodeid, 1 of 109.

Schema closure — reconvergence required

Both changed files are IN. DerivedTier.index: 96aca24d… → d947bd97…; ops unchanged. No DDL changed — this is the AST-closure case CLAUDE.md describes. gate schema-closure green, membership unchanged, INDEX_SCHEMA_VERSION untouched at 107.

Must land before a fresh rebuild starts, never during one.

Residuals

  • Latent gate gap: verify_durable_enum_checks.py only walks PolylogueStrEnum subclasses, so a durable CHECK generated from a typing.Literal would evade it while carrying the same durability cost. Latent, not live — the durable tiers have zero generator call sites today. The embeddings conversion this bead already landed used Literal owners.
  • sze30 full removal needs migrations/source/003 adding a typed detail_code plus a backfill, and re-pointing four producers, three outside this scope. The read/write split landed here is what makes the eventual drop provable: once the rebuilt archive contains no row carrying the legacy spelling, LEGACY_… can go.
  • audit.required_confirmation/confirmation_strength and audit.principal_surface/surface are byte-identical member sets — real collapse candidates, both durable.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

… fact

polylogue-sze30 (partial) and polylogue-cuxz.11 (append path).

`LEGACY_FULL_REVISION_GOVERNANCE_DETAILS`' declaration has always said the
pre-#3234 spelling is "read-compatibility only -- never write", and nothing
enforced it: `replace_raw_membership_census` accepted the whole read
vocabulary at its write boundary. Split the vocabulary into a writable set and
a legacy read-only set, keep the read set as their union, and narrow the write
boundary to the writable one. Until this, no query could tell a durable
pre-#3234 census row from one written afterwards, which is exactly what makes
the compat branch impossible to retire after the rebuild.

The polylogue-hm2f fixture seeded its "durable legacy row" *through* the
writer, so it was more permissive than production; it now retires under the
writable marker and rewrites `raw_membership_census.detail` directly, which is
what a pre-#3234 row actually is on disk.

Also pins the polylogue-cuxz.11 value-change grain across a merge-append.
`_last_agent_policy_values` reads the highest-position stored row so an
appended chunk compares against stored state instead of starting a fresh run;
no test covered that, and live sessions are appended to many times, so it is
the half of the grain that the 402,869-row census actually measured.

Derived schema identity (index tier) moves 96aca24d -> d947bd97; ops tier
unchanged. No DDL changed -- both edited production files are closure members.

Verification:
  devtools verify --quick                      25/25 ok, exit 0
  devtools render all --check                  exit 0, 0 "out of sync"
  devtools test tests/unit/storage/test_revision_replay.py
               tests/unit/pipeline/test_archive_write.py   exit 0

Executed anti-vacuity:
  guard -> RETIRED_FULL_REVISION_GOVERNANCE_DETAILS
    test_legacy_governance_marker_is_never_writable
    E  Failed: DID NOT RAISE ValueError
  _last_agent_policy_values -> return None
    test_agent_policy_interval_survives_a_merge_append
    E  AssertionError: Left contains one more item:
       (1, 'on-request', 'read-only', 'restricted')

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 17:11
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 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: fde73758-d6f5-4cf7-98db-0ce67da45cab

📥 Commits

Reviewing files that changed from the base of the PR and between 9ef655c and 4473929.

📒 Files selected for processing (4)
  • polylogue/archive/revision_authority.py
  • polylogue/storage/sqlite/archive_tiers/revision_governance.py
  • tests/unit/pipeline/test_archive_write.py
  • tests/unit/storage/test_revision_replay.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.

@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-22T17:14:26.275397Z 4473929 PR opened
🔒 Security Review ✅ Completed 2026-09-22T17:17:13.426938Z 4473929 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.

@Sinity
Sinity merged commit 1e396eb into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the work/wave-d branch September 22, 2026 17:22
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