Skip to content

feat(cron): let a failing automation's owner conversation repair it before alerting - #161007

Merged
obviyus merged 3 commits into
mainfrom
feat/cron-failure-repair
Sep 30, 2026
Merged

obviyus merged 3 commits into
mainfrom
feat/cron-failure-repair

Conversation

@obviyus

@obviyus obviyus commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When a scheduled automation keeps failing, OpenClaw posts "Automation X failed N times" to the chat and waits for the user to ask for a fix, even when the fix is something the agent in the conversation that created the job could make itself.

User Impact

When a job created from a conversation (it has an owner session) reaches its failure-alert threshold (default: 2 failures in a row, same cooldown and incident dedupe), OpenClaw sends one repair request to that owner conversation instead of the first chat alert. The conversation handles it as an ordinary agent turn, as if it had received a message: its own session and transcript, its workspace, its normal tool policy, and its reply goes to that conversation's own route (chat, thread or forum topic). The request tells it to:

  • fix the problem in the workspace if it can (for example the helper script or instructions file the job follows) and say what it fixed in one line;
  • otherwise ask the user for exactly what it needs;
  • say nothing if the failure was transient.

Heartbeat settings do not apply to the repair: heartbeat.target: "none", isolatedSession, lightContext and activeHours do not route, isolate, trim or hold it, and it carries no first-heartbeat notice.

The normal alert is still sent when the job has no owner conversation, for operator-only jobs (command payloads, on-exit and stream schedules), for webhook alert routes, and when the job fails again after the repair request (once, noting that a repair was requested). A successful run clears the streak silently.

Upgrade behavior change (intentional): repair is on by default. Opt-out is per job: failureAlert: false disables both the repair request and the alert. No config key is added. The chat "Automation … recovered" notice is removed; recovery stays in automation history. This reverses the notice added in #146582.

Why This Change Was Made

The owner conversation is where these jobs get fixed in practice: in our setup a user had to reply "just fix it" to a failure notice, and the agent in that conversation then repaired the job. This change starts that step automatically.

The repair is dispatched through the Gateway's existing agent method on the instance's lifecycle principal (dispatchGatewayLifecycleMethod, the same owner restart-sentinel continuations and exec-approval follow-ups use), with the owner sessionKey and deliver: true, so the agent method resolves the reply route from that session's stored delivery context, thread included. The cron service reaches it through one injected dependency (runCronFailureRepair, wired in server-cron.ts), so src/cron does not import Gateway code. Nothing in the sessions_send tool needed extracting: its default path also calls agent, but with deliver: false plus its own announce flow, which is what this does not want.

An earlier revision carried the request on a heartbeat wake (system event plus requestHeartbeat) and patched the result with a heartbeat: { target: "last" } override. That made the repair inherit heartbeat behavior it should not have: an isolated :heartbeat side session without the conversation's transcript, light context, the internal-handling prompt, and heartbeat routing. This revision removes that path (system event, heartbeat wake, override, and their docs and tests); heartbeat behavior is unchanged for everything else.

Tradeoffs (maintainer decisions):

  • The request is scheduler-authored, not a user message: it runs on the Gateway's system principal with internal_system provenance (sourceTool: "cron_failure_repair"), so it carries no sender-owner identity. Under the existing trust model the turn gets the conversation's normal non-owner tool policy (workspace and exec tools, not owner-only control tools such as automations); a change to the job itself goes through the user's reply turn. No new authority plumbing.
  • The job's name, payload and last error are wrapped as untrusted data in the request.
  • The request goes to the job's owner at dispatch time. If it is lost (the job was removed in between, or the agent dispatch rejects), nothing extra is sent at that moment; the job's next failure sends the normal alert naming the repair.
  • A repair reply is posted at any hour, like the failure alert it replaces.

Persisted state: the incident gains an optional repair: { atMs } marker. It means "this incident's first alert became a repair request". It survives restarts, and the next alert of that incident clears it.

