Skip to content

fix(cron): keep automations bound across message edits - #199512

Merged
obviyus merged 6 commits into
mainfrom
openclaw/nimble-shell
Nov 15, 2026
Merged

obviyus merged 6 commits into
mainfrom
openclaw/nimble-shell

Conversation

@obviyus

@obviyus obviyus commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Editing a message or switching a branch in the Control UI gives the chat a new transcript ID (sessionId) and keeps its lifecycle revision. Automations stored the creating chat's sessionId and compared it every time they used it. After an edit:

  • In-session continuations were refused with "operator authority … refused (… definition changed); recreate it from an authenticated turn".
  • Isolated announce results were dropped with session rebound for sessionKey. The run still reported ok, and the Gateway logged no warning.
  • Cron child runs quietly lost the parent's workspace, memory and sandbox requirement.

Daily, idle and manual resets rotate the lifecycle revision, so pinning the revision instead would end automations at every auto-reset.

Fix

  • Automations link the creating chat by key. The stored sessionId and revision are ignored when read. In-session runs, isolated results and child-run parent bindings follow the chat's current transcript through edits, branch switches and resets. Archiving or deleting the chat still pauses the job, with the existing notice.
  • The session generation lease no longer compares sessionId by default. It follows the chat's current transcript, and compares the lifecycle revision only when the reference carries one. Live-writer fences opt into exactTranscript.
  • Background result commits write to the current transcript. A pinned revision still rejects a reset.
  • Operator sources no longer record conversation IDs. The in-session ID recheck in cron-operator-source.ts is removed.
  • A dropped conversation delivery logs a Gateway warning. The run records not-delivered, which the existing failure-alert owner handles.

There is no schema change and no migration. Existing jobs with old stored IDs work as they are.

Lease caller audit (14)

Mode Caller Why
follow chat (default) cron admission (execution-context-admission) stored automation link
follow chat cron delivery target (single + batch) stored automation link
follow chat outbound delivery queue (delivery-generation) queued send to a chat
follow chat memory-audience stored memory link
follow chat session-event-target, session-event-handoff delivers an event into a chat
exact transcript prepareCronRootSessionGeneration (cli-runner, run-orchestrator, attempt-transcript-lifecycle-prepare) live run writing the transcript
exact transcript session-restart-resume-custody resumes a run in that transcript
exact transcript commands-fork copies a specific transcript
exact transcript subagent-control-session, subagent-controller-read, subagent-control-kill controls a live child run

Evidence

  • Regression tests: 11 new tests fail on the merge base (7b81788) and pass here, covering delivery after an edit or reset, the warning when a chat is deleted, child bindings after a parent edit or reset, the in-session continuation, and the lease following an edit. About 650 tests pass across the touched suites and their siblings. Typecheck, oxlint and oxfmt are clean.
  • E2E on an isolated Gateway from source, with a real model: the agent created both automations through its own tool, and the message was edited through sessions.rewind, the RPC behind the Control UI edit button.
    • origin/main after an edit: the in-session job is refused, and the isolated result is ok/not-delivered with nothing in the chat and no warning.
    • This branch after an edit: both deliver into the current transcript.
    • This branch after a reset: both still deliver.
    • This branch after an archive: both pause, with the visible notice.
  • Build: build --dts and the packed-install smoke both pass.

Production code: +207 / −265.

Supersedes #199510 (same change plus test-type fixes for callers of the removed fields).

Follow-ups

  • Owner-based operator authority, so admins can repair or retarget automations from any chat.
  • Other per-chat state keyed by sessionId still breaks after an edit: reactions, GitHub publication status, deep-research view state, the knowledge conversations/<sessionId> partition, and goal continuation.

obviyus and others added 3 commits November 15, 2026 12:19
Automations name their creating conversation by key. Message edits,
branch switches and resets rotate the transcript id or lifecycle
revision; in-session continuations, isolated announce results and
child-run parent bindings now follow the conversation to its current
transcript instead of refusing or silently dropping. Archive and
deletion still pause the job visibly.

The session generation lease no longer compares the transcript id for
stored references; live-writer fences opt into exactTranscript.
Dropped conversation deliveries now log a Gateway warning.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 3c3bda07-5575-8aa3-80d0-79e4a53d9de6
@clawsweeper

clawsweeper Bot commented Nov 15, 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 scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: L labels Nov 15, 2026
@obviyus obviyus changed the title Publish openclaw/nimble-shell fix(cron): keep automations bound across message edits Nov 15, 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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR keeps automations linked to their creating conversation across message edits, branch switches, and resets.

