Repository navigation
fix(webchat): preserve trusted actor in Concierge task handoffs - #2200
Conversation
Bind one private same-owner task input to its live source turn. Preserve the automated sender and existing action and approval boundaries. Adapt the isolated candidate to current main, including widget-event admission and task resume.
Merge main without dropping sameActor or audience exports. Carry the source audience into admitted task inputs and revoke changed audiences. Guardian handoffs require a private source audience so shared work cannot acquire a private identity handoff. Preserve visitor attribution, action guards and approval checks.
Merge current main without dropping asking-device route context or the host-only task actor handoff. Extend route and Concierge regression fixtures to cover device preservation. Leave the unrelated task-list CI assertion unchanged.
zoolsher
left a comment
There was a problem hiding this comment.
Design & Alternatives review: 💬 COMMENT
Problem. When a guardian (or visitor) asks Concierge in a private chat to start or continue a task, the task's turn runs with no actor. Guardian-only actions then refuse the task. The cause: sendInput delivers the input as CONCIERGE_ACCOUNT through service.dashboard.send → chats/send.ts → dashboardSend → runtime.post → handleChatSend({saidBy}). In that last step, turnActor() (webchat.ts:5528) returns undefined whenever saidBy is set.
Goals. Attribute one Concierge-to-task input to the live source turn's verified guardian or visitor actor, only when the task has the same owner and came from that Concierge chat. Keep Concierge as the message's source. Never take identity from the model, the message text or HTTP fields.
Non-goals. No approval inheritance, no wider action catalogs, no change to app guards, the database or the SDK.
The PR's approach. The tool port (rome-tool-ports.ts) builds a TaskInputSource from the live turn. A new module, webchat/task-input-actor.ts, wraps the generic send in an AsyncLocalStorage claim. The claim carries:
- a WeakMap state machine with five flags: active, used, checked, authorized, admitted;
- a 30-second deadline;
- an exact text and skill match, so an unrelated send in the same async scope can't pick the claim up;
- a re-run of the owner and origin checks (task chat, private owner, origin Concierge chat, not archived).
runtime.post claims the input, handleChatSend checks it again after opening the model session, and admitTaskInput submits it. The PR also changes currentTurnActorRef for every agent, so a stopped or closing turn reports no actor. That affects any action started from an interrupted turn, not just this path.
Alternatives I checked
- A. Do nothing / blanket inheritance: make
turnActorinherit the ambient session actor wheneversaidByis an agent account. The PR rightly rejects this: groups, forks, autonomous turns and other agents would gain an actor. - B. Reuse the existing host-only seam with an explicit parameter.
ConciergeDashboard.chatsis already theWebchatRuntime, an in-process interface apps can't reach (api/index.ts:265). It already offers explicit-identity operations such asstartChat(input, ownerKey)andsendAsGuardian. Add one method, e.g.postTaskInput(chatId, body, as, source), that callshandleChatSendwithtaskActor: source.actorand checkssource.isCurrent()right beforesubmit.SessionToolContextexposes the source the PR already computes inrome-tool-ports.ts, instead of awithTaskInput(send)wrapper.sendInputinconcierge/tools.tsalready runs afterrequireOwnTaskChat, or right after creating the chat withownerHere(). It only needs to addsessionOwnerKey(source.actor) === await ownerHere().chats/send.tsis a thin router, and Concierge only readssent.okfrom it, so bypassing it loses nothing.
- C. Data-model change: derive the actor from the task row's owner (
privateOwnerOf(target)). I rejected this: scheduled and autonomous task runs would gain an actor, and aSessionActorwould be rebuilt from stored data rather than from verified session material.
| Approach | Added complexity | Correctness/completeness | Blast radius | Reversibility | Maintenance | Effort |
|---|---|---|---|---|---|---|
| A. Inherit ambient actor | Very low | Wrong: widens identity to every agent-said input | All dashboard sends | Two-way | Low | XS |
| PR: ALS claim + lease | High (≈170-line module, 5-flag state, timer, body matching, withoutTaskInputActor wrappers, duplicate owner/origin check) |
Meets its invariants, but an expired or revoked lease marks the input failed while post still returns ok |
Concierge task admission + currentTurnActorRef for all turns |
Two-way (internal only) | High: ambient state must be fenced at every receiver | Done |
B. Explicit source on TaskChats |
Low–medium (one runtime method, one context getter, reuses requireOwnTaskChat/ownerHere) |
Same invariants. Nothing ambient can leak or be replayed, so the one-use and expiry rules aren't needed. Revocation is just isCurrent() |
Concierge task admission only | Two-way | Low | S (most of the PR's handleChatSend changes stay) |
| C. Actor from task owner | Medium | Wrong: autonomous runs gain an actor | All task turns | Two-way | Medium | M |
There are no public API, schema or wire-format commitments in any option, so all are two-way doors.
Recommendation. The goal and the security rules are right. The PR's trust gate in rome-tool-ports.ts (private webchat thread, core:concierge, not a subagent, guardian only with a private audience) and its route-level taskActor plumbing should stay. The transport is the problem: an ambient AsyncLocalStorage claim brings in replay, expiry, scope-leak and body-matching concerns that exist only because the actor travels implicitly. Prefer alternative B and delete most of task-input-actor.ts. Separately, consider whether the global currentTurnActorRef change is intended for all agents; isCurrent() could check turn liveness itself.
Verification notes: I read the full new module and the changed parts of webchat.ts, rome-tool-ports.ts, concierge/tools.ts and agent-session.ts. I traced the send chain through chats/send.ts, webchat/send.ts and api/index.ts, plus the ownership helpers in concierge/tools.ts and concierge-tasks.ts. I did not run the tests.
Verdict: COMMENT — The fix is needed and its narrow trust rules are sound, but passing the actor through an AsyncLocalStorage claim with a 30-second timer is a more complex and more fragile choice than passing the turn's actor directly over the host-only TaskChats interface. The choice is reversible, so this is a COMMENT, not a block.
2 finding(s) posted as inline comments below.
| Severity | Category | File | Title |
|---|---|---|---|
| P2 | architecture | packages/core/src/webchat/task-input-actor.ts |
Pass the actor directly over TaskChats instead of an ambient claim with a timer |
| P2 | correctness | packages/core/src/api/routes/webchat.ts |
A revoked or expired handoff loses the task input but reports success |
Automated review by RomeOS Code Review · commit 77a43ba · Full review history
| readonly expires: number; | ||
| } | ||
|
|
||
| const inputs = new AsyncLocalStorage<TaskInputClaim | undefined>(); |
There was a problem hiding this comment.
[P2] architecture — Pass the actor directly over TaskChats instead of an ambient claim with a timer
The handoff travels as an ambient AsyncLocalStorage claim. That forces the extra machinery: a five-flag WeakMap state, a 30-second deadline, an exact text/skill match against unrelated sends in the same scope, withoutTaskInputActor fences at the receiver, and a second owner/origin check that repeats requireOwnTaskChat/ownerHere in concierge/tools.ts.
ConciergeDashboard.chats is already the host-only WebchatRuntime, and it already takes explicit identity (startChat(input, ownerKey), sendAsGuardian). Expose the TaskInputSource that rome-tool-ports.ts already builds through SessionToolContext. Add chats.postTaskInput(chatId, body, as, source), which calls handleChatSend with taskActor and checks source.isCurrent() just before submit. In sendInput, also require sessionOwnerKey(source.actor) === await ownerHere().
With nothing ambient left, there is nothing to replay or let expire. Most of this module, plus the ALS wrapping in concierge/tools.ts and rome-tool-ports.ts, can be deleted, and every invariant in the PR still holds.
There was a problem hiding this comment.
Thanks. I kept the scoped transport for this focused repair rather than replacing the task-delivery port. f91e20a now makes the source capture explicit at tool-handler entry, before any await. An explicit transport could be reasonable, but passing a source object alone would not enforce the existing single-use, bounded-lifetime and revocation contract. The claim still fences receiver setup and revalidates owner/origin across async setup. I am not treating either architecture preference as a correctness verdict. The concrete capture, refusal-reporting and Stop-identity defects are fixed in this commit; 180 targeted regressions and Core typecheck/build pass.
| // Refuse the recorded input rather than replaying it as autonomous work. | ||
| if (said.taskInput) { | ||
| try { | ||
| await refreshTaskInputActor(said.taskInput, deps.webchatRepo, taskSourceChat); |
There was a problem hiding this comment.
[P2] correctness — A revoked or expired handoff loses the task input but reports success
The 30-second clock starts before dashboard.send and keeps running through agentSessionManager.open. The comment above admits a cold model session can outlast it. If the recheck fails, this branch marks the already-recorded input failed and answers 409.
But runtime.post treats any recorded input as said: it sees getUserInput exists and returns ok: true. So Concierge believes the task received its brief, while the task chat holds a failed input and never runs. Before this PR, the input would at least have run without an actor.
Alternative B removes the timer, which leaves Stop as the only way to revoke. Whichever design stays, a refused attribution should either return an error to post, or deliver the input without an actor (the main behavior) instead of silently dropping it.
There was a problem hiding this comment.
Confirmed and fixed in f91e20a. A refused attributed input now returns ok:false even if it was recorded, so chat_start/chat_send no longer report successful delivery. Regressions cover Stop, cold-open expiry, owner change and archiving, with submit never called. The final synchronous admission check is inside the refusal-handling boundary. The 30-second deadline remains part of the bounded-handoff contract; refusal is visible rather than silently dropping the work. The ordinary unattributed recorded-message path is unchanged. This is a confirmed pre-submit refusal, not an automatic retry after an unknown outcome.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| turnId, | ||
| actor, | ||
| audience, | ||
| isCurrent: () => { |
There was a problem hiding this comment.
[P1] correctness — A guardian follow-up cancels an in-flight task start or task send
The web client sends every Concierge message with priority: "now" (Chat.tsx:2111). AgentInputQueue.submit then stops the running Concierge turn as superseded, which sets lifecycleInterrupted and gives it a new turn id. isCurrent() then returns false (and currentTurnActorRef returns undefined). If the guardian types a follow-up while chat_start/chat_send is still delivering, one of two things happens. Before recordUserInput, the claim or the assert throws, so chat_start deletes the chat and marks the task failed. After it, refreshTaskInputActor fails, the input is set to failed, and post still returns {ok:true}, so the task never runs while Concierge reports success. Before this PR the input was delivered without an actor. Suggested fix: when the handoff is merely no longer current, fall back to the old unattributed delivery, and refuse only on an explicit guardian Stop (stoppedByGuardian) or a real ownership mismatch. Add a test where a now input arrives during delivery.
There was a problem hiding this comment.
I reproduced and fixed the silent-success part in f91e20a. I did not adopt the fallback to unattributed execution: absence of an actor is not uniformly less privileged than a visitor in the host, as the Stop finding demonstrates. Supersession still revokes a not-yet-admitted handoff under the stated source-turn contract. It now produces an explicit delivery error instead of claiming Sent. Tests cover same-person turn replacement, async first-lookup/asking-device races, and delayed superseded acknowledgement. After admission the task still has its independent lifetime. Keeping an old input alive across a replaced source turn would need a separate policy decision, not a silent actor downgrade.
| // Refuse the recorded input rather than replaying it as autonomous work. | ||
| if (said.taskInput) { | ||
| try { | ||
| await refreshTaskInputActor(said.taskInput, deps.webchatRepo, taskSourceChat); |
There was a problem hiding this comment.
[P2] error-handling — 30-second deadline at admission can drop a task silently after a slow session open
The 30-second clock starts in withTaskInput, before dashboard.send. refreshTaskInputActor checks it again after agentSessionManager.open. For a new task chat that open is cold: it builds session tools and opens the provider session, which can take a long time on a loaded host. When the deadline passes, the input is marked failed and post returns {ok:true}, as the 'does not invite resend' test requires. Concierge then reports the task as started when it never ran. Once the claim is consumed, the admitted flag already guarantees a single admission and isCurrent() still handles revocation. Suggested fix: check the deadline only when the claim is made, or at least fail visibly (return ok:false / a clear refusal) instead of returning success.
There was a problem hiding this comment.
Confirmed the hidden failure and fixed its reporting in f91e20a. The cold-open regression advances the clock beyond 30seconds, expects ok:false, verifies a failed input and released handle, and asserts no submit. I retained expiry at admission: the approved scope is a short-lived source-bound handoff, not an indefinitely transferable actor after the initial claim. A slow open may therefore fail visibly. No automatic resend or unattributed fallback was added. Core typecheck/build and180 targeted regressions pass.
| readonly expires: number; | ||
| } | ||
|
|
||
| const inputs = new AsyncLocalStorage<TaskInputClaim | undefined>(); |
There was a problem hiding this comment.
[P3] design — Optional simplification: pass the actor explicitly instead of through the AsyncLocalStorage state machine
AsyncLocalStorage plus WeakMap state with used/checked/authorized/admitted flags and four separate entry points is a lot of machinery for one host-internal call path (sendInput → dashboard.send → runtime.post). A host-only option on that path, never exposed to the model or HTTP, with one ownership check right before submit, would give the same guarantees with far less code. Optional: the current design is defensible as defence in depth.
There was a problem hiding this comment.
Deferred the optional transport rewrite for the reasons discussed in discussion_r4577747273. f91e20a does adopt explicit source capture before asynchronous handler setup, while retaining the tested single-use claim and receiver-scope fence. The concrete correctness and identity defects were addressed without widening the port or removing freshness/revocation checks.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| inputId, | ||
| state: "failed", | ||
| }); | ||
| return answer({ error: "Task input attribution is unavailable" }, 409); |
There was a problem hiding this comment.
[P1] correctness — A task input refused after it is recorded is reported to the Concierge as sent
If refreshTaskInputActor throws, the input is marked failed and the route answers 409. post() (~5414) then finds the input recorded and returns { ok: true }. sendInput succeeds, chat_start/chat_send say "Sent", and sendLinked never takes its failure path, but the task never runs.
This does not need a Stop. The 30-second HANDOFF_MS deadline also covers agentSessionManager.open, and every chat_start opens a new session, so a slow open (cold model process, MCP setup, load) is enough. That delivery used to succeed, without attribution.
Suggested fix: drop the deadline, since isCurrent() plus single use already limit the claim to the live turn. Also make post return ok: false for this refusal so the Concierge, and chat_start's mark-failed path, see it.
There was a problem hiding this comment.
Confirmed. f91e20a returns ok:false for a refused attributed input even when its record exists, so Concierge sees the delivery failure. Stop, expiry during cold open, owner-change and archive regressions assert no submit and a visible error. I retained the bounded 30-second lease rather than expanding the lifetime policy. The generic unattributed recorded-message behavior is unchanged, and there is no automatic retry after an uncertain outcome. 180 targeted regressions and final Core typecheck/build pass.
|
|
||
| get currentTurnActorRef(): TurnActor | undefined { | ||
| return this.currentSink?.actor; | ||
| return this.currentSink?.lifecycleInterrupted || this.closing |
There was a problem hiding this comment.
[P2] security — Reporting no actor during Stop affects every tool call, and some paths treat no actor as more trusted than a visitor
currentTurnActorRef feeds turn.actor() for every action call (asTurnActor → actionEngine.run), every subagent and share-location, not just the handoff's isCurrent(). A tool call that races a Stop now runs with no actor instead of being refused. Some host paths read no actor as Rome's own work. The automated send into a Concierge chat (webchat.ts ~4084), for example, refuses actorKind === "visitor" but lets a missing actor through. So a visitor turn racing a Stop can gain access instead of losing it.
Suggested fix: leave the actor unchanged and add a separate liveness check (e.g. turn.live()) that isCurrent() uses.
There was a problem hiding this comment.
Confirmed and fixed in f91e20a. currentTurnActorRef again keeps the admitted actor unchanged. A separate live() fact becomes false before waiting for Stop/superseded acknowledgement and is consulted only by the handoff gate; missing liveness cannot grant attribution. Real session-level synthetic tests keep the visitor actor during both delayed acknowledgements, and the action-port regression confirms an action still receives visitor rather than undefined. No App guard or approval behavior was relaxed.
| } | ||
|
|
||
| const inputs = new AsyncLocalStorage<TaskInputClaim | undefined>(); | ||
| const states = new WeakMap< |
There was a problem hiding this comment.
[P3] code-quality — Over-complicated: the claim tracks five state flags and repeats checks across modules
Optional. The WeakMap tracks five flags (active/used/checked/authorized/admitted) and runs ownership checks twice. The audience and agent-name checks are written out both in rome-tool-ports.ts and in current()/claimTaskInputActor. One used flag set on claim, plus one checkTaskInputActor call immediately before the synchronous submit, gives the same single-use and revocation guarantees with fewer moving parts. If security review wants checks both before and after the session opens, keep them, but share one predicate instead of three copies.
There was a problem hiding this comment.
Kept the optional state-machine simplification out of this focused repair. The before/after-open checks protect an actual async ownership boundary; the flags distinguish claiming, validated authorization and final single admission. Removing them needs an equivalent replay/expiry/revocation argument, not just one ownership lookup. f91e20a fixes the demonstrated defects and captures the source before awaits. The alternative transport discussion is grouped at discussion_r4577747273. No claim that the current implementation is the only possible design.
yunfanye
left a comment
There was a problem hiding this comment.
Design & Alternatives review: ✅ APPROVE
Problem
When a guardian delegates work through Concierge, guardian-only task actions fail because webchat discards the authenticated actor whenever an automated source exists.
Goals and non-goals
Preserve actor identity separately from Concierge's sender identity; restrict delegation to a live source turn and one matching input into its same-owner task; retain audience restrictions and independent task cancellation after admission. Do not trust model/HTTP identity fields, widen action catalogs or approvals, or introduce durable delegation.
Design & Alternatives
The PR introduces a short-lived, single-use host claim (packages/core/src/webchat/task-input-actor.ts). The session-tool adapter captures live turn facts, webchat rechecks ownership after asynchronous setup, and submission reuses existing actor/audience options. Receiver setup runs outside the handoff scope.
| Approach | Added complexity | Correctness/completeness | Blast radius | Reversibility | Maintenance | Effort |
|---|---|---|---|---|---|---|
| PR: bounded host-only handoff | Moderate lifecycle state | Meets stated contract | Concierge admission; actor access during Stop | High; internal-only | Localized checks | Moderate |
| Do nothing | None | Delegated actions remain broken | None | High | None added | None |
| Explicit host-only task-input port | New port and wiring | Same guarantees with equivalent validation | Concierge/dashboard interfaces | High if internal | More plumbing, less ambient context | Moderate |
| Reuse subagent delegation | Existing attribution; substantial task adaptation | Changes task lifetime and ownership semantics | Task orchestration and presentation | Costly rollback | Reuses child lifecycle | High |
An explicit port is feasible through TaskChats/ConciergeDashboard in packages/core/src/concierge/service.ts, wired in packages/core/src/api/index.ts and sharing handleChatSend. It still needs the same freshness, ownership and replay checks while bypassing or extending ordinary delivery through packages/core/src/chats/send.ts and packages/core/src/webchat/send.ts; it is not clearly simpler overall.
Existing subagent calls accept actor/audience (packages/core/src/agent/application/subagent-calls.ts), but agent-session.ts cancels them with their parent. Reuse therefore requires a broader task redesign and does not preserve independent task lifetime. Blanket ambient-actor inheritance is unsuitable: rome-tool-ports.ts deliberately clears that scope because provider callbacks may arrive under an unrelated request.
Recommendation
The PR's approach is the best fit: it fixes attribution at admission while retaining normal delivery, queueing and action execution. No new public API, database schema or wire-format commitment is introduced; those one-way doors remain closed.
Verification
Inspected the changed implementation and regression tests, plus send wiring, privacy/ownership facilities, input queue, audience calculation, action-worker actor forwarding and requester-bound approval replay. Targeted tests could not execute because this clone lacks dependencies (rstest not found). Deployed fullstack acceptance remains unverified.
Verdict: APPROVE — The bounded, host-only handoff preserves trusted attribution without broadening automated-message authority or changing task lifetime.
No issues found. Code looks good!
Automated review by RomeOS Code Review · commit 77a43ba · Full review history
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| withTaskInput: (chatId, body, send) => | ||
| turn.inTurn(() => { | ||
| const thread = turn.threadContext(); | ||
| const turnId = turn.turnId(); |
There was a problem hiding this comment.
[P1] security — Bind attribution before asynchronous tool setup
These getters read the session's current turn, but withTaskInput is reached only after asynchronous chat_send/chat_start setup. If an autonomous turn's callback remains pending while a newer guardian turn starts, the old callback snapshots that guardian here, and subsequent isCurrent checks validate the wrong originating turn. I reproduced this by pausing setAskingDevice, advancing to a guardian turn, and resuming the old chat_send: its handoff carried the new guardian actor. Capture the originating turn at tool-handler entry, before any await, and reject a changed turn before minting the handoff; add a regression covering this transition.
There was a problem hiding this comment.
Confirmed with a failing regression, fixed in f91e20a. chat_start and chat_send now call captureTaskInput at handler entry, before their first await. Its sender closes over immutable actor/turn/chat/audience facts and refuses changed sources instead of sampling a later actor. Integration probes pause both the first task lookup and setAskingDevice; an old autonomous callback cannot borrow a newer guardian. Additional port tests cover visitor-to-guardian and same-guardian/new-turn replacement. 180 targeted regressions, Core typecheck/build and four zero-network App-guard probes pass.
Capture handoff identity before async Concierge setup, preserve visitor identity during Stop, and report refused admission as a delivery failure. Keep the bounded single-use and revocation contract.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| return async (chatId, body, send) => | ||
| turn.inTurn(() => { | ||
| if (!sameSource() || turn.live?.() === false) { | ||
| throw new Error("Task input source changed before delivery; it was not sent"); |
There was a problem hiding this comment.
[P1] correctness — Superseding the source turn fails task start/send, even when no actor would be granted
This throw, and the not live throw at line 222, run whether or not source is defined. Concierge web messages always use priority: "now", which supersedes the running turn and sets lifecycleInterrupted. So a guardian follow-up typed while chat_start is running makes the delivery throw: the new chat is deleted and the task is marked failed with "Do not start it again". On main the input was delivered. The 30-second HANDOFF_MS deadline (a slow cold agentSessionManager.open) and the post-open refresh failure lead to the same failed start. Suggested fix: fail closed only on the attribution. If source is undefined, or the handoff is no longer current only because of a supersede or the deadline, deliver through withTaskInputActor(undefined, …) without an actor, as main does. Refuse delivery only on an explicit guardian Stop (stoppedByGuardian) or an ownership mismatch. Also add a test where a now input arrives during delivery. This keeps the thread Jessie-QingYu opened: the PR distinguishes neither Stop from supersede nor attributed from unattributed sends.
There was a problem hiding this comment.
Accepted the already-unattributed case separately in ad5cef7. A callback captured with no eligible source keeps ordinary automated delivery; it never re-samples the newer turn's actor. Three probes failed before that refinement. The integration tests now cover autonomous, visitor and guardian origins paused at both the first lookup and asking-device setup. Autonomous work is sent without a claim; changed attributed origins are refused. 184 targeted regressions, final Core typecheck/build, 162 import rules and four zero-network App-guard probes pass.
I have not adopted stripping an existing attributed claim on supersession/expiry or removing its deadline. The bounded source-bound revocation contract remains explicit, and refusal is visible. A missing actor is not uniformly less privileged in the host, so a revoked visitor claim must not silently become autonomous authority. A callback already interrupted at entry is also refused. This remaining lifetime-policy disagreement still needs review agreement; I am not calling it approved or deploying the change.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| return async (chatId, body, send) => | ||
| turn.inTurn(() => { | ||
| if (!sameSource() || turn.live?.() === false) { | ||
| throw new Error("Task input source changed before delivery; it was not sent"); |
There was a problem hiding this comment.
[P1] correctness — A superseded or mixed-actor source now drops task delivery, even with no handoff to protect
The sender throws whenever sameSource() fails, including when source is undefined (an autonomous, group or visitor-less turn). In that case withTaskInputActor(undefined, …) would run unattributed anyway, so refusing protects nothing. The web client sends every Concierge message with priority: "now" (Chat.tsx:2111), which supersedes the running turn. A steered automated input sets the actor to undefined (agent-input-queue.ts:236). Either one between handler entry and the post-open recheck at webchat.ts:5113 now makes chat_start delete the chat and markStartFailed with "Do not start it again", and makes chat_send lose the input. Main delivered both. Simplest fix: when source is undefined or no longer current, call send() under withoutSessionActor with no claim, which is main's behavior. If Stop must cancel delivery, refuse only on an explicit guardian Stop. Add a test where a now input lands mid-chat_start.
There was a problem hiding this comment.
The already-unattributed case is fixed in ad5cef7: the throw is now guarded by source, and an initially ineligible callback remains an ordinary automated send without ever sampling a newer actor. Three probes failed before this refinement; 184 targeted regressions now pass. The review summary names f91e20a, although this inline comment is associated with ad5cef7, so I checked the current code rather than relying on the inline commit field. For an actual revoked attributed claim, the source-turn refusal policy remains as discussed in discussion_r4577864662; it is visible, not a silent success.
| TaskInputClaim, | ||
| { active: boolean; used: boolean; checked: boolean; authorized: boolean; admitted: boolean } | ||
| >(); | ||
| const HANDOFF_MS = 30_000; |
There was a problem hiding this comment.
[P2] error-handling — 30-second deadline adds a failure mode that liveness and single use already cover
The claim's lifetime is already bounded: state.active goes false when withTaskInputActor returns, used/admitted make it single-use, and isCurrent() revokes it on Stop or turn change. HANDOFF_MS does not narrow the trust boundary further. It is still checked after the target's cold agentSessionManager.open, so a slow open (model process or MCP startup under load) now fails chat_start and marks the task failed, where main ran it. Drop expires and the Date.now() check in current(), or check it only at claimTaskInputActor.
There was a problem hiding this comment.
The expiry refusal is visible since f91e20a and remains covered on ad5cef7. I am retaining expiry at admission as the stated bounded-handoff policy rather than broadening actor lifetime during this repair. An active but indefinitely slow async setup is not the same lifetime bound as 30 seconds. This does trade off slow-start availability, and I am documenting the disagreement rather than claiming review approval. Related source-revocation discussion: discussion_r4577864662. No automatic resend, actor stripping, or deployment has been added.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
Keep a callback with no eligible actor on ordinary automated delivery without re-reading identity from a newer turn. Retain fail-closed expiry and revocation for an attributed handoff.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| ); | ||
| if (sent.status >= 400) { | ||
| // A refused attributed input never reached submit, even if recorded. | ||
| if (claim) return { ok: false, error: `${routeError(sent)}; task input was not admitted` }; |
There was a problem hiding this comment.
[P3] error-handling — An attributed send that fails after recording leaves a queued input but reports failure
Only the refresh-refusal path marks the recorded input failed. If agentSessionManager.open throws a non-model error (the 500 at ~4638), the attributed input stays queued in the task chat, while post now returns ok:false. Concierge may then resend through chat_send, leaving the stale queued message beside the new one. Optional: mark the input failed before returning ok:false for a claim, as the refresh path already does.
There was a problem hiding this comment.
Confirmed with a failing regression and fixed in eccee45. A pre-submit refusal now atomically changes only queued user/prompt inputs to failed. Both legacy WebChatRepository and current Chats/TurnLinks storage implement the conditional write; already submitted/accepted/consumed/unknown/failed inputs, turn links, missing inputs and other chats are preserved. Tests also cover a stale queued read followed by consumption. Ordinary unattributed recorded-message behavior is unchanged, and no resend was added. 226 selected regressions, Core typecheck/build, 162 import rules and four zero-network App-guard probes pass. The preceding ad5 full CI had two failing tests, whose unchanged cases pass locally; the new head still requires its own CI, not a blanket all-green claim.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| return async (chatId, body, send) => | ||
| turn.inTurn(() => { | ||
| if (source && (!sameSource() || turn.live?.() === false)) { | ||
| throw new Error("Task input source changed before delivery; it was not sent"); |
There was a problem hiding this comment.
[P1] correctness — A routine supersede, steered input or slow open during chat_start permanently fails the task
The web client sends every Concierge message with priority: "now" (Chat.tsx:2111). AgentInputQueue.submit then stops the running turn with SUPERSEDED_INTERRUPT_REASON, which sets lifecycleInterrupted and starts a new turn id. A steered input from another source clears the turn's actor through mixActors. Either one between handler entry and the recheck at webchat.ts:5113 makes this throw, as does a cold open that runs past HANDOFF_MS. chat_start then deletes the chat, calls markStartFailed, and tells the model "Do not start it again". Main started the task in all three cases.
The reply argued that an actorless fallback is unsafe for visitors. That is fair, but it does not justify failing the task outright. A guardian's own follow-up has the same actor and the same chat, so keeping the handoff borrows no identity.
Suggested fix: revoke only on an explicit Stop (stoppedByGuardian), on close, or on a real actor or owner change. Let a supersede by the same actor keep the handoff valid. At a minimum, do not mark an attribution refusal as a permanent start failure. Add a test where a now input arrives mid-chat_start.
There was a problem hiding this comment.
This remains a deliberate lifetime-policy disagreement, not an identity-capture defect. Stable identity alone does not establish that the old turn's exact task brief remains admitted after that turn is replaced or mixed. The current contract revokes before admission on source-turn change, Stop or expiry, while an already-admitted task has its own lifetime. Refusal is visible; stripping visitor attribution is not a safe fallback. I have therefore not expanded the source-bound lease to survive supersession or removed the deadline in this repair. eccee45 fixes the separate failed-input state bookkeeping; it does not claim to settle this availability trade-off or obtain review approval.
| getTurnPushLevel: turn.pushLevel, | ||
| getTurnReportedTask: turn.reportedTask, | ||
| captureTaskInput: () => { | ||
| if (turn.live?.() === false) throw new Error("Task input source is not live"); |
There was a problem hiding this comment.
[P3] correctness — Liveness check at handler entry still refuses callbacks that have no actor to grant
ad5cef7 keeps "already-unattributed" callbacks on ordinary automated delivery, but this check still throws for any source once live() is false. Examples are an autonomous or task-event turn superseded by a guardian message, or a mixed turn. In that case chat_start and chat_send fail at entry even though source would be undefined and nothing would be granted. To match the sender, return the sender with source = undefined here instead of throwing. Its own source && guard then handles the attributed case.
There was a problem hiding this comment.
The entry check is intentionally stronger than the in-flight sender check. ad5cef7 preserves a callback that started while live with no eligible actor, without letting it acquire a later actor. It does not permit a provider callback to start new delivery after its source is already interrupted. Removing the entry gate would also permit that new work after Stop; live() alone cannot distinguish your proposed supersession-only exception. I am retaining this cancellation boundary, as the latest Jessie review also considers the entry refusal reasonable. No code change for this point; the unrelated queued-state defect is fixed in eccee45.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
Condition the failure update on queued state atomically in legacy and Chats storage. Preserve later dispatch states, turn links, and ordinary unattributed delivery; never resend.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| : undefined; | ||
| return async (chatId, body, send) => | ||
| turn.inTurn(() => { | ||
| if (source && (!sameSource() || turn.live?.() === false)) { |
There was a problem hiding this comment.
[P2] correctness — A same-actor supersede still fails an attributed chat_start permanently
I concur with the open threads at lines 264/265 and do not find the reply convincing for this case. Concierge web input always uses priority: "now" (Chat.tsx:2111), and AgentInputQueue.submit stops the active turn with SUPERSEDED_INTERRUPT_REASON. That sets lifecycleInterrupted and starts a new turn id, so sameSource()/isCurrent() fail. chat_start then deletes the chat and calls markStartFailed ("Do not start it again"), where main started the task. When the new turn has the same actor, audience and source chat, keeping the claim moves no identity across, so refusing it narrows no trust boundary. Suggested narrow fix: expose stoppedByGuardian/closing as the revocation fact. Ignore the turn-id change when a turn with the same sameActor, audience and chat supersedes it. Keep refusing on explicit Stop, close, or a change of actor or audience, and add a regression where a now input arrives during chat_start.
There was a problem hiding this comment.
Implemented the narrow same-person continuation after the owner confirmed that behavior. 6210f67 keeps the originally captured actor and source turn when a same-actor, same-private-chat, unchanged-audience now input supersedes startup. It does not recapture the newest actor or fall back to anonymous work.
Rather than only dropping turn-id/liveness checks, a host-owned revocation epoch remembers intervening actor/chat/audience changes and mixed input. Stop revokes synchronously, including the between-turn gap; close, expiry, ownership/origin checks, single-use admission and approval binding remain intact. Returning to the original scope cannot revive the old handoff.
Both actual chat_start handler probes (chat creation and simulated cold open) fail on the preceding head and pass here. 26 session-boundary cases and 250 selected regressions pass, plus Core types/build and scoped static checks. Broad local preflight is not green (channel-test-ui dependencies; related-suite run stopped at 180s). New-head CI and deployed end-to-end acceptance are separate; nothing is deployed.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
| const sameSource = () => { | ||
| const live = turn.threadContext(); | ||
| return ( | ||
| turn.turnId() === turnId && |
There was a problem hiding this comment.
[P1] correctness — A same-person follow-up during chat_start still deletes the chat and marks the task permanently failed
Every Concierge web message is sent with priority: "now" (Chat.tsx:2111), and AgentInputQueue.submit supersedes the running turn. That sets lifecycleInterrupted, which makes live() false, and starts a new turn id, which fails the turnId check here. It does this even when the actor, audience and private chat are unchanged. So if the guardian types anything while chat_start is in its window, which includes the cold agentSessionManager.open, the sender or the post-open recheck refuses. chat_start then deletes the chat and calls markStartFailed with the message "Do not start it again"; on main this task ran. The earlier reply argued against falling back to unattributed delivery, and I agree. But it does not cover this case. In a private Concierge chat, only the same owner can start the next turn with the same actor, and an automated or mixed turn already fails sameActor, so binding to the turn id adds no identity protection. Simplest fix: revoke on stoppedByGuardian or close rather than on any lifecycleInterrupted, and drop the turn-id equality while keeping sameActor, audience and chat. Then add a test where a now input arrives during chat_start.
There was a problem hiding this comment.
Implemented the narrow same-person continuation after the owner confirmed that behavior. 6210f67 keeps the originally captured actor and source turn when a same-actor, same-private-chat, unchanged-audience now input supersedes startup. It does not recapture the newest actor or fall back to anonymous work.
Rather than only dropping turn-id/liveness checks, a host-owned revocation epoch remembers intervening actor/chat/audience changes and mixed input. Stop revokes synchronously, including the between-turn gap; close, expiry, ownership/origin checks, single-use admission and approval binding remain intact. Returning to the original scope cannot revive the old handoff.
Both actual chat_start handler probes (chat creation and simulated cold open) fail on the preceding head and pass here. 26 session-boundary cases and 250 selected regressions pass, plus Core types/build and scoped static checks. Broad local preflight is not green (channel-test-ui dependencies; related-suite run stopped at 180s). New-head CI and deployed end-to-end acceptance are separate; nothing is deployed.
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
zoolsher
left a comment
There was a problem hiding this comment.
Code Review: ✅ APPROVE
at 6210f67
Goal. A live, private Concierge turn may pass its verified guardian or visitor actor to exactly one input in a task chat that the same person owns. The message's source stays Concierge. The model, the message text and HTTP fields can never supply identity.
Since the last round (eccee45 → 6210f67). This commit answers the open P1 threads: a guardian's own now follow-up during chat_start or chat_send used to revoke the handoff, so the start failed and the chat was deleted. Now isCurrent is AgentSession.captureTaskInputLiveness(). It pins the source sink plus a taskInputEpoch instead of the turn id. I checked every place the epoch is bumped or preserved:
- Same-person
now.submitcallsobserveTaskInputScopebefore the queue stops the running turn. The same actor (kind/accountId/userId), audience and thread (channel, threadId, threadType) settaskInputContinues. The queue's supersede goes throughhandle.stop(SUPERSEDED)andstopRunning(SUPERSEDED), and neither bumps the epoch. - Re-observing the next turn.
runOneTurnobserves again withparentAudience: sink.audience.turnAudienceis idempotent for that input, so the next turn's start does not trigger a false revocation. - Stop. User Stop (
turn.stop("user-stop")→ createTurn callback, andstopRunningwith a reason other than supersede),session.stop,closeand a mixed actor from a steered input each bump the epoch. So does any submit whose scope changed. That revocation is permanent, even if a later input restores the scope, as the docs state. - Done turns.
closeSinkclearscurrentSink, so a laternowcannot revive a source that finished on its own.
Beyond the diff. Automated and backend inputs into a Concierge chat (runSystemTurn → enqueueSessionTask) wait behind the active stream. So submits with a different scope seldom land during the source turn. When one does land after a supersede, the documented policy refuses it, and the refusal is visible. Since this round's question was submit-time ordering, I reconfirmed that the webchat route has no now-specific interrupt before submit. The rest of this paragraph comes from the earlier rounds and does not change in this commit, so I did not retrace it: post → claimTaskInputActor → taskInputActor → handleChatSend (refreshTaskInputActor, admitTaskInput), and failQueuedUserInput in both storage adapters. The tool entry captureTaskInput in chat_start/chat_send runs before the first await.
Not repeated. These were discussed and the author's replies explain them: the 30-second lease still applies at admission after a cold open, as a deliberate choice that fails visibly, and the AsyncLocalStorage-claim transport was kept instead of an explicit parameter. The machinery is heavy, with claim state flags, an epoch, a scope snapshot and a continues flag. But each part now guards a specific async boundary, and an explicit transport would still need single use, expiry and revocation. One minor note: after the superseding turn finishes, the UI has no turn left to Stop. A pending same-person handoff then lasts until it is admitted or the lease expires (at most 30 seconds). The person is the same one who asked, so this is no worse than main.
Not verified. No dependencies are installed in the clone, so I could not run the test suites, including the new agent-session-actor.test.ts. I read them but did not execute them.
No issues found.
Verdict: APPROVE — The new head fixes the last open P1, where a same-person follow-up cancelled a pending handoff, and I found no new correctness or security defect in the paths I traced.
No issues found. Code looks good!
Automated review by RomeOS Code Review · commit 6210f67 · Full review history
yunfanye
left a comment
There was a problem hiding this comment.
Code Review: 💬 COMMENT
Reviewed head 6210f67: source capture, supersession, revocation, admission, ownership checks and queued-only cleanup, including related delivery and action paths. Previously fixed findings were not repeated. Unrelated portions of large existing files were not fully audited. Targeted tests could not start because node_modules/rstest are absent; CI was still running.
Verdict: COMMENT — No new actionable defect was found, but verification remains incomplete.
No issues found. Code looks good!
Automated review by RomeOS Code Review · commit 6210f67 · Full review history
Jessie-QingYu
left a comment
There was a problem hiding this comment.
Code Review: ✅ APPROVE
at 6210f67
Goal. A live, private Concierge turn may pass its verified guardian or visitor actor to exactly one input in a task chat that the same person owns. Concierge stays the message source. The model, the message text and HTTP fields never supply identity. This round makes a pending handoff survive a now follow-up from the same person, which was the main open P1/P2 thread from @Jessie-QingYu and @zoolsher.
What changed since eccee45. AgentSessionImpl now has three new pieces of state:
- a session-wide
taskInputEpoch, bumped on Stop, close, mixed actors and any interrupt other than supersede; - a record of the last observed
(actor, audience, channel/threadId/threadType)scope, bumped on everysubmit,startTurnandrunOneTurnthat changes it; - a per-sink
taskInputContinuesflag, set only when anowinput arrives with the same scope and no guardian Stop.
captureTaskInputLiveness() pins the sink and the epoch when the tool handler is entered. rome-tool-ports uses that as isCurrent.
Checks beyond the diff
- Supersede path.
AgentInputQueue.submitcallsactive.handle.stop(SUPERSEDED_INTERRUPT_REASON). ThecreateTurninterrupt callback skips the epoch bump only for that reason, and so doesstopRunning. A user Stop arrives through/chat/turns/:id/interrupt, thenturn.stop("user-stop"), which bumps the epoch. That holds even when the Stop lands on a queued T2 or between turns (stop()bumps first). - Steered or mixed inputs.
flush()callsmixActors, which bumps the epoch. A mixed queue start strips the actor, so therunOneTurnobservation sees a changed scope. - Backend system turns (task events, approvals, defers).
enqueueSessionTaskwaits for the previous webchat stream before it callssubmit("after"), so it cannot revoke a handoff while the source turn is still running. - Forks. These have no speaker, so
forTurngives them no Concierge session tools. A fork can never reachcaptureTaskInput. - Identity.
sameActorcompares kind, accountId and userId. A visitor has an accountId, so two visitors are never treated as the same person. The DB-backed owner and origin recheck incheckTaskInputActorstill covers a source chat that becomes shared.
Not re-raised. The earlier threads on the 30-second lease and the ALS/WeakMap transport were explained as deliberate policy and are documented in actions.md. I do not re-raise them. This commit does add more Concierge-specific state to the generic AgentSessionImpl (taskInput* names, an observation on every submit). It works, but it adds to the complexity those threads describe. If this design is kept long term, consider moving the state behind one small lease object.
Verification limits. Dependencies are not installed in the clone, so I did not run the new tests locally. On the new head, CI unit-tests-core was still pending, while lint, integration and rest had passed. The new session tests do cover Stop, close, and changes of actor, audience, chat, group, channel, unattributed input and expiry after a same-person now. They also cover a source that completes normally.
Findings. Two optional P3s: a narrow race in which a queued automated input revokes the handoff, and a sameSource fallback that production never uses.
Verdict: APPROVE — The latest commit fixes the open same-person supersession findings without granting identity across a scope change, and I found only two optional P3 issues.
2 finding(s) posted as inline comments below.
| Severity | Category | File | Title |
|---|---|---|---|
| P3 | correctness | packages/core/src/agent/application/agent-session.ts |
An automated input queued after a same-person supersede revokes a pending handoff before it runs |
| P3 | code-quality | packages/core/src/core/rome-tool-ports.ts |
sameSource fallback is unreachable in production, and tests exercise only the fallback |
Automated review by RomeOS Code Review · commit 6210f67 · Full review history
| const { priority = "next", onInputStatus, ...turnOptions } = options; | ||
| // Observe before the queue synchronously stops a superseded turn. A changed | ||
| // scope revokes old callbacks even if another input restores it before delivery. | ||
| const sameScope = this.observeTaskInputScope(turnOptions); |
There was a problem hiding this comment.
[P3] correctness — An automated input queued after a same-person supersede revokes a pending handoff before it runs
Every submit observes its scope, including after/next inputs that do not supersede the running turn. Here is the race: a backend task event is waiting behind T1's stream, and the guardian sends a now follow-up while chat_start is cold-opening. T1's stream then finishes, and the event's submit("after", actor: undefined) bumps the epoch. chat_start then fails permanently ("Do not start it again"), even though no other identity has run in the source session. The race is narrow. Optional fix: observe at submit only for now inputs. That is the case the comment's synchronous-stop argument needs. Leave runOneTurn and mixActors to catch other inputs once they actually run or are steered in.
There was a problem hiding this comment.
Confirmed by the current submit/start path: an unattributed after input can revoke a pending handoff before that input runs. I am deferring this optional availability refinement, not treating it as an identity leak. The current contract conservatively revokes when a changed scope is accepted, and refuses visibly without retry or an anonymous fallback.
The suggested now-only observation is not sufficient on its own: startTurn also observes queued after work, and a next input can be steered into a running turn. mixActors covers identity changes, but not a same-actor thread/audience change on that steer. Deferring scope observation would need a reliable pre-steer scope boundary as well as the run-start boundary; simply removing the current observations loses that protection. I will keep that broader queue-policy refinement outside this focused repair. The owner-authorized same-person, unchanged-scope now case remains covered.
| live?.threadId === sourceChatId | ||
| ); | ||
| }; | ||
| const sourceCurrent = |
There was a problem hiding this comment.
[P3] code-quality — sameSource fallback is unreachable in production, and tests exercise only the fallback
turnFacts() always supplies captureTaskInputLiveness, and forks never get Concierge session tools. So the sameSource() fallback and the captured turnId comparison never run in production. Several rome-tool-ports.test.ts cases, such as "revokes a handoff when the live audience changes", therefore cover only the fallback. Optional: delete sameSource and treat a missing captureTaskInputLiveness as "no source" (unattributed), so the tests exercise the path production uses.
There was a problem hiding this comment.
The fallback is indeed not used by normal root-session production facts. It is deliberately stricter for adapters that lack the host capture fact; removing it and changing those sends to unattributed work is optional cleanup, not needed to fix the reported identity loss. I am leaving that cleanup out of this repair.
The coverage is not limited to the fallback: core/agent-session-actor.test.ts creates real root Sessions and runs their TurnFacts through romeToolPorts, exercising captureTaskInputLiveness in 26 cases. It includes two actual chat_start handlers paused at chat creation or simulated cold open, plus same-person replacement, Stop before acknowledgement/between turns, closure, transient actor/audience/thread changes, expiry and single-use admission. Those cases passed locally and the current-head Core CI now passes. The smaller adapter fixtures retain the strict fallback tests; they are not the sole production-path evidence.
Why
Concierge task delivery keeps an automated source but loses the authenticated chain actor. Guardian-only app actions then refuse guardian-started work. The host now binds the actor to a task input without trusting message text or forwarded identity. Fixes #2199. Related: #2137.
Sketch
Invariants
The contract lives in
docs/concepts/actions.md#actor.Scope
Merge danger
Revertible code change affecting Concierge task admission and source liveness. A cold open beyond the lease can still be refused. Running instances remain unchanged until deployment.
Evidence
nowduring actualchat_startcreation or simulated cold open: two cases fail on the old head and pass with the fix. The source actor and turn stay pinned.