Skip to content

fix: validate archive index schema semantics before opening - #4472

Merged
Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-keogq.2
Aug 31, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-keogq.2

Conversation

@Sinity

@Sinity Sinity commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Add canonical sqlite_master semantic manifests to index-tier bootstrap and the shared archive-layout opener. Fresh and same-version index initialization now verifies the complete declared object shape, including runtime indexes; undeclared or drifted objects produce an exact typed diff. Source-generation sealing is immutable and rejects unknown or already-sealed generations.

Problem

PRAGMA user_version alone accepted an index whose object shape had drifted, including historical undeclared FTS residue or indexes. A source generation could also be resealed after publication.

Solution

Render canonical DDL into an in-memory database, normalize its sqlite_master projection, fingerprint it, and compare it with the live projection at the open boundary. Ensure fresh index construction creates the same runtime indexes before validation. Add a regression proving a current user_version does not hide an undeclared table.

Verification

bash nix/devtools-wrapper.sh test tests/unit/storage/test_index_generation.py tests/unit/maintenance/test_rebuild_index_candidate_promotion.py tests/unit/maintenance/test_inactive_candidate_durable_barrier.py tests/unit/storage/test_archive_tuple_location.py — 93 passed.

bash nix/devtools-wrapper.sh verify schema-versioning — Schema evolution policy intact.

bash nix/devtools-wrapper.sh verify oracle-integrity — Oracle integrity intact.

bash nix/devtools-wrapper.sh verify --quick — all quick gates passed.

Residual risk

The dispatch-named tests/unit/storage/test_archive_tuple_activation.py is absent from this branch, so that exact command cannot collect it. This change validates the existing index open/bootstrap route; it does not add a new whole-tuple activation API.

Reviewed-by: Claude (Opus) cross-family review

@Sinity
Sinity enabled auto-merge (squash) August 31, 2026 09:35
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6263b35d-528d-449a-b500-9d5c722b51d8


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 Aug 31, 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-08-31T09:48:42.355161Z e6a1072 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 2929881 into master Aug 31, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-keogq.2 branch August 31, 2026 09:36

@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: e6a107284a

ℹ️ 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 polylogue/storage/sqlite/schema.py Resolved
Sinity added a commit that referenced this pull request Sep 1, 2026
Summary

Add canonical sqlite_master semantic manifests to index-tier bootstrap
and the shared archive-layout opener. Fresh and same-version index
initialization now verifies the complete declared object shape,
including runtime indexes; undeclared or drifted objects produce an
exact typed diff. Source-generation sealing is immutable and rejects
unknown or already-sealed generations.

Problem

PRAGMA user_version alone accepted an index whose object shape had
drifted, including historical undeclared FTS residue or indexes. A
source generation could also be resealed after publication.

Solution

Render canonical DDL into an in-memory database, normalize its
sqlite_master projection, fingerprint it, and compare it with the live
projection at the open boundary. Ensure fresh index construction creates
the same runtime indexes before validation. Add a regression proving a
current user_version does not hide an undeclared table.

Verification

`bash nix/devtools-wrapper.sh test
tests/unit/storage/test_index_generation.py
tests/unit/maintenance/test_rebuild_index_candidate_promotion.py
tests/unit/maintenance/test_inactive_candidate_durable_barrier.py
tests/unit/storage/test_archive_tuple_location.py` — 93 passed.

`bash nix/devtools-wrapper.sh verify schema-versioning` — Schema
evolution policy intact.

`bash nix/devtools-wrapper.sh verify oracle-integrity` — Oracle
integrity intact.

`bash nix/devtools-wrapper.sh verify --quick` — all quick gates passed.

Residual risk

The dispatch-named `tests/unit/storage/test_archive_tuple_activation.py`
is absent from this branch, so that exact command cannot collect it.
This change validates the existing index open/bootstrap route; it does
not add a new whole-tuple activation API.

Reviewed-by: Claude (Opus) cross-family review
Sinity added a commit that referenced this pull request Sep 3, 2026
The upward walk that resolves a session's repository stopped at nothing,
so with the managed temp trees inside the checkout every scratch path
resolved to the checkout itself. The walk now stops before a listed
ceiling, as git does, and the ceiling is part of the normalization
cache key.

Tests: tool results without structural evidence are admitted as unknown
with not_reported (#4539) and the writer refusal is exercised on a block
with no evidence at all; block payloads carry tool_outcome (#4502); a
provider-reported cost rolls up as "exact" (#4493); the v61 replace-table
keeps the surviving canonical columns; the bulk-delete canaries and the
naive-join survivor use TEMP objects on the opened connection so the
schema manifest check at open no longer refuses them (#4472, #4594).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
@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 0914f89):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 74.F052 / P1: fixed-already at the checked revision: The current-version index branch installs runtime indexes before checking the identity and canonical manifest at polylogue/storage/sqlite/archive_tiers/bootstrap.py:351-353. A missing runtime index therefore reaches the writable ensure rather than failing the manifest check first.
  • 74.F053 / P1: stale at the checked revision: initialize_archive_database no longer has the clone-safe fast-forward-and-return branch. At polylogue/storage/sqlite/archive_tiers/bootstrap.py:600-623 a nonzero noncurrent derived version raises with rebuild guidance, while the current-version branch uses converge_same_version_tier and its manifest assertion at :353.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 76.F063 / P1: fixed-already at the checked revision: The readable-layout helper computes the canonical semantic manifest diff and rejects mismatched non-FTS objects; the explicitly degradable message-FTS surface is handled separately rather than all objects being admitted by version alone. See polylogue/storage/sqlite/schema.py:108.
  • 76.F076 / P1: refuted at the checked revision: Admitting the predecessor v77 trigger definitions is not required by the current fresh format; no same-version index variants are declared at this pin. The fresh-format contract excludes migration or readback of earlier Polylogue state, while allowing new external source ingestion. See AGENTS.md:75.

Only the rows listed above are dispositioned. Held findings remain open.

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