Repository navigation
refactor(gateway): one refusal owner with a required next step - #205337
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Operator refusals now name a typed cause from one table in src/gateway/operator-refusal.ts. Each cause carries a required next step; the person sees what was not done, whose access and why, and that step. The tool result gives the model the same sentence plus "Do not retry." A shrink-only boundary rule keeps refusal construction in listed files. Co-authored-by: obviyus <[email protected]>
|
9962519 to
2926527
Compare
|
E2E on exact head
verdict.json: {"pass":true,"checks":["R.running-turn-finishes","Q.queued-input-refused-visibly","S.stop-cancels"],"elapsedMs":58674}Refusal produced by admission for the revoked member's queued input (Gateway log): Known gap, recorded (not fixed here): for this queued |
Co-authored-by: obviyus <[email protected]>
|
Codex review: needs changes before merge. What this changesThis PR centralizes operator refusal messages and gives tool callers the same explanation followed by “Do not retry.”. Example: A member without operator write permission asks github_publish to act on another person's PR.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this maintainer-authored PR open: the shared refusal owner is useful, but the GitHub error conversion introduces a structured-error regression. Reviewed head: Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway admission and publication operations produce refusals; chat error handling and the agent tool adapter present them to people and models. flowchart LR
A[Operator request] --> B[Admission or publication]
B --> C[Typed refusal cause]
C --> D[Shared refusal text]
D --> E[Chat reply]
D --> F[Tool result]
F --> G[Agent model]
Technical reviewBest possible solution: Keep the shared refusal owner while preserving existing publication error envelopes when retaining typed causes. Do we have a high-confidence way to reproduce the issue? Source confirms inconsistent refusal presentation and the introduced publication-envelope failure; no target code was executed during this read-only review. Is this the best way to solve the issue? A shared typed cause table is a focused solution, but retaining an error cause should not also replace unrelated publication failure metadata. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 31a4d60036b6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +37, Tests +91, Docs +1, Other +73. Total +202 across 53 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 25, 2026, 8:08 AM ET / 13:08 UTC. |
|
Maintainer override: every red on head ci-triage: Proof per file (local runs on the merge base
The only OURS red on the first head ( |
|
Landed as 2a14180. Refusals now come from one cause table ( |
* commit '92569e37ab84a8cb1e4a12c3dcbb45acb97977c9': fix: distinguish Desktop sources without wrapping their names or IDs (#203747) fix(ui): Greek sigma searches miss matches outside Sessions and Files (#189518) fix: keep agent skill names on one line beside their switches (#203734) test(cron): admit scheduled occurrences in cron fixtures and fix Node 24 toHex in Vitest (#205383) fix: keep the Agents menu usable after copying an ID (#203739) fix(whatsapp): preserve code table spaces across message chunks (#205327) refactor(cron): admit legacy scheduled requesters through operator admission (#205346) fix: keep silent Codex turns healthy with running commands (#196062) test(update): verify the recorded preparation failure (#205363) fix(test): prove sibling imports on the active update path fix(chat): complete mentions without leaving part of the name behind (#205326) fix(test): restore Side chat hydration and retry checks (#205376) refactor: plugin-run turns get owner status from commands.ownerAllowFrom, like text messages (#205373) chore(ui): refresh control ui locales (#205378) fix: keep Telegram rich <details> and list blocks in one message when replies stream in chunks (#205318) refactor(gateway): one refusal owner with a required next step (#205337) fix(discord): keep long table labels bold across messages (#205328) feat: invitation, sharing and participant controls in the Control UI (#204920) fix(test): distinguish stamped Skill Library upgrade policies fix(markdown): preserve trailing inline-code spaces in plain-text tables (#205317)
## Problem A queued input (including `/followup`) that admission refused at start was visible only in the Gateway log. In chat the person saw only the generic pending-input line "This message was blocked by a policy and did not run." The cause sentence from #205337 (`OperatorRefusalError`, e.g. "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to …") did not reach them. Cause: `followup-runner.ts` treats a start refusal as a plain retry→consumed failure, so the existing "withheld" outcome (visible transcript notice plus source delivery) never runs for it. Some refusal texts also still sat outside the cause table (follow-ups listed in #205337). ## Fix - `src/auto-reply/reply/followup-runner.ts`: an `OperatorRefusalError` thrown before the turn is admitted (`!admittedTurn`) now takes the existing withheld branch, like a retired cron delivery. The notice is the refusal's own sentence (no `withheld:` prefix). That branch already records a visible `run-failed-before-reply` transcript notice and hands the failed completion to the source owner (Gateway chat records it in the run's chat). A refusal after the turn starts does not match, so a running turn never gets a false "I did not run". - Cause table (`src/gateway/operator-refusal.ts`) gets three rows. These sites now use it: - role agent refusal (`operator-role-policy.ts`, `agent-not-in-role`) - channel access notice (`agent-runner-error-handler.ts`, `channel-access-ended`) - workflow-permission failure (`github-publication-failure.ts`, `role-denies`; the nextAction keeps "not a token scope failure, saved changes intact") - session tool-policy refusals (`session-resource-tool-policy.ts`, `session-access-authority.ts`, `tool-policy-denies`) ### Decision: no new pending-input column The brief allowed one new nullable field on `session_pending_inputs` to carry the cause id. I did not add it. The existing withheld path already puts the sentence in the chat, so the schema change is avoidable (schema changes only when unavoidable; no new state). A column would have needed a PostgreSQL schema bump, a protocol field and about 20 files of threading. Consulted Fable 5.2; same pick. Trade-off: the pending-input line stays generic ("blocked by a policy"). The sentence shows as its own notice right after it. Old rows: unchanged, because nothing is stored. ### Known gap: channel messages Channel-originated queued inputs get the transcript notice (seen in the session in Control UI). They do not get a channel message. Channel inbound followups register no `onQueuedFollowupReplyBatch` source delivery, and a refused input has no admitted turn to deliver through. Sending one needs a new delivery path for unadmitted input, which this PR does not add. Tracked in #205417. Production `src`: net +25 lines (three cause rows, the refusal condition and notice selection; long free-text strings removed). ## User impact A member whose role was lowered while their `/followup` waited sees in the chat: "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to do it, or to add the permission to your role." Before, they saw only "This message was blocked by a policy and did not run." ## Evidence - `src/gateway/server-methods/chat-send-direct-followup.test.ts` "refuses a queued /followup … and says why in chat": real chat dispatch, queued `/followup`, requester demoted before start. It asserts the sentence in the transcript notice. It fails on base (followup-runner reverted) and passes on head. - Updated wording tests for the moved texts; `operator-refusal.test.ts` covers the new causes through the tool adapter. - E2E (isolated Gateway, real model) on `17bb2763cffa`: R, Q (with the new sentence assertion) and S pass; #205408 (comment) Co-authored-by: Ayaan Zaidi <[email protected]>
…law#205337) ## Problem Refused operator work had no single owner for what the person sees. Each throw site wrote its own sentence, so the same cause read differently by entry point, scope ids and internal words leaked ("Gateway access stopped [access-cause=grant-revoked]", "Restart recovery could not admit this input"), the D23 channel text was copied twice, and the model only got a "do not retry" hint for method-scope refusals. Other refusals reached the model as raw errors, which it paraphrased or retried. ## Fix - New owner `src/gateway/operator-refusal.ts`: one cause table (same pattern as `connect-error-details.ts`). Each cause has a required `why` and `nextStep`; the compiler rejects a cause without a next step. Text shape: "I did not <action>. <whose access and why>. <one next step>." Causes: `access-ended`, `sign-in-ended`, `role-denies`, `channel-unverified`, `owner-removed`, `requester-access-ended`, `invitation-ended`, `github-not-linked` (only on the path where linking helps: a profile with no linked account and no write access). - `OperatorRefusalError(cause, { action })` replaces `GatewayOperatorRecoveryAuthorizationError` and its free-text messages. Admission (`operator-admission.ts`) and the recovery helpers pick a cause; R5 ("Gateway access is not active for this requester") is now `role-denies`; R3/R13 (`access-cause=grant-revoked`) are now `access-ended` with the cause chain kept. - Refusal sites moved onto the table: R9 / requester write (`role-denies`), R8/D23 channel identity (`channel-unverified`, was duplicated), GitHub link (`github-not-linked`), ownerAllowFrom removal (`owner-removed`), restart completion notice (`requester-access-ended`). - Delivery: chat already shows `OperatorRefusalError.message` (`agent-runner-error-handler.ts`). The tool adapter now returns the same sentence plus "Do not retry." for any refusal (and for method-scope refusals, through the same table). `sessions.github.*` errors keep the typed failure for in-process tool callers (`errorShapeFromError`), so R9 reaches the model as a refusal. - Boundary lint `no-operator-refusal-construction` (shrink-only, ceiling 9): `new OperatorRefusalError` or a subclass outside the owner fails unless the file is listed. No wording lint. R3 retry loop: already settled by openclaw#204609 (definite refusals settle once); unchanged here except the class name and the notice text. Not in this PR (remaining refusal texts, follow-up): `operator-role-policy.ts` request-time agent refusal, channel run authorization notice in `agent-runner-error-handler.ts`, `github-publication-failure.ts` workflow permission, `session-access-authority.ts` / tool-policy refusals, connect-time `access-cause` texts (connect owner). Production `src`: net positive (recorded): the cause table is the new owner; 9 free-text refusal producers and one duplicate moved onto it. ## User impact Example (revoked member's queued message): "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to do it, or to add the permission to your role." The model gets the same sentence plus "Do not retry." ## Evidence - `src/gateway/operator-refusal.test.ts`: one case per cause through the real tool adapter (sentence + "Do not retry."), plus the in-process Gateway method path. Red on base (no owner). - Updated contract tests: restart completion notice, tool-bridge member refusal, GitHub inspection, recovery. - E2E (isolated Gateway, real model) on `2926527b454e`: R/Q/S pass; openclaw#205337 (comment) - Known gap: a queued `/followup` refusal shows the existing pending-input status in chat, not the cause sentence (needs a queue-lifecycle notice or a pending-input field; follow-up). Co-authored-by: Ayaan Zaidi <[email protected]>
…05408) ## Problem A queued input (including `/followup`) that admission refused at start was visible only in the Gateway log. In chat the person saw only the generic pending-input line "This message was blocked by a policy and did not run." The cause sentence from openclaw#205337 (`OperatorRefusalError`, e.g. "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to …") did not reach them. Cause: `followup-runner.ts` treats a start refusal as a plain retry→consumed failure, so the existing "withheld" outcome (visible transcript notice plus source delivery) never runs for it. Some refusal texts also still sat outside the cause table (follow-ups listed in openclaw#205337). ## Fix - `src/auto-reply/reply/followup-runner.ts`: an `OperatorRefusalError` thrown before the turn is admitted (`!admittedTurn`) now takes the existing withheld branch, like a retired cron delivery. The notice is the refusal's own sentence (no `withheld:` prefix). That branch already records a visible `run-failed-before-reply` transcript notice and hands the failed completion to the source owner (Gateway chat records it in the run's chat). A refusal after the turn starts does not match, so a running turn never gets a false "I did not run". - Cause table (`src/gateway/operator-refusal.ts`) gets three rows. These sites now use it: - role agent refusal (`operator-role-policy.ts`, `agent-not-in-role`) - channel access notice (`agent-runner-error-handler.ts`, `channel-access-ended`) - workflow-permission failure (`github-publication-failure.ts`, `role-denies`; the nextAction keeps "not a token scope failure, saved changes intact") - session tool-policy refusals (`session-resource-tool-policy.ts`, `session-access-authority.ts`, `tool-policy-denies`) ### Decision: no new pending-input column The brief allowed one new nullable field on `session_pending_inputs` to carry the cause id. I did not add it. The existing withheld path already puts the sentence in the chat, so the schema change is avoidable (schema changes only when unavoidable; no new state). A column would have needed a PostgreSQL schema bump, a protocol field and about 20 files of threading. Consulted Fable 5.2; same pick. Trade-off: the pending-input line stays generic ("blocked by a policy"). The sentence shows as its own notice right after it. Old rows: unchanged, because nothing is stored. ### Known gap: channel messages Channel-originated queued inputs get the transcript notice (seen in the session in Control UI). They do not get a channel message. Channel inbound followups register no `onQueuedFollowupReplyBatch` source delivery, and a refused input has no admitted turn to deliver through. Sending one needs a new delivery path for unadmitted input, which this PR does not add. Tracked in openclaw#205417. Production `src`: net +25 lines (three cause rows, the refusal condition and notice selection; long free-text strings removed). ## User impact A member whose role was lowered while their `/followup` waited sees in the chat: "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to do it, or to add the permission to your role." Before, they saw only "This message was blocked by a policy and did not run." ## Evidence - `src/gateway/server-methods/chat-send-direct-followup.test.ts` "refuses a queued /followup … and says why in chat": real chat dispatch, queued `/followup`, requester demoted before start. It asserts the sentence in the transcript notice. It fails on base (followup-runner reverted) and passes on head. - Updated wording tests for the moved texts; `operator-refusal.test.ts` covers the new causes through the tool adapter. - E2E (isolated Gateway, real model) on `17bb2763cffa`: R, Q (with the new sentence assertion) and S pass; openclaw#205408 (comment) Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Refused operator work had no single owner for what the person sees. Each throw site wrote its own sentence, so the same cause read differently by entry point, scope ids and internal words leaked ("Gateway access stopped [access-cause=grant-revoked]", "Restart recovery could not admit this input"), the D23 channel text was copied twice, and the model only got a "do not retry" hint for method-scope refusals. Other refusals reached the model as raw errors, which it paraphrased or retried.
Fix
src/gateway/operator-refusal.ts: one cause table (same pattern asconnect-error-details.ts). Each cause has a requiredwhyandnextStep; the compiler rejects a cause without a next step. Text shape: "I did not . . ." Causes:access-ended,sign-in-ended,role-denies,channel-unverified,owner-removed,requester-access-ended,invitation-ended,github-not-linked(only on the path where linking helps: a profile with no linked account and no write access).OperatorRefusalError(cause, { action })replacesGatewayOperatorRecoveryAuthorizationErrorand its free-text messages. Admission (operator-admission.ts) and the recovery helpers pick a cause; R5 ("Gateway access is not active for this requester") is nowrole-denies; R3/R13 (access-cause=grant-revoked) are nowaccess-endedwith the cause chain kept.role-denies), R8/D23 channel identity (channel-unverified, was duplicated), GitHub link (github-not-linked), ownerAllowFrom removal (owner-removed), restart completion notice (requester-access-ended).OperatorRefusalError.message(agent-runner-error-handler.ts). The tool adapter now returns the same sentence plus "Do not retry." for any refusal (and for method-scope refusals, through the same table).sessions.github.*errors keep the typed failure for in-process tool callers (errorShapeFromError), so R9 reaches the model as a refusal.no-operator-refusal-construction(shrink-only, ceiling 9):new OperatorRefusalErroror a subclass outside the owner fails unless the file is listed. No wording lint.R3 retry loop: already settled by #204609 (definite refusals settle once); unchanged here except the class name and the notice text.
Not in this PR (remaining refusal texts, follow-up):
operator-role-policy.tsrequest-time agent refusal, channel run authorization notice inagent-runner-error-handler.ts,github-publication-failure.tsworkflow permission,session-access-authority.ts/ tool-policy refusals, connect-timeaccess-causetexts (connect owner).Production
src: net positive (recorded): the cause table is the new owner; 9 free-text refusal producers and one duplicate moved onto it.User impact
Example (revoked member's queued message): "I did not run your queued request. Your role on this Gateway does not allow it. Ask a Gateway admin to do it, or to add the permission to your role." The model gets the same sentence plus "Do not retry."
Evidence
src/gateway/operator-refusal.test.ts: one case per cause through the real tool adapter (sentence + "Do not retry."), plus the in-process Gateway method path. Red on base (no owner).2926527b454e: R/Q/S pass; refactor(gateway): one refusal owner with a required next step #205337 (comment)/followuprefusal shows the existing pending-input status in chat, not the cause sentence (needs a queue-lifecycle notice or a pending-input field; follow-up).