Example: The transcript for agent:main:dashboard:edited changes from original-session to edited-session.

  • Before: An automation continuation is refused or its result is dropped because the stored transcript ID differs.
  • After: The automation uses the current transcript and retains its parent resource bindings.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent, both prior findings are resolved, and supplied checks pass; independently inspectable behavioral evidence remains limited to the production-path tests.
Proof confidence 🦐 gold shrimp (3/6) Maintainer authorship exempts this PR from the contributor runtime-proof gate; the body and discussion describe isolated Gateway/model scenarios but supply no raw runtime artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Editing a conversation can stop its automations from continuing or delivering results and remove their inherited workspace, memory, and sandbox bindings.
Reason: The workflow failure is source-verifiable, and maintainer authorship establishes direction for keeping automation links across edits and resets.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current automation failure, resolves both prior findings, and has no remaining actionable patch defects identified.

Priority: P1
Reviewed head: 9abf466cfa9ae3b3545c76210226ca91d5eabcdf

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron admission combines stored jobs, current conversation facts, and requester authority to run scheduled work and deliver results through the shared transcript owner.

flowchart LR
A[Stored automation] --> B[Occurrence admission]
C[Current conversation] --> B
D[Requester authority] --> B
B --> E[Agent or plugin command]
E --> F[Delivery owner]
F --> G[Current transcript]
Loading

Technical review

Best possible solution:

Use the existing conversation, admission, authority, and transcript owners to resolve automation links by key while preserving exact identity checks for live writers.

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

Current-main source directly establishes the stored-transcript mismatch after an edit; the author's real-Gateway reproduction was not independently executed during this read-only review.

Is this the best way to solve the issue?