Evidence

  • Size vs origin/main (merge base accde9e31a9, head 435e097ee7c): production +233/−85 (net +148), docs +14/−4, tests/QA +649/−49; 21 files. To stay within the line-cap ratchet, the Gateway dispatch lives in server-cron-notifications.ts next to the failure-alert transport (2 lines of wiring in server-cron.ts), reconcileCronExitWatchers moved to cron-exit-watchers.ts, and two input helpers moved from the qa-lab mock server to mock-openai-input.ts.
  • Our production shape, Telegram Test Server forum topic, live OpenAI model (telegram-e2e-userbot, Convex-leased credential, the lease's forum supergroup with a run-owned topic created before recording and deleted after; fresh isolated gateway from this checkout via --source-gateway on ports 19951/19952; provider slot = logging proxy to the OpenAI API). Config mirrors ours: agents.defaults.heartbeat = { every: "1h", activeHours: 08:00–23:00 Asia/Kolkata, target: "none", directPolicy: "allow", to: <the tester's DM>, lightContext: true, isolatedSession: true }, cron.failureAlert and messages unset. The QA user posts in the topic, which creates the owner conversation agent:main:telegram:group:<forum>:topic:<n>. A command action seeds scripts/meeting-sync.md (step 1: sleep 150), adds an isolated agentTurn job "Meeting sync" owned by that topic and announcing to it (timeoutSeconds: 45), and force-runs it twice: both time out (consecutiveErrors: 2, notification status not-requested).
    • Command (secrets omitted): E2E_MOCK_SERVER_PATH=<logging proxy to the OpenAI API> E2E_ROOT_CONFIG_PATCH=<live model + the heartbeat block above, messages: null> node <runner with forum-topic setup hooks> --backend mock --source-gateway --gateway-port 19951 --mock-port 19952 --chat <lease forum> --scenario <scenario> --timeout-ms 1000000 --record events.ndjson --output summary.json → exit 0.
    • Topic timeline (all messages):
      Elapsed Topic message (SUT unless noted)
      0.8 s user: Hi! This topic owns our hourly sync automations. Reply with one short sentence confirming you are here.
      61 s I’m here in this topic for your hourly sync automations.
      272 s Fixed scripts/meeting-sync.md by removing the 150-second wait that exceeded the automation’s 45-second timeout. (the repair turn)
      393 s Sync: 3 new meetings. (third run, ok, consecutiveErrors: 0)
      514 s Automation "Calendar sync" failed 2 times / Cause: timeout / Run started: … (the unowned control's alert)
      620 s user: What did you change in the meeting sync automation earlier? One sentence.
      651 s I updated scripts/meeting-sync.md to read the CSV immediately instead of waiting 150 seconds, which exceeded the automation’s 45-second timeout; the schedule stayed unchanged.
    • The repair ran in the topic session itself: chat.history of agent:main:telegram:group:<forum>:topic:<n> holds, in order, the owner-ready exchange, the repair request (user role, internal_system), read → exec → exec → edit scripts/meeting-sync.md → exec, the one-line reply, the next run's result, and the follow-up exchange. No …:topic:<n>:heartbeat session exists (sessions list). Its 6 main-model requests carried the brief with the topic's ordinary tool surface. The step file changed about 30 s after the second failure.
    • No Automation "Meeting sync" failed … alert and no First heartbeat alert text anywhere (7 SUT messages). Control: an unowned job "Calendar sync" with the same broken step fails twice and alerts (delivery status delivered); its step file stays unchanged. The provider log also shows one NO_REPLY turn without the brief right after the repair's exec calls that sent nothing.
  • Telegram Test Server DM owner, live OpenAI model, activeHours excluding now (same harness with --dm, window 06:00–07:00 Asia/Kolkata at 21:06 IST, otherwise the same heartbeat block). The DM creates the owner conversation agent:main:main; the same owned job fails twice (timeouts). DM timeline: 29.5 s I’m here in the chat that owns your hourly meeting sync automation., 310.8 s Fixed meeting sync’s timeout by replacing its 150-second blocking wait with a nonblocking export-readiness check. (the repair turn; it chose to delegate the edit to a subagent via sessions_spawn/sessions_yield), 339.1 s Sync: 3 new meetings. (third run ok). The repair request and reply are in agent:main:main's transcript; no alert, no onboarding notice, 3 SUT messages.
  • Regression test (src/gateway/server.cron-failure-repair.test.ts, new file, "repairs an owned job with an ordinary owner-topic turn whatever the heartbeat config"; 4.3–5.8 s): a real Gateway with its real cron service and agent method (agent command mocked at the runtime boundary), heartbeat target: "none", isolatedSession, lightContext and an activeHours window that excludes now; an owned job owned by a Telegram topic session fails twice; the agent command runs once in agent:main:telegram:group:<g>:topic:42 with deliver: true, channel: "telegram", to: <g>, threadId: 42 and the repair request as its message, and no announce is sent. Fails on the previous head (no agent run).
  • qa-lab end to end (cron-failure-repair-owner-conversation, real gateway child, qa-channel, mock-openai, isolated state): OPENCLAW_BUILD_PRIVATE_QA=1 OPENCLAW_ENABLE_PRIVATE_QA_CLI=1 pnpm openclaw --profile <isolated> qa suite --provider-mode mock-openai --scenario cron-failure-repair-owner-conversation → passed=1 failed=0. An owned job fails twice and no alert is sent; the owner conversation receives the repair request, its ordinary turn fixes the workspace step file (write), the reply lands in that conversation, and the request and reply are in the owner session's own chat.history. Control: an unowned job with the same failures alerts, and the repaired job never does.
  • Service tests (src/cron/service.failure-repair.test.ts, 11 tests): threshold → one runCronFailureRepair request to the owner session (no system event, no heartbeat wake) and no alert; the job's name, payload and error sit only inside <untrusted-text>; the next failure sends one alert naming the repair, later failures nothing more and never a second repair; a rejected repair request alerts on the next failure; success clears the incident silently; no owner → the old alert; agentTurn, systemEvent and script jobs repair, command jobs and on-exit or stream schedules alert. The heartbeat-route case in src/cron/service.wake-now-real-heartbeat.test.ts is removed (the file is back to main).
  • On 435e097ee7c: node scripts/check-changed.mjs exit 0 (line-cap ratchet, all tsgo shards, lint, import cycles, dead exports); cron repair/alert/persistence/real-heartbeat, gateway cron, cron-exit-watchers, server-cron, notifications and qa-lab mock-openai suites pass (30 files, 538 tests); pnpm config:docs:check is clean.
  • Existing-state upgrade (recorded on an earlier head, harness not kept): published [email protected] created an owner session, an owned and an unowned agentTurn job with an announce failure route and each job's first failure; its own openclaw update --tag <candidate tarball> succeeded and both streaks and owners survived; one more failure each reached the threshold: the owned job's incident gained repair: {atMs} with delivery status not-requested and its repair request reached the model; the unowned job alerted. The persisted state is unchanged by this rework.
  • Config compatibility: no config key is added or changed (config:docs:check OK). The behavior change is the default for owned chat-alerting jobs, documented above; per-job failureAlert: false opts out.
    • Downgrade: a persisted repair marker is an extra field older releases ignore; an incident that was mid-repair at downgrade keeps its signature there, so the older release dedupes that same-cause failure (no new alert until the cause changes or the job recovers), as it does for any already-alerted incident.
  • Owner boundary: owner is fixed at creation (CronJobPatch omits it), so it cannot be reassigned; dispatch reads the live job and sends nothing if the job is gone.

@clawsweeper

clawsweeper Bot commented Sep 29, 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 extensions: qa-lab size: XL labels Sep 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 1:10 PM ET / 17:10 UTC (Revision 21).

ClawSweeper review

What this changes

The branch sends a failing automation's first eligible alert to its owner conversation as a repair turn, records that choice in the failure incident, and makes recovery notices silent.

Merge readiness

✅ Ready for maintainer review

Current main and the latest release still use the alert-first flow, so this PR remains useful. The discussion accepts repair by default and silent recovery, and current-head Telegram traces support the new flow.

Priority: P2
Reviewed head: 435e097ee7cc8375a30334c6f3f412ac8c19af27

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Real channel traces and focused boundary coverage support a coherent implementation; accepted default changes remain visible in the documentation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Current-head Telegram Test Server topic and DM traces exercise the Gateway cron-to-agent path and show the owner conversation editing the workspace, replying, and succeeding on a later run; an unowned control alerts. The optional marker uses the existing SQLite state JSON, and the reported published-version upgrade run covered that stored shape before later non-storage edits.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Current-head Telegram Test Server topic and DM traces exercise the Gateway cron-to-agent path and show the owner conversation editing the workspace, replying, and succeeding on a later run; an unowned control alerts. The optional marker uses the existing SQLite state JSON, and the reported published-version upgrade run covered that stored shape before later non-storage edits.
Evidence reviewed 7 items Current main and release: Both current main and v2026.9.7 retain the recovery-notice path; neither contains this repair flow.
Scheduler decision: The PR records a repair marker and defers an owner repair request for eligible execution failures; a later failure follows the alert path.
Gateway dispatch: The repair uses the existing Gateway agent method with the owner session key, internal-system provenance, and delivery through the conversation route.
Findings None None.
Security None None.

How this fits together

OpenClaw's cron scheduler records job outcomes and decides when failures warrant notification. The Gateway turns an eligible repair request into an agent turn in the owning conversation and delivers its reply through that conversation's route.

flowchart LR
  A[Scheduled job result] --> B[Failure threshold and route]
  B --> C{Owner conversation eligible?}
  C -->|Yes| D[Recorded repair request]
  D --> E[Gateway agent turn]
  E --> F[Owner conversation reply]
  C -->|No or later failure| G[Failure alert]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +193, Tests +302, Docs +10, Other +253. Total +758 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 13 296 103 +193
Tests 5 333 31 +302
Docs 2 14 4 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 253 0 +253
Total 21 896 138 +758

Review metrics

Metric Value Why it matters
Production versus proof growth production +233/−85; tests and QA +649/−49 The production growth implements the new incident and dispatch flow, with larger boundary and scenario coverage.
Upgrade-facing settings 1 default behavior changed; 0 new config keys Existing owned jobs change from alert-first to repair-first, while the documented per-job setting disables both.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/qa-lab/src/providers/mock-openai/mock-openai-cron-failure-repair.ts, migration/backfill/repair: extensions/qa-lab/src/providers/mock-openai/server.ts, migration/backfill/repair: qa/scenarios/scheduling/cron-failure-repair-owner-conversation.yaml, migration/backfill/repair: src/cron/service/failure-alerts.ts, migration/backfill/repair: src/cron/service/failure-repair-brief.ts, migration/backfill/repair: src/cron/service/notification-dispatch.ts, and 2 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep the scheduler as the incident owner and use the Gateway's ordinary conversation turn for repair, with the accepted alert behavior documented for upgrades.

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

Not applicable as a bug reproduction: this PR adds a new flow. Current main documents and implements alert-first behavior, while the PR body records current-head runs of the proposed flow.

Is this the best way to solve the issue?

Yes. The scheduler retains the failure decision, and the Gateway starts a normal turn in the owning conversation; this reuses the existing session and delivery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 450dba2dc67a.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Current-head Telegram Test Server topic and DM traces exercise the Gateway cron-to-agent path and show the owner conversation editing the workspace, replying, and succeeding on a later run; an unowned control alerts. The optional marker uses the existing SQLite state JSON, and the reported published-version upgrade run covered that stored shape before later non-storage edits.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.

Label justifications:

  • P2: This is a useful automation improvement with bounded impact rather than an urgent existing-workflow repair.
  • merge-risk: 🚨 compatibility: Upgraded owned jobs change to repair-first and recovery notices become silent; the discussion explicitly accepts and documents both changes.
  • merge-risk: 🚨 message-delivery: The first notification now goes through the owner conversation rather than the prior alert route; current-head channel proof covers that routing and the unowned control.
  • merge-risk: 🚨 security-boundary: A scheduler-originated turn can use the conversation's ordinary workspace tools; the discussed scope deliberately excludes owner-only job authority.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. Letting the conversation that created an automation attempt a workspace repair can turn a recurring failure alert into a completed fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. Current-head Telegram Test Server topic and DM traces exercise the Gateway cron-to-agent path and show the owner conversation editing the workspace, replying, and succeeding on a later run; an unowned control alerts. The optional marker uses the existing SQLite state JSON, and the reported published-version upgrade run covered that stored shape before later non-storage edits.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The repair request changes visible Telegram topic and DM replies, and the PR body supplies Test Server observations.

Evidence

What I checked:

  • Current main and release: Both current main and v2026.9.7 retain the recovery-notice path; neither contains this repair flow. (src/cron/service/failure-alerts.ts:371, 450dba2dc67a)
  • Scheduler decision: The PR records a repair marker and defers an owner repair request for eligible execution failures; a later failure follows the alert path. (src/cron/service/failure-alerts.ts:360, 435e097ee7cc)
  • Gateway dispatch: The repair uses the existing Gateway agent method with the owner session key, internal-system provenance, and delivery through the conversation route. (src/gateway/server-cron-notifications.ts:61, 435e097ee7cc)
  • Accepted behavior change: The PR discussion explicitly accepts repair by default, removal of chat recovery notices, and an ordinary non-owner conversation turn without a job-scoped fence. The documentation describes the upgrade behavior and per-job opt-out. Public docs: docs/automation/cron-jobs/delivery.md. (docs/automation/cron-jobs/delivery.md:139, 435e097ee7cc)
  • Current-head behavior proof: The captured PR body reports Telegram Test Server topic and DM runs from this head: two owned-job failures led to an ordinary owner-session turn, a workspace edit, a reply, and a successful rerun; an unowned control alerted. The review did not independently execute those runs. (435e097ee7cc)
  • Stored-state compatibility: Cron state remains JSON in the existing SQLite row, and the new repair marker is optional. The reported published-version upgrade run used an earlier head; GitHub comparison shows no subsequent changes to the stored marker definition or row codec. (src/cron/store/row-codec.ts:78, 435e097ee7cc)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (20 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-29T13:47:47.009Z sha e301ac6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T14:50:45.885Z sha 9e9065f :: blocked before merge. :: none
  • reviewed 2026-09-30T05:51:27.888Z sha 9e9065f :: blocked before merge. :: none
  • reviewed 2026-09-30T11:28:09.981Z sha b0adcb6 :: blocked before merge. :: none
  • reviewed 2026-09-30T11:43:37.029Z sha b0adcb6 :: blocked before merge. :: none
  • reviewed 2026-09-30T14:53:42.616Z sha 2fc3451 :: blocked before merge. :: [P1] Preserve an alert-only choice for upgraded jobs
  • reviewed 2026-09-30T16:06:38.946Z sha 136912d :: needs real behavior proof before merge. :: [P1] Preserve an alert-only choice for upgraded jobs | [P1] Retire the repair turn when its job authority ends
  • reviewed 2026-09-30T16:37:47.467Z sha 57af3c1 :: needs real behavior proof before merge. :: [P1] Preserve an alert-only choice for upgraded jobs | [P1] Retire the repair turn when its job authority ends

@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper I'm the maintainer who asked for this. Here's where I stand on your review of 361b5a905d35, so we can agree on what "merge-ready" means for this PR.

Owner decisions (please treat these as accepted, not as open risks):

  • Repair on by default for owned announce jobs is intentional. Upgraded jobs switch from "alert at the threshold" to "repair turn first, then alert if the repair can't run, fails, or the job keeps failing". Users with repeated failure alerts want the agent to fix the job, not a chat message. cron.failureAlert.repair: false is the opt-out. I'll say this in the PR body and docs as an upgrade note.
  • The chat "recovered" notice is removed on purpose (reversing fix(cron): recover automations after plugin reloads #146582). Recovery stays visible in run history.

Agreed; we'll fix these next:

  1. [P1] Tie the repair grant to the exact failure incident that started it: its signature and repair.atMs. Reject update and run once that incident is resolved, replaced or alerted.
  2. [P2] Only hold alerts while the repair is still active. Once repair.settled is set, the next failure alerts, not after 15 minutes.
  3. Final-effect proof in the qa-lab flow: after the verification run clears the incident, a further update and run from the same repair turn are rejected, and the job stays unchanged.
  4. Upgrade proof: start from a job row written by the last stable release (no repair marker), upgrade to this head, and run the failure → repair → settle path.
  5. Rebase to fix the merge conflict.

The open question where I'd like your recommendation: tool scope for the repair turn. Today it gets toolsAllow: ['*'] inside the failing job's scheduled tool policy and exec pin. The repair needs two things:

  • to diagnose using the job's own tools, and
  • to edit the job's workspace helper script (read/write/edit/exec).

Would you accept this narrower cap?

toolsAllow = the job's own toolsAllow plus read, write, edit, apply_patch, exec, process and the repair-scoped automations (get/update/run on this job only), still inside the job's scheduled tool policy and exec pin.

If you think exec should be left out, or that repair should only change payload.message when the job doesn't already allow exec, say so. If this scope plus items 1–5 would clear the security concern, confirm that too, and list anything else you'd still need before merge.

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper assist is taking a look at your question.

I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes.

Request: I'm the maintainer who asked for this. Here's where I stand on your review of 361b5a905d35, so we can agree on what "merge-ready" means for this PR. Owner decisions (please treat these as accepted, not as open risks): - Repair on by default for owned announce jobs is intentional. Upgraded jobs switch from "alert at the threshold" to "repair turn first, then alert if the repair can't run, fails, or the job keeps failing". Users with repeated failure alerts want the agent to fix the job,...

@obviyus
obviyus force-pushed the feat/cron-failure-repair branch from 361b5a9 to e88ee05 Compare September 29, 2026 07:45
@clawsweeper

clawsweeper Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper assist: I accept the stated default-repair and silent-recovery decisions as product choices. The proposed tool cap is narrower than ['*'], but I would not treat it as clearing the security concern: adding write, edit, apply_patch, exec, or process gives a repair turn capabilities the job may explicitly lack. Keep the job’s effective tool cap and add only the repair-scoped automations actions. If the job lacks the needed file and exec permissions, limit automatic repair to its job text and let the owner handle helper-script changes.

Items 1–5 address the recorded findings and proof gaps. I would still need a full review of the current head and PR body, including proof that a job without those permissions cannot gain them, before calling this merge-ready.

Evidence:

  • The PR body says the current repair turn uses toolsAllow: ['*']; the prior review covered 361b5a905d35, while the supplied current head is e88ee052049d.
  • The prior review asks for incident-bound grant revocation, final-effect rejection, and upgrade proof.

Suggested next action: Add the agreed changes and permission-boundary proof to the PR body, then request @clawsweeper review for the current head and body.


Source: #161007 (comment)
Assist reasoning: medium.

@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 29, 2026
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 29, 2026
@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit fb2052a into main Sep 30, 2026
303 of 379 checks passed
@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in fb2052a (squash of 435e097ee7c).

  • Problem: a failing automation posted "failed N times" and waited for the user to ask for a fix, even when the conversation that created it could fix it.
  • Fix: at the failure-alert threshold, an owned job's first chat alert becomes a repair request, which runs as an ordinary agent turn in the owner conversation. It uses that conversation's session, transcript, workspace and tool policy, and the reply goes to its own route, thread or topic included. Heartbeat settings don't apply. If the job fails again, the alert follows once and names the repair. Unowned jobs alert as before. failureAlert: false opts out.
  • Proof: Telegram Test Server forum topic with our production heartbeat config (target: "none", isolatedSession, lightContext) and a live model: one repair reply in the topic, the step file fixed, the next run ok, no alert, no onboarding notice, and the repair turn is in the topic session's own transcript. The unowned control alerted. The DM owner with activeHours excluding now behaved the same. qa-lab cron-failure-repair-owner-conversation passed. There is a new Gateway regression test with our heartbeat shape. At 435e097ee7c, check-changed exits 0 and the affected suites pass (30 files, 538 tests).
  • CI bypass (admin, unrelated red): src/cli/update-cli.target-schema.test.ts › "reuses captured invocation paths after process.cwd becomes unavailable" fails identically on a clean origin/main checkout at accde9e31a9 (run 36748866272). On the previous head, test/scripts/ci-test-timings.test.ts › "retains recorded runtime work when its current group gains a file" also failed on accde9e31a9. The first run of this head segfaulted a bun shard (exit 139) and was rerun once. The changed-lane shards cancelled by fail-fast are covered by the local check-changed and suite runs above. The PR touches none of those test areas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: qa-lab feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant