Skip to content

fix(cron): failure repair turns can read and fix the job they repair - #188105

Merged
obviyus merged 5 commits into
mainfrom
fix/cron-scheduler-turn-grant
Oct 30, 2026
Merged

obviyus merged 5 commits into
mainfrom
fix/cron-scheduler-turn-grant

Conversation

@obviyus

@obviyus obviyus commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #161007, #180304, #187346

What Problem This Solves

Fixes: an automation's failure repair turn cannot read or change the job it was asked to repair, so it asks the user to fix it instead.

User Impact

User impact: when an owned automation fails, the repair turn in its owner conversation can now read the job's runs and update the job when the job's requester is still an owner, so most repairs no longer need a human reply. Scheduler notices about a job follow the same rule.

Risk to note: a job whose requester is not an owner (or whose stored operator source can no longer be restored) now gets read-only automation access in its repair and notice turns, and no session-owner fallback. Jobs that record no requester keep the session owner's current access, as other system turns do since #187346.

Why This Change Was Made

System-started turns got their authority from what kind of turn they were: a label match for notices (#180304), a caller rule for completions (#187346, which left cron out), and nothing for repairs, which went through the public agent RPC. Any client can send the repair's provenance label on that RPC, so it could never carry authority.

Now:

  • A scheduler turn about a job acts for the job's recorded requester, the same requester and owner check its scheduled runs use (channel sender, profile, or restored operator source). Owner status is rechecked before each owner-only effect.
  • Repairs run on the host session-event path, like notices and completions.
  • Every host system turn gets one rule for caller-scoped automation reads; the sourceTool === "cron" match is gone.

Evidence

Production repair transcripts (read-only, one Gateway, since the repair feature shipped): 57 repair turns, 3 fixed their job, 28 asked the user. No repair turn ever completed an automations call: before 2026-10-19 the tool was absent, then a schema check failed, and since 2026-10-22 all 18 calls were refused by the owner gate. All 3 script-payload repairs were refused.

Final-effect test src/gateway/server-cron-failure-repair.final-effect.test.ts runs the real repair dispatcher, real session-event admission, the turn's real tool surface and in-process Gateway dispatch into a real CronService and its store (model synthetic). Each case reports the tool result and the stored job afterwards:

Job requester automations update Stored description
Channel owner ok changed
Channel non-owner gated unchanged
Channel owner revoked while the repair was queued turn refused at admission, no tool ran unchanged
Channel owner revoked after admission refused: tool host retired by the config change unchanged
Restored Control UI admin operator source ok changed
Restored non-admin operator source gated unchanged
Operator source with its device revoked before the repair gated (no session fallback) unchanged
Operator source device revoked while queued turn refused at admission, no tool ran unchanged

Two fixes came out of this proof:

  • The queued-revocation case first let the update through: the requester recheck read the config captured at capture time. It now reads the Gateway's current config, as completion turns do (authority.isCurrent(getSessionEventRuntimeConfig())).
  • A restored operator source is an owner only when it was a Control UI administrator, matching the job's in-session runs (session-run.ts). The non-admin case fails without this rule.

On the base commit the file fails (the repair cannot dispatch outside the old lifecycle path); production transcripts above show the base refusal itself.

Runtime-error suppression from #162772 is kept: repair session events set a host-owned suppressErrorDelivery, so error payloads stay in the transcript and out of chat. The owner-topic Gateway test now has the repair return a provider-error payload and asserts no chat delivery; without the flag that test fails (prepareSessionEventDelivery called once).

Gateway cron suite (server.cron.test.ts): the owner-topic repair and NO_REPLY repair cases drive the real reply runtime; they check the owner topic's session and thread route, repair pending through retries until the turn settles (success and error), one escalation, and that a forged public cron_failure_repair label still gets no silence. The monotonic deadline cases in server-cron-notifications.repair.test.ts now run against the session-event dispatcher.

Focused runs (pnpm test <file> --maxWorkers=1, wall time):

File Tests Time
src/gateway/server-cron-failure-repair.final-effect.test.ts (new) 8 34 s
src/gateway/server-cron-notifications.repair.test.ts 2 7 s
src/gateway/tool-resolution.exclude.test.ts 37 9 s
src/agents/agent-tools.turn-authority.test.ts 14 1 s
src/gateway/server.cron.test.ts 15 30 s
src/auto-reply/reply/session-event-permissions.test.ts 27 37 s
src/cron/execution-context-admission.test.ts 26 6 s

The new test file adds about 8 s of test time (eight cases, one shared fixture). server.cron.test.ts stays at its prior cost. oxfmt, type-aware oxlint on changed files, pnpm tsgo:core, the src test-type shards and the baseline ratchets (check:test-mock-exports, check:max-lines-ratchet, check:assertion-safety, check:test-timeout-race-ratchet) pass. Hosted CI and the ClawSweeper review are green on the merged head.

Gaps:

  • Profile requesters reuse the scheduled-run owner check unchanged; channel and operator-source requesters are the tested paths.
  • The managed tool host used by openEventToolHost does not pass inputProvenance into tool construction, so caller-scoped reads for non-owner turns are shown in the unit matrices, not this harness (the embedded attempt path does pass it). Follow-up.
  • Live proof needs a deploy; the next real failing job on a production Gateway will show it.

Scheduler repair and notice turns now act for the job's recorded requester,
the same requester its scheduled runs act for, rechecked before each
owner-only effect. Repairs move from the public agent RPC, whose provenance
label any client can send, to the host session-event path. Every host
system turn now takes one scoped-read rule instead of a per-label match.
@clawsweeper

clawsweeper Bot commented Oct 30, 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 Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 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: 391a6ce721499c4a65b43959e130db0b2bd761c3
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/agent-tools.turn-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets automation repair and notice turns use the job requester's current authority through host-owned session events.

Example: Telegram sender 456 owns a Health check automation whose description needs correction.

  • Before: The repair turn's automation update is refused by the owner gate.
  • After: The repair can update the job while sender 456 remains an owner; revocation prevents the stored update.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent repair with no remaining verified finding and meaningful final-effect authority coverage; evidence remains an in-process harness.
Proof confidence 🦐 gold shrimp (3/6) ✨ media proof bonus Sufficient (linked_artifact): The requested authority proof reaches persisted automation updates through real repair dispatch, admission, tool gates and Gateway handlers, covering allowed and nearest-forbidden channel and operator requesters plus revocation. The supplied results support this maintainer PR's authority boundary; the model is synthetic and no deployed repair is shown.
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 automatic repair asks the user for help because it cannot inspect or update the automation it was asked to repair.
Reason: The maintainer-authored direction restores useful automatic repair with the existing requester authority boundary and no new configuration or public API.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR fixes a current automation-repair limitation; the reviewed head resolves the earlier findings, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 391a6ce721499c4a65b43959e130db0b2bd761c3

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No deployed repair or base run reaching the original owner gate is supplied; the reported base harness failure occurs at the replaced dispatcher.
Agent review details

How this fits together

Cron starts repair or notice work in the owning conversation; session admission and tool gates carry current requester authority to automation handlers and persisted job changes.

flowchart TD
  A[Failed automation] --> B[Capture requester and conversation]
  B --> C[Host session event]
  C --> D[Session admission]
  D --> E[Current authority tool gates]
  E --> F[Cron handlers and job store]
  D --> G[Conversation reply delivery]
Loading

Technical review

Best possible solution:

Use the shared host-event target capture and existing requester checks while preserving revocation fences, silent repairs and owner-conversation delivery.

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

Current-main source explains the refusal: repairs enter through public agent dispatch without the host-event authority path; the author also reports production owner-gate refusals, but this review executed no target code.

Is this the best way to solve the issue?

The change fixes authority at the trusted producer, shares requester checks with scheduled execution, and removes the replaced repair dispatch instead of authorizing client-supplied provenance.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Repair dispatch and settlement changes intended behavior with a stated reason (fb2052a: Let the owning conversation repair failures before alerting; later changes preserved runtime-error silence, fresh-run verification and monotonic deadlines.)
  • Notice-only automation read exception changes intended behavior with a stated reason (3afef59: Permit caller-visible reads without borrowing owner identity; public-RPC repairs lacked a trustworthy host-only signal.)
  • Requester owner checks keeps the original intent (2011274: Give scheduled runtimes one requester owner decision and recheck it before owner-only effects.)
  • Session-event caller custody keeps the original intent (52bc4b5: Known callers retain their current authority; only unattributed host work may use the session principal.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit cb63a46 adds src/gateway/server-cron-notifications.ts:69 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cb63a46f0e56; files: src/gateway/server-cron-notifications.ts)
  • Josh Lehman: Raw commit 2011274 adds src/cron/execution-context-admission.ts:92 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 201127429a03; files: src/cron/execution-context-admission.ts)
  • Vito Cappello: Raw commit 3afef59 adds src/agents/agent-tools.turn-authority.ts:104 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3afef59bd8e1; files: src/agents/agent-tools.turn-authority.ts)
  • Peter Steinberger: Raw commit 753a7a5 adds src/auto-reply/reply/session-event-handoff.ts:476 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 753a7a57be10; files: src/auto-reply/reply/session-event-handoff.ts)

