Skip to content

fix(storage): preserve committed response-handle lifetimes - #5009

Merged
ScriptedAlchemy merged 2 commits into
masterfrom
fix/response-handle-completion
Nov 29, 2026
Merged

ScriptedAlchemy merged 2 commits into
masterfrom
fix/response-handle-completion

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Why

The registered response-handle store still treats a valid creation timestamp later than the current wall clock as corruption. A backwards clock correction therefore makes a previously issued handle unreadable; replaying the same content rewrites its creation and expiry backwards.

The consolidation also lacked direct evidence for interruption after a successful SQL commit and between expiry-cleanup batches.

Changes

  • Preserve the committed lifetime when the wall clock moves backwards. Digest, content length, canonical expiry, namespace, and collision checks remain authoritative.
  • Cover restart, clock rollback, zero-row replay, the exact half-TTL renewal boundary, renewal, and typed expiry with Unicode and embedded-NUL content.
  • Exercise a lost completion after actual SQL commit for both fresh publication and renewal. The test pauses at the existing write-authority boundary, observes the committed row through a separate registered reader without consuming the publication result, cancels and drops that wait, then restarts and verifies an identical zero-row retry.
  • Interrupt cleanup after its first committed 256-row batch using the existing FIFO writer lane. Restart, resume the remaining expired rows, and verify live and foreign-namespace records survive throughout.
  • Retain corruption repair coverage by corrupting the stored expiry itself, rather than treating a valid future creation timestamp as corrupt.

No production fault hook, schema change, new storage owner, or compatibility reader is introduced.

Completion of #4448

Requirement Evidence
Registered owner, admitted namespace, atomic publish/renew, full collision evidence #4964 moved all response-handle callers to the registered session store. Existing registered-store tests cover collision refusal, corrupt content, namespace isolation, renewal, and restart.
Metadata-only inventory and bounded indexed expiry #4964 provides the covering index and bounded cleanup. #4979 adds large-handle cost probes; the current inventory test also uses invalid UTF-8 payload bytes as a falsifiable content-read tripwire. This PR exercises interruption between actual committed cleanup batches.
Unicode paging and exact reconstruction #4964 includes real MCP multipage reconstruction, and #5004 verifies handle retrieval from the retained core connection across owner admission. The bounded character-offset API remains unchanged.
Filesystem publication machinery and all callers removed Completed in #4964, including root lockfiles, per-handle envelopes, staging/rollback/tombstone helpers, directory scans, and storage-layout fields.
Concurrent operations and faults around commit Existing tests cover concurrent publish/read/cleanup and refusal after the row write but before COMMIT. This PR adds cancellation after an independently observed successful COMMIT, including restart and idempotent retry.
Typed missing/expired/invalid/corrupt/unavailable outcomes Existing store and MCP journeys cover the distinct outcomes. This PR fixes the clock-rollback case without relaxing content or expiry integrity.
Large-payload measurements #4979 reports isolated 8 MiB publication/replay lock tenure, metadata-query execution, expiry VM work, and full-record lookup cost. These historical measurements were not rerun here; this PR makes no speedup claim.

The retained transition policy is explicit: pre-upgrade filesystem handles return the existing typed, retryable handle_not_found and require rerunning the original tool. The repository's current no-legacy policy supersedes the issue's proposed compatibility reader; this PR does not claim that old JSON handle contents survive that transition.

Page retrieval continues to read and verify the full record. #4979 measured the existing SQLite TEXT slicing path as more expensive than a sequential copy; omitting the whole-record digest check would lose corrupt-content refusal. This PR preserves that deliberate choice and the external bounded paging contract.

Validation

  • The storage changes and hook-fixture correction pass the pinned Rust 1.100.1 formatter.
  • git diff --check passes.
  • Commitlint passes against the repository configuration.
  • Independent source review checked the clock invariant, FIFO cleanup interruption, and observation of a real commit before cancellation.
  • The full Linux Bazel run at 75f5fb073aeea63e1db04bc13513937a8de6cd82 passed 182/182 targets: 50 executed and 132 cached. The hook/LSP suite actually ran in 25.7 seconds and the full MCP suite in 277.8 seconds. The global-db unit suite was a valid cached pass from its 218.3-second execution; these results are not claimed as local runtime runs.
  • Windows CI passed the complete workspace build (26,700 actions) and actually executed the locked-Node-addon upgrade regression: 1/1 target passed in 1.2 seconds.

Full CI fixture preparation

The first Linux run exposed a hook-fixture preparation wait that reused the 10-second PROMPT_DRAIN budget. Daemon startup had already completed; the project reached graph admission at 9,880 ms and session capability publication at 9,914 ms, before the independent-owner hold marker existed.

The fixture now waits for that existing .entered owner gate while checking that its daemon remains alive, as the shared startup harness does. The enclosing Bazel test timeout bounds a stalled setup. All actual 10-second failure-status, receipt-drain, and recovery assertions remain unchanged, including the shared elapsed repair budget, durable corrupt receipt, orchestrator hold, and final release.

That run also failed the existing MCP fact-add journey at capability expiry. The fact journey and its production expiry handling are unchanged. The corrected head's full MCP suite passed in the Linux run linked above, validating that unchanged journey alongside the corrected hook fixture.

Focused target: bazel test //crates/tracedecay-global-db:unit_test --test_arg=response_handles::tests:: --test_output=all.

The tests exercise actual registered-store commits and reopen operations. They do not simulate power loss or assert new latency thresholds for product behavior.

Closes #4448.


Devin Review

@ScriptedAlchemy
ScriptedAlchemy enabled auto-merge (squash) November 29, 2026 05:44
@changeset-bot

changeset-bot Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 75f5fb0

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 merged commit 912f2d1 into master Nov 29, 2026
16 checks passed
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.

simplify(response-handles): replace the JSON-file cache database with the existing registered store

1 participant