The patch repairs identity resolution in the existing owners, updates affected consumers together, and preserves requester authorization without adding a competing state owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Scheduled parent classification and resource inheritance changes intended behavior with a stated reason (71bbd18: Removed or archived parents pause jobs, while reset parents intentionally continued unbound without inheriting replacement-conversation resources.)
  • Background result reset isolation changes intended behavior with a stated reason (5b07247: Prevent delayed current-session results from entering replacement history after a reset, including revision-less source rows.)
  • Scheduled plugin-command parent identity changes intended behavior with a stated reason (ad40743: Requester-command schedules restored their original requester and required the exact parent session before dispatching bounded native work.)
  • Scheduled requester authorization keeps the original intent (f211f3d: Revalidate the creator's device and access grant on scheduled runs rather than treating profile attribution as authority.)
  • Shared generation authority keeps the original intent (b1a2aa2: The earlier refactor preserved live authority checks while moving generation-backed file-write preparation off the main thread; this PR retains exact transcript fencing for those writers.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 240a90e adds src/cron/execution-context.ts:288 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 240a90ef9f95; files: src/cron/execution-context.ts)

PR surface

Source -52, Tests +53, Docs +2, Other +3. Total +6 across 59 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 33 218 270 -52
Tests 21 219 166 +53
Docs 3 10 8 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 7 4 +3
Total 59 454 448 +6

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: canonical
Canonical: #199512
Summary: This PR replaces the earlier closed proposal for the same automation-binding failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Ordinary conversation edits can stop existing automation continuations, drop their results, and discard inherited execution resources.
  • merge-risk: 🚨 compatibility: The maintainer-authored direction deliberately changes existing automation and scheduled plugin-command behavior across resets; that tradeoff is explicitly recorded and accepted.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 (1 earlier review cycle)
  • reviewed 2026-11-15T07:41:50.510Z sha e078957 :: blocked before merge. :: [P2] Bind scheduled plugin invocations to the current transcript | [P2] Update the remaining consumers of the generation contract

Reviewed November 15, 2026, 5:32 AM ET / 10:32 UTC (Revision 2).

RomneyDa added a commit that referenced this pull request Nov 15, 2026
Adapt f3fd75a and
700e8f4 to the 11.4 generation
lease architecture. Stored links follow edits/resets, while live writers
retain exact transcript fences and current operator authority checks.
Reject deleted sources before restoring retained scheduled authority.

Approved upstream head: b56ead5.
Reviewed 24-file adaptation; 153 focused tests plus 12 correction tests,
scoped type/lint/format and docs checks. No newer PR scope adopted.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
obviyus and others added 2 commits November 15, 2026 13:16
Turn admission, dispatch and persistence now use the parent's current session id, and the remaining generation-contract tests prove key-following behavior.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review of e078957 in 6abf251 and 9abf466:

  1. Scheduled plugin invocations use the current transcript. plugin-command-scheduled-run.ts builds the invocation parent from the current entry, with its sessionId and lifecycleRevision. Turn admission (withSessionTurn), the recorder provenance, dispatch and result persistence now all use that same target.
  2. Remaining generation-contract consumers updated:
    • session-entry-read.worker.test.ts: a revisionless descriptor now resolves per store and follows the reset chat. The live-lease revocation assertions are kept.
    • run.fast-mode.test.ts: a stored creating conversation forwards its key-linked generation with no revision.
    • run.bind-parent.test.ts: asserts that the bound operator source has no sessionId. The device-revocation refusal is kept.
    • Locally: check:test-types and tsgo:core are clean; the src/cron suite and the scheduled plugin-command, cron operator-source and notification tests pass.
  3. Upgrade compatibility proof. I ran this branch's Gateway (source tier) on a copy of state that origin/main created and then edited:
    • Both automations were created on main. Their stored sourceConversation and operatorSource.source both carry the pre-edit sessionId (101fa03a…). After the edit the chat is on c31fc00d…, and on main the in-session job was refused and the isolated result was dropped.
    • On this branch, without any migration, both jobs were re-enabled and force-run: in-session-e2e ok/delivered and isolated-e2e ok/delivered. IN-SESSION-RAN and ISOLATED-DELIVERED landed in the chat's current transcript, and the Gateway logged no refusal or rebound.
    • Legacy sources still decode, because sessionId stays an optional, ignored field in operator-run-recovery-source.codec.ts.

@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Nov 15, 2026
@obviyus
obviyus merged commit 3bbf675 into main Nov 15, 2026
162 checks passed
@obviyus
obviyus deleted the openclaw/nimble-shell branch November 15, 2026 10:51
nxmxbbd added a commit to nxmxbbd/openclaw that referenced this pull request Nov 15, 2026
Drop the parent-reset retirement and its per-parent cap exemption. Since
openclaw#199512 a scheduled plugin command follows its parent conversation by key
to the current transcript, so a reset no longer ends its schedules. The
disabled / removed plugin retirement stays.
RomneyDa pushed a commit that referenced this pull request Nov 15, 2026
Backport PR #199512 from head e078957
to the existing beta.4 line. Stored automation links follow the current
conversation through message edits, branch switches and resets; archived
or deleted chats still stop visibly. Keep exact transcript and lifecycle
fences for live writers and current operator authority.

Adapt the older generation and operator-source owners without importing
newer batching or changing the shared restart recovery schema. Preserve
existing stored source fields while interpreting automation links by key.

Source commits: f3fd75a,
700e8f4,
e078957.

Five original-baseline regressions fail before the repair. Focused
regressions, consumer tests, core/scripts types, lint and docs checks
verify the adapted owners. Isolated real-model Gateway proof covers
rewind, branch switch, reset and visible archive refusal. The unrelated
cron handover fixture still has its preexisting requestHeartbeat type
error; no ignore or production workaround was added.

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

(cherry picked from commit e06e36cd47f52069c23639f22881176a1f33198a)
RomneyDa added a commit that referenced this pull request Nov 15, 2026
Preserve the #199512 conversation-key binding contract in the isolated source fixture while retaining exact generation checks for current-source delivery. The old expectation fails on Node and Bun; the corrected file passes all 15 cases, targeted types, lint, formatting, and independent review.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
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)
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
Adapt f3fd75a and
700e8f4 to the 11.4 generation
lease architecture. Stored links follow edits/resets, while live writers
retain exact transcript fences and current operator authority checks.
Reject deleted sources before restoring retained scheduled authority.

Approved upstream head: b56ead5.
Reviewed 24-file adaptation; 153 focused tests plus 12 correction tests,
scoped type/lint/format and docs checks. No newer PR scope adopted.

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

(cherry picked from commit c15040a)

Release adaptation: Existing 11.6 key-following delivery and exact writer fences retained. Reject deleted authenticated sources before either shared-session enqueue or isolated session preparation; do not recreate the deleted conversation. Six focused current-owner cases pass; both new deletion regressions fail without their fixes. Initial wrong-owner adaptation failure and artifact-lock lint setup failure preserved.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit abbee9c54faf8bc8590b19c0fa07e71c392b9bef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant