Skip to content

fix(cron): preserve operator continuations across edits and restarts - #180891

Merged
steipete merged 5 commits into
mainfrom
claude/team-server-landing-reliability-3dd238
Oct 23, 2026
Merged

steipete merged 5 commits into
mainfrom
claude/team-server-landing-reliability-3dd238

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: scheduled operator continuations (the "finish this after CI" turns agents schedule while landing PRs) fail closed and silently stop the task when the owner refreshes a queued continuation, or when a recurring trigger fires with context.

User Impact

User impact: an agent that schedules a same-conversation continuation from an authenticated owner turn can refresh it while it waits, and a CI-watch trigger can hand back context, without the continuation losing the owner's authority. A continuation whose stored source is unusable now stops after one failure with its error kept, instead of retrying with backoff for hours. Non-owner edits still strip the owner's authority, and model-facing names and schedules stay part of the bound definition.

Why This Change Was Made

Two production incidents on a shared Gateway, both observed during PR landings:

  • Queued owner edit. The owner turn created a one-shot continuation, which became due while that turn was still running. The turn then refreshed the continuation's payload text. That edit revoked the waiting occurrence, so it failed 8 ms after dispatch with "Cron occurrence source authority is no longer active". The one-shot job was auto-disabled, and the landing stopped for two days. Separately, cron.update never recaptured operatorSource, so even an owner edit stripped the owner's own authority.
  • Trigger context. A recurring CI-watch continuation's trigger returned {fire:true, message:"Continue the existing authorized PR… Exact-head CI signal: …"}. appendCronPayloadText appends that message to the execution copy, and restoration hashed the copy instead of the stored definition. Every fire therefore failed with "Scheduled operator continuation definition changed" and retried with backoff. The journal shows 40 such failures in a week.

The repair:

  • Launch-time check. A queued continuation waits for its target session to become idle, then admits the current stored job. Its source is checked once, at launch, against that stored definition, not against the trigger-augmented copy. A turn that has already been admitted keeps its definition. Disable, remove and cancellation still revoke it through their existing owners.
  • Owner update capture. Owner-authenticated cron.update captures the source through the same owner that add uses. The capture is applied only if its definition revision matches the definition committed under the mutation lock, so a concurrent manager edit cannot borrow it.
  • Hash. resolveCronRequesterExecutionRevision is unchanged, so Discord/local requester and message-action consumers are untouched. Only the operator-source binding normalizes enabled, the one field the runtime row writer puts into job_json. Every existing stored source was captured while enabled, so stored data validates without a migration or a fallback hash.
  • Terminal failures. Failures while restoring the source before admission become a typed CronOperatorSourceError, which both run callers classify as permanent, so the job retires after one failure. Aborts (restarts, cancellation) are rethrown unchanged and stay retryable.

