Repository navigation
fix(cognition): scope persona tool calls to the turn's room, not nil - #1703
Merged
Merged
Conversation
The deliberation faculty built ToolExecutionContext with context_id = Uuid::nil(), so command_executor's `scoped(ctx.context_id)` scoped every persona tool call to a PHANTOM nil room. That's both a correctness bug (a persona's hands act in the wrong room) and a security one (commands land outside the authorized context) — see docs/architecture/IDENTITY-SCOPE-PEER-LIVENESS-MODEL.md Part A: context (the room/contextId) is the third ID tier and must be carried, never dropped to nil. Thread the turn's room through the cognition cycle: - Workspace gains `room_id` (the contextId the tick reasons within); `Workspace::new` is the nil-room shorthand for faculty-isolation tests, `Workspace::in_room` / `WorkspaceCycle::run_in_room` carry the real room. - WorkspaceTrace gains `room_id` so a replayed trace correlates to its room. - LlmDeliberationFaculty::tool_context(ws) stamps context_id = ws.room_id; session_id stays nil deliberately (ephemeral, never load-bearing for scope/trust per A.5). - service_loop runs the cycle via run_in_room(burst, default_room) — the room the burst already declares. (IncomingMessage carries no per-message room yet; a per-message contextId on the cognition input is the deeper fix — the missing context axis. Today default_room is the correct available context.) Test: tool_calls_are_scoped_to_the_turns_room asserts the executor receives context_id == the turn's room (and never nil). Full lib suite: 4599 pass; the only failure is the known parallelism flake record_turn_writes_fixture_json_under_home (task #7, passes in isolation), unrelated to this change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Problem (correctness + security)
The deliberation faculty built
ToolExecutionContextwithcontext_id = Uuid::nil(), socommand_executor'sscoped(ctx.context_id)scoped every persona tool call to a phantom nil room. A persona's hands acted in the wrong room — and, per the trust model, that's a security bug too: commands land outside the authorized context.This is the cognition instance of the identity-model work: per IDENTITY-SCOPE-PEER-LIVENESS-MODEL.md Part A (airc #1273), Context (the room /
contextId) is the third ID tier and must be carried, never dropped to nil — and never conflated with Session (which stays nil here, deliberately: it's ephemeral and not load-bearing for scope/trust, per A.5). A.6 step 3.Fix
Thread the turn's room through the cognition cycle:
Workspacegainsroom_id(the contextId the tick reasons within).Workspace::newis the nil-room shorthand for faculty-isolation tests;Workspace::in_room/WorkspaceCycle::run_in_roomcarry the real room.WorkspaceTracegainsroom_idso a replayed trace correlates to its room.LlmDeliberationFaculty::tool_context(ws)stampscontext_id = ws.room_id;session_idstaysnildeliberately.service_loopruns the cycle viarun_in_room(burst, ctx.identity.default_room)— the room the burst header already declares.Note surfaced (not fixed here)
IncomingMessagecarries no per-message room (lamport,peer_id,textonly) — itself an instance of the missing context axis on the cognition input. A per-messagecontextIdis the deeper follow-up; todaydefault_roomis the correct available context.Test
tool_calls_are_scoped_to_the_turns_roomasserts the executor receivescontext_id == the turn's room(and never nil) — the regression guard for the nil-scope bug.Full
cargo test -p continuum-core --lib: 4599 pass; the only failure is the known parallelism flakerecord_turn_writes_fixture_json_under_home(task #7 — passes in isolation, confirmed), unrelated to this change. No#[derive(TS)]types touched (ts-rs binding guard unaffected).🤖 Generated with Claude Code