Skip to content

fix: Replace mutable SQLite byte snapshots with declared logical-source… - #5022

Merged
Sinity merged 2 commits into
masterfrom
batch/polylogue-20260913-133117-aee40170/integration
Sep 13, 2026
Merged

Sinity merged 2 commits into
masterfrom
batch/polylogue-20260913-133117-aee40170/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260913-133117-aee40170 on base a0187cfc1fed.

polylogue-jbcln Replace mutable SQLite byte snapshots with declared logical-source semantics

  • 1. Every admitted mutable SQLite path has a keep-logical, exclude, or bounded-forensic disposition, with the logical data product and its consumer named for every keep.
  1. Wanted content is acquired t

@coderabbitai

coderabbitai Bot commented Sep 13, 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: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f984605b-2574-4a4d-80f2-ad6d1387d7be


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 13, 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-13T13:59:11.912698Z 72a64af 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 5f487b1 into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the batch/polylogue-20260913-133117-aee40170/integration branch September 13, 2026 14:03
Sinity added a commit that referenced this pull request Sep 14, 2026
…5163)

## Summary

Four Hermes marker tests failed with `ValueError: Hermes marker
{state_db_path,verification_db_path} does not name the declared logical
export for its own source; refusing to open it`. All four are **stale
tests**, not a product defect: they build markers production no longer
mints. Retargeted to the material the ingest route actually produces. No
product code changed.

## Evidence

Full-corpus `verify_all` on frozen `master` (`890a2921e`), job 1570,
receipt `.cache/verify/runs/20260914T200510Z-all-4027943-f8bc83ff`,
22,524 selected, **147 failures with zero schema skew**. Four of them:

```
tests/unit/sources/parsers/test_hermes_verification.py::test_dispatch_detects_and_parses_verification_marker_through_the_real_pipeline
tests/unit/sources/parsers/test_hermes_verification.py::test_dispatch_wires_profile_root_from_source_path_for_verification_marker
tests/unit/sources/test_parsers_local_agent.py::test_hermes_state_db_dispatch_marker_parses_multiple_sessions
tests/unit/sources/test_parsers_local_agent.py::test_hermes_state_db_profile_qualifies_identity_and_retains_raw_id
  E   ValueError: ... does not name the declared logical export for its own source; refusing to open it
```

## Per-failure classification

All four: **stale test**. Which side is wrong was established from the
production route before changing anything.

`archive/raw_payload/decode.py::_hermes_sqlite_marker_payload` is the
only place that mints a Hermes SQLite marker, and it mints one **only**
behind `is_declared_logical_export(path, source_path)`. So in production
`state_db_path` / `verification_db_path` always names the *retained
declared logical export blob*, while `source_path` names the original
database. `hermes_state.require_declared_export` re-checks exactly that
pairing at parse time — the confused-deputy guard that stops an imported
JSON document from steering the parser at another database.

What the tests passed instead:

| Test | What it built | Why production never builds it |
| --- | --- | --- |
| `test_hermes_state_db_dispatch_marker_parses_multiple_sessions` |
marker over the **live** `state.db`, `source_path` = the same live path
| `_hermes_sqlite_marker_payload` only sees a retained export, never the
live member |
|
`test_dispatch_detects_and_parses_verification_marker_through_the_real_pipeline`
| marker over the live `verification_evidence.db`, **no** `source_path`
| fail-closed default, pinned by
`test_state_db_marker_without_a_source_path_is_refused` |
|
`test_dispatch_wires_profile_root_from_source_path_for_verification_marker`
| same, per install | same |
| `test_hermes_state_db_profile_qualifies_identity_and_retains_raw_id` |
marker over a hand-made `conn.backup()` **page image**, no `source_path`
| a page image cannot regain logical-source identity
(`retained_content_revision`); acquisition retains the declared export |

Behaviour changed by **#5040** (`is_declared_logical_export` gate on the
marker route) and **#5022** (mutable SQLite sources retained as declared
logical exports rather than page images). The refusals these tests hit
are the guards those PRs added working correctly —
`tests/unit/sources/parsers/test_hermes_state.py::test_state_db_marker_refuses_a_database_it_does_not_declare`
and `::test_state_db_marker_without_a_source_path_is_refused` pin
exactly this and were green throughout.

**Not** the Hermes profile-root defect. `polylogue-q5j3o` ("Hermes
artifact families derive different profile roots, splitting one
install's session in two") is a real open P2 about
`profile_root_for_session_snapshot` disagreeing between `state.db` and
the ATOF/ATIF/verification families. It is a different mechanism (which
directory the profile key hashes) and is **untouched by this PR** — none
of these four failures is caused by it, and none of them is fixed by
fixing it.

## Solution

Each test retains the member's canonical logical export via
`snapshot_sqlite_to_blob` (a small `_declared_export_of` helper per
file) and parses the marker against its own `source_path` — the pairing
the ingest route creates. No guard was weakened; the refusal behaviour
is unchanged.


`test_dispatch_detects_and_parses_verification_marker_through_the_real_pipeline`
now gets profile-qualified ids, because dispatch wires the install's
profile root (which is the point of the sibling test next to it). Its
assertion splits accordingly: base ids compared as a set, plus an
explicit assertion that every id carries `@profile-`. That is strictly
more than it asserted before.

Anti-vacuity, restated in each docstring: point the marker at any
database that is not the declared export of its `source_path` (or drop
`source_path`) and the parse raises `ValueError` instead of returning
the sessions asserted — the confused-deputy read the guard exists to
refuse.

## Verification

```
devtools test tests/unit/sources/parsers/test_hermes_verification.py \
              tests/unit/sources/parsers/test_hermes_state.py \
              tests/unit/sources/test_sqlite_logical_source_identity.py \
              tests/unit/sources/test_parsers_local_agent.py
devtools test: PASSED exit=0 diagnosis=pytest_passed receipt=.cache/verify/runs/20260914T221308Z-focused-test-5853-86fc175c/run.json
```

The selection deliberately includes the two guard tests and the
logical-source-identity suite, so a change that made these four pass by
weakening the confinement would have gone red in the same run.

`devtools verify --quick` — all 17 gates ok.

## Schema closure

```
out  tests/unit/sources/parsers/test_hermes_verification.py
out  tests/unit/sources/test_parsers_local_agent.py
```

Neither file is in the derived-schema identity closure; this PR does not
gate the archive rebuild.

## Residuals

- `polylogue-q5j3o` (Hermes families derive different profile roots)
remains open and unaddressed here.
- The retargeted tests now exercise the export-blob marker route. The
live-database *iterator* route (`iter_source_sessions_with_raw`) was
already covered separately and was green before and after.

🤖 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]>
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