Skip to content

fix: scheduled runs fail after unrelated channel reloads - #188650

Merged
roboclaw-bot merged 3 commits into
mainfrom
roboclaw/team-r6-scoped-policy-retry
Oct 31, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
roboclaw/team-r6-scoped-policy-retry

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #188530 covers caller-turn custody separately; this change does not modify that boundary.

What Problem This Solves

Fixes scheduled work failing after unrelated channel configuration reloads, and known pre-effect policy refusals stranding an occurrence until a later slot.

User Impact

Unrelated channel reloads leave valid scheduled work active. Relevant policy changes can re-admit genuinely unstarted work under fresh authority. Work that may already have performed effects, including model-resolution hooks, is not replayed by this policy retry.

Why This Change Was Made

Scheduled events compare effective policy using canonical runtime/source snapshots for the selected agent, trusted creator and delivery channels, including shared channel policy and activation. Live source/job and per-effect authority checks remain. The existing event owner retains the same occurrence, with its existing two-readmission limit and 100/200 ms backoff. A typed lifecycle refusal before operation acquisition returns the existing mailbox receipt to the existing FIFO drain.

Execution and registered hook dispatch consume existing custody. This includes before_model_resolve, the only registered hook dispatched by the logical entry/setup modules before native candidate preparation, alongside the existing bootstrap and reply-hook barriers. Treating a registered model hook as possible work conservatively gives up policy retry even if that handler happened to be pure. No hook-runner semantics, second retry queue, persistence, configuration option or FIFO/coalescing behavior changed.

Evidence

  • Seven original regressions are red on integrated main 8034bb1fafbe83e5ce95fc985686bc2f95ff5ce1 and green with R6. The committed registered-hook regression is red on incoming 67533beaef03f344b1386afa081c1b5096919afa, observing two persisted filesystem appends. Corrected 4607413216a54980402d55074ce7bedbaaf90279 produces one append, one preparation, no provider request and terminal error after the relevant policy publication.
  • All 100 focused cases pass: 28 native cron/preparation/model cases, 23 event-owner cases, 18 execution cases, 14 stable prompt/tool-prefix cases and 17 timer/session-custody cases. The final two hook cases were rerun after the mechanical test return-type alignment and pass. The unchanged setup/model-entry consumer suites also pass (43 + 7). Whole-PR test lines remain −1; all cases remain, and a redundant fixture setup readback is still covered before effect and after settlement.
  • Targeted format, typecheck and correction-file lint pass. Full-PR local lint retains the handoff max-lines finding: 735/700, with unmodified integrated main also above the cap at 712/700. The existing GitHub Actions advisory size policy is unchanged; no cap, baseline or suppression changed. Focused suites used the pinned CI Bun runtime in isolated, network-disabled rootless Podman, limited to 4 CPUs/8 GiB and one test worker.
  • Fresh independent autoreview of committed 4607413216a54980402d55074ce7bedbaaf90279 completed scoped-clean at P0–P2, with no findings. It assessed source and did not independently execute tests. The native correction review resolves R6-HOOK-REPLAY and retains the incoming NEEDS WORK evidence.
  • Exact-head CI 41157345030, attempt 1 finished failed: 48 jobs succeeded, 27 skipped, and the Workboard job plus its aggregate failed. The only two failing cases, agent_end survives closure and subagent_ended survives closure, have the same log.isEnabled TypeError and assertion/diagnostic locations as scheduled-main 41155320395. Their test and diagnostic files are byte-identical in main, tested merge 6703bc567b47782bd99056ff07e794109d74b0cb, and its first parent 21fd5cbb06b33b1c45daa2eb178843d014cd1b43. The automatic failure table is unknown because job groupings differ; attribution uses the actual logs and Git objects. CI remains failed, and native inherited-failure admission must still enforce current review/security gates. No full-package, live external-model/channel or R3 external-owner proof is claimed.
  • The observed 2526-second duration was active execution with prior Code Mode work, not a proven 42-minute queue/preparation wait. Its exact delay remains unidentified; natural occurrence ownership, slot deduplication and explicit forced runs are unchanged.

Requested by @steipete.

Work sessions

Keep policy freshness scoped to the scheduled run and restore existing
pre-effect event and mailbox readmission without replaying possible effects.

Co-authored-by: steipete <[email protected]>
@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 size: XL labels Oct 30, 2026
@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 real behavior proof before merge.

What this changes

The PR preserves scheduled work across unrelated channel reloads and retries known refusals before execution through existing admission owners.

Example: A scheduled session turn is preparing when another Discord channel's users allowlist changes.

  • Before: The occurrence fails with “Session event configuration changed; retry under the current policy.”
  • After: The scheduled turn continues when its relevant policy is unchanged.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful existing-owner repair, blocked by a concrete hook replay defect and insufficient final-effect authority evidence.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Scheduled automations fail when unrelated channel settings reload, and some pre-execution refusals consume the occurrence.
Reason: The maintainer-authored direction repairs an owned workflow without adding configuration, persistence, or another scheduling owner.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open: it addresses a current scheduled-run failure, but the later execution marker can replay model-resolution hook effects.

Priority: P1
Reviewed head: 4660529741d886b2089e509bf4b911fc36163938

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied native tests use synthetic provider I/O, and their revocation controls inject assertions rather than revoke an authenticated source through its owner; demonstrate successful reload recovery plus rejection of a revoked source and newly forbidden destination channel before real effects, with sensitive values redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Consume replay custody for model-resolution hook work (P2) - For an unlocked scheduled job with a before_model_resolve hook, let the hook perform an external request or persisted write, then publish a relevant tools policy change during native target preparation. runEmbeddedAgentEntry has already dispatched that hook, but this new condition leaves started false when no bootstrap hook is registered, and the added execution-phase marker covers only before_agent_reply. The subsequent policy rejection therefore re-admits the occurrence and dispatches the model-resolution hook again, repeating its effects up to the retry limit. Previously beforeScheduledStart marked the occurrence started before target preparation, preventing this replay. Feed actual effect-capable hook dispatch into the existing start/custody marker and retain retryability for preparation that dispatched no such work.
  • Resolve security review attention item - The relaxed policy fence needs final-effect authorization evidence, although source review found no concrete credential or supply-chain regression.
  • Resolve merge risk - The PR owner must establish that channel policies excluded from the retained projection still reject newly unauthorized scheduled message actions before final transport I/O.

