Skip to content

refactor(cron): admit legacy scheduled requesters through operator admission - #205346

Merged
obviyus merged 7 commits into
mainfrom
refactor/oa2-cron-owner
Nov 25, 2026
Merged

obviyus merged 7 commits into
mainfrom
refactor/oa2-cron-owner

Conversation

@obviyus

@obviyus obviyus commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

OA2 PR 6c, part 1 (DESIGN §4.8; split from #205297). A cron job saved without an operator source names its requester as a channel sender or a profile. Its owner bit was decided outside admission, by checkRequesterOwner in src/cron/execution-context-admission.ts, at two places: each scheduled run (occurrence mint) and each scheduler turn about the job (repair, notices) through session-event-target. That check used its own rules: a configured or linked-admin channel owner; for a profile, "named roles are off, or the Gateway owner profile". So a profile whose named role is admin was the owner in the Control UI but not in its own scheduled runs.

Fix

  • New admitScheduledRequesterGrant in src/gateway/operator-admission.ts returns the requester's TurnGrant:
    • channel requester: decideChannelOwnerPrincipal (configured owner), else the sender's linked admin profile (prepareChannelOperatorAdmin, the same gatherer as before);
    • profile requester: person facts (with the job's agent, so a role's agents list applies) through prepareOperatorAdmission + decideOperatorAdmission.
  • Occurrence mint and scheduler turns take the owner bit from grant.owner. The run gets only the grant, never operator scopes (no scope widening).
  • Deleted checkRequesterOwner and the requesterOwner capture in session-event-target / session-event-context / cron-job-turn-target (renamed to scheduledRequester with its admitted grant).
  • Lint lists shrink: OWNER_PRODUCER_FILES 28 → 24, TURN_FLAG_FILES 19 → 18, ADMISSION_FILES 59 → 58.
  • Doctor's read-only replay (execution-context-check.ts) reads the requester's own profile (a transferred job's ownerProfileId, not its creator's). An admin-role profile requester is reported as unverified: its owner bit depends on the role's agents list and access policy, which only admission reads. New Doctor cells: admin-role requester (unverified), transferred job whose creator is admin and requester is member (loses owner tools; red without the fix).

Decisions (recorded, not asked)

  • Named widening: a profile requester with an admin named role is now the owner of its scheduled runs (was not). This is the design rule (owner = operator.admin in the admitted scopes), the same answer the person gets in the Control UI.
  • Kept fallback (today's answer, named): on an install without named roles, every profile requester stays the owner. person facts would refuse them (no role → no scopes; PR 4 left that cell for later), which would take owner-only tools from existing jobs. The fallback lives inside the admission module, next to the decision, not in cron.
  • Unchanged (today's answer): trusted-policy jobs, unlinked legacy jobs and unbound parents keep owner via the existing legacy/trusted-policy basis in execution-context.ts.
  • Scheduler turns for a channel owner no longer carry the command-owner recovery reference; their queued successors re-admit the native sender, as every channel owner's queued work does (prepareReplyCommandOwnerAuthority).
  • Split (next PR): plugin requester-owner continuation (openclaw-plugin-tools, tool-factory-context, bindRequesterOwnerIdentity, the cron creator requesterOwner chain), scheduled-message-invocation, message-action-dispatch, execution-context-registry, openclaw-tools. That chain runs through agent-run-user-turn, chat-send and subagent requester custody and would put this PR over the file cap.

Tests

  • New cell execution-context-admission.test.ts "admits a stored profile requester through its named role": admin role → owner, admin role limited to another agent → not owner, member role → not owner, untiered → owner. Red on base 5cb1764fc2de (admin role: owner: false, basis: "none"), green on head.
  • Unchanged and green: execution-context-owner-authority.test.ts (trusted policy, unbound parent, untiered profile, removed profile, no requester: real embedded/Codex/CLI tool surfaces), the Discord configured-owner cell, server-cron-notifications.repair.test.ts.

Evidence

  • Production lines (src + scripts, non-test, vs merge base): +126 / −127.
  • Pre-push: one ocx test call over 64 files (touched tests + direct importers of every changed source + importers of the cron test-support files). All green except src/cron/service.pr-automation.test.ts and service.pr-automation-feedback.test.ts (37 cases, "occurrence admission is not configured"): red on base 5cb1764fc2de too (37 failed there), from refactor(cron): refuse a scheduled run whose occurrence admission failed #205297's fixture gap; imports no changed file. pnpm tsgo:core, pnpm tsgo:test, oxfmt and oxlint clean; pnpm check:changed reds only on main's CHANGELOG/2026.11.10.md bot attribution and main's dead exports (none in this diff).
  • E2E (one-admission-e2e/run.sh, isolated Gateway, real gpt-5.5) on the final head (see PR comments): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels: all pass.
  • Legacy-job owner tools: proven at the integration tier (execution-context-owner-authority.test.ts builds the real embedded, Codex and CLI tool surfaces for an untiered profile job (owner tools) and a removed/non-owner requester (no owner tools)) plus the new admission cell for named roles. No real-Gateway run of a hand-written legacy job row; such rows cannot be created through the product any more.

Review

  • Round 1 (P1, real): person admission skipped the role's agents check; the job's agent is now passed. Cell added.
  • Round 2 (P2, real): Doctor's preview ignored the same agents list; fixed, cells added.
  • Round 3 on f0370ee7da42 (P2, real): Doctor read the creator's profile for a transferred job's requester; fixed, cell added. Review on the final head is the merge gate.
  • Round 4 on e555208d1f82 (P2, real): Doctor's admin-role preview ignored access policy. Cut less: Doctor no longer re-derives that answer; it reports the requester as unverified.
  • Round 5 on final head 7f016c02292e: clean (patch is correct, no findings). Five review runs exceeded the two-round cap in the pipeline; rounds 3-4 were Doctor-preview findings, each real and fixed (round 4 by cutting the re-derivation, not adding to it).

@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 gateway Gateway runtime scripts Repository scripts commands Command implementations size: M labels Nov 25, 2026
…mission

A cron job saved without an operator source takes its owner bit from the
grant admission gives its channel or profile requester, at each run and
each scheduler turn about the job. Delete checkRequesterOwner and the
requesterOwner capture in session events and cron-job-turn-target.

Co-authored-by: obviyus <[email protected]>
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels Nov 25, 2026
Person facts now carry the job's agent, so a role whose agents exclude it
gives no owner grant (local review round 1).

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus force-pushed the refactor/oa2-cron-owner branch from 435e69f to 644d11d Compare November 25, 2026 12:40
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on head 644d11dfb2c7 (isolated scratch Gateway, real gpt-5.5 turns): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels. All pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-071d4781","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["73968828-1aaa-4c30-a454-21f614a3b9c8"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":66482}

results.jsonl (the run transcript, 28 lines) is kept with the task proof; it holds scratch-Gateway state only.

Doctor's read-only owner preview applies the role's agents list, as admission
does (local review round 2). Also trims comments and the admission helper.

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

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on final head f0370ee7da42 (isolated scratch Gateway, real gpt-5.5 turns): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels. All pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-09726c1d","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["2b8bafd4-1717-47f9-8239-e47fc7f70788"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":56972}

results.jsonl (28 lines, scratch-Gateway state only) is kept with the task proof.

@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on final head e555208d1f82 (isolated scratch Gateway, real gpt-5.5 turns): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels. All pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-6781ee62","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["9566a7cb-3f50-411b-8291-978a2481a29a"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":55950}

results.jsonl (28 lines, scratch-Gateway state only) is kept with the task proof.

Doctor cannot read access policies or the run's agent check, so an
admin-role profile requester is reported as unverified instead of
reimplementing admission (local review round 4).

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

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on final head 7f016c02292e (isolated scratch Gateway, real gpt-5.5 turns): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels. All pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-eab6fb02","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["8c128a8a-c56c-411d-915e-45f153240742"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":57038}

results.jsonl (28 lines, scratch-Gateway state only) is kept with the task proof.

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

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the two red jobs on head 7f016c02292e fail only in test files that are red on this PR's merge base 4254357796d3 too, with the same cases and the same cause.

ci-triage 205346:

checks-node-changed-compact-large-32-2	src/cron/isolated-agent/run.account-policy.test.ts	OURS
checks-node-changed-compact-large-41	src/cron/service.failure-alert-silent-reply.test.ts	OURS
checks-node-changed-compact-large-41	src/cron/service.pr-automation-feedback.test.ts	OURS
checks-node-changed-compact-large-41	src/cron/service.pr-automation.test.ts	OURS
checks-node-changed-compact-large-41	src/cron/service.restart-session-event.test.ts	OURS

OURS is the triage tag because main's changed-file lanes did not select these files; this PR selects them because it changes execution-context-admission.ts.

Merge-base evidence (local ocx test on 4254357796d3, no PR code):

  • run.account-policy.test.ts: 4 failed / 4 passed (same 4 cases). Run error: "This automation's access could not be admitted (occurrence admission is not configured), so the run did not start."
  • service.failure-alert-silent-reply.test.ts + service.restart-session-event.test.ts: 2 failed / 2 passed (same 2 cases).
  • service.pr-automation.test.ts + service.pr-automation-feedback.test.ts: 37 failed / 2 passed (same cases, same error).

Cause on main: #205297 refuses a scheduled run whose occurrence admission is missing; these CronService fixtures do not pass admitScheduledOccurrence. Not fixed here (red main gets its own owner).

@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR routes legacy scheduled requesters through shared operator admission and updates Doctor’s ownership preview.

Example: A legacy job targets agent main and belongs to a profile with an admin role that permits main.

  • Before: The scheduled run loses owner-only tools despite the profile having administrator authority.
  • After: The scheduled run receives owner authority from its admitted grant.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has useful regression coverage and no identified code defect, but the required shipped-path evidence does not exercise its changed behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An administrator’s legacy automation lacks owner-only tools even though the same profile has administrator authority in interactive use.
Reason: The maintainer-authored direction resolves inconsistent ownership through the established admission owner and explicitly records the intended widening and compatibility fallback.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it addresses a source-verified ownership mismatch, and no definite introduced code defect was found.

Reviewed head: 7f016c02292e44fdb1e9b4508928a4edace7e8eb

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output or logs showing a persisted legacy admin-profile job running with owner tools through an isolated Gateway, its scheduler repair path and Doctor preview, including an upgrade from the latest stable with existing jobs and settings intact.
Agent review details

How this fits together

Cron occurrence admission and scheduler event preparation consume stored requester identities and current policy, then pass a frozen owner decision to scheduled runs and repair turns.

flowchart TD
  A[Stored automation] --> B[Requester identity]
  B --> C[Operator admission]
  D[Current profile and policy] --> C
  C --> E[Turn grant]
  E --> F[Scheduled occurrence]
  E --> G[Scheduler repair turn]
Loading

Technical review

Best possible solution:

Use shared admission for legacy requester ownership, retain the documented compatibility behavior, and let scheduled consumers read the resulting grant.

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

Current-main source deterministically denies owner status to an ordinary named-role admin profile requester; the PR reports a matching base-red regression test, but this review ran no target code.

Is this the best way to solve the issue?

The patch uses the existing admission owner, supplies the target agent, removes the replaced runtime check, and keeps Doctor from claiming an ownership decision it cannot fully evaluate.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Legacy scheduled profile ownership changes intended behavior with a stated reason (240a90e: The scheduled execution context preserved legacy ownership rules; later admission work retained the untiered-or-Gateway-owner profile rule.)
  • Scheduler repair and notice requester authority keeps the original intent (8100c60: Scheduler turns needed the job requester’s authority rather than authority inferred from a turn label or destination session.)
  • Read-only Doctor ownership preview keeps the original intent (c668bc0: Doctor warns about scheduled access loss without requiring a running Gateway.)
  • Admission lint exemptions keeps the original intent (3358612: The guard prevents additional owner producers outside admission and requires obsolete exemptions to shrink.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit c668bc0 adds src/commands/doctor/cron/execution-context-check.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c668bc056518; files: src/commands/doctor/cron/execution-context-check.ts)

PR surface

Source +5, Tests +80, Other -6. Total +79 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 126 121 +5
Tests 3 83 3 +80
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 0 6 -6
Total 11 209 130 +79

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.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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, 8:29 AM ET / 13:29 UTC.

# Conflicts:
#	src/gateway/operator-admission.ts
#	test/scripts/oxlint-boundary-guards.test.ts
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on head 0c863cb98cc1 (merge of main for a conflict; isolated scratch Gateway, real gpt-5.5 turns): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels. All pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-990783b4","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["23c93591-cfec-4906-b239-c7bf46bcd98f"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":59020}

# Conflicts:
#	test/scripts/oxlint-boundary-guards.test.ts
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

E2E on head 9e1ab4a8e3bd (second merge of main for a lint-ceiling conflict; isolated scratch Gateway, real gpt-5.5 turns): Q, R, S all pass.

verdict.json:

{"pass":true,"prefix":"HEAD","sessionKey":"agent:main:one-admission-45974540","models":["gpt-5.5-2026-04-23"],"relayStatuses":[200],"checks":[{"id":"R.running-turn-finishes","pass":true,"detail":{"state":"final","toolEnds":3,"toolEndsAfterRevoke":3}},{"id":"Q.queued-input-refused-visibly","pass":true,"detail":{"accepted":true,"providerRequestsWithQueuedMarker":0,"visibleRefusalInTranscript":true}},{"id":"S.stop-cancels","pass":true,"detail":{"abort":{"ok":true,"aborted":true,"runIds":["1d6a5f16-3b3f-4189-95a6-ddb9938808e9"]},"state":"aborted","requestsWithStopMarker":1}}],"elapsedMs":57611}

@obviyus
obviyus merged commit 86d835e into main Nov 25, 2026
120 of 124 checks passed
@obviyus
obviyus deleted the refactor/oa2-cron-owner branch November 25, 2026 14:17
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 86d835e.

  • Bug: cron jobs saved without an operator source got their owner bit from a local cron check (checkRequesterOwner) with its own rules. An admin-role profile was the owner in the Control UI but not in its own scheduled runs.
  • Fix: run starts and scheduler turns now take that bit from operator admission's grant (admitScheduledRequesterGrant). The local check and the requesterOwner capture are deleted, and OWNER_PRODUCER_FILES is smaller.
  • Proof: the new admission cell fails on base and passes on head. Local review is clean on 9e1ab4a8e3bd, and E2E Q/R/S pass. The only CI reds are the main-side cron fixture gap test(cron): CronService fixtures without occurrence admission fail after #205297 #205368 (override authorized).
  • Next: the plugin requester-owner continuation, in a separate PR.

vincentkoc added a commit that referenced this pull request Nov 25, 2026
* 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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…mission (openclaw#205346)

## Problem

OA2 PR 6c, part 1 (DESIGN §4.8; split from openclaw#205297). A cron job saved without an operator source names its requester as a channel sender or a profile. Its owner bit was decided outside admission, by `checkRequesterOwner` in `src/cron/execution-context-admission.ts`, at two places: each scheduled run (occurrence mint) and each scheduler turn about the job (repair, notices) through `session-event-target`. That check used its own rules: a configured or linked-admin channel owner; for a profile, "named roles are off, or the Gateway owner profile". So a profile whose named role is `admin` was the owner in the Control UI but not in its own scheduled runs.

## Fix

- New `admitScheduledRequesterGrant` in `src/gateway/operator-admission.ts` returns the requester's `TurnGrant`:
  - channel requester: `decideChannelOwnerPrincipal` (configured owner), else the sender's linked admin profile (`prepareChannelOperatorAdmin`, the same gatherer as before);
  - profile requester: `person` facts (with the job's agent, so a role's `agents` list applies) through `prepareOperatorAdmission` + `decideOperatorAdmission`.
- Occurrence mint and scheduler turns take the owner bit from `grant.owner`. The run gets only the grant, never operator scopes (no scope widening).
- Deleted `checkRequesterOwner` and the `requesterOwner` capture in `session-event-target` / `session-event-context` / `cron-job-turn-target` (renamed to `scheduledRequester` with its admitted `grant`).
- Lint lists shrink: `OWNER_PRODUCER_FILES` 28 → 24, `TURN_FLAG_FILES` 19 → 18, `ADMISSION_FILES` 59 → 58.
- Doctor's read-only replay (`execution-context-check.ts`) reads the requester's own profile (a transferred job's `ownerProfileId`, not its creator's). An admin-role profile requester is reported as unverified: its owner bit depends on the role's `agents` list and access policy, which only admission reads. New Doctor cells: admin-role requester (unverified), transferred job whose creator is admin and requester is member (loses owner tools; red without the fix).

## Decisions (recorded, not asked)

- **Named widening:** a profile requester with an admin named role is now the owner of its scheduled runs (was not). This is the design rule (owner = `operator.admin` in the admitted scopes), the same answer the person gets in the Control UI.
- **Kept fallback (today's answer, named):** on an install without named roles, every profile requester stays the owner. `person` facts would refuse them (no role → no scopes; PR 4 left that cell for later), which would take owner-only tools from existing jobs. The fallback lives inside the admission module, next to the decision, not in cron.
- **Unchanged (today's answer):** trusted-policy jobs, unlinked legacy jobs and unbound parents keep owner via the existing `legacy`/`trusted-policy` basis in `execution-context.ts`.
- **Scheduler turns for a channel owner** no longer carry the command-owner recovery reference; their queued successors re-admit the native sender, as every channel owner's queued work does (`prepareReplyCommandOwnerAuthority`).
- **Split (next PR):** plugin requester-owner continuation (`openclaw-plugin-tools`, `tool-factory-context`, `bindRequesterOwnerIdentity`, the cron creator `requesterOwner` chain), `scheduled-message-invocation`, `message-action-dispatch`, `execution-context-registry`, `openclaw-tools`. That chain runs through `agent-run-user-turn`, `chat-send` and subagent requester custody and would put this PR over the file cap.

## Tests

- New cell `execution-context-admission.test.ts` "admits a stored profile requester through its named role": admin role → owner, admin role limited to another agent → not owner, member role → not owner, untiered → owner. **Red on base `8ea184867868`** (admin role: `owner: false, basis: "none"`), green on head.
- Unchanged and green: `execution-context-owner-authority.test.ts` (trusted policy, unbound parent, untiered profile, removed profile, no requester: real embedded/Codex/CLI tool surfaces), the Discord configured-owner cell, `server-cron-notifications.repair.test.ts`.

## Evidence

- Production lines (`src` + `scripts`, non-test, vs merge base): +126 / −127.
- Pre-push: one `ocx test` call over 64 files (touched tests + direct importers of every changed source + importers of the cron test-support files). All green except `src/cron/service.pr-automation.test.ts` and `service.pr-automation-feedback.test.ts` (37 cases, "occurrence admission is not configured"): red on base `8ea184867868` too (37 failed there), from openclaw#205297's fixture gap; imports no changed file. `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt and oxlint clean; `pnpm check:changed` reds only on main's `CHANGELOG/2026.11.10.md` bot attribution and main's dead exports (none in this diff).
- E2E (`one-admission-e2e/run.sh`, isolated Gateway, real `gpt-5.5`) on the final head (see PR comments): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels: all pass.
- Legacy-job owner tools: proven at the integration tier (`execution-context-owner-authority.test.ts` builds the real embedded, Codex and CLI tool surfaces for an untiered profile job (owner tools) and a removed/non-owner requester (no owner tools)) plus the new admission cell for named roles. No real-Gateway run of a hand-written legacy job row; such rows cannot be created through the product any more.

## Review

- Round 1 (P1, real): person admission skipped the role's `agents` check; the job's agent is now passed. Cell added.
- Round 2 (P2, real): Doctor's preview ignored the same `agents` list; fixed, cells added.
- Round 3 on `f0370ee7da42` (P2, real): Doctor read the creator's profile for a transferred job's requester; fixed, cell added. Review on the final head is the merge gate.
- Round 4 on `e555208d1f82` (P2, real): Doctor's admin-role preview ignored access policy. Cut less: Doctor no longer re-derives that answer; it reports the requester as unverified.
- Round 5 on final head `7f016c02292e`: clean (`patch is correct`, no findings). Five review runs exceeded the two-round cap in the pipeline; rounds 3-4 were Doctor-preview findings, each real and fixed (round 4 by cutting the re-derivation, not adding to it).

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. commands Command implementations gateway Gateway runtime impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant