Repository navigation
feat(ops): fast-forward index v36 without raw replay - #2931
Conversation
Index v37 only retires three derived run-projection cache tables, but the blanket rebuild path replays 74.7 GB of unchanged raw evidence. Add a clone-first, receipt-backed actuator that proves the exact v36 schema surplus, preserves every surviving table count, validates foreign keys and quick-check, and promotes through the owned generation lifecycle. Ref polylogue-n3an Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 44 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 (3)
📝 WalkthroughWalkthroughAdds a clone-first CLI workflow that advances a Polylogue SQLite index from schema v36 to v37 by removing retired caches, validating evidence, writing receipts, and promoting the prepared generation. It also cleans stale attachment mappings during writes and lineage re-extraction. ChangesIndex v37 Fast-Forward and Attachment Cleanup
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant FastForwardCLI
participant SQLiteIndex
participant GenerationStore
Operator->>FastForwardCLI: run prepare
FastForwardCLI->>SQLiteIndex: validate v36 and capture evidence
FastForwardCLI->>GenerationStore: create and clone inactive generation
FastForwardCLI->>SQLiteIndex: repair mappings, retire caches, set v37
FastForwardCLI-->>Operator: print prepared receipt
Operator->>FastForwardCLI: run activate
FastForwardCLI->>GenerationStore: revalidate and promote generation
FastForwardCLI-->>Operator: print activated receipt
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7366b18ac7
ℹ️ 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".
A cleanly stopped daemon may leave committed pages in the active index WAL. The schema-forward actuator previously rejected that valid state before it could establish clone evidence.\n\nCheckpoint and truncate the stopped database under the rebuild lease, then retain the existing strict sidecar and schema checks. Cover the production failure shape with a focused actuator test.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
SQLite can retain a non-empty shared-memory sidecar after the final writer exits even when WAL checkpointing completed successfully. Treat the checkpoint tuple as the proof boundary and remove WAL/SHM coordination files only after a complete checkpoint under the stopped-daemon rebuild lease.\n\nExercise the observed non-empty SHM residue in the actuator test.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devtools/index_v37_fast_forward.py`:
- Around line 49-52: Update _normalize_ddl so schema comparisons preserve SQL
token boundaries and whitespace within string literals instead of removing all
whitespace and quoting. Prefer comparing structured PRAGMA metadata; otherwise
tokenize the DDL while retaining identifiers, literals, and token boundaries,
and ensure both preflight and postflight use the safer comparison.
- Around line 292-319: Update the activation flow around RebuildLease and
store.promote to call IndexGenerationStore.recover_promotion() after loading the
generation, allowing interrupted promoting states to resume. When the receipt is
still prepared but its verified generation is already the active pointer,
finalize the receipt metadata without attempting a second promotion; preserve
the existing ownership, state, snapshot, identity, schema, and count
validations, and add coverage for interruptions before metadata completion and
after promotion before receipt persistence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4a104aac-a488-467e-9c22-344e366c057e
📒 Files selected for processing (4)
devtools/command_catalog.pydevtools/index_v37_fast_forward.pydocs/devtools.mdtests/unit/devtools/test_index_v37_fast_forward.py
Persist activation intent before promotion and reconcile interrupted pointer swaps through IndexGenerationStore recovery. Bind the prepared receipt to the clone's exact bytes and canonical schema so count-preserving in-place mutations cannot be promoted.\n\nReuse the completed prepare proof during activation instead of repeating full integrity and row-count scans; exact byte identity is the activation boundary.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
Prove the v36-to-v37 drop-only transition with zero DML changes and stable root-page identities for every surviving table and index. Retain one final integrity and foreign-key pass, exact canonical DDL, and byte identity while removing full pre/post table-count scans.\n\nRecord active evidence, reflink, postflight, hash, and total phase timings in the receipt so maintenance cost is observable.\n\nRef polylogue-n3an. Ref polylogue-6mvg.\n\nCo-Authored-By: Claude <[email protected]>
The live index intentionally carries safe runtime index extensions outside the base INDEX_DDL. Build the exact v37 target schema from both the canonical DDL and the runtime index registry, and make the v36 fixture reflect the same production initialization path.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
Bulk ingest can suspend foreign-key enforcement while FTS triggers are dropped. The manual lineage cleanup removed attachment refs but left their native-id children behind, producing 1,108 live FK violations in the derived index.\n\nDelete native identifiers explicitly before prefix/session ref cleanup and ref replacement. Repair the existing orphan set only in the inactive v37 clone, recording the exact repaired count before full integrity verification.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
A completed production foreign-key scan showed every live violation belonged to the orphan attachment-native-id relation. For the drop-only forward, prove no surviving FK targets a retired table, preserve every surviving root page, and validate the repaired child relation directly.\n\nKeep the full physical quick check and exact-byte identity while avoiding a logically redundant archive-wide FK rescan.\n\nRef polylogue-n3an. Ref polylogue-6mvg.\n\nCo-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devtools/index_v37_fast_forward.py`:
- Around line 343-360: The activation flow around recover_promotion and the
active-state branch must preserve an already-activated receipt as immutable
historical evidence. When the existing receipt is already activated, return it
unchanged without refreshing generation, active_identity_after, or
activated_at_ms; only update and write the receipt when recovering an activating
state.
In `@tests/unit/storage/test_lineage_normalization.py`:
- Around line 754-765: Add an assertion in the test flow after the parent is
written and the child’s prefix is extracted or deleted, verifying that the
attachment_native_ids table count drops from one to zero. Anchor the assertion
to the existing write_parsed_session_to_archive and child-prefix cleanup logic,
preserving the current insertion-count assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d89fa616-69af-4510-9b54-6658e1187ce4
📒 Files selected for processing (4)
devtools/index_v37_fast_forward.pypolylogue/storage/sqlite/archive_tiers/write.pytests/unit/devtools/test_index_v37_fast_forward.pytests/unit/storage/test_lineage_normalization.py
Fail before checkpointing or cloning the production index when the requested receipt cannot be written atomically. This prevents a long proof run from being discarded only at its final persistence step.\n\nAdd a regression proving an invalid receipt parent creates no generation and never reaches active-index checkpointing.\n\nRef polylogue-n3an.\n\nCo-Authored-By: Claude <[email protected]>
An already-activated receipt could be rewritten against later database state, corrupting the historical activation proof. Schema comparison also erased token and literal boundaries while normalizing DDL.\n\nReturn completed receipts unchanged and tokenize SQLite DDL while preserving identifier, literal, numeric, and operator boundaries. Cover both invariants with focused regressions.\n\nCo-Authored-By: Claude <[email protected]>
The child-before-parent lineage regression inserted an attachment mapping but did not assert its removal after prefix extraction with foreign keys suspended. Add the missing production-route assertion.\n\nCo-Authored-By: Claude <[email protected]>
## Summary Records the completed and live-activated v36→v37 fast-forward in `polylogue-n3an`. ## Problem PR #2931 merged the proof-gated actuator and the live activation succeeded, but the owning Bead remained in progress. That stale state made an already-v37 archive appear to need another cutover. ## Solution Close `polylogue-n3an` with the activated receipt and live-schema evidence. Keep the ongoing raw-revision CAS retries explicitly separate in their existing authority work. ## Verification - `jq` over `/realm/tmp/polylogue-index-v37-fast-forward/receipt.json` → `status: activated`. - `PRAGMA user_version` on the live index → `37`. - Retired-table census → `0`. - `systemctl --user is-active polylogued.service` → `active`. - `.agent/scripts/bd-graph-lint` → zero cycles/violations. Co-authored-by: Codex <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds a proof-gated clone-first index v36→v37 actuator for the exact schema transition that retires three run-projection cache tables. It preserves the active v36 generation as rollback and avoids replaying 52,066 raw rows / 74.7 GB.
Problem
The documented blanket derived-tier rebuild spent about 86 seconds of one CPU core before writing its first session and would reread 74.7 GB, even though v37 changes no surviving schema object. Current master cannot run against the live v36 index, blocking deployment of the browser-capture reliability repair.
Solution
devtools workspace index-v37-fast-forward prepare|activate.user_versiontransactionally.IndexGenerationStorerollback retention.Ref polylogue-n3an
Verification
devtools test tests/unit/devtools/test_index_v37_fast_forward.py→ 4 passed in 18.94s.devtools verify --quick→ all 16 checks passed; run20260716T100223Z-quick-111389-3f295a18.devtools verify --quick→ all checks passed; run20260716T100312Z-quick-113641-65d7e0ab.Summary by CodeRabbit
attachment_native_idswhen bulk operations affect foreign key enforcement.