Findings

  • [P2] Consume replay custody for model-resolution hook work — src/auto-reply/reply/session-event-handoff.ts:272-274

Tests

  • Missing end-to-end proof: Provide production-entry-point evidence for reload recovery and allowed versus revoked source/destination authority before real provider, tool, or message effects; the reported red/green tests were not independently rerun.
Agent review details

How this fits together

Cron submits occurrences to the session-event owner, which checks current authority, joins the session FIFO, dispatches agent execution, and records or delivers the result.

flowchart TD
  A[Cron occurrence] --> B[Session event owner]
  C[Runtime policy snapshots] --> B
  B --> D[Session FIFO admission]
  D --> E[Hooks and agent execution]
  E --> F[Result and delivery]
  E --> B
Loading

Technical review

Best possible solution:

Retain the existing event and FIFO owners, with relevant-policy comparison and replay custody consumed before every effect-capable hook dispatch.

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

Current-main source establishes the unconditional publication rejection, and the introduced hook-replay path is source-traceable; no target code was executed during this review.

Is this the best way to solve the issue?

The existing-owner approach is proportionate, but its definition of possible execution must include model-resolution hooks before readmission is safe.

Full review comments:

  • [P2] Consume replay custody for model-resolution hook work — src/auto-reply/reply/session-event-handoff.ts:272-274
    For an unlocked scheduled job with a before_model_resolve hook, let the hook perform an external request or persisted write, then publish a relevant tools policy change during native target preparation. runEmbeddedAgentEntry has already dispatched that hook, but this new condition leaves started false when no bootstrap hook is registered, and the added execution-phase marker covers only before_agent_reply. The subsequent policy rejection therefore re-admits the occurrence and dispatches the model-resolution hook again, repeating its effects up to the retry limit. Previously beforeScheduledStart marked the occurrence started before target preparation, preventing this replay. Feed actual effect-capable hook dispatch into the existing start/custody marker and retain retryability for preparation that dispatched no such work.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify current policy at final effects (recommended)
    The PR owner demonstrates allowed and newly forbidden destination-channel actions through production admission and real transport I/O.
  2. Pause the scoped-policy relaxation
    Retain conservative publication rejection while separating the pre-execution custody repair from the policy relaxation.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: The relaxed policy fence needs final-effect authorization evidence, although source review found no concrete credential or supply-chain regression.

Evidence

What I checked:

PR surface

Source +125, Tests -1, Docs +1. Total +125 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 134 9 +125
Tests 2 482 483 -1
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 617 492 +125

Review metrics

Metric Value Why it matters
Production versus test LOC Production +134/-9; tests +482/-483 The production growth implements scoped snapshot comparison and reuses existing retry owners; test consolidation retains distinct controls, but hook-effect coverage misses model resolution.

Labels

Label changes:

  • add P1: Unrelated channel reloads can fail scheduled conversation work on current main.
  • add merge-risk: 🚨 security-boundary: The diff permits execution across publications previously rejected by the authority fence and relies on current per-invocation authorization for excluded destination channels.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: Unrelated channel reloads can fail scheduled conversation work on current main.
  • merge-risk: 🚨 security-boundary: The diff permits execution across publications previously rejected by the authority fence and relies on current per-invocation authorization for excluded destination channels.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

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

Reviewed October 30, 2026, 4:02 PM ET / 20:02 UTC.

roboclaw-bot and others added 2 commits October 31, 2026 00:33
Integrate main after scheduled-main run 41144429846 passed the formerly
failing cron fallback, Gateway fallback, thinking-claim and manual-custody
leaves. Preserve main's prepared source-effect authority around the R6
policy comparison when resolving the handoff conflict.

Current-main baseline remains red on seven R6 regressions. The integrated
candidate passes all 99 focused cases and targeted typecheck/format. Local
lint retains its max-lines finding under the existing CI advisory policy.

Co-authored-by: steipete <[email protected]>
Consume the existing event custody marker at registered before_model_resolve
dispatch, after live authority checks and before invoking the handler. Keep
locked and no-hook preparation eligible for the existing bounded readmission.

Exercise registered model/reply hooks with persisted effects through native
cron dispatch and preparation. Reuse the job fixture's metadata defaults.

Co-authored-by: steipete <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 31, 2026
@roboclaw-bot
roboclaw-bot merged commit 1bf930c into main Oct 31, 2026
142 of 145 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/team-r6-scoped-policy-retry branch October 31, 2026 02:18
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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

* fix: preserve scheduled work across unrelated policy reloads

Keep policy freshness scoped to the scheduled run and restore existing
pre-effect event and mailbox readmission without replaying possible effects.

Co-authored-by: steipete <[email protected]>

* fix: prevent scheduled policy retries after model hook effects

Consume the existing event custody marker at registered before_model_resolve
dispatch, after live authority checks and before invoking the handler. Keep
locked and no-hook preparation eligible for the existing bounded readmission.

Exercise registered model/reply hooks with persisted effects through native
cron dispatch and preparation. Reuse the job fixture's metadata defaults.

Co-authored-by: steipete <[email protected]>

---------

Co-authored-by: steipete <[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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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