Skip to content

test(response-handles): prove commit-gate rollback, measure large-handle I/O - #4979

Merged
ScriptedAlchemy merged 2 commits into
masterfrom
t3/measure-response-handle-store-io
Nov 27, 2026
Merged

ScriptedAlchemy merged 2 commits into
masterfrom
t3/measure-response-handle-store-io

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Closes nothing: see "Scope against #4448" below.

Issue: #4448

What this adds

#4964 moved response handles into the registered store and deleted the JSON-file machinery, and listed three things it left open. This PR completes the two that are evidence, and records a measurement that settles the third.

1. A real post-write fault test. The exact-SQL write path is verify(BeginTransaction) → BEGIN IMMEDIATE → job body → verify(Commit) → COMMIT. The Commit check is the last gate, reached after the body has already written the handle row. A guard that admits every intent except Commit drives that fault deterministically, with no racing and no held writer. The test asserts the row rolled back, no handle was issued, and the writer still serves the next publication. The guard records the intents it admitted, and the test asserts the row write preceded the refused commit, so it cannot pass on an earlier refusal.

2. Large-handle measurements (tests/response_handle_store_cost.rs, 8 MiB handles, isolated harness):

Operation Measurement What it shows
Inventory, tiny vs 8 MiB handle reader execution 15 µs vs 9 µs does not read payload bytes
Expiry sweep, tiny vs 8 MiB handle 61 vs 61 writer VM steps selects from the covering index only
Fresh 8 MiB publish writer lock held 48–104 ms scales with payload
Replay of the same live handle writer lock held 0.8–1.2 ms ~1–2% of a fresh publish; writes nothing
Lookup of an 8 MiB handle 5.4–6.5 ms wall (tiny: 0.24–0.29 ms) loads and digests the whole record

The inventory and expiry assertions are falsifiable: a payload-reading inventory or sweep would scale with the 8 MiB handle and fail.

3. No slice read, by measurement. The issue says to avoid whole-record loads "where the existing storage API can safely slice it." It cannot. Measured through the SQLite C API on a 4 MiB TEXT row:

  • one full copy: 582 µs
  • substr page of 12,952 chars: 953 µs
  • length() predicates, no copy: 1,429 µs

A large TEXT value is an overflow chain. substr and length() walk that chain to find character boundaries, which costs more than one sequential read of the value. Slicing in SQL would make paging slower, so paging keeps the whole-record read and the digest check that guarantees served content is never corrupt.

Root cause

Nothing was broken. The store's rollback at the commit gate was already correct; it had no test. The measurements confirm the metadata-only claims that #4964 rested on EXPLAIN QUERY PLAN alone.

Verification

Target Result
//crates/tracedecay-global-db:unit_test (full) 585/585
response-handle filter (store + cost) 18/18, non-vacuous
bazel build --config=ci --config=clippy //crates/tracedecay-global-db:all pass
//crates/tracedecay-global-db:rustfmt_check_2024 pass
tests::response_handle_store_cost::replay_does_not_rewrite_a_live_handle 1/1 after replacing the timing ratio with an exact zero-row assertion

Re-verified after rebasing onto 3620245514.

Scope against #4448

Residual risk

  • The commit-gate test exercises the store's own ExactSqlWriteAuthority hook. The engine's one genuinely post-commit failure (watermark publication) belongs to the runtime-submit batch path, which this store does not use, so it is not reachable here and is not covered.
  • Lock-tenure numbers vary with disk and scheduler load, so they are measurements only. The replay test asserts zero changed rows and preserves the existing handle, creation time, expiry, and content. It does not assert a wall-clock ratio.
  • A backward clock step still makes live handles look corrupt until the clock catches up (noted in refactor(response-handles)!: keep handles in the registered store #4964; unchanged).

Devin Review

Completes the evidence #4448 asks for that #4964 left open.

A publication whose write authority refuses at the Commit gate is
refused after the job body has already written the handle row. The
written row rolls back, no handle is issued, and the writer stays
usable. The guard records the intents it admitted, so the test proves
the row write preceded the refused commit rather than passing on an
earlier refusal.

Large-handle cost tests record payload I/O and writer lock tenure on an
8 MiB handle: inventory and expiry selection read the covering index
only, so their work does not follow payload size, and a replay of live
content holds the writer for about 1-2% of a fresh publication.

No slice read is added. Measured through the SQLite C API on a 4 MiB
row, substr costs 953us and length() predicates 1429us against 582us
for one full copy: a large TEXT value is an overflow chain, so slicing
walks more pages than reading it once. The issue's "where the existing
storage API can safely slice it" condition is not met.

Refs #4448
@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9dcbe29

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: 6 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

@ScriptedAlchemy
ScriptedAlchemy merged commit c3b9f64 into master Nov 27, 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.

1 participant