PR surface

Source +182, Tests +342, Docs 0. Total +524 across 22 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 15 283 101 +182
Tests 6 400 58 +342
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 684 160 +524

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Automated repair cannot currently control the failing job, but an owner reply remains an available recovery path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-30T05:09:03.074Z sha 7a5ef89 :: needs real behavior proof before merge. :: [P2] Preserve runtime-error suppression when moving repairs to session events | [P2] Keep the provenance test compatible with the predicate's input type | [P2] Migrate the deadline regressions to the new repair dispatcher | [P2] Update the CLI consumer's host-event read expectations
  • reviewed 2026-10-30T07:07:03.302Z sha 709ffe8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-30T07:29:29.212Z sha 391a6ce :: needs maintainer review before merge. :: none

Reviewed October 30, 2026, 3:36 AM ET / 07:36 UTC (Revision 4).

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Head 709ffe86 addresses the 7a5ef89a findings: runtime-error suppression is restored for repair session events (red without it, green with it), the provenance test type error is fixed, the monotonic deadline cases run against the new dispatcher, the CLI read matrix covers every host event turn, and the authority test now records the in-process Gateway cron calls for owner, non-owner, revoked-while-queued and revoked-after-admission requesters with exact results. CI is green on this head.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Head 391a6ce7 adds the requested final-effect proof: server-cron-failure-repair.final-effect.test.ts drives the real repair dispatcher, session-event admission, tool surface and in-process Gateway dispatch into a real CronService store, covering channel owner, non-owner, revoked while queued, revoked after admission, and restored operator sources (Control UI admin, non-admin, device revoked before, device revoked while queued). The proof found and fixed two issues: the requester recheck now reads the Gateway's current config, and a restored operator source is an owner only when it was a Control UI administrator, matching in-session runs. PR body evidence is updated.

