Skip to content

fix(projection): isolate SQLite TEMP preflight and integrity fixes - #4822

Open
ScriptedAlchemy wants to merge 5 commits into
masterfrom
fix/4152-sqlite-temp-isolated-20261108
Open

ScriptedAlchemy wants to merge 5 commits into
masterfrom
fix/4152-sqlite-temp-isolated-20261108

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Focused SQLite TEMP storage repair — Refs #4152

This is the reviewable issue-only successor to #4812 at its last #4152 commit a9c68c2ba2b203e2a1e7d005a409f89b81c41274, before the later separate Refs #4532 automation-scheduler test commit was appended there. The four #4152 commits and both modified paths are preserved byte-for-byte, with their original ancestry based on master 91c72aba7750a398dd28e83d64bf0c6d6fef4172: no rebase, rewrite, forced update or peer commit removal. The other PR/branch is left intact; do not merge duplicate changes from both.

Production changes

  • Remove the observation_projection_rebuild_preexisting_outputs TEMP materialization from the persistent projection writer's collision preflight. Use indexed durable staged/provenance/active-output checks before changing ownership. Repeated activation checks no longer grow the named TEMP database on the writer.
  • Fix an actual false collision for unchanged, externally compacted canonical message bodies. The previous comparison read placeholder_text while the staged row contained the full body. The new indexed, bounded keyset preflight hydrates eligible protected bodies with the existing integrity-verifying reader. Corrupt or missing body bytes fail closed; foreign and Hermes ownership rules remain.

Nonvacuous regressions

  • Registered-global-DB test exercises foreign-output collision refusal and compatibility, missing/staged-created semantics, no TEMP table or page growth, full committed-data rollback and PRAGMA integrity_check.
  • Another registered-DB test commits 129 large compacted messages, proves compatible bodies beyond the first page, rejects a changed tail outside the same snippet, checks missing/corrupt canonical bytes, and verifies after rollback that every committed body/metadata and integrity remain.
  • Existing shipped-mimalloc allocator integration test now exercises both MEMORY and FILE TEMP, live main/TEMP integrity, eight rollback cycles, cross-thread frees/collection, real Linux unlinked SQLite TEMP and sorter file lifetimes (with production census), and main-store durability after reopening.

Verification / merge hold

The precise two changed targets ran successfully with noncached Bazel results on the original clean code head a9c68c2 in CI run 42468670167: //crates/tracedecay-cli:c_library_allocator and //crates/tracedecay-global-db:unit_test. Later mixed-head CI run 42525786166 likewise passed those two targets, but has unrelated runtime acceptance failures. These are target passes, not independently printed individual test counts; the new PR needs its own exact-head CI, review, and applicable Windows/macOS coverage.

LSP acknowledgement verification

At 897390ff, the Linux fleet passed 140 of 141 runtime acceptance cases. The production LSP journey reported DeadlineExceeded while acknowledging a frame. The artifact records the client error without a server-phase timing. Linux fleet artifact

The same journey passed on this PR’s preceding head a9c68c2b, where all 141 runtime acceptance cases passed on Linux. The journey, daemon acknowledgement handler, client transport and durable receipt writer have identical source on both heads. A subsequent Linux run at b0f6277d also passed all 141 cases with that source. Earlier run on this PR · Subsequent Linux artifact

The unmodified 897390ff journey passed on native macOS. Three additional runs with temporary phase tracing passed and recorded 60 acknowledgements. The client round trip had a median of 11.27 ms and a maximum of 23.10 ms. Durable receipt recording had a median of 10.23 ms and a maximum of 22.70 ms, including one file sync and one parent-directory sync per acknowledgement. These measurements leave the Linux timeout unattributed.

Partial fix only. The original 2026-10 in-memory page overwrite cause is still unproven; merged #4173 removed an allocator owner-heap UAF, not proved TEMP corruption causality. Other persistent TEMP ownership tables and physical-spill-census changes remain on held mixed DRAFT #4776—do not copy, merge, or auto-merge that work. Safe live connection reclamation and end-to-end storage bounds need further acceptance evidence. #4152 stays open until all requirements are proven on master.

No Cargo, Kody, Copilot, delegated agents, CI weakening, protected integration/release changes, production/infra/tags or credentials.


Devin Review

Refs #4152

Exercise MEMORY and FILE TEMP databases under the shipped allocator.
Check live main/TEMP pages and exact committed bodies across rollback,
cross-thread frees, allocator collection, sorting and connection close.
Verify real Linux unlinked files against the production spill census.
Keep the glibc routing control and run integrity checks on other Unix hosts.

The local SQLite 3.46.1 SQL/FD probe passed both modes; repository Bazel,
mimalloc and native macOS execution remain pending.
Refs #4152

Unchanged compacted foreign outputs were compared against their shortened
placeholders instead of their full staged bodies. Hydrate canonical body
candidates through the existing verified reader in bounded keyset pages,
without restoring connection-local TEMP materialization or trusting only
a stored hash. Preserve existing ownership and Hermes collision rules.

Add a registered-SQLite regression for 129 matching canonical bodies,
a later-page conflict, corrupt and missing persisted bodies, and rollback
preserving committed messages and database integrity.

The independent SQLite SQL/hydration probe passes these scenarios.
Repository Bazel and native macOS execution remain pending.
Refs #4152

