Skip to content

fix(mcp): preserve invoking turn identity - #360

Merged
wibus-wee merged 7 commits into
mainfrom
fix/mcp-turn-principal
Sep 5, 2026
Merged

fix(mcp): preserve invoking turn identity#360
wibus-wee merged 7 commits into
mainfrom
fix/mcp-turn-principal

Conversation

@wibus-wee

@wibus-wee wibus-wee commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • use the active execution runtime as the authoritative source of MCP invocation identity; never reconstruct identity from persisted history
  • route Session ownership, member-scoped Machine/GitHub access, and downstream Turn attribution through that runtime requester
  • freeze source-Turn and requester provenance across Operation retries, recovery, and completion continuations; reject cross-Turn operation id reuse

Validation

  • pnpm --filter lody typecheck
  • pnpm --filter lody exec vitest run src/mcp/lody-mcp-server.test.ts src/mcp/lody-mcp-server-chat-sync.test.ts src/orchestration/operation-store.test.ts src/orchestration/operation-coordinator.test.ts
  • pnpm --filter lody exec vitest run src/commands/session.test.ts -t "delegated requester identity"
  • scoped Prettier check
  • pnpm check:public-boundary
  • scoped type-aware Oxlint (0 errors)

Full session.test.ts was also attempted. Three existing Git fixture tests fail before assertions because this machine enables global GPG signing without the corresponding private key; all identity-related tests pass.

The HTTP MCP host continues to use one daemon bearer token with unsigned session/workspace/machine context headers. This is currently acceptable under the existing trust model where agent runtimes and subprocesses under the same OS user are trusted. The active session header now participates in requester/principal selection, so an untrusted coding agent would require a session-bound capability or signed context in a future hardening change.

Route delegated session creation and chat through the exact persisted Turn principal while keeping machine credentials scoped to the executor. Freeze that provenance for retries, recovery, and continuation delivery.

Model: gpt-5
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-09-03T17:02:21.500507Z 40b4a4d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@wibus-wee
wibus-wee force-pushed the fix/mcp-turn-principal branch from 5aab8dc to 40b4a4d Compare September 4, 2026 03:22
Use the execution runtime as the authoritative source for delegated Session identity, keeping persisted history only as a legacy fallback. Preserve source-turn operation binding while narrowing Session authorization to the effective request subject.

Model: gpt-5
Remove history-based identity reconstruction and keep active execution runtime identity fail-closed. Flatten source-turn provenance, centralize retry identity matching in the operation store, and narrow session delegation/runtime state.

Model: gpt-5

Copy link
Copy Markdown
Member Author

Non-blocking architectural/security note: the HTTP MCP host still uses one daemon-wide bearer token, while session/workspace/machine identity is supplied by unsigned headers. Since x-lody-mcp-session-id now feeds active invocation lookup and therefore requester selection, the existing host comment that “header-supplied ids grant nothing the agent could not already reach” is no longer literally accurate.

This remains acceptable if the intended threat model is that agent runtimes and subprocesses under the same OS user are trusted. If coding agents become untrusted in the future, this boundary needs a session-bound capability or signed context rather than relying on a shared bearer plus unsigned session header. This does not block #360 identity correctness.

Copy link
Copy Markdown
Member Author

Implementation LGTM after syncing origin/main at 2407786. The active execution runtime is authoritative for invocation identity; persisted history is not used for identity reconstruction. New CI is green on the updated base/head. The HTTP MCP shared-bearer and unsigned-context-header concern remains non-blocking under the documented same-OS-user trusted-runtime assumption.

@wibus-wee
wibus-wee merged commit 9355c1f into main Sep 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant