Skip to content

fix(storage): adopt read profiles in archive support consumers - #5564

Merged
Sinity merged 1 commit into
masterfrom
work/bp12n5-read-inventory
Sep 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
work/bp12n5-read-inventory

Conversation

@Sinity

@Sinity Sinity commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Summary

Adopt the profiled SQLite read boundary in another set of archive support consumers and reject persistent writes through profiled readers.

Problem

Several diagnostics, maintenance commands, embedding paths, and archive reads still opened SQLite directly. A connection intended for reads could also execute a write after setup, and read-only attachment behavior was inconsistent.

Solution

Use the existing connection profiles at the touched consumers. Install a read authorizer after connection setup, provide an explicit read-only ATTACH helper, and allow narrowly scoped TEMP vector staging while persistent tiers remain protected. The broader remaining-open inventory is recorded in successor bead polylogue-2w2mr; bp12n.5 remains open.

Verification

  • devtools test tests/unit/storage/test_connection_profile.py tests/unit/cli/test_reset.py tests/unit/storage/test_vec.py tests/unit/daemon/test_metrics_endpoint.py -k 'profiled_reader_rejects_write_mutants_at_sqlite_boundary or readonly_temp_staging_cannot_write_persistent_or_attached_database or reset_session_resolution_uses_readonly_database_boundary or reset_source_tombstones_matching_archive_sessions or open_vector_read_snapshot_uses_only_the_explicit_pinned_paths or archive_storage_metrics_gate_runtime_readiness_on_schema_match': 13 selected, 13 passed; receipt 20260926T223021Z-focused-test-4171985-12240a77 on the exact pre-rebase worktree content.
  • devtools verify --quick: passed; receipt 20260926T222212Z-quick-4133889-b86896c7 on that content.
  • Two independent read-only reviews found no concrete wrong output in the authorizer, attachment, TEMP staging, or final import/layering changes.

The branch was rebased onto master after these local checks; the hosted quick gate checks the published head. The focused selection does not establish the remaining mixed-load and archive-generation measurements in bp12n.5.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 19 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: ed9c63dd-8351-42df-a089-e99f2cf2ff23

📥 Commits

Reviewing files that changed from the base of the PR and between dddac24 and e225410.

📒 Files selected for processing (25)
  • docs/plans/sqlite-degradation-baseline.json
  • polylogue/api/archive.py
  • polylogue/cli/commands/embed.py
  • polylogue/cli/commands/maintenance/_assertion_export.py
  • polylogue/cli/commands/paths.py
  • polylogue/cli/commands/reset.py
  • polylogue/daemon/metrics.py
  • polylogue/daemon/provenance.py
  • polylogue/maintenance/archive_verification.py
  • polylogue/operations/archive_debt.py
  • polylogue/operations/daemon_workload_probe.py
  • polylogue/operations/durable_change_train.py
  • polylogue/security/secret_scan.py
  • polylogue/storage/archive_readiness.py
  • polylogue/storage/embeddings/preflight.py
  • polylogue/storage/embeddings/reconcile.py
  • polylogue/storage/embeddings/status_payload.py
  • polylogue/storage/raw_authority.py
  • polylogue/storage/search_providers/sqlite_vec_runtime.py
  • polylogue/storage/source_sessions.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/connection_profile.py
  • polylogue/storage/usage.py
  • tests/unit/cli/test_reset.py
  • tests/unit/storage/test_connection_profile.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 26, 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-26T23:01:41.355785Z e225410 New commits
ℹ️ 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.

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

ℹ️ 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 on lines +1266 to +1268
if pragma in read_pragmas and (argument2 is None or pragma in parameterized_reads):
return sqlite3.SQLITE_OK
return sqlite3.SQLITE_DENY

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the action-join mutation survivor executable

With a normal ArchiveStore.open_existing connection, this authorizer denies the PRAGMA query_only = OFF used by test_survivor_detects_naive_duplicate_id_join_mutation before it creates its TEMP actions view. The resulting sqlite3.DatabaseError escapes instead of the expected cardinality AssertionError, so the full suite fails and the named anti-vacuity mutation no longer verifies ordinal tool-result pairing; provide a supported TEMP-view staging route or adapt the harness without removing that mutation.

AGENTS.md reference: AGENTS.md:L232-L233

Useful? React with 👍 / 👎.

@Sinity
Sinity force-pushed the work/bp12n5-read-inventory branch from e379d04 to e225410 Compare September 26, 2026 22:57
@Sinity
Sinity merged commit 0723a95 into master Sep 26, 2026
3 checks passed
@Sinity
Sinity deleted the work/bp12n5-read-inventory branch September 26, 2026 23:10
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Realigns the master tests whose failures are stale tests rather than
code defects: 16 test ids, 12 from the coordinator's list plus the
pinned read-only store test. Each one asserted a contract that a later
PR changed on purpose. The fixes below are grouped by the PR that broke
them.

## Problem and fix, by breaking PR

| Breaking PR | Tests | Why they fail | Fix |
| --- | --- | --- | --- |
| #5564 (0723a95) |
`test_pinned_read_only_store_blocks_all_archive_tier_mutations`,
`test_convergence_one_shot_readers_cannot_mutate` | The read profile's
authorizer rejects writes at prepare time with `DatabaseError: not
authorized`, before SQLite's own `OperationalError: readonly` is
reached. | Expect `sqlite3.DatabaseError` matching `not
authorized\|readonly`. The existing checks that nothing changed stay. |
| #5550 (da5346d) | Seven `test_store_ops` tag tests | Facade writes
now belong to the daemon: `add_tag` and `remove_tag` raise
`FacadeDaemonRequiredError` when no daemon is running. | The three
parametrized tests run the resident writer on the archive's own socket,
through a new `tests/infra/daemon_operations.daemon_serving_archive`;
the MCP helper now reuses it. The Hypothesis tag law calls
`ArchiveStore.add_user_tags`, the primitive the daemon's actuator
applies. It clears `open_connection`'s per-path cache between examples,
because otherwise each new example archive keeps about 11 descriptors
and trips the fd-leak guard. |
| #5700 (f2562c3) |
`test_daemon_required_envelope_preserves_resolved_archive_root` | #5700
made a daemon-absent machine refusal exit with `FAILED_READ_EXIT_CODE`
(1). The test, added in #5722, asserted 2. | Assert
`FAILED_READ_EXIT_CODE`. |
| #5727 (ee567d0) |
`test_recent_attempts_report_the_file_count_not_the_session_count` |
Read-only opens now check derived schema identity, so a hand-built
`ops.db` is refused and the probe returns no attempts. | Seed a real ops
tier with `initialize_archive_database` and a valid status. |
| #5727 | `test_compare_reports_archive_derived_readiness_deltas` |
`compare` is now not ok when either side's convergence-debt ledger is
unavailable, and a missing `ops.db` counts as unavailable. | Initialize
`ops.db`. |
| #5727 |
`test_unavailable_debt_is_rendered_unknown_and_cli_fails_closed` | The
test was added in #5727 and never passed: `"0 failed" not in output`
also matched the attempt-count line (`0 running, 0 failed`), which has
existed since #4010. | Check only the convergence-debt line. |
| #5551 (aa19052) |
`test_daemon_workload_probe_does_not_claim_derived_ready_on_schema_mismatch`
| Under the fresh format every tier starts at `user_version = 1`, so
writing 1 no longer produces a mismatch. | Set `user_version = 2`. |

Not in this PR:
- `test_raw_existence_journal_is_declared_as_content_free_bookkeeping`
was a real duplicate declaration and is fixed in #5767.
- polylogue-njwky (sqlite-vec on async attaches) was confirmed real and
is fixed in #5765.

## Verification

- `devtools test tests/unit/security/test_excision_carrier_reach.py
tests/unit/security/test_excision.py
tests/unit/storage/test_archive_tiers_archive.py
tests/unit/daemon/test_maintenance_read_profiles.py
tests/unit/cli/test_machine_main.py
tests/unit/sources/test_refused_state_is_reported.py
tests/unit/operations/test_daemon_workload_probe.py
tests/unit/storage/test_store_ops.py
tests/unit/mcp/test_mcp_writer_boundary.py`: `PASSED exit=0` (run with
#5767's change applied)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@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 ef10e59):

Resolving the fixed, stale and refuted threads; tracked threads stay open.

@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 64a9bd0):

  • P1 polylogue/storage/sqlite/connection_profile.py:1200: Fixed on master (checked at 64a9bd0): All three named sites attach through the authorizer-aware helpers: the embedding adapter (embeddings/derivation.py:320), raw_frontier_blocked_raw_ids (raw_retention.py:1314) and daemon/convergence_stages.py:840. attach_readonly_database removes the authorizer for the single read-only ATTACH (connection_profile.py:1364-1368).

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

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