Match the Bazel rustfmt check on both issue-specific files without
changing the production preflight or altering test assertions.
@changeset-bot

changeset-bot Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 897390f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@ScriptedAlchemy ScriptedAlchemy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Refs #4152 — independently checked the exact four-commit master...a9c68c2 ancestry and two-path patch after the unrelated Refs #4532 test commit landed on the prior #4812 branch. No peer code is present in this clean PR and no history was rewritten. Reviewed the indexed preflight ownership predicates, absence/staged-creation collision refusal, verified canonical-body hydration and keyset page boundary; the new 129-row test exercises matching compacted bodies, later-page divergent tails, missing/corrupt canonical bytes, rollback and integrity. The allocator integration test retains the glibc positive control and exercises live FILE/MEMORY TEMP pages, rollback, sorter lifetime, FD census and durable reopen. Bazel previously passed both affected targets on this identical commit in run 42468670167; individual libtest counts, full CI green and native macOS acceptance are not claimed. New PR CI 42529505627 is queued. Not an approval or merger clearance: the original allocator page-corruption cause, other held writer TEMP sets, storage bound and safe reclamation remain outstanding; #4152 stays open. #4776 must remain DRAFT and unmerged, and the mixed duplicate #4812 is held DRAFT for separate owner disposition.

Copy link
Copy Markdown
Owner Author

Refs #4152 — exact-head validation update for isolated PR #4822 at a9c68c2ba2b203e2a1e7d005a409f89b81c41274.

CI 42529505627 completed failed. The Linux fleet executed 183 targets: 182 passed, one failed. Both changed-area Bazel targets passed again on this exact SHA:

  • //crates/tracedecay-cli:c_library_allocator — PASSED, 4.5s (uncached).
  • //crates/tracedecay-global-db:unit_test — PASSED, 88.5s (uncached).

The sole failed target is //crates/tracedecay:automation_runner_test (167 tests passed, 3 failed): jobs::retained_scheduler_runner_reacquires_after_due_prefilter, jobs::scheduler_prefilter_live_lock_wins_over_not_due_summary, and jobs::scheduler_trigger_skips_repeat_and_respects_lock_discipline. The last two show backend_unconfigured instead of the expected scheduler_lock_active / scheduler_schedule_manual. None of #4822's two changed files is in this automation test owner; these failures are not attributed to #4152 and are not being patched on this issue-specific branch. The independent PR-maintenance/scheduler owner should resolve them, without weakening CI.

The Windows workspace build/type-check passed on this run (30,944 Bazel actions), but its native-test step was skipped; macOS was skipped. Do not claim native-platform test acceptance. Repository gates, Clippy and Dashboard passed. No source change, rerun of known-red other-owner tests, PR merge, or CI bypass is warranted here.

#4152 remains OPEN: the original SQLite page overwrite's cause has not been demonstrated; removing a TEMP table does not reclaim its unlinked file until its owner connection retires, while resetting temp_store with live tables risks data loss. The two other writer TEMP ownership tables are held on mixed DRAFT #4776 and must not be promoted through this PR. This remains Refs #4152 only, not Fixes or merge clearance.

Refs #4152

Inherit the separately reviewed and merged #4821 repair from master.
Both sides changed disjoint paths: preserve all four SQLite commits and
both SQLite file blobs exactly, and take jobs.rs verbatim from master.
No held integration work, CI policy changes, or history rewrites.

Copy link
Copy Markdown
Owner Author

Scheduler CI prerequisite fixed and inherited — Refs #4152

The three automation_runner_test failures were caused by fixtures reaching the intentional backend_unconfigured prefilter before their intended schedule/lock checks. I independently reviewed the existing one-file repair in #4821 rather than duplicating it or changing production admission.

#4821 was merged with an expected-head check at adc55f8, producing master commit 83694e0. Its exact-head workflow_dispatch run 42527367514 completed successfully; the automation suite reported 45 passing tests. The fixture repair preserves the schedule/lock assertions and adds unconfigured-refusal, deduplication and same-occurrence recovery coverage without provider execution or an effectful terminal.

Published merge commit 897390f on this PR using force=false and expected old head a9c68c2ba2b203e2a1e7d005a409f89b81c41274. Its parents are the prior SQLite head and the new master commit. The changes are disjoint: both SQLite files are unchanged from a9c68c2, and jobs.rs is taken verbatim from master. Comparison against master confirms this PR still changes only crates/tracedecay-cli/tests/c_library_allocator.rs and crates/tracedecay-global-db/src/observation_projection/rebuild.rs (715 additions / 104 deletions), preserving all four original SQLite commits. No mixed #4812 or held #4776 work was copied.

Fresh exact-head CI 42540616028 is queued. The scheduler repair's successful run and the earlier SQLite target passes are evidence for their respective heads, not a claimed pass of this newly combined head. No CI checks, timeouts or assertions were relaxed; no local Cargo or Rust test execution is claimed.

#4822 remains open and unmerged pending its fresh checks and review. #4152 remains open: original page-corruption causality, remaining spill bounds, safe live-writer reclamation and applicable native coverage still require proof. #4776 / Kev holds, release #4763, other owners' branches and task schedules are unchanged.

This branch has not been deployed

No deployments
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