Repository navigation
refactor(response-handles)!: keep handles in the registered store - #4964
Merged
Merged
Conversation
Response-handle records now live in a `response_handles` table of the registered store, keyed by the admitted store-shard namespace plus the handle, so a content digest alone grants no access to another namespace. One row keeps the immutable content, its full SHA-256, exact byte and character counts, and creation/expiry, so one SQLite transaction publishes, reuses, or renews the whole record and the handle is returned only after commit. A different text that shares the truncated digest is refused as a collision; a row whose digest or text no longer matches is never served and is rewritten by an identical publication. Inventory and expiry selection are answered by the covering `(namespace, expires_at, content_bytes)` index (asserted with EXPLAIN QUERY PLAN), and cleanup deletes expired rows in bounded batches. The table installs with CREATE IF NOT EXISTS in the existing schema stage sequence, so no schema revision is reserved. Refs #4448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every caller now publishes and reads response handles through the daemon-owned registered project store instead of a per-project filesystem cache, and the cache machinery is deleted: the root writer lock, per-response JSON envelopes, staging/rollback/tombstone publication, and directory-wide scans. Render paths hold a publish-only `ResponseHandlePublisher`; retrieve, feedback request handles, and LSP expansion handles hold the registered `ResponseHandleStore`. A route with neither answers the feature-scoped `handle_storage_unavailable` refusal. The CLI, which renders locally but cannot open the daemon's store, publishes through a new internal `ResponseHandlePublish` invocation bounded by the call's own deadline and verifies the returned handle names the content it rendered. Maintenance sweeps mounted registered session stores and retires the owned `response-handles/` directory and its lock. Status reports the metadata inventory as `stored`. `StoreLayout.response_handle_root` and `ActiveProjectStorageV1.response_handle_root` are removed (contracts regenerated), along with the now-unreachable handle-store-busy LockDeadline branches. BREAKING CHANGE: handles issued by the filesystem cache are not read after upgrade; retrieving one answers the typed, retryable `handle_not_found`. `ActiveProjectStorageV1` drops `response_handle_root`. Refs #4448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ScriptedAlchemy
enabled auto-merge (squash)
November 25, 2026 06:15
Fence response-handle publication through writer admission and commit, use owner time for expiry, and repair corrupt stored metadata on republish. Await feedback and LSP storage and render synchronous tool output on the blocking pool. Scope maintenance leases to admitted stores. Read Doctor's full typed runtime result without depending on session-store handles. Refresh the embedded contract bundle and add focused regression coverage.
Carry native project-open backoff through a canonical typed application problem, including its bounded cause and measured retry delay. Preserve it through wire/source round trips and verify the authenticated socket probe. Regenerate the closed SDK and dashboard contract surfaces, rebuild the embedded host server, and cover valid and malformed native SDK responses.
Response-handle records now live in a `response_handles` table of the registered store, keyed by the admitted store-shard namespace plus the handle, so a content digest alone grants no access to another namespace. One row keeps the immutable content, its full SHA-256, exact byte and character counts, and creation/expiry, so one SQLite transaction publishes, reuses, or renews the whole record and the handle is returned only after commit. A different text that shares the truncated digest is refused as a collision; a row whose digest or text no longer matches is never served and is rewritten by an identical publication. Inventory and expiry selection are answered by the covering `(namespace, expires_at, content_bytes)` index (asserted with EXPLAIN QUERY PLAN), and cleanup deletes expired rows in bounded batches. The table installs with CREATE IF NOT EXISTS in the existing schema stage sequence, so no schema revision is reserved. Refs #4448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every caller now publishes and reads response handles through the daemon-owned registered project store instead of a per-project filesystem cache, and the cache machinery is deleted: the root writer lock, per-response JSON envelopes, staging/rollback/tombstone publication, and directory-wide scans. Render paths hold a publish-only `ResponseHandlePublisher`; retrieve, feedback request handles, and LSP expansion handles hold the registered `ResponseHandleStore`. A route with neither answers the feature-scoped `handle_storage_unavailable` refusal. The CLI, which renders locally but cannot open the daemon's store, publishes through a new internal `ResponseHandlePublish` invocation bounded by the call's own deadline and verifies the returned handle names the content it rendered. Maintenance sweeps mounted registered session stores and retires the owned `response-handles/` directory and its lock. Status reports the metadata inventory as `stored`. `StoreLayout.response_handle_root` and `ActiveProjectStorageV1.response_handle_root` are removed (contracts regenerated), along with the now-unreachable handle-store-busy LockDeadline branches. BREAKING CHANGE: handles issued by the filesystem cache are not read after upgrade; retrieving one answers the typed, retryable `handle_not_found`. `ActiveProjectStorageV1` drops `response_handle_root`. Refs #4448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The handle sweep held every mounted store's owner lease for the whole maintenance tick, so a parked tick pinned idle stores against capacity retirement. The sweep now takes its own leases and drops them when it returns, restoring the listing's lease lifetime. `TraceDecay` is only used under `cfg(any(test, feature = "test-transport"))` in the MCP handler module, so its import carries the same gate; the bare library build reported it unused. Tests whose responses truncate publish a handle through the synchronous store wait, which a current-thread runtime refuses. They now run on the multi-thread flavor the daemon and CLI use, like the tests already moved. The embedded ChatGPT server bundle is regenerated for the SDK contract change that removed `response_handle_root`.
Use the existing report-reader readiness authority for typed runtime requests. Preserve terminal failed/reset-required publication states and keep ordinary telemetry available while the report mounts. Seed MCP retrieval fixtures with captured current timestamps while preserving exact payload, digest, pagination, expiry, and refusal checks.
ScriptedAlchemy
force-pushed
the
triage/response-handles
branch
from
November 25, 2026 22:17
79a6807 to
0e7e0ef
Compare
Integrate current master and the concurrently rebased response-handle history. Preserve deadline, cancellation, async publication, Doctor readiness, and typed backoff fixes alongside incoming runtime coverage. Keep feedback tests on the current-thread runtime to exercise the repaired asynchronous boundary.
Keep project-server capacity and deferred repository discovery visible to Doctor without changing ordinary typed clients' mounting retries. Exercise both refusals over the real typed socket and assert a single diagnostic request, the original retry contract, and the existing actionable finding. Integrate current master, including the validated configuration fixes.
Doctor reads the runtime report through the typed graph-tool surface, which calls the executor's `invoke`. The single-attempt probe counted only `invoke_controlled`, so two admission-refusal tests read zero attempts and failed after the request had already crossed the socket. Count the method the production path calls.
ScriptedAlchemy
disabled auto-merge
November 26, 2026 00:40
ScriptedAlchemy
enabled auto-merge (squash)
November 26, 2026 00:57
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #4448
What changes
Response handles move out of the per-project filesystem cache (root lockfile, per-response JSON envelopes, staging/rollback/tombstone publication helpers, directory-wide scans) into the registered project session store that the daemon already owns.
Store (
tracedecay-global-db, first commit). There's aresponse_handlestable keyed by(admitted store-shard namespace, handle), so a content digest alone grants no access to another namespace. One row holds:created_at/expires_atOne SQLite transaction publishes, reuses or renews the whole record, and the handle is returned only after commit.
Collision.CorruptRecord). An identical publication rewrites it.(namespace, expires_at, content_bytes)index. A test asserts this withEXPLAIN QUERY PLAN.Capabilities (
tracedecay-session-memory). There are now two types:ResponseHandleStore: a registered lease that can publish and look up. Retrieve, feedback request handles and LSP hold it.ResponseHandlePublisher: publish-only, behind a port. Render paths hold it.A surface with neither gets the feature-scoped
handle_storage_unavailablerefusal.Callers. All of these now use the store:
tracedecay_retrieve(reads only the admitted project's store; refuses typed without one)tracedecay_statusinventory, reported asstored.record_countCLI. The CLI renders locally but can't open the daemon-owned store. It publishes through a new internal daemon invocation,
ResponseHandlePublish, routed to the project's feedback runtime store. The publish is bounded by the CLI call's own deadline, and the CLI verifies that the returned handle matches the content it rendered.Deleted:
StoreLayout.response_handle_rootandActiveProjectStorageV1.response_handle_root(contracts regenerated: 2 lines insdks/typescript/src/operations.ts)cgargument ofhandle_tool_call_with_registry_optionsRetirement. Maintenance removes the owned retired
response-handles/directory and its lock beside the profile root and each registered project shard. A test proves unrelated store files survive.Verification (focused Bazel, bounded fixtures, no operator data)
//crates/tracedecay-global-db:unit_test(full)//crates/tracedecay-mcp:unit_test(full)//crates/tracedecay-cli:tracedecay_unit_test(full)//crates/tracedecay-application:unit_test(feedback/lsp/advisory filters)//crates/tracedecay-daemon-service:unit_test(filtered)//crates/tracedecay-daemon-protocol:unit_test(filtered)//crates/tracedecay:unit_test(maintenance/invocation/dispatch/rmcp/multi_root filters)//crates/tracedecay:mcp_suite(retrieve/protocol/truncation/active_project filters)//crates/tracedecay:storage_suite(filtered)//crates/tracedecay:runtime_acceptance_suite(CLI transport + feedback bootstrap)files→ CLI publish → multipageretrieve; refused publication → typedhandle_store_failed; held-stream--json//crates/tracedecay:unit_test(full, after the Doctor probe fix)bazel build --config=ci --config=clippy //crates/tracedecay:allNot done / open against #4448 (hence
Refs, notCloses)handle_not_found("re-run the original tool") instead of their content. This follows the repo's no-legacy rule, but it's a deliberate deviation from the issue text.EXPLAIN QUERY PLANtest.native_runtime::block_on. On a current-thread Tokio runtime this is a typed store failure. Production daemon and CLI runtimes are multi-thread. Tests whose responses truncate publish a handle, so they run onflavor = "multi_thread"to match production (upgrades only, no flavor downgrades). The first push missed 19 such test files; the follow-up commit converts them.doctoron a project whose session store is reset-required. Fixed in this PR.doctorno longer renders atracedecay_runtimetool reply that needs a handle. It reads the typed runtime result before any tool-output rendering, so a refused session store that mounts no handle publisher still yields the report that explains its reset state.transport_acceptance_suitecovers it (stale_sessions_store_reset,stale_project_sessions_census) and passes.created_at > nowasCorruptRecord, so if the daemon's wall clock steps backwards, handles published moments earlier fail as corrupt until the clock catches up. Nothing wrong is ever served, and republishing the same content repairs the row. Low severity, and left as is.runtime_surface_acceptance::production_lsp_negotiates_and_projects_canonical_contextfails locally on macOS on routed-analyzerdocumentSymbolProvidernegotiation (line 2655). It passes on Linux CI at the same head (runtime_acceptance_suite142/142), so it is specific to that machine and not caused by this change. The PR's LSP edits are limited to the feedback and test-run handle sources, and capability negotiation lives intracedecay-lsp/src/capabilities.rs, which this PR does not touch.Coordination
ac2940760c, registered run-state store) also editscrates/tracedecay-global-db/src/lib.rsandschema_stages.rs. Neither lane reserves a schema version (both useCREATE … IF NOT EXISTSin the same stage sequence). My install call sits beside native-integration, away from their anchor. Trial 3-way merges of both files are clean in either order.pnpm --dir dashboard run contracts:generate; that lane confirmed no conflict.🤖 Generated with Claude Code