Skip to content

feat(devtools): fast-forward v32 indexes without raw replay (#2804) - #2804

Merged
Sinity merged 5 commits into
masterfrom
feature/fix/v35-index-fast-forward
Jul 12, 2026
Merged

Sinity merged 5 commits into
masterfrom
feature/fix/v35-index-fast-forward

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Add a clone-first operator actuator that advances a quiesced derived index.db from v32 to v35 without parsing raw exports. The live 32 GiB archive was upgraded through this path and atomically activated with its v32 generation retained as the rollback target.

Ref polylogue-5ucz.

Problem

The healthy live index was at schema v32 while current code requires v35. Ordinary recovery would rebuild from raw material, although the intervening changes are derived-only: one CHECK widening, one index/view change, and three FTS tokenizer/folding rebuilds. A raw replay would add hours of avoidable work and expose the archive to the already-observed resource/rate-limit hazards.

Solution

  • Add devtools workspace index-fast-forward with plan, clone-upgrade, validate, activate, and rollback operations.
  • Reflink the quiesced active generation and rebuild only canonical v33-v35 derived objects from normalized index tables.
  • Keep user_version at 32 until exact structural, DDL, FK, FTS, fold, and integrity gates pass.
  • Emit a fsynced, self-hashed receipt with identities, counts, stages, pressure samples, timings, and explicit raw_reparse=false evidence.
  • Require exact stable source/clone identities plus a fresh quick_check before the atomic symlink swap.
  • Retain the v32 target and automatically restore it when the restarted service fails its version/object contract or does not keep the same active PID through a stability window.

Acceptance criteria

  • AC1 fixture/delta/failure proof: satisfied by the six focused tests, including injected failure before version advance and automatic rollback.
  • AC2 source preservation/receipts: satisfied; original generation remains at /realm/db/polylogue/.index-generations/gen-1783732901896-284abd9a/index.db.
  • AC3 no raw replay: satisfied; receipt records raw_reparse=false, and only normalized derived tables fed FTS rebuilds.
  • AC4 clone gates: satisfied; count/DDL drift empty, FK zero, quick_check=ok, exact FTS parity, folded-query smoke green, v35 final validation ready.
  • AC5 activation/rollback/postflight: satisfied for database activation and live direct queries; v32 rollback target retained. A temporary standalone browser-capture listener was removed after it conflicted with integrated daemon port 8765.
  • AC6 evidence: satisfied in the Bead notes and receipt path below.

Verification

  • devtools test tests/unit/devtools/test_index_fast_forward.py
    • 6 passed in 19.24s
  • devtools verify --quick
    • run 20260712T225217Z-quick-1722344-c0ec918b, 15/15 steps green in 68.1s
  • pre-push devtools verify --quick
    • run 20260712T225454Z-quick-1736683-eb31b5e9, 15/15 steps green in 49.86s
  • live receipt: /realm/staging/polylogue-sqlite/recovery/v35-fast-forward-20260712/receipt.json
    • sessions 17,727; messages 4,554,188; blocks 4,598,092 unchanged
    • FTS source/index counts 4,544,958 / 23,799 / 9,844, with zero missing, excess, or duplicates
    • Jaroslaw live hits 41; tlumacz live hits 245; PRAGMA user_version=35

The default testmon gate was not available in the fresh worktree because it had no seed; the complete owning test file and quick static/generated gates were run instead.

Follow-up

The installed Nix-store daemon package predates current v35 code and reports schema mismatch index; update the deployed package after merge, then repeat runtime status/journal postflight before closing polylogue-5ucz.

Sinity and others added 5 commits July 13, 2026 00:53
Add a clone-first, pressure-gated derived-index actuator that applies the exact v33-v35 schema and FTS deltas, validates the inactive clone, and activates or rolls back through an atomic generation symlink. Receipts are fsynced, self-verifying, and retain source identity, phase timings, counts, DDL hashes, and restart outcomes.\n\nRef polylogue-5ucz.\n\nCo-Authored-By: Claude <[email protected]>
Problem: activation repeated the full exact clone validator even though a hash-verified clone_ready receipt already recorded that proof. On the live 32 GB index this adds an unnecessary hour-scale scan before and after the symlink swap.

Reuse the receipt proof only when both source and clone file identities remain exact, run a fresh read-only quick_check before swapping, and reduce post-restart validation to service readiness plus v35/object sanity. Automatic v32 rollback remains intact.

Ref polylogue-5ucz.

Co-Authored-By: Claude <[email protected]>
Problem: SQLite can checkpoint and remove WAL/SHM sidecars as the final validator connection closes. Capturing file identity before that lifecycle completes makes a valid clone fail the exact activation identity guard.

Explicitly truncate the clone WAL after final validation, require a non-busy checkpoint, and only then bind the stable file identity into the receipt. The activation guard remains exact.

Ref polylogue-5ucz.

Co-Authored-By: Claude <[email protected]>
SQLite may leave an empty WAL or shared-memory file until process exit even after a successful truncate checkpoint. Remove those quiescent sidecars before binding the final clone identity so activation sees a stable exact proof.

Ref polylogue-5ucz.

Co-Authored-By: Claude <[email protected]>
Problem: systemd can report a newly restarted daemon active briefly before a bind or startup failure exits it. A single active sample allowed a later crash loop to escape automatic rollback.

Require the same active MainPID to remain healthy across a five-second window before activation succeeds. The rollback regression now exercises a late stability failure.

Ref polylogue-5ucz.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6fbbced7-7d2e-457f-93b2-3a1a68e869ac

📥 Commits

Reviewing files that changed from the base of the PR and between 58691ab and 62ad0b3.

📒 Files selected for processing (4)
  • devtools/command_catalog.py
  • devtools/index_fast_forward.py
  • docs/devtools.md
  • tests/unit/devtools/test_index_fast_forward.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/v35-index-fast-forward

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.

@Sinity Sinity changed the title feat(devtools): fast-forward v32 indexes without raw replay feat(devtools): fast-forward v32 indexes without raw replay (#2804) Jul 12, 2026
@Sinity
Sinity merged commit 07fbbee into master Jul 12, 2026
3 of 14 checks passed
@Sinity
Sinity deleted the feature/fix/v35-index-fast-forward branch July 12, 2026 23:00

@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: 62ad0b3f99

ℹ️ 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 thread devtools/index_fast_forward.py Resolved
Sinity added a commit that referenced this pull request Jul 13, 2026
## Summary

Reconciles the declared fast-forward plan layer onto the live-proven
v32→v35 executor deployed by #2804/#2805. The deployed executor remains
the only implementation of clone, activation, rollback, and recovery
behavior.

## Problem

PR #2788 was based before the executor landed and independently
implemented the same operational surface. The merge conductor correctly
held it: replacing a live-archive-proven executor would be unsafe and
would create two competing recovery mechanisms.

## Solution

- Keep the declarative layer in `polylogue/storage/sqlite/lifecycle.py`:
versioned delta classes, clone-safe operation metadata, policy coverage,
and explicit semantic-reparse routing.
- Drive the deployed executor’s canonical objects, receipt delta
classes, and exact stage order from the declared v32→v35 plan. Its
live-proven SQL, pressure checks, reflink handling, receipts, symlink
activation, rollback, and service checks are retained unchanged.
- Declare v36 as `semantic-reparse`: it is a source-origin vocabulary
change and is rebuild/reprocess-only, not clone SQL.
- Keep ma2’s v34 `idx_web_constructs_message` as the first `index-only`
plan operation and assert that the deployed executor receipt records
that declaration.
- Delete the branch’s competing executor/activation/rollback
implementation and its conflicting executor tests; no parallel entry
point remains.
- Retain the schema-version policy gate and generated docs/topology
projection.

## Acceptance criteria

| Bead | Status | Evidence |
| --- | --- | --- |
| `polylogue-9rw0` | partially satisfied; replay equivalence deferred to
`polylogue-p5r4` | Every current index bump is classified (v33–v35
clone-safe; v36 semantic reparse); policy rejects gaps; the deployed
v32→v35 executor consumes the plan and records stages/classes; semantic
deltas route away from executor SQL. Independent replay of sampled raw
bytes and hash comparison remains explicitly deferred. |
| `polylogue-ma2` | satisfied | v34 declares the FK-supporting index as
`index-only`; the deployed executor’s v32 fixture runs the canonical
index DDL and asserts `EXPLAIN QUERY PLAN` uses
`idx_web_constructs_message` without a table scan. No in-place migration
helper was added. |

## Verification

- `POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest
POLYLOGUE_PYTEST_WORKERS=0 nix develop --command devtools test
tests/unit/storage/test_index_fast_forward_lifecycle.py
tests/unit/devtools/test_index_fast_forward.py` → **13 passed**.
- `nix develop --command devtools lab policy schema-versioning` →
**Schema evolution policy intact**.
- `nix develop --command devtools verify --quick` → passed; the
subsequent pre-push hook reported `HEAD already verified (7527883)`.
- Executor census: `rg -l "def create_and_fast_forward_generation|def
fast_forward_clone" devtools polylogue tests -g '*.py'` → only
`devtools/index_fast_forward.py`.

Anti-vacuity: the executor integration test calls the deployed clone
path and checks receipt stages/classes against the production lifecycle
plan; removing that plan consumption or ma2’s operation fails it. The
policy test invokes the real schema-version lab command. The
pre-existing deployed executor tests still cover clone failure,
activation identity proof, rollback, tamper rejection, sibling links,
and restart rollback.

Ref polylogue-9rw0.
Ref polylogue-ma2.
Ref polylogue-p5r4.

---------

Co-authored-by: Codex <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

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.

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