Skip to content

refactor(gateway): decide automations rights once, as the turn grant - #205173

Merged
obviyus merged 4 commits into
mainfrom
refactor/oa2-automations-grant-2
Nov 25, 2026
Merged

obviyus merged 4 commits into
mainfrom
refactor/oa2-automations-grant-2

Conversation

@obviyus

@obviyus obviyus commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

OA2 PR 4c, steps 1 and 2 (DESIGN §2, PR 4b leftovers from #205082). The same owner got a different automations answer depending on how the turn started:

  • An authless local socket had no admitted authority. On a gateway.auth.mode: "none" Gateway, a local client (CLI, local Control UI) was never admitted through decideOperatorAdmission, so its turn carried no grant. Its automation rights came from a transport check instead.
  • Automation management was decided outside admission, from the transport. The cron-creator classifier gave manage only to operator.admin and (local socket or Control UI admin or native-app admin). The same owner over a remote CLI, TUI or any other client got only caller-scoped creation. operator.cron was read from raw connect scopes, not from the admitted grant.
  • Children got nothing. A subagent child of an owner turn had no automation rights at all (fresh-turn gate), so "update my automation" worked from the parent and failed from its subagent.
  • The channel-owner cron mint ignored the admitted grant. A configured owner linked to a personal profile was admitted as that profile (refactor(channels): admit channel senders through the turn grant #204904), but the mint still gave full management from the owner list.

Fix

  • grant.automations ("none" | "self" | "manage") is decided once in decideTurnGrant: manage iff the grant is owner (operator.admin), self iff operator.cron (or operator.write, which covers it), else none.
  • Local-host principal: an authless local operator socket (authMethod: "none", handshake-attested direct-local, no named-profile actor, not an agent runtime) is admitted through decideOperatorAdmission as the owner principal with its own connect scopes — the same admission an HTTP mode: "none" owner request already uses (refactor(gateway): admit HTTP shared-secret requests as the owner principal #205091). The HTTP owner path and the socket path now share one helper. Like every other socket path, the admitted run keeps the request's invocation ceiling and lifetime (retainGatewayOperatorInvocation: delegated-child participation ceiling, invocation signal and release).
  • Classifier reads the grant. cron-creator-authority-admission.ts keeps only the turn-shape gate (fresh direct input, not system, not handoff). The rights come from grant.automations. Deleted: the operator.admin + isLocalClient/UI-admin/native-app-admin rule, the raw operator.cron connect-scope read, and the Template setup controlUiAdmin + admin check (it now requires a manage grant).
  • localClient / uiAdminSource settled: deleted from the manage rule. An owner's remote and local browser (and CLI, TUI, native app) get the same manage. The management entitlement source collapses to "operator" | "channel-owner"; resolveGatewayUiAdminSource becomes the boolean isGatewayUiAdmin (its labels had no reader left). Local-host stays only as job provenance (callerOrigin: local, already stored on jobs) for a manage turn on a direct-local socket; it grants nothing more.
  • Children: a subagent child (lane: "subagent") gets the automations of its own admitted grant: the parent's authority, re-admitted at launch and capped by the child launch's operator scopes (operator.write). An owner's or writer's child gets self; a child of a read-only or unadmitted parent gets none.
  • Channel-owner mint: a channel turn with an admitted operator authority mints channel-owner management only when its grant is manage.
  • Deleted: the expired (2026-10-12) controlUiAdmin harness getter on the creator capability, and the controlUiAdmin admission output (no production reader).
  • Docs: automation/cron-jobs/managing-jobs.md conversational management.

Decisions (recorded, not asked)

  • Deliberate widenings (same principal, same answer):
    • An owner on a remote non-UI client (remote CLI, TUI) now manages every automation, like the owner's Control UI. That socket already holds operator.admin, so it can already call every cron.* method directly; only the model's tool gains reach.
    • A local CLI owner now also gets the management entitlement (it already had the local creator origin).
    • Subagent children get the parent's re-admitted automations right (MATRIX M9). Before, a child had none. A child never exceeds its parent. It does not reach manage: the in-process child launch carries operator.write, which caps the child's admitted grant at self. Lifting that cap is a launch-scope change, not an automations rule; not in this PR.
  • Narrowing (brief rule, refactor(channels): admit channel senders through the turn grant #204904): a configured commands.ownerAllowFrom owner whose verified channel identity is linked to a non-admin personal profile now gets that profile's automations, not channel-owner management.
  • Asserted-identity owners keep today's mint. Signal/WhatsApp/iMessage owners are not admitted through decideOperatorAdmission (DESIGN §10, D23): they have no grant to read. Cutting their mint would remove automation management they have today, so the mint still applies when there is no admitted grant. Closing that needs the D23 decision, not this PR.
  • Accepted edge: an authless Gateway that also configures named roles has no owner profile at startup; a local socket turn there is now refused at admission. mode: "none" with named roles has no identities to apply roles to, so this combination is not a working setup.
  • Split (brief rule: over ~25 files → land steps 1–2 first). 37 files. Steps 3 (in-session scheduled scope into admission, delete the automations-run-scope.ts trigger fallback) and 4 (split the pre-start session-event config check out of the attempt-session-target.ts source, delete the R7 re-check) go in the next PR. The replay automationAdmin output (saved UI-admin delegation) stays with step 3: it decides what an in-session scheduled run gets.

User impact

  • The owner manages automations from chat the same way from any client, including a local client of an authless Gateway.
  • A subagent of an owner or writer turn can create and edit its own automations.
  • A channel owner linked to a non-admin profile manages only their own automations from that channel.

Evidence

  • Production lines (src, non-test): +77 / −78 (net −1)..
  • Red on base, green on head:
    • message-handler.post-connect-health.test.ts "admits an authless local socket as the local host": real WS handshake on an authless Gateway, real prepareGatewayOperatorRunAuthority → owner profile, grant.automations: "manage". Base returns no authority.
    • Same file, trusted-proxy person over openclaw-tui with operator.admin: head gets management through the grant; base gave caller-scoped only.
    • agent-run-local-operator-authority.test.ts: remote Control UI, native app and CLI owners get the same management; a subagent child gets automations from its admitted grant; a local-host admission keeps the request's invocation signal and release (local review round 2).
    • operator-admission.table.test.ts: matrix grants carry automations (owner manage, writer self) for every entry kind.
  • Pre-push: (1) one ocx test call over 125 files (touched tests plus importers of every changed source/test-support), then (2) one frozen-tree ocx test call over the 32 touched/re-run files: all green except src/cron/service.pr-automation.test.ts, which fails the same way on the merge base 529e37f3a53a (13 failed on base, ocx base merge-base). pnpm tsgo:core and tsgo:core:test clean; oxfmt/oxlint clean; line-cap ratchet OK. pnpm check:changed: all lanes ok except two that fail on files this PR does not touch (changelog attribution in CHANGELOG/2026.11.10.md; Knip unused exports in update-cli, schtasks-process, upgrade-survivor).
  • E2E: see the follow-up comment (Q/R/S on the exact head).

- add grant.automations (none/self/manage) to the turn grant: manage iff owner, self iff operator.cron
- admit an authless local socket (auth mode none) as the local-host principal through decideOperatorAdmission
- the cron-creator classifier, Template setup and the channel-owner mint read the admitted grant; drop the local/UI-admin transport rule
- a subagent child gets automations from its own re-admitted grant
- delete the expired controlUiAdmin harness getter and the unread controlUiAdmin admission output

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 1dd9321f2d95cac363638976b2b4ef9ac7a5b560
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/admitted-run-operator-authority.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/cron-creator-authority-grant.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/cron-creator-authority-grant.types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-scopes.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/chat-send-external-authority-contract.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/cron-creator-authority-admission.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels Nov 25, 2026
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on exact head 9937836feba8 (one-admission-e2e/run.sh, isolated Gateway, live gpt-5.5-2026-04-23): pass=True

  • R.running-turn-finishes: pass
  • Q.queued-input-refused-visibly: pass
  • S.stop-cancels: pass

verdict.json and results.jsonl kept in the task proof directory. Live Peanutto Gateway pid unchanged.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 25, 2026
…n participation recovery

- main added a restored-authority literal with the controlUiAdmin field this branch removes
- requester-custody fixture passes the admitted grant to the chat classifier (local review round 1)

Co-authored-by: obviyus <[email protected]>
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR makes automation permissions come from the admitted turn grant across Gateway clients, subagents, and configured channel owners.

Example: An authenticated remote CLI owner with operator.admin asks to disable a Telegram-created reminder.

  • Before: The model receives caller-scoped automation access and cannot manage the foreign reminder.
  • After: The admitted manage grant lets the model disable that reminder.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The design is coherent, but the consumer migration is incomplete and the supplied live scenarios do not establish the changed automation behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: The same authenticated owner receives different automation permissions depending on the client, and delegated subagents cannot use the initiating turn’s scoped automation access.
Reason: The maintainer author explicitly approves the permission changes, and consolidating them under the existing grant removes divergent transport policy without adding configuration or persistent state.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authorized consolidation is useful, but current-head CI exposes a missed consumer-fixture update.

Reviewed head: eee1c4056a4f727fe766e5778a505a7db7c874cb

Before merge

  • Migrate the direct-agent automation fixture to admitted authority (P2) - The author needs to update this consumer fixture alongside the grant-based classifier. It currently supplies only operator.admin connect scopes and isLocalClient, with no inherited authority, authenticated profile, or authless-socket admission facts. prepareGatewayOperatorRunAuthority therefore returns undefined, and the changed classifier supplies no cron capability. Exact-head CI already fails “carries exact cron creator authority through direct local agent RPC” because capability?.active is undefined instead of false. Give this fixture a valid admitted authority and retain its active-during-run and revoked-after-run assertions.

Findings

  • [P2] Migrate the direct-agent automation fixture to admitted authority — src/gateway/server-methods/agent.base.test-utils.ts:240-241

Tests

  • Missing end-to-end proof: Supply redacted live output through an isolated Gateway showing authless-local and remote-owner automation management, a spawned child creating or updating its own job, and a linked non-admin channel owner retaining only caller-scoped access.
Agent review details

How this fits together

Gateway admission converts authenticated identity and scope facts into a turn grant; agent and chat entry points translate that grant into run-bound capabilities consumed by automation tools.

flowchart TD
  A[Authenticated client or channel sender] --> B[Operator admission]
  B --> C[Turn grant]
  C --> D[Agent and chat admission]
  C --> E[Subagent admission]
  D --> F[Run bound automation capability]
  E --> F
  F --> G[Cron tools and Gateway methods]
Loading

Technical review

Best possible solution:

Keep the existing admission owner and grant-based classifier, and migrate the direct-agent test fixture to carry admitted authority while preserving its capability-lifecycle assertions.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the remote-client and subagent permission differences, and exact-head CI independently demonstrates the unmigrated direct-agent fixture; no target code was executed during this review.

Is this the best way to solve the issue?

Using the existing turn-admission owner is the smallest coherent solution: it removes duplicate permission policy, shares owner admission between HTTP and local sockets, and preserves the separately documented scheduled-recovery follow-up.

Full review comments:

  • [P2] Migrate the direct-agent automation fixture to admitted authority — src/gateway/server-methods/agent.base.test-utils.ts:240-241
    The author needs to update this consumer fixture alongside the grant-based classifier. It currently supplies only operator.admin connect scopes and isLocalClient, with no inherited authority, authenticated profile, or authless-socket admission facts. prepareGatewayOperatorRunAuthority therefore returns undefined, and the changed classifier supplies no cron capability. Exact-head CI already fails “carries exact cron creator authority through direct local agent RPC” because capability?.active is undefined instead of false. Give this fixture a valid admitted authority and retain its active-during-run and revoked-after-run assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 14db7f3bf34a.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 63e0742 adds src/gateway/operator-admission.ts:231 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 63e0742f9970; files: src/gateway/operator-admission.ts)
  • Peter Steinberger: Raw commit 3ae3e4d adds src/gateway/server-methods/cron-creator-authority-admission.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3ae3e4dc88ed; files: src/gateway/server-methods/cron-creator-authority-admission.ts)
  • Jacqueline Henriksen: Raw commit db69f01 adds src/gateway/operator-scopes.ts:57 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: db69f011ab08; files: src/gateway/operator-scopes.ts)
  • Vincent Koc: Raw commit 35801a1 adds src/auto-reply/reply/get-reply-run.cron-requester.ts:79 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 35801a1e0ae0; files: src/auto-reply/reply/get-reply-run.cron-requester.ts)

