Repository navigation
fix(cron): failure repair turns can read and fix the job they repair - #188105
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCron 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +182, Tests +342, Docs 0. Total +524 across 22 files. Added test files: 2. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 30, 2026, 3:36 AM ET / 07:36 UTC (Revision 4). |
|
@clawsweeper re-review Head |
|
🦞👀 Re-review progress:
|
…erator-source ownership
|
@clawsweeper re-review Head |
|
Landed in 8100c60.
|
…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]>
…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)
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
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
agentRPC. Any client can send the repair's provenance label on that RPC, so it could never carry authority.Now:
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
automationscall: 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.tsruns the real repair dispatcher, real session-event admission, the turn's real tool surface and in-process Gateway dispatch into a realCronServiceand its store (model synthetic). Each case reports the tool result and the stored job afterwards:automations updateTwo fixes came out of this proof:
authority.isCurrent(getSessionEventRuntimeConfig())).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 (prepareSessionEventDeliverycalled 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 publiccron_failure_repairlabel still gets no silence. The monotonic deadline cases inserver-cron-notifications.repair.test.tsnow run against the session-event dispatcher.Focused runs (
pnpm test <file> --maxWorkers=1, wall time):src/gateway/server-cron-failure-repair.final-effect.test.ts(new)src/gateway/server-cron-notifications.repair.test.tssrc/gateway/tool-resolution.exclude.test.tssrc/agents/agent-tools.turn-authority.test.tssrc/gateway/server.cron.test.tssrc/auto-reply/reply/session-event-permissions.test.tssrc/cron/execution-context-admission.test.tsThe new test file adds about 8 s of test time (eight cases, one shared fixture).
server.cron.test.tsstays at its prior cost.oxfmt, type-awareoxlinton changed files,pnpm tsgo:core, thesrctest-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:
openEventToolHostdoes not passinputProvenanceinto 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.