Carved out of the #317 epic. Per-user tokens (#327) and connections (#329) resolve lazily and are keyed by `subject`; the auth-required gate (#330 / PR #331) parks and resumes. What's missing is the teardown end of the lifecycle — dropping a user's delegated token + connection when their session ends.
Problem
Today the delegated per-user token + connection are torn down only:
- at server stop — `subjectConnPool.Close()` tears down the whole pool (`server.go:441`), and
- on TTL expiry — `memSubjectTokenStore` sweeps expired tokens opportunistically.
There is no per-session-end teardown. The #317 acceptance calls for: "session end drops token + connection; new session re-consents." Without it, a subject's token + live MCP connection persist past the session that established them — up to the token TTL / process lifetime — which is both a footprint and an isolation concern (a new session should re-consent, not silently reuse the prior session's grant).
Scope
- Thread a session id onto the invocation (work-breakdown item 1 notes this is needed) and make the delegated token cache + connection pool aware of it, or maintain a subject→session binding.
- On session end, drop that subject/session's token (`SubjectTokenStore.Evict`) and connection (`subjectConnPool.Evict` / `Close` for that entry) — the primitives already exist; they need a lifecycle trigger.
- A new session for the same subject with no live grant re-enters the auth-required gate (re-consents) rather than reusing a stale connection.
Decisions to make
Already in place (build on these)
Acceptance
Out of scope
Related
Epic #317 · tokens #327 · connections #329 · gate #330 (PR #331) · AARM R10 #319 · authority `design-tool-registry.md` §18.
Problem
Today the delegated per-user token + connection are torn down only:
There is no per-session-end teardown. The #317 acceptance calls for: "session end drops token + connection; new session re-consents." Without it, a subject's token + live MCP connection persist past the session that established them — up to the token TTL / process lifetime — which is both a footprint and an isolation concern (a new session should re-consent, not silently reuse the prior session's grant).
Scope
Decisions to make
Already in place (build on these)
Acceptance
Out of scope
Related
Epic #317 · tokens #327 · connections #329 · gate #330 (PR #331) · AARM R10 #319 · authority `design-tool-registry.md` §18.