PR surface

Source -2, Tests +18, Docs 0. Total +16 across 43 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 76 78 -2
Tests 27 195 177 +18
Docs 1 3 3 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 43 274 258 +16

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +76/-78; tests and support +195/-177 Production shrinks slightly while fixtures migrate to the shared grant and cover distinct admission boundaries.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The harness-visible capability loses its expired controlUiAdmin projection and changes entitlement source tags; removal is explicitly recorded by the maintainer author and follows the documented compatibility deadline.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • merge-risk: 🚨 compatibility: The harness-visible capability loses its expired controlUiAdmin projection and changes entitlement source tags; removal is explicitly recorded by the maintainer author and follows the documented compatibility deadline.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 25, 2026, 2:50 AM ET / 07:50 UTC.

- an authless local socket's admitted run keeps the request's invocation ceiling, signal and release, like every other socket path (local review round 2)
- the direct local agent RPC fixture carries its admitted owner authority

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on exact head 1dd9321f2d95 (one-admission-e2e/run.sh, isolated Gateway, live model): pass.

  • R.running-turn-finishes: pass
  • Q.queued-input-refused-visibly: pass
  • S.stop-cancels: pass

verdict.json and results.jsonl kept in the task proof directory. Live Peanutto Gateway pid unchanged.

obviyus added a commit that referenced this pull request Nov 25, 2026
…205206)