@obviyus
obviyus merged commit 8100c60 into main Oct 30, 2026
175 checks passed
@obviyus
obviyus deleted the fix/cron-scheduler-turn-grant branch October 30, 2026 07:46
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 8100c60.

  • Bug: a failing automation's repair turn could not read or update the job it was asked to repair. On one production Gateway, 28 of 57 repair turns ended by asking the user, and no repair turn ever completed an automations call.
  • Fix: scheduler repair and notice turns now act for the job's recorded requester, the same requester and owner check its scheduled runs use. The check is rerun against the current config before each owner-only effect. Repairs run as host session events, and runtime errors stay out of chat.
  • Proof: a final-effect test sends repair updates through the in-process Gateway into a real cron store. A channel owner's update and a Control UI admin operator source's update persist. Non-owners, non-admin sources, revoked devices, and requesters revoked while queued or after admission change nothing.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…penclaw#188105)

Related: openclaw#161007, openclaw#180304, openclaw#187346

## What Problem This Solves

Fixes: an automation's failure repair turn cannot read or change the job it was asked to repair, so it asks the user to fix it instead.

## User Impact

User impact: when an owned automation fails, the repair turn in its owner conversation can now read the job's runs and update the job when the job's requester is still an owner, so most repairs no longer need a human reply. Scheduler notices about a job follow the same rule.

