Skip to content

agent: the restore window never waits on a session that will not restore; release binaries scanned for seams - #159

Closed
jaredLunde wants to merge 1 commit into
mainfrom
jared/restore-window-and-seams
Closed

jaredLunde wants to merge 1 commit into
mainfrom
jared/restore-window-and-seams

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

This PR fixes the two LOW audit findings on #156. Each fix has a test that fails without it.

1. The restore window never waits on a session that will not restore

Problem: a listed restoring session could hold the 503 window for its full 10 minutes in four cases:

  • it failed to start (serve_ws only logged);
  • its body ended with an error;
  • it got no events hub because its MCP catalog is now empty;
  • it panicked on every start.

Fix: mcp_events::restored(session_id) (now public) is called on each terminal path:

  • a failed boot pin, for the events session and for each runtime session;
  • serve_session_body ending with an error;
  • serve_session starting with no events hub;
  • every panic. A panicked incarnation reserves nothing more. Tokens it already reserved stay held, and a restart reserves its own again.

Tests (mcp_events_receiver):

  • a_restoring_session_with_no_events_hub_closes_the_restore_window: the session's server is no longer configured on restart.
  • a_restoring_session_that_fails_to_start_closes_the_restore_window: its transcript no longer opens.

Each asserts that a token nothing holds is 410 within 10 s. With the terminal calls reverted, both stay 503 and fail.

2. The release binary is the authority on "no test seam ships"

  • New script: crates/agent/scripts/scan-release-seams.sh greps each given artifact for BEYOND_AI_AGENT_TEST_ and fails on any hit, listing the names it found. It checks what the compiler kept, so source tricks don't matter: a concat!-assembled name, a // inside a string literal, anything a text heuristic misreads.
  • CI: the build (release) job now runs mise check:release-seams right after mise build:rs:release, over every top-level release binary. It reuses the job's own artifacts, so there is no extra build and it adds seconds. The agent test shards are untouched.
  • Source checker: tests/release_seams.rs stays as the fast early warning and now says the binary scan is the authority.
  • Scanner test: release_seams::the_release_artifact_scan_fails_on_any_seam_name. The scanner must fail on this crate's debug build (which carries the seams by design), must fail on a concat!-assembled name, and must pass a clean file.
  • Local check: the scan passes on a release build and fails on the debug build.

Verification

  • clippy (-D warnings, all targets), cargo fmt and dprint check are clean.
  • lib: 1600 passed.
  • These targets pass: mcp_events_receiver, mcp_events_nested, mcp_events_lifecycle, mcp_events_durability, release_seams, serve_service_session_end, serve_session_lifecycle, serve_harness_deadlines.
  • ARCHITECTURE is updated for both changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk

…ore; release binaries scanned for seams

Audit of #156:

- A listed restoring session could hold the 503 window for its full 10 min
  if it failed to start, ended with an error, got no events hub (its MCP
  catalog now empty), or panicked on every start. `mcp_events::restored`
  is now called on each of those terminal paths: a failed boot pin (events
  session or runtime session), a session body that ends with an error, a
  session that starts with no hub, and every panic (a restart reserves its
  own tokens again). Tests: a listed session with no events hub, and one
  whose transcript no longer opens, each close the window, so a dead token
  is 410 within moments; both stay 503 without the fix.
- No test seam ships, enforced on the artifact: `build (release)` now runs
  `mise check:release-seams`, which scans every release binary for the
  `BEYOND_AI_AGENT_TEST_` prefix and fails on any hit (a grep, seconds; no
  extra build). The source checker stays as the fast early warning. The
  scanner is pinned by a test: it fails on this crate's debug build (which
  carries the seams), on a `concat!`-assembled name, and passes a clean
  file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk
@jaredLunde

Copy link
Copy Markdown
Contributor Author

Superseded by #161 (the release-binary seam scan, split out). The restore-window half is dropped: it covers a narrow MCP Events webhook edge case, and main's current behaviour (a retrying server may get 503 for up to 10 min after a restart) is acceptable.

@jaredLunde jaredLunde closed this Oct 7, 2026
jaredLunde added a commit that referenced this pull request Oct 7, 2026
The authority on "no test seam ships" is now the artifact itself: CI's
`build (release)` job runs `mise check:release-seams`, which greps every
top-level release binary for the BEYOND_AI_AGENT_TEST_ prefix and fails on
any hit. tests/release_seams.rs stays as the fast source-level warning and
pins the scanner (it must fail on the debug build and on a concat!-built
name). Split out of #159; its restore-window half is dropped.


Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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