> Lint-precision prerequisite for the owner-producer sweep. It moves no owner producer onto `grant.owner`; the sweep itself is parked as area PRs (see "Not in this PR").

## Problem

`no-turn-authority-derivation` (owner-production check) flagged 49 files as owner producers. 16 of them do not produce owner status: they only narrow a bit that was passed along (`x.senderIsOwner === true`, `admin ? request.senderIsOwner === true : false`, `profile === "full" ? params.senderIsOwner : undefined`, `input.senderIsOwner && externalUser`, a getter that returns `ctx.senderIsOwner`). Because they were listed, the allowlist overstated the work left and gave no reason for any entry.

## Fix

- `passesOwnerAlong` now accepts the forms that cannot make an owner: `<pass> === true`, a conditional whose two branches pass along, `a && b` with one side passing along, `a || b` / `a ?? b` with both sides passing along, and a property getter whose only statement returns a pass-through. Defaults that make an owner (`x ?? true`, `x !== false`) and function or method values (truthy whatever they return) still fail (fixture lines 32-41).
- `OWNER_PRODUCER_FILES` 49 → 33 (ceiling lowered). Every remaining entry is grouped with its reason:
  - principals admission does not see yet (Discord native/voice owner match, FaceTime caller claim, plugin ingress trust gate, CLI `--local`/`message`, standalone MCP, MCP loopback token, worker placement);
  - requests, not turns (OpenAI-compatible HTTP pre-run check, `conversations`, `tools.invoke`, session resource tools, Talk client tools): owner = connection admin scope, to move with the OA3 request grant;
  - channel command owner (`command-auth`, reply execute/source admission, message-action dispatch, `agent-run-user-turn` channel requester);
  - scheduled and requester-owner continuations (cron creator authority, scheduled targets, plugin tool owner continuation);
  - recorded data read back (protocol schema field, transcript metadata, memory lineage receipt, maintenance copy).

