Repository navigation
Description
Goal
The MCP task bookkeeping no longer grows without bound in a long-lived MCP session, and the closed-session not-found behaviour is tested and fully specified.
Context
Follow-up of #1633 (PR #1653): ExtensionSet::tasks (crates/mcp-server/src/extension.rs:458) only shrinks when the MCP session closes (notify_session_closed, extension.rs:623). The ttlMs of a task is not honoured, so a long-lived session keeps one entry per task answer. Further, Spec 0028 §10a says a task of a closed MCP session gives not-found, but no test covers it, and the spec does not mention the PendingDecision::Completed case (approved without an approval signal, tool_server.rs:134).
Requirements
- A task entry is dropped once its
ttlhas elapsed (measured from creation; tasks without a ttl are kept until the session closes). After that,tasks/getandtasks/cancelgive the protocol's not-found error without asking the extension. - Expiry is checked lazily on lookup and when a new task is registered (no new background timer).
- Add a test: after the MCP session closes,
tasks/getandtasks/cancelfor its task id return not-found and the extension is not called. - Spec 0028 §10a: state the ttl behaviour and describe the
Completeddecision.
Acceptance Criteria
- A task with a short ttl: after the ttl,
tasks/getandtasks/cancelreturn not-found and the extension hook is not called. - Before the ttl, both reach the extension as before.
- Expired entries are removed when a new task is registered (checked via a test-visible count or behaviour).
- After the session closes,
tasks/getandtasks/cancelreturn not-found, asserting the error code (-32602 for 2026-07-28 peers), and the extension is not called. - Spec 0028 §10a covers ttl and
Completed. - Relevant automated tests pass
Technical Notes
Affected: crates/mcp-server/src/extension.rs (TaskOwner gets a creation instant and optional ttl), crates/mcp-server/tests/tasks.rs. Use tokio::time::pause or a short ttl to keep the test fast and stable; avoid notify_waiters for signalling (use notify_one or a watch). Security: the owner check on the client must stay unchanged.
Files: crates/mcp-server/src/extension.rs, crates/mcp-server/tests/tasks.rs, docs/specs/0028-mcp-server-integration.md, changelog.d
Spec impact: update 0028
Open questions
- Lazy expiry vs. a periodic sweep. Recommendation: lazy, no extra timer.
Activity
fix(mcp-server): honour task ttl and test not-found after session clo…
smart-ssh-coder commentedon Dec 4, 2026
Implementation ready for review. PR #1671. MCP tasks now expire after their ttlMs (lazy check on lookup and registration, no timer); added unit tests for ttl and expiry purge, an integration test for not-found (-32602) after session close, and updated Spec 0028 §10a. CI green.
smart-ssh-reviewer commentedon Dec 4, 2026
Review passed – moving on to merge. Approved. All acceptance criteria are met:
Counter-proofs for all three new tests failed without the fix and passed with it. mcp-server tests, clippy and CI are green. The owner check is unchanged. Note: PR fix(mcp-server): contain panics in the MCP task hooks #1672 edits the same functions and will need a textual merge.
fix(mcp-server): honour task ttl and test not-found after session clo…
smart-ssh-coordinator commentedon Dec 4, 2026
Merged and branch deleted: PR #1671 (squash) in develop