feat(session): session lifecycle management and audit export - #132
Merged
Conversation
Add SessionManager (create/close/get) with signed TRACE Claim generation
on session close, staleness detection for attestation reports, and a signed
audit bundle export endpoint. Extend MCPServer with optional session_manager
and audit_chain kwargs to serve GET /sessions/{id}/trace-claim and
GET /audit/export with chain integrity verification before export.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
SessionManagerinsrc/cmcp_gateway/session/manager.pyimplementingcreate_session,close_session,get_trace_claim, andget_audit_bundleclose_sessionappends asession_endaudit entry, builds and signs aGatewayClaimviagenerate_trace_claim, detects attestation staleness, and stores the claim keyed by session IDget_audit_bundleverifies chain integrity withverify_chain()before export and signssha256(canonical_json(entries))with the TEE signing keyMCPServer.__init__with optionalsession_managerandaudit_chainkwargs; addsGET /sessions/{session_id}/trace-claim(404 on miss) andGET /audit/export?session_id=<id>(500 on broken chain, 501 if not wired up)tests/unit/test_session_manager.pycovering all acceptance criteriaTest plan
python -m ruff check src/ tests/— cleanpython -m bandit -r src/ -c pyproject.toml— no issuespython -m mypy src/cmcp_gateway/— 30 files, no errorspython -m pytest tests/— 197 passed, 0 failedCloses #60, Closes #55
🤖 Generated with Claude Code