refactor(devtools): prove lifecycle fast-forwards with raw replay - #3793
Conversation
Problem: the surviving v37 actuator had a per-version implementation and no source-backed semantic proof before promotion. What changed: lifecycle declarations now drive one generic actuator and executor. Preparation replays deterministic retained-raw samples through the production parser and writer, compares canonical rows, records sample IDs and parser, lowering, and materializer fingerprints, and activation refuses drift or incomplete proof. The v37 orphan repair is now a declared lifecycle operation. The obsolete actuator and focused test were removed. Compatibility/migration: semantic-reparse declarations remain ineligible for SQL fast-forward and continue through replay or rebuild. The command is now workspace index-fast-forward.
|
Warning Review limit reached
Next review available in: 40 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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 Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR replaces the version-specific v36-to-v37 actuator with a generic ChangesIndex fast-forward lifecycle
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant prepare_forward
participant RetainedRawSessions
participant CandidateIndex
participant Receipt
participant activate_forward
CLI->>prepare_forward: prepare archive
prepare_forward->>RetainedRawSessions: replay sampled sessions
RetainedRawSessions->>CandidateIndex: produce replay corpus
CandidateIndex-->>prepare_forward: return equivalence proof
prepare_forward->>Receipt: write integrity-hashed receipt
CLI->>activate_forward: activate receipt
activate_forward->>Receipt: revalidate proof and fingerprints
activate_forward->>CandidateIndex: promote inactive generation
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 5
🤖 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_fast_forward.py`:
- Around line 408-427: Update _require_complete_proof to directly compare the
validated fast_forward_hashes and canonical_replay_hashes dictionaries,
including their scoped contents, and raise IndexFastForwardError when they
differ. Keep the existing structural validation and mismatch_details checks, but
make activation-time proof validation self-contained rather than relying solely
on the replay-generated mismatch list.
- Around line 289-309: Chunk SQLite IN-list lookups to stay below the
host-variable ceiling while preserving ordering, grouping, and selection
semantics: update _sample_manifest and the message lookup in _canonical_hashes,
including the blocks query that binds message IDs. Apply limit only after
collecting the same logical results. Add coverage in
tests/unit/devtools/test_index_fast_forward.py that exceeds a small
variable-limit threshold, such as 10 parameters per chunk, and verifies these
paths complete without too-many-variables errors.
- Around line 357-361: Update the fts query in the hash construction to order
rows by stable identity columns rather than rowid, using the same deterministic
ordering across replay and clone databases. Keep the selected columns and
session filtering unchanged so multi-row FTS samples produce comparable hashes.
- Around line 228-235: Update _expected_surplus to import
FastForwardOperationKind and compare operation.kind directly with
FastForwardOperationKind.DROP_TABLE instead of comparing operation.kind.value to
a string literal.
In `@tests/unit/devtools/test_index_fast_forward.py`:
- Around line 166-187: Add a test alongside the existing fast-forward integrity
tests that prepares a receipt, loads its JSON, mutates a field such as
source_snapshot, and writes it back without updating the hash. Then call
activate_forward and assert IndexFastForwardError with a “hash mismatch”
message, while verifying the archive’s active generation remains v36; reuse the
existing _archive, running_daemon_pid patching, and _no_corpus_failure helpers.
🪄 Autofix
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 Plus
Run ID: e6f1190c-e44e-427b-b7aa-4042991f8b84
📒 Files selected for processing (10)
devtools/command_catalog.pydevtools/index_fast_forward.pydevtools/index_v37_fast_forward.pydocs/devtools.mddocs/internals.mdpolylogue/storage/index_generation.pypolylogue/storage/sqlite/archive_tiers/index_fast_forward_executor.pypolylogue/storage/sqlite/lifecycle.pytests/unit/devtools/test_index_fast_forward.pytests/unit/devtools/test_index_v37_fast_forward.py
💤 Files with no reviewable changes (2)
- devtools/index_v37_fast_forward.py
- tests/unit/devtools/test_index_v37_fast_forward.py
The retained-raw proof must work for archive-scale identifier sets and must reject a receipt whose declared equivalence no longer matches its stored hashes. Chunk SQLite IN queries, normalize FTS comparison ordering, and make activation validate the two hash dictionaries directly. The regressions exercise chunked archive reads, forged proof data, and a receipt modified without updating its integrity hash. Co-Authored-By: Codex <noreply@openai.com>
Bind scoped proof query parameters explicitly and preserve typed manifest session identifiers in the archive-scale regression. Co-Authored-By: Codex <noreply@openai.com>
Summary
Unify derived-tier fast-forward proof under the lifecycle planner and require retained-raw replay equivalence before activation.
Problem
Version-specific upgrade helpers could establish a schema-compatible candidate without proving that the current parser, lowering, and materialization path reproduces the derived model from retained source evidence.
Solution
The generic lifecycle executor records a deterministic bounded raw sample, parser and materialization fingerprints, and canonical table comparisons. Activation refuses source, fingerprint, schema, clone, or replay-proof drift. The obsolete v37 helper and its test are removed.
Verification
direnv exec . devtools test tests/unit/devtools/test_index_fast_forward.pyResult:
4 passed in 9.18s.Ref polylogue-9rw0.
Summary by CodeRabbit
New Features
Documentation