Accepted edges:

  • A source originally captured while its job was paused does not validate after upgrade; the owner recreates it. Operator sources (fix: scheduled follow-ups lose authorized task access #176422) are in no release yet, stable or beta, and all stored rows on the one main-tracking deployment that has them were captured while enabled.
  • A transient authority race during restore retires a recurring continuation after one visible failure.
  • The idle wait has no deadline of its own; stalled sessions are owned by the session watchdog.

Evidence

  • Real cron queue, Gateway automation handlers, session admission and guarded publication owners, with synthetic model and GitHub execution (src/cron/isolated-agent/run.operator-continuation.test.ts, 17 passed). Covered: queued owner payload edit, recurring trigger message across disable/re-enable, reschedule and restart, manager rename (no owner authority, no guarded effect), manager payload replacement racing an owner metadata capture, next_check leaving the hash unchanged, a pre-upgrade row built with main's hash and runtime-disabled through the real row writer, and one terminal failure for definition mismatch, malformed source and oversized source.
  • src/gateway/cron-operator-source.test.ts: an aborted restore stays retryable, while an unusable source is typed (red on the previous head, green now).
  • Red on base: the queued-edit and recurring-trigger cases fail on main. The rename, concurrent-capture and malformed-source cases fail on the previous PR head 420854d100a4.
  • Consumer suites: requester, run-receipt, timer outcomes, tool policy, mutation authority, active jobs, plugin-command scheduling, requester Gateway integration, session run and run queue. 223 tests across 13 files passed with pnpm test <files> --maxWorkers=1.
  • pnpm tsgo, cron and gateway test typechecks, changed-file oxlint and format checks, and git diff --check all passed.
  • No live Gateway was touched. Production is +85 net lines: owner-update wiring, the typed failure, and the launch-time read.

Read the current stored continuation after its conversation becomes idle, and recapture authenticated owner authority on updates. Bind authority to executable inputs instead of scheduling metadata, retain compatible stored sources, and retire invalid sources after one failed attempt.
@clawsweeper

clawsweeper Bot commented Oct 22, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T01:36:40.683322Z cd9a38b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 420854d100

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cron/service/jobs-tool-policy.ts Outdated
} = job;
return resolveLegacyCronRequesterExecutionRevision({
...execution,
name: "Scheduled execution",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include the job name in the execution revision

resolveCronRequesterExecutionRevision now replaces name with a constant even though buildCronCommandBody injects job.name directly into the model prompt as [cron:<id> <name>]. Consequently, a remote manageAll caller can rename an operator-backed job to contain new instructions without supplying fresh operator authentication; reconciliation considers the execution unchanged and preserves the stored operator source, so those instructions run with the previous operator authority. Keep this model-facing field in the revision or stop adding it to the prompt.

AGENTS.md reference: AGENTS.md:L66-L66

Useful? React with 👍 / 👎.

Comment on lines +239 to +243
operatorCapture = await captureCronCreatorSession(
nextJob,
creatorScope,
{ client, context, signal },
cfg,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind the operator capture to the locked job revision

The operator source is captured from the initially read nextJob before updateWithPrecondition acquires the mutation lock. If another manager changes the payload and clears its source during this await, the precondition later validates the newer locked job but still passes this stale capture; because reconcileCronOperatorSource unconditionally accepts any captured source, even a metadata-only first request reauthorizes the concurrent manager's payload with the owner's operator authority. Recapture from the locked job or reject when its revision differs from the job used for this capture.

AGENTS.md reference: AGENTS.md:L66-L66

Useful? React with 👍 / 👎.

Comment thread src/cron/service/timer-outcomes.ts Outdated
Comment on lines +329 to +333
((result.errorClassification?.kind === "permanent" && isPluginCommandCronJob(job)) ||
(job.operatorSource &&
/(?:Scheduled operator continuation definition changed|Scheduled operator source no longer owns this conversation|Cron occurrence source authority is no longer active|Restart recovery (?:authentication owner changed|operator (?:source policy changed|identity changed|authority (?:changed|is no longer active))))/.test(
result.error ?? "",
)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Classify every permanent operator-source rejection

The new terminal handling recognizes only a hand-maintained subset of restoration messages. Permanent failures such as Restart recovery operator source is invalid, Restart recovery operator source exceeds its storage bound, and Restart recovery operator profile is unavailable are thrown by the same restoration path but do not match this regex, so a recurring continuation is scheduled and retried instead of being disabled after its first unrecoverable authority failure. Use a structured permanent classification for operator restoration failures rather than matching selected error text.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Preserves authenticated scheduled continuations across owner edits and restarts, validates stored definitions independently of trigger context, and retires unusable sources.

Example: A scheduled continuation receives trigger context containing "CI passed".

  • Before: Restoration treats the appended context as an executable-definition change and rejects the continuation.
  • After: Restoration validates the stored definition and allows the continuation to consume the trigger context.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful repair with meaningful authority coverage, but wrong-definition execution and released-state incompatibility prevent merging.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): For this maintainer-authored PR, the inspected production-path authority harness covers owner refresh, unauthorized manager edits, session replacement, and role revocation before guarded publication, using synthetic model and external GitHub execution; this establishes the exercised authority scenarios without proving the defective launch case.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Authorized scheduled follow-ups stop after owner refreshes or fail repeatedly when triggers supply context.
Reason: The maintainer-authored direction repairs recorded incidents using existing cron and authentication owners.

Merge readiness

⛔ Blocked before merge - 5 items remain

This PR addresses demonstrated continuation failures, but three defects still block merging: premature revision capture, inconsistent launch definitions, and broken compatibility with released paused jobs.

Priority: P2
Reviewed head: 1e37b366adff46fadd4c4743b2a2f632dd918b44

Before merge

  • Use the admitted definition for every launch input (P1) - When an operator-backed event occurrence waits for a busy conversation and the owner edits its payload, this selects the current job, but cronEventPayload still reads entry.job at line 105 and active-authority markers still read it at lines 132–134. Payload-only edits preserve event source identity, so launch proceeds with the old instructions and tool cap while restoration validates the new current source. For example, replacing a merge instruction with an inspect-only instruction can still execute the queued merge prompt. Construct payloads and authority markers from admittedJob. This was already visible at the previous reviewed head; its late discovery is acknowledged.
  • Compute capture revisions after interval-anchor finalization (P2) - The previous finding remains unresolved. An owner update with schedule:{kind:"every",everyMs:180000} omitting anchorMs hashes the intermediate patched job here. assertValidCronUpdatePatch only applies the patch; finalizeUpdatedJob subsequently restores the previous anchor for an equivalent resave or supplies the mutation timestamp for a changed interval. Reconciliation rejects the fresh capture, and an interval change or equivalent resave combined with a payload edit also loses the previous source. Derive the capture revision from the same finalized mutation projection while retaining rejection of concurrent manager edits.
  • Preserve source revisions captured by released paused jobs (P1) - A continuation created with enabled:false on v2026.10.6 stores a revision containing false, but this helper always hashes true. After upgrade, force-running that unchanged paused job fails restoration and is treated as permanent; re-enabling it also discards its source during reconciliation. The PR accepts this case on the premise that operator sources were never released, but the verified v2026.10.6 tag contains capture, persistence, restoration, and release notes for this capability. Preserve or migrate those released revisions through the existing owner and prove paused-job upgrade behavior. This assessment uses new release-tag evidence.
  • Resolve security concern: Keep executed instructions bound to restored authority - The launch finding crosses the executable-definition authority boundary: validation uses the current stored source while event payload construction can restore superseded instructions.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Use the admitted definition for every launch input — src/cron/service/run-queue-execution.ts:99-105
  • [P2] Compute capture revisions after interval-anchor finalization — src/gateway/server-methods/cron.ts:239-242
  • [P1] Preserve source revisions captured by released paused jobs — src/cron/service/jobs-tool-policy.ts:103-104
  • [medium] Keep executed instructions bound to restored authority — src/cron/service/run-queue-execution.ts:105

Tests

  • Missing end-to-end proof: Upgrade proof from v2026.10.6 must retain a source originally captured with enabled:false; the supplied compatibility case captures while enabled and disables afterward.
Agent review details

How this fits together

Gateway automation handlers capture authenticated operator sources, the SQLite-backed cron mutation owner binds them to job definitions, and the run queue restores current authority before admitting scheduled conversation work.

flowchart TD
  A[Authenticated owner turn] --> B[Gateway cron handlers]
  B --> C[Cron mutation owner]
  C --> D[Stored job and source]
  D --> E[Run queue and idle wait]
  E --> F[Operator source restoration]
  F --> G[Session admission]
  G --> H[Guarded tool effects]
Loading

Technical review

Best possible solution:

Use the existing finalized mutation projection for capture, one admitted definition throughout launch, and an upgrade-safe conversion of released source revisions.

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

Source tracing establishes all three failing paths, and the supplied harness reports reproduce the original continuation failures; no target code was executed during this review.

Is this the best way to solve the issue?

The existing owners are appropriate, but capture and launch must consume the same canonical definition, and compatibility must account for released paused sources.

Full review comments:

  • [P1] Use the admitted definition for every launch input — src/cron/service/run-queue-execution.ts:99-105
    When an operator-backed event occurrence waits for a busy conversation and the owner edits its payload, this selects the current job, but cronEventPayload still reads entry.job at line 105 and active-authority markers still read it at lines 132–134. Payload-only edits preserve event source identity, so launch proceeds with the old instructions and tool cap while restoration validates the new current source. For example, replacing a merge instruction with an inspect-only instruction can still execute the queued merge prompt. Construct payloads and authority markers from admittedJob. This was already visible at the previous reviewed head; its late discovery is acknowledged.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Compute capture revisions after interval-anchor finalization — src/gateway/server-methods/cron.ts:239-242
    The previous finding remains unresolved. An owner update with schedule:{kind:"every",everyMs:180000} omitting anchorMs hashes the intermediate patched job here. assertValidCronUpdatePatch only applies the patch; finalizeUpdatedJob subsequently restores the previous anchor for an equivalent resave or supplies the mutation timestamp for a changed interval. Reconciliation rejects the fresh capture, and an interval change or equivalent resave combined with a payload edit also loses the previous source. Derive the capture revision from the same finalized mutation projection while retaining rejection of concurrent manager edits.
    Confidence: 0.99
  • [P1] Preserve source revisions captured by released paused jobs — src/cron/service/jobs-tool-policy.ts:103-104
    A continuation created with enabled:false on v2026.10.6 stores a revision containing false, but this helper always hashes true. After upgrade, force-running that unchanged paused job fails restoration and is treated as permanent; re-enabling it also discards its source during reconciliation. The PR accepts this case on the premise that operator sources were never released, but the verified v2026.10.6 tag contains capture, persistence, restoration, and release notes for this capability. Preserve or migrate those released revisions through the existing owner and prove paused-job upgrade behavior. This assessment uses new release-tag evidence.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Operator executable-definition binding changes intended behavior with a stated reason (d74a4ae: Bind captured operator authority to the exact executable definition and conversation while preserving current authorization checks.)
  • Queued launch ownership changes intended behavior with a stated reason (543dd39: Keep durable cron queue custody and final admission with existing owners while waiting for agent readiness.)
  • Worker-owned mutation finalization keeps the original intent (b943945: Centralize scheduling and complete job-edit decisions in the cron worker.)
  • Permanent continuation failures keeps the original intent (ad40743: Retire unusable scheduled-command authority after its first permanent refusal rather than retrying an unrecoverable source.)
  • Released source-revision compatibility changes intended behavior with a stated reason (fix: scheduled follow-ups lose authorized task access #176422: Released sources include enabled in their executable revision; the proposed normalization addresses runtime disable writes, but its stated unreleased-only exception is contradicted by v2026.10.6.)

Testing

Proof path: in-process harness.

Security

Needs attention: The launch mismatch breaks the binding between the executable payload and the operator source being validated.

Evidence

Security concerns:

  • [medium] Keep executed instructions bound to restored authority — src/cron/service/run-queue-execution.ts:105
    The launch finding crosses the executable-definition authority boundary: validation uses the current stored source while event payload construction can restore superseded instructions.
    Confidence: 0.99

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head changes; the checkout matches the original PR head. (1e37b366adff)
  • Capture precedes canonical finalization: The Gateway hashes assertValidCronUpdatePatch's intermediate job, whereas finalizeUpdatedJob later supplies an omitted every-schedule anchor before source reconciliation. (src/gateway/server-methods/cron.ts:241, 1e37b366adff)
  • Launch mixes current and queued definitions: Admission selects current, but event payload construction and active message-authority markers still consume entry.job; payload-only edits preserve event source identity and can reach this path. (src/cron/service/run-queue-execution.ts:99, 1e37b366adff)
  • Earlier-head comparison: The launch and update-handler code is unchanged from the previous completed review, establishing that the newly reported launch mismatch was already visible. (src/cron/service/run-queue-execution.ts:99, 1e37b366adff)
  • Released operator-source contract: The v2026.10.6 tag resolves to fe06181 and contains operator-source capture, enabled-sensitive source revisions, and restoration; its release notes explicitly include scheduled operator follow-ups. This contradicts the PR body's unreleased-only premise. (src/gateway/cron-operator-source.ts:5, fe06181dc5ec)
  • Paused creation is supported in the release: Released creator capture does not exclude enabled:false jobs, and cron.add forwards that source to persistence. (src/gateway/server-methods/cron-input-validation.ts:212, fe06181dc5ec)

Likely related people:

  • Peter Steinberger: Raw commit 3d2f7ca adds src/cron/session-run.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3d2f7ca06b26; files: src/cron/session-run.ts)
  • Jason (Json): Raw commit ad40743 adds src/cron/service/timer-outcomes.ts:301 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ad407430c464; files: src/cron/service/timer-outcomes.ts)

PR surface

Source +85, Tests +270, Docs +10. Total +365 across 18 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 14 151 66 +85
Tests 3 284 14 +270
Docs 1 14 4 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 449 84 +365

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Normalizing enabled changes the interpretation of operator-source revisions already supported by v2026.10.6.
  • add merge-risk: 🚨 security-boundary: An event occurrence can validate the current source while executing a queued payload from a different definition.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: The repair addresses observed failures in scheduled operator continuations with a limited cron-specific blast radius.
  • merge-risk: 🚨 compatibility: Normalizing enabled changes the interpretation of operator-source revisions already supported by v2026.10.6.
  • merge-risk: 🚨 security-boundary: An event occurrence can validate the current source while executing a queued payload from a different definition.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

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

Workflow

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

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-22T18:54:52.479Z sha 420854d :: needs real behavior proof before merge. :: [P1] Keep model-facing names in the execution revision | [P1] Bind fresh operator capture to the locked executable definition | [P2] Classify invalid operator sources before scheduling another attempt
  • reviewed 2026-10-23T01:14:00.162Z sha 49d1bf3 :: needs changes before merge. :: [P2] Compute the capture revision after interval-anchor finalization

Reviewed October 22, 2026, 9:29 PM ET / October 23, 2026, 01:29 UTC (Revision 3).

Merge main and preserve exact requester revision semantics. Normalize only
operator-source enablement, bind fresh captures to the locked definition,
and classify pre-admission source failures as permanent.

Keep current-definition admission after the creator finishes and validate
the stored job independently of trigger-added context. Add guarded-effect
regressions for manager edits, stale captures, runtime-disabled stored data,
and malformed sources without a compatibility bridge or format change.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49d1bf3781

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


/** Runtime auto-disable writes enabled into job_json without rebinding the owner's source. */
export function resolveCronOperatorExecutionRevision(job: CronStoredJob): string {
return resolveCronRequesterExecutionRevision({ ...job, enabled: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve legacy revisions for initially disabled jobs

For a continuation created before this commit with enabled: false, cron.add stored the revision from resolveCronRequesterExecutionRevision(job), which included that false value. After upgrading, this helper always hashes enabled: true, so force-running the still-paused job fails the exact restoration comparison as a changed definition and permanently retires it. Accept the legacy false-enabled revision during restoration or migrate it before applying the canonical revision.

AGENTS.md reference: AGENTS.md:L56-L56

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Oct 23, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Oct 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e37b366ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
const manual = options.source === "manual" || options.source === "event";
const admittedJob = structuredClone(entry.job);
const admittedJob = structuredClone(continuationSession ? current : entry.job);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the admitted definition throughout launch

When an operator-backed event run waits on a busy session and its owner edits the job before the wait completes, this selects current only for admittedJob; the same launch still builds the event payload and active marker from the stale entry.job. The occurrence can therefore execute the old prompt while restoreCronOperatorSource validates the new current revision, and newly added message authority is omitted because the marker reflects the old tool cap. Use the admitted definition for all launch-time payload and authority inputs.

AGENTS.md reference: AGENTS.md:L66-L66

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
Resolve the mechanical overlap with a3909d8 while preserving its live self-removal guard and all continuation scenarios. Keep the operator restore admission boundary and retryable abort classification. Self-removal occurs after admission, so the admitted early return retains the current occurrence without reading the deleted job row; no captured-job fallback is needed.

Validation: all 151 tests in the seven requested cron and Gateway files pass, including self-removal with subsequent role revocation and session replacement. pnpm tsgo, both requested cron/Gateway test typechecks, scoped oxlint, scoped format:check, and git diff --check pass. Existing coordinator and Codex reviews retained; this commit reconciles reviewed changes without expanding behavior.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd9a38be00

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +84 to +86
throw new CronOperatorSourceError(error instanceof Error ? error.message : String(error), {
cause: error,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep transient restoration failures retryable

When prepareUserProfileIdentity or loadPairedDevicePairingStoreRecordReadOnly fails because of a temporary SQLite/worker error, this blanket wrapper turns that infrastructure failure into CronOperatorSourceError. Both run paths classify that type as permanent, and applyJobResult then disables a recurring operator continuation, so one transient read failure can retire an otherwise valid job instead of retrying it. Restrict the permanent classification to confirmed invalid or revoked source failures.

Useful? React with 👍 / 👎.

@steipete
steipete enabled auto-merge (squash) October 23, 2026 01:39
@steipete
steipete merged commit 718bd3d into main Oct 23, 2026
120 checks passed
@steipete
steipete deleted the claude/team-server-landing-reliability-3dd238 branch October 23, 2026 01:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

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

* fix(cron): preserve operator continuations across edits and restarts

Read the current stored continuation after its conversation becomes idle, and recapture authenticated owner authority on updates. Bind authority to executable inputs instead of scheduling metadata, retain compatible stored sources, and retire invalid sources after one failed attempt.

* fix(cron): keep aborted continuation restores retryable

* test(cron): type the aborted restore fixture
obviyus added a commit that referenced this pull request Nov 17, 2026
…0396)

## Problem

Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs.

- A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before #200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, #200307).
- A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. #180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable."
- Failure-repair turns compared the restored target's transcript id with the source's. Since #199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner.

Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session).

## Fix

- `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it.
- `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job.
- `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key.

Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use.

Production code: +13 / −20.

## User impact

- Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created.
- A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled.
- Deleting the chat still stops its running automations.
- Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`.

## Evidence

- Regression tests, red on the merge base `b4fc0534`, green on this head:
  - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit).
  - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it).
- Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement.
- `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons.
- Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat:

  | Event while a condition is running | Base `b4fc0534` | Head |
  |---|---|---|
  | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) |
  | Reset (`sessions.reset`) | not reached (already disabled) | condition completes |
  | Another chat created | not reached | condition completes |
  | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations |

  A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit).

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

## Problem

Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs.

- A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before openclaw#200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, openclaw#200307).
- A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. openclaw#180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable."
- Failure-repair turns compared the restored target's transcript id with the source's. Since openclaw#199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner.

Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session).

## Fix

- `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it.
- `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job.
- `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key.

Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use.

Production code: +13 / −20.

## User impact

- Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created.
- A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled.
- Deleting the chat still stops its running automations.
- Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`.

## Evidence

- Regression tests, red on the merge base `a0d35bd4`, green on this head:
  - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit).
  - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it).
- Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement.
- `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons.
- Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat:

  | Event while a condition is running | Base `a0d35bd4` | Head |
  |---|---|---|
  | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) |
  | Reset (`sessions.reset`) | not reached (already disabled) | condition completes |
  | Another chat created | not reached | condition completes |
  | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations |

  A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit).

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
…0396)

Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs.

- A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before #200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, #200307).
- A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. #180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable."
- Failure-repair turns compared the restored target's transcript id with the source's. Since #199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner.

Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session).

- `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it.
- `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job.
- `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key.

Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use.

Production code: +13 / −20.

- Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created.
- A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled.
- Deleting the chat still stops its running automations.
- Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`.

- Regression tests, red on the merge base `b4fc0534`, green on this head:
  - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit).
  - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it).
- Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement.
- `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons.
- Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat:

  | Event while a condition is running | Base `b4fc0534` | Head |
  |---|---|---|
  | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) |
  | Reset (`sessions.reset`) | not reached (already disabled) | condition completes |
  | Another chat created | not reached | condition completes |
  | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations |

  A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit).

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

Release adaptation: preserve retired session identity allowlist; apply deletion-only key guard to baseline subscriber and retain new regression.

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

Follow-up disposition: bounded pinned-main same-path audit recorded in the lane report; cross-lane changes remain parent-owned.

(cherry picked from commit 75f490aee889734669c4d8d718e4cbec0934491f)
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant