Repository navigation
refactor(gateway): local-host owner producers read the admitted grant - #205255
Conversation
The CLI --local run, the message CLI, the Codex supervision stdio MCP and the in-process MCP owner token now read LOCAL_HOST.grant.owner, decided by decideTurnGrant, instead of deciding owner status themselves. Delete the unused raw MCP loopback non-owner token. OWNER_PRODUCER_FILES 33 -> 29; the remote worker placement stays listed (its run's grant is not on the worker protocol). Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
…st-owner # Conflicts: # test/scripts/oxlint-boundary-guards.test.ts
|
E2E on the exact head
Local CLI owner check: |
|
Codex review: needs changes before merge. What this changesThis PR centralizes local-host ownership in the turn-grant owner and removes the unused raw non-owner MCP token. Example: Run openclaw agent --local and call the sessions tool.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-authored PR open: the authority consolidation is coherent, but an unchanged transcript test now fails because it still treats a local operator run as non-owner. Reviewed head: Before merge
Findings
Agent review detailsHow this fits togetherLocal CLI and standalone MCP entry points prepare tool-execution contexts; Gateway MCP authentication separately maps owner tokens, run-bound client grants, and attach grants into those contexts. flowchart TD
A[Local operator entry points] --> B[Local host principal]
B --> C[Turn grant decision]
C --> D[Tool execution context]
E[MCP bearer request] --> F[Bearer authentication]
F --> B
F --> G[Scoped client or attach grant]
G --> D
Technical reviewBest possible solution: Keep the centralized local-host grant and adapt transcript ownership coverage to distinguish local operator runs from non-owner ingress runs. Do we have a high-confidence way to reproduce the issue? This is a behavior-preserving authority refactor rather than a reproduced user bug; exact-head CI independently demonstrates the obsolete local transcript expectation. Is this the best way to solve the issue? Reusing decideTurnGrant and deleting the unused token is the smallest coherent consolidation; production caller inspection supports retaining local owner behavior without adding another admission mechanism. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8616182ae3f2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -3, Tests -14, Other -4. Total -21 across 20 files. Added test files: 0. 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, 4:55 AM ET / 09:55 UTC. |
The local-host grant names every local run's sender owner, so the case that passed senderIsOwner: false to a local agentCommand asserted removed behavior. Co-authored-by: obviyus <[email protected]>
|
E2E on head CI round 1 red: |
|
Landed as 71b629c.
|
…openclaw#205255) ## Problem OA2 PR 6a (one admission owner). Processes the operator runs on this host each decided "the sender is the owner" for themselves: - `openclaw agent --local` (and `agent exec`, BOOT.md, Template setup): `senderIsOwner: opts.senderIsOwner ?? true`. - `openclaw message`: `senderIsOwner: opts.senderIsOwner !== false`. - Codex supervision stdio MCP: a private `{ senderIsOwner: true }` constant. - MCP loopback: `{ senderIsOwner: ownerTokenMatched }`, where the alternative was a raw non-owner token that no production code ever hands out. These were four more owner producers outside admission (`OWNER_PRODUCER_FILES`). ## Fix - `operator-admission.ts` exports `LOCAL_HOST = { grant: decideTurnGrant(["operator.admin"]) }`: the local host is the owner principal, and `decideTurnGrant` decides its grant. The four entries read `LOCAL_HOST.grant.owner`. - `agent-command-local.ts`: no caller option narrows the local owner (no production caller set it). The local cron-creator capability is now gated only by `operatorAuthority`, because the `senderIsOwner === true` check is always true. - MCP loopback: deleted the unused raw non-owner token (`nonOwnerToken` in the runtime, listener and request auth). CLI backends get run-bound client grants; attach clients get attach grants. Only the in-process owner token remains, and it names the local host. - `OWNER_PRODUCER_FILES` 32 → 28 after merging main (ceiling lowered). ## Decisions (recorded, not asked) - **Worker placement stays listed** (`src/worker/embedded-agent.runtime.ts`). The worker runs tools on a separate box for a run the Gateway admitted. The correct value is that run's `grant.owner`, and the worker protocol does not carry it. `LOCAL_HOST` there would declare every remote box an owner. Carrying the bit is a protocol change, so it is not in this PR (Fable 5.2 consult). - **No full `decideOperatorAdmission` for in-process local runs.** It would set `operatorAuthority` on CLI-local runs and change many downstream branches. It would also need the profile store in the stdio MCP and the worker. The grant comes from the same `decideTurnGrant`. - **Raw non-owner MCP token deleted, not kept.** Only `mcp-http.ts` created it and only `resolveMcpSender` compared it; no production path hands it to a client (CLI backends use run-bound client grants, `attach` uses attach grants). Deleting it closes no client route. Without it the owner-token producer could not move, and production would not be net negative. - **Accepted risk:** any file can import `LOCAL_HOST` and pass the owner lint. Today it has four readers; adding an import allowlist would be a new guard. ## User impact None. A local CLI user, the `message` CLI, the standalone Codex supervision MCP and the in-process MCP owner token stay owner. ## Evidence - Production (`src`, non-test): +18 / −21. - One cell per entry, through the real entry function: - `agent-command-local.test.ts`: every local run reaches preparation with `senderIsOwner: true`; the operator run gets the local cron-creator capability. - `message.test.ts`: the `message` CLI dispatches with `senderIsOwner: true`. - `plugin-tools-serve.test.ts`: Codex supervision MCP context has `senderIsOwner: true`. - `mcp-http.test.ts`: a real loopback listener request with the owner token resolves tools with `senderIsOwner: true`. - `test/scripts/oxlint-boundary-guards.test.ts`: ceiling 28; the stale-entry check passes for the four removed files. - Real `openclaw agent --local` on an isolated profile (`ocx src -- --profile e2e`), real `openai/gpt-5.5`: the model called the owner-only `sessions` tool and replied `LOCAL_OWNER_DONE 0`; exit 0. - Pre-push checks: one `ocx test` call over 62 files (touched tests plus direct importers of every changed source; the 318-file set with test-support importers is over the 150 cap), all green. `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt and oxlint on changed files: clean. `pnpm check:changed`: the changelog attribution lane fails on files this PR does not touch (same as openclaw#205173); the rest was still running at 15 min, so CI runs it. - Q/R/S E2E on the exact head: see the follow-up comment. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
OA2 PR 6a (one admission owner). Processes the operator runs on this host each decided "the sender is the owner" for themselves:
openclaw agent --local(andagent exec, BOOT.md, Template setup):senderIsOwner: opts.senderIsOwner ?? true.openclaw message:senderIsOwner: opts.senderIsOwner !== false.{ senderIsOwner: true }constant.{ senderIsOwner: ownerTokenMatched }, where the alternative was a raw non-owner token that no production code ever hands out.These were four more owner producers outside admission (
OWNER_PRODUCER_FILES).Fix
operator-admission.tsexportsLOCAL_HOST = { grant: decideTurnGrant(["operator.admin"]) }: the local host is the owner principal, anddecideTurnGrantdecides its grant. The four entries readLOCAL_HOST.grant.owner.agent-command-local.ts: no caller option narrows the local owner (no production caller set it). The local cron-creator capability is now gated only byoperatorAuthority, because thesenderIsOwner === truecheck is always true.nonOwnerTokenin the runtime, listener and request auth). CLI backends get run-bound client grants; attach clients get attach grants. Only the in-process owner token remains, and it names the local host.OWNER_PRODUCER_FILES32 → 28 after merging main (ceiling lowered).Decisions (recorded, not asked)
src/worker/embedded-agent.runtime.ts). The worker runs tools on a separate box for a run the Gateway admitted. The correct value is that run'sgrant.owner, and the worker protocol does not carry it.LOCAL_HOSTthere would declare every remote box an owner. Carrying the bit is a protocol change, so it is not in this PR (Fable 5.2 consult).decideOperatorAdmissionfor in-process local runs. It would setoperatorAuthorityon CLI-local runs and change many downstream branches. It would also need the profile store in the stdio MCP and the worker. The grant comes from the samedecideTurnGrant.mcp-http.tscreated it and onlyresolveMcpSendercompared it; no production path hands it to a client (CLI backends use run-bound client grants,attachuses attach grants). Deleting it closes no client route. Without it the owner-token producer could not move, and production would not be net negative.LOCAL_HOSTand pass the owner lint. Today it has four readers; adding an import allowlist would be a new guard.User impact
None. A local CLI user, the
messageCLI, the standalone Codex supervision MCP and the in-process MCP owner token stay owner.Evidence
src, non-test): +18 / −21.agent-command-local.test.ts: every local run reaches preparation withsenderIsOwner: true; the operator run gets the local cron-creator capability.message.test.ts: themessageCLI dispatches withsenderIsOwner: true.plugin-tools-serve.test.ts: Codex supervision MCP context hassenderIsOwner: true.mcp-http.test.ts: a real loopback listener request with the owner token resolves tools withsenderIsOwner: true.test/scripts/oxlint-boundary-guards.test.ts: ceiling 28; the stale-entry check passes for the four removed files.openclaw agent --localon an isolated profile (ocx src -- --profile e2e), realopenai/gpt-5.5: the model called the owner-onlysessionstool and repliedLOCAL_OWNER_DONE 0; exit 0.ocx testcall over 62 files (touched tests plus direct importers of every changed source; the 318-file set with test-support importers is over the 150 cap), all green.pnpm tsgo:core,pnpm tsgo:test, oxfmt and oxlint on changed files: clean.pnpm check:changed: the changelog attribution lane fails on files this PR does not touch (same as refactor(gateway): decide automations rights once, as the turn grant #205173); the rest was still running at 15 min, so CI runs it.