No production code changes. `TURN_FLAG_FILES` (19), `ADMISSION_FILES` (59) and `CAPABILITY_PROVENANCE_FILES` (4) are unchanged; all lists stay shrink-only.

## Not in this PR (split)

The real owner moves need principals or grants that do not exist yet, or files another open PR owns:
- `automationAdmin`/`controlUiAdmin` and the cron creator `requesterOwner` continuation: owned by open OA2 PR 4c (#205173).
- CLI `--local`, `message`, standalone MCP, worker: need the `local-host` principal that PR 4c adds.
- RPC/HTTP request sites: need the OA3 request grant from method authorization.
- Channel command owner and Discord native/voice: next channel PR, after 4c lands.

## User impact

None. Lint tooling only.

## Evidence

- `test/scripts/oxlint-boundary-guards.test.ts`: 35/35 pass, including the stale-entry check (every listed file still trips the rule) and the new fixture lines.
- E2E Q/R/S pass (`one-admission-e2e/run.sh`, head `5d33e525`; the follow-up commit only changes the lint rule, no product code): `verdict.json` pass=true, `R.running-turn-finishes`, `Q.queued-input-refused-visibly`, `S.stop-cancels`.
- Before/after `ignoreAllowlists` run over all 49 listed files: 16 stop tripping, 33 still do.

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus
obviyus merged commit 5e3065e into main Nov 25, 2026
138 checks passed
@obviyus
obviyus deleted the refactor/oa2-automations-grant-2 branch November 25, 2026 08:48
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 5e3065e.

  • Bug: an owner's automation rights depended on the client (local socket, Control UI, native app) and on a transport check outside admission; authless local sockets had no admitted grant at all; subagent children got none.
  • Fix: grant.automations is decided once in decideTurnGrant; authless local sockets are admitted as the local-host (owner) principal; the cron-creator classifier, Template setup and the channel-owner mint read the grant.
  • Proof: CI green on the exact head, local review clean, E2E Q/R/S pass (comment above), red-on-base tests in the PR body.
  • Next (split per brief): step 3 (in-session scheduled scope into admission, delete the trigger fallback) and step 4 (split the pre-start session-event check, delete the R7 re-check).

obviyus added a commit that referenced this pull request Nov 25, 2026
…#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 #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]>
obviyus added a commit that referenced this pull request Nov 25, 2026
…ource re-check (#205268)

## Problem

OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps #205173 split off). Two places still decided what a running scheduled turn may do outside admission:

- **Replay `automationAdmin` output.** `decideOperatorAdmission` returned a second owner-like bit for replays: admin scope **and** a saved Control UI delegation. In-session scheduled runs (`runCronSessionTurn`) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job.
- **R7 mid-run re-check (`source_authority_refused`).** The prepared session target in `attempt-session-target.ts` re-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused with `source_authority_refused` (REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start.

## Fix

- `automationAdmin` is deleted from the admission decision, `RestoredGatewayOperatorAuthority`, `ScheduledSessionAutomation` and the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (`grant.owner`), the same rule restart and owner continuations already use.
- `createPreparedSessionTargetAssertion` no longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (`assertScopeCurrent`), and the session row predicates still reach the writer through `composeSessionSourceAssertion`.
- **Pre-start session-event config check:** no split code needed. The session-event config policy already stops at `start()`; before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target.

## Decisions (recorded, not asked)

- **Widening (same principal, same answer):** an in-session scheduled run whose restored requester is an admin now binds command-owner authority even when the job was created outside the Control UI (remote CLI, TUI, native app). Same rule as #205173 for `grant.automations`.
- **Stored rows unchanged:** the codec keeps writing/reading `automationAdmin`/`controlUiAdmin` on saved sources (no stored-row change); `hasAutomationAdminDelegation` keeps its two non-admission readers (`cron-job-turn-target.ts`, the control-edit refresh in `cron-operator-source.ts`).
- **Cut less: the `automations-run-scope.ts` trigger fallback stays.** Every Gateway occurrence is admitted through `admitScheduledOccurrence`, but when that admission fails (`status: "fail"`), `bind()` binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here.
- **Accepted edge (AGENTS.md "a started request may finish"):** an operator whose access is revoked mid-run no longer has the run's transcript/context writes refused; Stop and the run lifetime still end it.

## Tests

- Deleted (assert removed behavior): `run-attempt-dispatch.owner` "policy" case (mid-run access-policy revoke → `source_authority_refused`); `operator-run-recovery.native` "preserves legacy browser grants…" (only asserted the deleted `automationAdmin` output).
- Changed: `run-attempt-dispatch.owner` now applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (`scope_authority_refused`). `run.operator-continuation` and `execution-context-owner-authority` fixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback.

## Evidence

- **Production lines** (`src`, non-test): +12 / −38 (net −26).
- **Red on base, green on head:** `run-attempt-dispatch.owner.test.ts` invalidation cases now assert the prepared target never calls the run's source (`assertSourceCurrent` not called). On base the same case asserted it was called once (`toHaveBeenCalledOnce`), i.e. the R7 mid-run re-check.
- **Pre-start refusal kept:** `session-run.session-model-strictness.integration.test.ts` "selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence with `status: "error"`, `executionStarted: false` and zero provider requests; the error now names the policy (`Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…`).
- **Scheduled scope:** `run.operator-continuation` (36/36, incl. self-removal and `next_check`) and `execution-context-owner-authority` (embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway.
- **Pre-push:** one `ocx test` call over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools with `trigger`/`jobId`): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green. `pnpm tsgo:core` and `tsgo:test` clean (also after rebase on `81d69df5dcea`); oxfmt/oxlint clean on changed files.
- **E2E:** Q/R/S pass on both heads (`75ac48d68d24`, `4cddd31e0f21`); see the PR comments.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…penclaw#205206)

> Lint-precision prerequisite for the owner-producer sweep. It moves no owner producer onto `grant.owner`; the sweep itself is parked as area PRs (see "Not in this PR").

## Problem

`no-turn-authority-derivation` (owner-production check) flagged 49 files as owner producers. 16 of them do not produce owner status: they only narrow a bit that was passed along (`x.senderIsOwner === true`, `admin ? request.senderIsOwner === true : false`, `profile === "full" ? params.senderIsOwner : undefined`, `input.senderIsOwner && externalUser`, a getter that returns `ctx.senderIsOwner`). Because they were listed, the allowlist overstated the work left and gave no reason for any entry.

## Fix

- `passesOwnerAlong` now accepts the forms that cannot make an owner: `<pass> === true`, a conditional whose two branches pass along, `a && b` with one side passing along, `a || b` / `a ?? b` with both sides passing along, and a property getter whose only statement returns a pass-through. Defaults that make an owner (`x ?? true`, `x !== false`) and function or method values (truthy whatever they return) still fail (fixture lines 32-41).
- `OWNER_PRODUCER_FILES` 49 → 33 (ceiling lowered). Every remaining entry is grouped with its reason:
  - principals admission does not see yet (Discord native/voice owner match, FaceTime caller claim, plugin ingress trust gate, CLI `--local`/`message`, standalone MCP, MCP loopback token, worker placement);
  - requests, not turns (OpenAI-compatible HTTP pre-run check, `conversations`, `tools.invoke`, session resource tools, Talk client tools): owner = connection admin scope, to move with the OA3 request grant;
  - channel command owner (`command-auth`, reply execute/source admission, message-action dispatch, `agent-run-user-turn` channel requester);
  - scheduled and requester-owner continuations (cron creator authority, scheduled targets, plugin tool owner continuation);
  - recorded data read back (protocol schema field, transcript metadata, memory lineage receipt, maintenance copy).

No production code changes. `TURN_FLAG_FILES` (19), `ADMISSION_FILES` (59) and `CAPABILITY_PROVENANCE_FILES` (4) are unchanged; all lists stay shrink-only.

## Not in this PR (split)

The real owner moves need principals or grants that do not exist yet, or files another open PR owns:
- `automationAdmin`/`controlUiAdmin` and the cron creator `requesterOwner` continuation: owned by open OA2 PR 4c (openclaw#205173).
- CLI `--local`, `message`, standalone MCP, worker: need the `local-host` principal that PR 4c adds.
- RPC/HTTP request sites: need the OA3 request grant from method authorization.
- Channel command owner and Discord native/voice: next channel PR, after 4c lands.

## User impact

None. Lint tooling only.

## Evidence

- `test/scripts/oxlint-boundary-guards.test.ts`: 35/35 pass, including the stale-entry check (every listed file still trips the rule) and the new fixture lines.
- E2E Q/R/S pass (`one-admission-e2e/run.sh`, head `5d33e525`; the follow-up commit only changes the lint rule, no product code): `verdict.json` pass=true, `R.running-turn-finishes`, `Q.queued-input-refused-visibly`, `S.stop-cancels`.
- Before/after `ignoreAllowlists` run over all 49 listed files: 16 stop tripping, 33 still do.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…penclaw#205173)

## Problem

OA2 PR 4c, steps 1 and 2 (DESIGN §2, PR 4b leftovers from openclaw#205082). The same owner got a different automations answer depending on how the turn started:

- **An authless local socket had no admitted authority.** On a `gateway.auth.mode: "none"` Gateway, a local client (CLI, local Control UI) was never admitted through `decideOperatorAdmission`, so its turn carried no grant. Its automation rights came from a transport check instead.
- **Automation management was decided outside admission, from the transport.** The cron-creator classifier gave `manage` only to `operator.admin` **and** (local socket **or** Control UI admin **or** native-app admin). The same owner over a remote CLI, TUI or any other client got only caller-scoped creation. `operator.cron` was read from raw connect scopes, not from the admitted grant.
- **Children got nothing.** A subagent child of an owner turn had no automation rights at all (fresh-turn gate), so "update my automation" worked from the parent and failed from its subagent.
- **The channel-owner cron mint ignored the admitted grant.** A configured owner linked to a personal profile was admitted as that profile (openclaw#204904), but the mint still gave full management from the owner list.

## Fix

- **`grant.automations`** (`"none" | "self" | "manage"`) is decided once in `decideTurnGrant`: `manage` iff the grant is owner (`operator.admin`), `self` iff `operator.cron` (or `operator.write`, which covers it), else `none`.
- **Local-host principal:** an authless local operator socket (`authMethod: "none"`, handshake-attested direct-local, no named-profile actor, not an agent runtime) is admitted through `decideOperatorAdmission` as the owner principal with its own connect scopes — the same admission an HTTP `mode: "none"` owner request already uses (openclaw#205091). The HTTP owner path and the socket path now share one helper. Like every other socket path, the admitted run keeps the request's invocation ceiling and lifetime (`retainGatewayOperatorInvocation`: delegated-child participation ceiling, invocation signal and release).
- **Classifier reads the grant.** `cron-creator-authority-admission.ts` keeps only the turn-shape gate (fresh direct input, not system, not handoff). The rights come from `grant.automations`. Deleted: the `operator.admin` + `isLocalClient`/UI-admin/native-app-admin rule, the raw `operator.cron` connect-scope read, and the Template setup `controlUiAdmin` + admin check (it now requires a `manage` grant).
- **`localClient` / `uiAdminSource` settled:** deleted from the manage rule. An owner's remote and local browser (and CLI, TUI, native app) get the same `manage`. The management entitlement source collapses to `"operator" | "channel-owner"`; `resolveGatewayUiAdminSource` becomes the boolean `isGatewayUiAdmin` (its labels had no reader left). Local-host stays only as **job provenance** (`callerOrigin: local`, already stored on jobs) for a `manage` turn on a direct-local socket; it grants nothing more.
- **Children:** a subagent child (`lane: "subagent"`) gets the automations of its own admitted grant: the parent's authority, re-admitted at launch and capped by the child launch's operator scopes (`operator.write`). An owner's or writer's child gets `self`; a child of a read-only or unadmitted parent gets `none`.
- **Channel-owner mint:** a channel turn with an admitted operator authority mints channel-owner management only when its grant is `manage`.
- **Deleted:** the expired (2026-10-12) `controlUiAdmin` harness getter on the creator capability, and the `controlUiAdmin` admission output (no production reader).
- Docs: `automation/cron-jobs/managing-jobs.md` conversational management.

## Decisions (recorded, not asked)

- **Deliberate widenings (same principal, same answer):**
  - An owner on a remote non-UI client (remote CLI, TUI) now manages every automation, like the owner's Control UI. That socket already holds `operator.admin`, so it can already call every `cron.*` method directly; only the model's tool gains reach.
  - A local CLI owner now also gets the management entitlement (it already had the local creator origin).
  - **Subagent children get the parent's re-admitted automations right** (MATRIX M9). Before, a child had none. A child never exceeds its parent. It does not reach `manage`: the in-process child launch carries `operator.write`, which caps the child's admitted grant at `self`. Lifting that cap is a launch-scope change, not an automations rule; not in this PR.
- **Narrowing (brief rule, openclaw#204904):** a configured `commands.ownerAllowFrom` owner whose verified channel identity is linked to a non-admin personal profile now gets that profile's automations, not channel-owner management.
- **Asserted-identity owners keep today's mint.** Signal/WhatsApp/iMessage owners are not admitted through `decideOperatorAdmission` (DESIGN §10, D23): they have no grant to read. Cutting their mint would remove automation management they have today, so the mint still applies when there is no admitted grant. Closing that needs the D23 decision, not this PR.
- **Accepted edge:** an authless Gateway that also configures named roles has no owner profile at startup; a local socket turn there is now refused at admission. `mode: "none"` with named roles has no identities to apply roles to, so this combination is not a working setup.
- **Split (brief rule: over ~25 files → land steps 1–2 first).** 37 files. Steps 3 (in-session scheduled scope into admission, delete the `automations-run-scope.ts` trigger fallback) and 4 (split the pre-start session-event config check out of the `attempt-session-target.ts` source, delete the R7 re-check) go in the next PR. The replay `automationAdmin` output (saved UI-admin delegation) stays with step 3: it decides what an in-session scheduled run gets.

## User impact

- The owner manages automations from chat the same way from any client, including a local client of an authless Gateway.
- A subagent of an owner or writer turn can create and edit its own automations.
- A channel owner linked to a non-admin profile manages only their own automations from that channel.

## Evidence

- **Production lines** (`src`, non-test): +77 / −78 (net −1)..
- **Red on base, green on head:**
  - `message-handler.post-connect-health.test.ts` "admits an authless local socket as the local host": real WS handshake on an authless Gateway, real `prepareGatewayOperatorRunAuthority` → owner profile, `grant.automations: "manage"`. Base returns no authority.
  - Same file, trusted-proxy person over `openclaw-tui` with `operator.admin`: head gets management through the grant; base gave caller-scoped only.
  - `agent-run-local-operator-authority.test.ts`: remote Control UI, native app and CLI owners get the same management; a subagent child gets automations from its admitted grant; a local-host admission keeps the request's invocation signal and release (local review round 2).
  - `operator-admission.table.test.ts`: matrix grants carry `automations` (owner `manage`, writer `self`) for every entry kind.
- **Pre-push:** (1) one `ocx test` call over 125 files (touched tests plus importers of every changed source/test-support), then (2) one frozen-tree `ocx test` call over the 32 touched/re-run files: all green except `src/cron/service.pr-automation.test.ts`, which fails the same way on the merge base `2e167172fe19` (13 failed on base, `ocx base merge-base`). `pnpm tsgo:core` and `tsgo:core:test` clean; oxfmt/oxlint clean; line-cap ratchet OK. `pnpm check:changed`: all lanes ok except two that fail on files this PR does not touch (changelog attribution in `CHANGELOG/2026.11.10.md`; Knip unused exports in `update-cli`, `schtasks-process`, `upgrade-survivor`).
- **E2E:** see the follow-up comment (Q/R/S on the exact head).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…ource re-check (openclaw#205268)

## Problem

OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps openclaw#205173 split off). Two places still decided what a running scheduled turn may do outside admission:

- **Replay `automationAdmin` output.** `decideOperatorAdmission` returned a second owner-like bit for replays: admin scope **and** a saved Control UI delegation. In-session scheduled runs (`runCronSessionTurn`) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job.
- **R7 mid-run re-check (`source_authority_refused`).** The prepared session target in `attempt-session-target.ts` re-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused with `source_authority_refused` (REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start.

## Fix

- `automationAdmin` is deleted from the admission decision, `RestoredGatewayOperatorAuthority`, `ScheduledSessionAutomation` and the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (`grant.owner`), the same rule restart and owner continuations already use.
- `createPreparedSessionTargetAssertion` no longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (`assertScopeCurrent`), and the session row predicates still reach the writer through `composeSessionSourceAssertion`.
- **Pre-start session-event config check:** no split code needed. The session-event config policy already stops at `start()`; before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target.

## Decisions (recorded, not asked)

- **Widening (same principal, same answer):** an in-session scheduled run whose restored requester is an admin now binds command-owner authority even when the job was created outside the Control UI (remote CLI, TUI, native app). Same rule as openclaw#205173 for `grant.automations`.
- **Stored rows unchanged:** the codec keeps writing/reading `automationAdmin`/`controlUiAdmin` on saved sources (no stored-row change); `hasAutomationAdminDelegation` keeps its two non-admission readers (`cron-job-turn-target.ts`, the control-edit refresh in `cron-operator-source.ts`).
- **Cut less: the `automations-run-scope.ts` trigger fallback stays.** Every Gateway occurrence is admitted through `admitScheduledOccurrence`, but when that admission fails (`status: "fail"`), `bind()` binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here.
- **Accepted edge (AGENTS.md "a started request may finish"):** an operator whose access is revoked mid-run no longer has the run's transcript/context writes refused; Stop and the run lifetime still end it.

## Tests

- Deleted (assert removed behavior): `run-attempt-dispatch.owner` "policy" case (mid-run access-policy revoke → `source_authority_refused`); `operator-run-recovery.native` "preserves legacy browser grants…" (only asserted the deleted `automationAdmin` output).
- Changed: `run-attempt-dispatch.owner` now applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (`scope_authority_refused`). `run.operator-continuation` and `execution-context-owner-authority` fixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback.

## Evidence

- **Production lines** (`src`, non-test): +12 / −38 (net −26).
- **Red on base, green on head:** `run-attempt-dispatch.owner.test.ts` invalidation cases now assert the prepared target never calls the run's source (`assertSourceCurrent` not called). On base the same case asserted it was called once (`toHaveBeenCalledOnce`), i.e. the R7 mid-run re-check.
- **Pre-start refusal kept:** `session-run.session-model-strictness.integration.test.ts` "selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence with `status: "error"`, `executionStarted: false` and zero provider requests; the error now names the policy (`Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…`).
- **Scheduled scope:** `run.operator-continuation` (36/36, incl. self-removal and `next_check`) and `execution-context-owner-authority` (embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway.
- **Pre-push:** one `ocx test` call over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools with `trigger`/`jobId`): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green. `pnpm tsgo:core` and `tsgo:test` clean (also after rebase on `5279ca48bbe1`); oxfmt/oxlint clean on changed files.
- **E2E:** Q/R/S pass on both heads (`75ac48d68d24`, `4cddd31e0f21`); see the PR comments.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Release adaptation: Read the existing admitted scope ceiling for stored operator sources. Keep current recovery, requester admission, and configured channel-owner handling.

Companion audit: #205173 and #205346 restructure newer admission contracts, not required for this stable repair.

(cherry picked from commit 4d07855)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot added a commit that referenced this pull request Nov 30, 2026
Release adaptation: Select the existing turn authority as the requester source; retain stable invocation, workflow, and data fences.

Companions: #205082 and #205173 affect automations, #205155 and #205184 affect channel trust, and #205232 affects reply dispatch; none is a prerequisite to selecting the already-admitted requester.

(cherry picked from commit ddc8340)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant