feat(operations): derive caller identity at the doors - #4603
Merged
Merged
Conversation
OperationCaller gains spaceId, role, agentId and agentName. Both doors resolve identity through one writer: the MCP door always carries its agent session and merges the scope resolved for it; the RPC door asserts a transport session only when it resolves to a known scope, so plain web calls stay bare rpc callers and message.send/task.create keep their existing provenance. The scope resolver is injected at boot from the space policy and installed on SessionManager, replacing the empty resolver the RPC door had. The three inline spaceId derivations in task-metadata, owned-pending-completion and the policy consumers collapse onto resolveSessionSpaceId. Input can never reach the caller slot — pinned at the invoke pipeline.
Review status
|
There was a problem hiding this comment.
Requires changes.
Engine claude (glm-5.3-flash) · Reviewed commit e428152 · Trigger: push
Anchored outside the PR's changes — usually pre-existing; blocking severities here still gate, and defect provenance is the reviewer's judgment, not a verified claim.
packages/daemon/src/routes/setup-websocket.ts:109— P2 — Pre-existing: wire sessionId is client-controlled, now identity-bearing
…ion id
CallContext.sessionId is the per-message routing label the websocket client sends; setup-websocket only checks the session exists. Deriving caller scope from it let any client assert any session's spaceId, role and agent identity, including long_term_agent via the deterministic space:agent:<spaceId>:<agentId> id, which would have stamped message.send origin and task.create provenance with the claimed session.
The RPC door goes back to a bare { source: 'rpc' } caller. Human-door identity needs an authenticated connection-bound principal and is out of scope here. The scope resolver stays, serving the MCP door only, where the session id is the daemon's own.
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.
Phase 2 of the subsystem restructure: the caller contract that every capability port builds on.
What changes
OperationCallergainsspaceId,role,agentId,agentName(all readonly).OperationCallerRoleis defined in the door;SpaceMcpSessionRolebecomes an alias of it, so the scope conforms to the door's vocabulary rather than the door importing fromspace/.lib/operations/caller.ts:resolveCallerIdentity(agent door — always carries the agent session, merges resolved scope).space/runtime/space-caller-scope.ts:createSpaceCallerScopeResolverderives role, space, and agent identity from the session policy. Injected at boot and installed onSessionManager; the agent door delegates to it late-bound.() => ({}): plain web calls remain bare{ source: 'rpc' }callers, somessage.sendorigin andtask.createprovenance are unchanged. The wiresessionIdis a client-declared routing label, so human-door identity requires an authenticated connection-bound principal and is out of scope here; the scope resolver serves the MCP door only. Pinned: a wire request carrying a claimed agent session in its envelope, input, andcallerstill invokes as{ source: 'rpc' }.spaceIdderivations (task-metadata,owned-pending-completion, and the eight policy consumers viaresolveMetadataSessionSpace) collapse ontoresolveSessionSpaceId.Invariant
Identity is derived at the door and never parsed from the payload. Pinned structurally at the invoke pipeline: an operation whose schema passes everything through receives the exact caller object the door supplied, untouched, regardless of identity keys in the input.
Not in this slice
Workflow position (
taskId,workflowRunId,workflowNodeId) and agent name aliases are lookups from identity, not identity; node ports add them to the resolver if repeated lookups prove costly.