Repository navigation
refactor(storage): normalize foreign_keys pragma across user-tier overlay writers - #3110
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…rlay writers Problem: only 4 of 10 user-tier overlay-write functions (upsert_suppression, upsert_mark, upsert_annotation, upsert_correction) set PRAGMA foreign_keys themselves, and the copy inside upsert_assertion itself ran after BEGIN IMMEDIATE had already started the transaction -- SQLite silently no-ops this pragma once a transaction is active, so that call was dead code on every invocation. The other 6 overlay functions (upsert_session_tag_assertion, upsert_session_metadata_assertion, upsert_saved_view, upsert_recall_pack, upsert_workspace, upsert_blackboard_note) never enabled it at all. Flagged as a completeness addendum on polylogue-41ow: low-impact today since assertions declares no FK constraint, but worth normalizing while every write call site in this file was already being read for that bead's TOCTOU fix. Solution: added _ensure_foreign_keys_pragma(conn), called once at the top of upsert_assertion before entering _immediate_user_write_transaction (so it actually takes effect instead of running mid-transaction). upsert_assertion is the single write chokepoint every overlay function and every direct external caller (security/lifecycle.py, security/secret_scan.py, scenarios/corpus.py, storage/repair.py, storage/raw_reconciler.py, annotations/write.py) already funnels through, so consolidating here covers all of them uniformly without duplicating the call at each site. Removed the four now-fully-redundant inline calls. No behavior change for any current test: assertions has no FK constraint, so enforcement being on or off doesn't affect any write today. This is a pure future-safety normalization. Verification: - New regression: test_overlay_writers_enable_foreign_keys_before_first_transaction (tests/unit/storage/test_archive_tiers_assertions.py) -- explicitly disables the pragma, calls upsert_saved_view (one of the six writers that never enabled it before), asserts it's enabled afterward. - Anti-vacuity: reverted the source change via git stash, keeping the new test -- it fails (0 == 1); passes after restoring the fix. - devtools test across the full assertion/annotation/security write-path suite -> 146 passed. - devtools verify --quick -> exit 0. Ref polylogue-41ow Co-Authored-By: Claude <[email protected]>
5693a31 to
f062b9f
Compare
…lution deliveries Ref polylogue-41ow, polylogue-fd2s, polylogue-9gh1, polylogue-2o3d Problem: two files staged at /realm/tmp/gpt-pro-intake-0719/ (judgment-*.md/.diff, config-*.md/.diff) were flagged as fresh wave-2 deliveries needing triage, targeting snapshot 536a53e (#3046). Master has since moved ~180 commits including 33 merges. Solution: verified pairing first (judgment-* files cross-reference polylogue-41ow/37t.12/mrxt and match mission ann-04; config-* files cross-reference polylogue-fd2s/9gh1 and match mission misc-01). SHA-256 of every file was then found byte-identical to the already-recorded results/ann-04/r01 and results/misc-01/r01 packages -- these are not new deliveries, they are exact re-submissions of packages already triaged 2026-07-18. Re-verified git apply --check against both the stated snapshot (passes cleanly for both) and current origin/master (fails on every production file for both -- confirms drift). Cross-referenced current source against each package's claims: - ann-04 (judgment-transaction): bd polylogue-41ow (closed, PR #3101+#3110) independently fixed the writer-slot TOCTOU race; bd polylogue-2o3d (closed, PR #3138) independently ported the delivery's entire additive scope (evidence previews, queue health, judge consolidation, capture idempotency) after its own line-by-line audit. Supersession is now total, not partial as r01 judged it before those PRs landed. Recorded as r02 (state=superseded). - misc-01 (config-resolution-closure): PR #3079 (merged 2026-07-18, explicitly sourced from an earlier revision of this same packet family) already shipped ResolvedRuntimeConfig/single-resolver/archive_root-fix. Live-checked polylogue/config.py:1514 -- deep-merge for nested health tables (polylogue-cxlk) is already landed. Genuine residual found: uu8r-scope env-bypass migrations (daemon/backup.py, pipeline/services/archive_ingest.py, and ~5-6 more files this delivery's own bypass-caller table names) are still unmigrated on current master, but must be re-derived against the already-landed config API rather than applying this patch's hunks (no shared ancestor). Recorded as r02 (state=superseded, with residual noted for polylogue-uu8r). Verification: sha256sum on all 8 delivered files cross-checked against existing r01 records (identical); git apply --check run against both 536a53e (clean) and origin/master e963e87 (fails, 20-73 files per patch); bd show on polylogue-41ow/fd2s/9gh1/cxlk/uu8r/2o3d to confirm current close/open state and what each merged PR actually covers; grep -rl ResolvedRuntimeConfig and read of _merge_toml/_deep_merge_table in polylogue/config.py to confirm the architecture is live, not just claimed. Triage notes appended to polylogue-41ow and polylogue-fd2s via bd update --append-notes. No patch was applied to master; no bead was closed or reopened by this change. Co-Authored-By: Claude <[email protected]>
… deliveries Ref polylogue-41ow, polylogue-fd2s, polylogue-9gh1, polylogue-2o3d Problem: two files staged at /realm/tmp/gpt-pro-intake-0719/ (judgment-*.md/.diff, config-*.md/.diff) were flagged as fresh wave-2 deliveries needing triage, targeting snapshot 536a53e (#3046). Master has since moved ~180 commits including 33 merges. Solution: verified pairing first (judgment-* files cross-reference polylogue-41ow/37t.12/mrxt and match mission ann-04; config-* files cross-reference polylogue-fd2s/9gh1 and match mission misc-01). SHA-256 of every file was then found byte-identical to the already-recorded results/ann-04/r01 and results/misc-01/r01 packages -- these are not new deliveries, they are exact re-submissions of packages already triaged 2026-07-18. Per results/README.md custody policy ("Duplicated browser downloads with identical SHA-256 values are deliberately not copied twice", precedent: lin-01/r01), this revision does NOT mint a second package-revision identity (r02) or duplicate the raw/extracted artifact bytes. Instead the 2026-07-20 reassessment is recorded as a dated `reassessments` entry inside each existing r01 receipt.json, alongside an updated top-level `state` where the evidence changed: - ann-04/r01: state needs_rebase_review -> superseded. bd polylogue-41ow (closed, PR #3101+#3110) independently fixed the writer-slot TOCTOU race; bd polylogue-2o3d (closed, PR #3138) independently ported the delivery's entire additive scope (evidence previews, queue health, judge consolidation, capture idempotency) after its own line-by-line audit found the MCP-surface hunks obsolete (six-tool cutover) and the delivery's transaction mechanism redundant with #3101. Supersession is now total, not partial as originally judged before those PRs landed. - misc-01/r01: state stays superseded, rationale now explicit. PR #3079 (merged 2026-07-18, sourced from an earlier revision of this same packet family) already shipped ResolvedRuntimeConfig/single-resolver/ archive_root-fix/deep-merge. There is no viable rebase target for this patch against the current config API -- #3079 shipped a differently shaped ResolvedRuntimeConfig with no common ancestor, so any further work must be re-derived, not revived from this diff. The genuine residual (uu8r-scope env-bypass migrations, e.g. daemon/backup.py, pipeline/services/archive_ingest.py, still unmigrated on master) is tracked durably as polylogue-uu8r directly, not as a pending state on this package. Re-verified git apply --check against both the stated snapshot (passes cleanly for both) and current origin/master, checked twice: once at the original triage base (e963e87) and again after rebasing onto the latest tip (1c0f4ec, three commits later -- #3175 CLI onboarding convergence plus two beads-filing commits, none touching the affected files). Both patches fail identically both times. Verification: sha256sum on all 8 delivered files cross-checked against existing r01 records (identical); git apply --check as above; bd show on polylogue-41ow/fd2s/9gh1/cxlk/uu8r/2o3d to confirm current close/open state and what each merged PR actually covers; grep -rl ResolvedRuntimeConfig and read of _merge_toml/_deep_merge_table in polylogue/config.py to confirm the architecture is live, not just claimed; devtools verify --quick 16/16 green (pre-push hook). Triage notes appended to polylogue-41ow and polylogue-fd2s via bd update --append-notes, including a correction note for the earlier (superseded) r02 framing. No patch was applied to master; no bead was closed or reopened by this change. Co-Authored-By: Claude <[email protected]>
…lution deliveries (#3177) ## Summary Re-triages two ChatGPT-Pro handoff packages staged at `/realm/tmp/gpt-pro-intake-0719/` (`judgment-*.md/.diff`, `config-*.md/.diff`), targeting snapshot `536a53efac0cbe4a2473ad379e4db49ef3fce74d` (#3046). Both are byte-identical duplicate downloads of packages already on file as `results/ann-04/r01` and `results/misc-01/r01`. Per the custody policy (`results/README.md`: "Duplicated browser downloads with identical SHA-256 values are deliberately not copied twice", precedent: `lin-01/r01`), this PR does **not** mint a second package-revision identity or duplicate raw/extracted artifact bytes — it records the 2026-07-20 reassessment as a dated `reassessments` entry inside each existing `r01` receipt, with the top-level `state` updated where the evidence changed. No patch is applied to master; no bead is closed or reopened. ## Problem Both files were flagged as fresh wave-2 deliveries needing triage. Master has moved ~180 commits (33+ merges) past the stated snapshot. ## Solution **Pairing verification (step 0):** `judgment-*` files cross-reference polylogue-41ow/37t.12/mrxt and match mission `ann-04-judgment-transaction`; `config-*` files cross-reference polylogue-fd2s/9gh1 and match mission `misc-01-config-closure`. The mapping was correct as staged. **Commission identification (step 1):** both missions already have `r01` result entries on disk. SHA-256 of every one of the 8 delivered files is byte-identical to the corresponding `results/ann-04/r01` and `results/misc-01/r01` artifacts (`diff -q` reports no differences) — these are re-submissions of packages already triaged 2026-07-18, not new deliveries. **Triage (step 2), recorded as `reassessments` entries in the existing `r01` receipts:** - `git apply --check` passes cleanly for both patches against the stated snapshot (integrity confirmed) and fails for both against current `origin/master`, re-checked three times as master advanced during triage (`e963e87f5` → `1c0f4eccd` → `610ce8d9`, none of the intervening commits touch the affected core files). - **ann-04 (judgment-transaction): `r01` state `needs_rebase_review` → `superseded`.** bd `polylogue-41ow` (closed, PR #3101+#3110) independently fixed the writer-slot TOCTOU race; bd `polylogue-2o3d` (closed, PR #3138) independently ported the delivery's entire non-overlapping additive scope (evidence previews, queue health, judge-command consolidation, capture idempotency) after its own line-by-line audit found the MCP-surface hunks obsolete (six-tool cutover) and the delivery's transaction mechanism redundant with #3101. Supersession is now total — every acceptance-matrix row this delivery claims already has an independent, merged, adjudicated master implementation. - **misc-01 (config-resolution-closure): `r01` state stays `superseded`, rationale now explicit.** PR #3079 (merged 2026-07-18, explicitly sourced from an earlier revision of this same GPT-Pro packet family) already shipped `ResolvedRuntimeConfig`, the single resolver, the `archive_root` TOML fix, and deep-merge for nested health tables (live-checked `polylogue/config.py:1514` `_merge_toml`/`_deep_merge_table`). `needs_rebase_review` does not apply here: there is no viable rebase target for this patch against the current config API — #3079 shipped a differently-shaped `ResolvedRuntimeConfig` with no common ancestor, so any further work must be **re-derived against the landed API, not revived** from this diff. The genuine residual (bd `polylogue-uu8r`'s env-bypass migration scope — spot-checked `polylogue/daemon/backup.py:695` and `polylogue/pipeline/services/archive_ingest.py:48`, both still direct `os.environ.get()` reads on master) is tracked durably as `polylogue-uu8r` directly, not as a pending state on this package. Also noted, out of scope for this PR: `polylogue-fd2s`/`polylogue-9gh1` still read `status=open` in `bd` despite #3079's landing — likely bookkeeping lag, flagged in the bead notes for a separate housekeeping pass. A stray `clipboard-current.txt` in the intake directory is unrelated leftover clipboard text for the already-integrated `mandate-01` delivery (same SHA as `results/mandate-01/r01`, PR #3088, merged) — not part of either package, not touched by this PR. ## Verification - `sha256sum` on all 8 delivered files, cross-checked against existing `r01` records: identical. - `git apply --check` against `536a53efac0cbe4a2473ad379e4db49ef3fce74d`: clean for both patches (detached worktree). - `git apply --check` against `origin/master`, checked at `e963e87f5`, `1c0f4eccd`, and `610ce8d9` as master advanced during triage: fails identically every time (20 production files for judgment, 21 for config; some judgment files/tests no longer exist post six-tool MCP cutover). - `bd show polylogue-41ow/fd2s/9gh1/cxlk/uu8r/2o3d --json` to confirm current close/open state and what each merged PR actually covers. - `grep -rl ResolvedRuntimeConfig polylogue/` plus a read of `polylogue/config.py:1514` (`_merge_toml`/`_deep_merge_table`) to confirm the architecture is live on master, not just claimed by a PR title. - `devtools verify --quick`: 16/16 green (pre-push hook, this branch, each push). - Triage notes appended to `polylogue-41ow` and `polylogue-fd2s` (plus a correction note on both retracting the earlier, policy-violating `r02` framing) via `bd update --append-notes` + `bd export`. Ref polylogue-41ow, polylogue-fd2s, polylogue-9gh1, polylogue-2o3d Co-authored-by: Claude <[email protected]>
Summary
Small follow-up from polylogue-41ow's completeness addendum: consolidates nine independently-inconsistent
PRAGMA foreign_keys = ONcall sites into one, actually-effective call at theupsert_assertionchokepoint.Problem
Only 4 of 10 user-tier overlay-write functions (
upsert_suppression,upsert_mark,upsert_annotation,upsert_correction) setPRAGMA foreign_keysthemselves, and the copy insideupsert_assertionitself ran afterBEGIN IMMEDIATEhad already started the transaction — SQLite silently no-ops this pragma once a transaction is active, so that call was dead code on every invocation. The other 6 overlay functions (upsert_session_tag_assertion,upsert_session_metadata_assertion,upsert_saved_view,upsert_recall_pack,upsert_workspace,upsert_blackboard_note) never enabled it at all.Solution
Added
_ensure_foreign_keys_pragma(conn), called once at the top ofupsert_assertionbefore entering_immediate_user_write_transaction(so it actually takes effect instead of running mid-transaction).upsert_assertionis the single write chokepoint every overlay function and every direct external caller (security/lifecycle.py,security/secret_scan.py,scenarios/corpus.py,storage/repair.py,storage/raw_reconciler.py,annotations/write.py) already funnels through, so consolidating here covers all of them uniformly. Removed the four now-fully-redundant inline calls.No behavior change for any current test:
assertionshas no FK constraint, so enforcement being on or off doesn't affect any write today. This is a pure future-safety normalization.Verification
test_overlay_writers_enable_foreign_keys_before_first_transaction(tests/unit/storage/test_archive_tiers_assertions.py) — explicitly disables the pragma, callsupsert_saved_view(one of the six writers that never enabled it before), asserts it's enabled afterward.git stash, keeping the new test — it fails (0 == 1); passes after restoring the fix.devtools testacross the full assertion/annotation/security write-path suite → 146 passed.devtools verify --quick→ exit 0.Ref polylogue-41ow