Risk to note: a job whose requester is not an owner (or whose stored operator source can no longer be restored) now gets read-only automation access in its repair and notice turns, and no session-owner fallback. Jobs that record no requester keep the session owner's current access, as other system turns do since openclaw#187346.

## Why This Change Was Made

System-started turns got their authority from what kind of turn they were: a label match for notices (openclaw#180304), a caller rule for completions (openclaw#187346, which left cron out), and nothing for repairs, which went through the public `agent` RPC. Any client can send the repair's provenance label on that RPC, so it could never carry authority.

Now:
- A scheduler turn about a job acts for the job's recorded requester, the same requester and owner check its scheduled runs use (channel sender, profile, or restored operator source). Owner status is rechecked before each owner-only effect.
- Repairs run on the host session-event path, like notices and completions.
- Every host system turn gets one rule for caller-scoped automation reads; the `sourceTool === "cron"` match is gone.

## Evidence

Production repair transcripts (read-only, one Gateway, since the repair feature shipped): 57 repair turns, 3 fixed their job, 28 asked the user. No repair turn ever completed an `automations` call: before 2026-10-19 the tool was absent, then a schema check failed, and since 2026-10-22 all 18 calls were refused by the owner gate. All 3 script-payload repairs were refused.

Final-effect test `src/gateway/server-cron-failure-repair.final-effect.test.ts` runs the real repair dispatcher, real session-event admission, the turn's real tool surface and in-process Gateway dispatch into a real `CronService` and its store (model synthetic). Each case reports the tool result and the stored job afterwards:

| Job requester | `automations update` | Stored description |
|---|---|---|
| Channel owner | ok | changed |
| Channel non-owner | gated | unchanged |
| Channel owner revoked while the repair was queued | turn refused at admission, no tool ran | unchanged |
| Channel owner revoked after admission | refused: tool host retired by the config change | unchanged |
| Restored Control UI admin operator source | ok | changed |
| Restored non-admin operator source | gated | unchanged |
| Operator source with its device revoked before the repair | gated (no session fallback) | unchanged |
| Operator source device revoked while queued | turn refused at admission, no tool ran | unchanged |

Two fixes came out of this proof:
- The queued-revocation case first let the update through: the requester recheck read the config captured at capture time. It now reads the Gateway's current config, as completion turns do (`authority.isCurrent(getSessionEventRuntimeConfig())`).
- A restored operator source is an owner only when it was a Control UI administrator, matching the job's in-session runs (`session-run.ts`). The non-admin case fails without this rule.

On the base commit the file fails (the repair cannot dispatch outside the old lifecycle path); production transcripts above show the base refusal itself.

Runtime-error suppression from openclaw#162772 is kept: repair session events set a host-owned `suppressErrorDelivery`, so error payloads stay in the transcript and out of chat. The owner-topic Gateway test now has the repair return a provider-error payload and asserts no chat delivery; without the flag that test fails (`prepareSessionEventDelivery` called once).

Gateway cron suite (`server.cron.test.ts`): the owner-topic repair and NO_REPLY repair cases drive the real reply runtime; they check the owner topic's session and thread route, repair pending through retries until the turn settles (success and error), one escalation, and that a forged public `cron_failure_repair` label still gets no silence. The monotonic deadline cases in `server-cron-notifications.repair.test.ts` now run against the session-event dispatcher.

Focused runs (`pnpm test <file> --maxWorkers=1`, wall time):

| File | Tests | Time |
|---|---|---|
| `src/gateway/server-cron-failure-repair.final-effect.test.ts` (new) | 8 | 34 s |
| `src/gateway/server-cron-notifications.repair.test.ts` | 2 | 7 s |
| `src/gateway/tool-resolution.exclude.test.ts` | 37 | 9 s |
| `src/agents/agent-tools.turn-authority.test.ts` | 14 | 1 s |
| `src/gateway/server.cron.test.ts` | 15 | 30 s |
| `src/auto-reply/reply/session-event-permissions.test.ts` | 27 | 37 s |
| `src/cron/execution-context-admission.test.ts` | 26 | 6 s |

The new test file adds about 8 s of test time (eight cases, one shared fixture). `server.cron.test.ts` stays at its prior cost. `oxfmt`, type-aware `oxlint` on changed files, `pnpm tsgo:core`, the `src` test-type shards and the baseline ratchets (`check:test-mock-exports`, `check:max-lines-ratchet`, `check:assertion-safety`, `check:test-timeout-race-ratchet`) pass. Hosted CI and the ClawSweeper review are green on the merged head.

Gaps:
- Profile requesters reuse the scheduled-run owner check unchanged; channel and operator-source requesters are the tested paths.
- The managed tool host used by `openEventToolHost` does not pass `inputProvenance` into tool construction, so caller-scoped reads for non-owner turns are shown in the unit matrices, not this harness (the embedded attempt path does pass it). Follow-up.
- Live proof needs a deploy; the next real failing job on a production Gateway will show it.

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

Related: openclaw#161007, openclaw#180304, openclaw#187346

Fixes: an automation's failure repair turn cannot read or change the job it was asked to repair, so it asks the user to fix it instead.

User impact: when an owned automation fails, the repair turn in its owner conversation can now read the job's runs and update the job when the job's requester is still an owner, so most repairs no longer need a human reply. Scheduler notices about a job follow the same rule.

Risk to note: a job whose requester is not an owner (or whose stored operator source can no longer be restored) now gets read-only automation access in its repair and notice turns, and no session-owner fallback. Jobs that record no requester keep the session owner's current access, as other system turns do since openclaw#187346.

System-started turns got their authority from what kind of turn they were: a label match for notices (openclaw#180304), a caller rule for completions (openclaw#187346, which left cron out), and nothing for repairs, which went through the public `agent` RPC. Any client can send the repair's provenance label on that RPC, so it could never carry authority.

Now:
- A scheduler turn about a job acts for the job's recorded requester, the same requester and owner check its scheduled runs use (channel sender, profile, or restored operator source). Owner status is rechecked before each owner-only effect.
- Repairs run on the host session-event path, like notices and completions.
- Every host system turn gets one rule for caller-scoped automation reads; the `sourceTool === "cron"` match is gone.

Production repair transcripts (read-only, one Gateway, since the repair feature shipped): 57 repair turns, 3 fixed their job, 28 asked the user. No repair turn ever completed an `automations` call: before 2026-10-19 the tool was absent, then a schema check failed, and since 2026-10-22 all 18 calls were refused by the owner gate. All 3 script-payload repairs were refused.

Final-effect test `src/gateway/server-cron-failure-repair.final-effect.test.ts` runs the real repair dispatcher, real session-event admission, the turn's real tool surface and in-process Gateway dispatch into a real `CronService` and its store (model synthetic). Each case reports the tool result and the stored job afterwards:

| Job requester | `automations update` | Stored description |
|---|---|---|
| Channel owner | ok | changed |
| Channel non-owner | gated | unchanged |
| Channel owner revoked while the repair was queued | turn refused at admission, no tool ran | unchanged |
| Channel owner revoked after admission | refused: tool host retired by the config change | unchanged |
| Restored Control UI admin operator source | ok | changed |
| Restored non-admin operator source | gated | unchanged |
| Operator source with its device revoked before the repair | gated (no session fallback) | unchanged |
| Operator source device revoked while queued | turn refused at admission, no tool ran | unchanged |

Two fixes came out of this proof:
- The queued-revocation case first let the update through: the requester recheck read the config captured at capture time. It now reads the Gateway's current config, as completion turns do (`authority.isCurrent(getSessionEventRuntimeConfig())`).
- A restored operator source is an owner only when it was a Control UI administrator, matching the job's in-session runs (`session-run.ts`). The non-admin case fails without this rule.

On the base commit the file fails (the repair cannot dispatch outside the old lifecycle path); production transcripts above show the base refusal itself.

Runtime-error suppression from openclaw#162772 is kept: repair session events set a host-owned `suppressErrorDelivery`, so error payloads stay in the transcript and out of chat. The owner-topic Gateway test now has the repair return a provider-error payload and asserts no chat delivery; without the flag that test fails (`prepareSessionEventDelivery` called once).

Gateway cron suite (`server.cron.test.ts`): the owner-topic repair and NO_REPLY repair cases drive the real reply runtime; they check the owner topic's session and thread route, repair pending through retries until the turn settles (success and error), one escalation, and that a forged public `cron_failure_repair` label still gets no silence. The monotonic deadline cases in `server-cron-notifications.repair.test.ts` now run against the session-event dispatcher.

Focused runs (`pnpm test <file> --maxWorkers=1`, wall time):

| File | Tests | Time |
|---|---|---|
| `src/gateway/server-cron-failure-repair.final-effect.test.ts` (new) | 8 | 34 s |
| `src/gateway/server-cron-notifications.repair.test.ts` | 2 | 7 s |
| `src/gateway/tool-resolution.exclude.test.ts` | 37 | 9 s |
| `src/agents/agent-tools.turn-authority.test.ts` | 14 | 1 s |
| `src/gateway/server.cron.test.ts` | 15 | 30 s |
| `src/auto-reply/reply/session-event-permissions.test.ts` | 27 | 37 s |
| `src/cron/execution-context-admission.test.ts` | 26 | 6 s |

The new test file adds about 8 s of test time (eight cases, one shared fixture). `server.cron.test.ts` stays at its prior cost. `oxfmt`, type-aware `oxlint` on changed files, `pnpm tsgo:core`, the `src` test-type shards and the baseline ratchets (`check:test-mock-exports`, `check:max-lines-ratchet`, `check:assertion-safety`, `check:test-timeout-race-ratchet`) pass. Hosted CI and the ClawSweeper review are green on the merged head.

Gaps:
- Profile requesters reuse the scheduled-run owner check unchanged; channel and operator-source requesters are the tested paths.
- The managed tool host used by `openEventToolHost` does not pass `inputProvenance` into tool construction, so caller-scoped reads for non-owner turns are shown in the unit matrices, not this harness (the embedded attempt path does pass it). Follow-up.
- Live proof needs a deploy; the next real failing job on a production Gateway will show it.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 8100c60)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 12819b3dac7eab80d73e174c19363fe1e29679e4)
obviyus added a commit that referenced this pull request Nov 28, 2026
…t run (#207186)

## Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

## Fix

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

## Review

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

## Evidence

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

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

## Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from openclaw#207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the openclaw#207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

## Fix

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (openclaw#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

## Review

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

## Evidence

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 28, 2026
…input (#207226)

## Problem

#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

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

## Problem

openclaw#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (openclaw#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as openclaw#207186 did. The openclaw#207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…t run (#207186)

## Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

## Fix

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

## Review

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

## Evidence

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 22a3aec)

Release adaptation: Keep the beta.2 cron troubleshooting document; its release-specific surrounding guidance conflicts. The runtime/test patch applies unchanged.

Companions: #207226 changes notice display to direct posting with hidden repair input; not needed for the failed-before-start fallback, and not in this lane.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…input (#207226)

## Problem

#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>

Follow-up scan: 494561c test: fix the participation admission test after cron notices became repair turns (#207414); 2a3bf24 fix(cron): let the agent stay silent after a posted automation notice (#207315). Other hits are not required by this focused beta.2 fix.

(cherry picked from commit fff3e0e)

Release adaptation: Backport direct posting onto the beta.2 cron target, preserving the admitted session generation and no-delivery policy.

Release adaptation: Resolve the lane-5 #207186 overlap in upstream order: replace the settle-time visible fallback with a direct post and hidden repair input, preserve next-turn context on permanent pre-start failure, and keep the release target-generation and delivery checks. The notice regression now checks chat projection and queued context; the separate removal, quota-alert and script-delivery fixes remain intact.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…input (#207226)

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit fff3e0e)

Release adaptation: Keep only session notice automatic-send policy resolution and transcript-only proof. Leave stable cron posting and repair behavior untouched.

Companion audit: 2a3bf24 and 494561c cover excluded cron redesign; b3f2fcc covers Goal scheduling; d62c462 changes an independent transcript write fence. None is required for the selected send-policy slice.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…t run (#207186)

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 22a3aec)

Release adaptation: use the already-captured original target and lifecycle revision for fallback; retain stable repair turns and exception handling. Follow-ups: do not import direct-post redesign; the stable fallback neither posts twice nor follows a replacement session.

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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant