Skip to content

feat(session): session lifecycle management and audit export - #132

Merged
imran-siddique merged 1 commit into
mainfrom
worktree-agent-a0590f97846b0089d
Jun 6, 2026
Merged

feat(session): session lifecycle management and audit export#132
imran-siddique merged 1 commit into
mainfrom
worktree-agent-a0590f97846b0089d

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Summary

  • Adds SessionManager in src/cmcp_gateway/session/manager.py implementing create_session, close_session, get_trace_claim, and get_audit_bundle
  • close_session appends a session_end audit entry, builds and signs a GatewayClaim via generate_trace_claim, detects attestation staleness, and stores the claim keyed by session ID
  • get_audit_bundle verifies chain integrity with verify_chain() before export and signs sha256(canonical_json(entries)) with the TEE signing key
  • Extends MCPServer.__init__ with optional session_manager and audit_chain kwargs; adds GET /sessions/{session_id}/trace-claim (404 on miss) and GET /audit/export?session_id=<id> (500 on broken chain, 501 if not wired up)
  • 19 new unit tests in tests/unit/test_session_manager.py covering all acceptance criteria

Test plan

  • python -m ruff check src/ tests/ — clean
  • python -m bandit -r src/ -c pyproject.toml — no issues
  • python -m mypy src/cmcp_gateway/ — 30 files, no errors
  • python -m pytest tests/ — 197 passed, 0 failed

Closes #60, Closes #55

🤖 Generated with Claude Code

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>
@imran-siddique
imran-siddique merged commit 88060d8 into main Jun 6, 2026
7 checks passed
@imran-siddique
imran-siddique deleted the worktree-agent-a0590f97846b0089d branch June 6, 2026 19:20
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.

[assembly] Session lifecycle management — create, track, close [audit] Audit log export — signed bundle for verifier access

1 participant