Skip to content

feat(doctor): report automations that will lose access or pause - #182328

Merged
jalehman merged 4 commits into
mainfrom
openclaw-0d5.15/doctor-cron-context-check
Oct 25, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw-0d5.15/doctor-cron-context-check

Conversation

@jalehman

@jalehman jalehman commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Scheduled jobs linked to the conversation that created them now run with that conversation's authority and pause when it is gone, but nothing tells an operator which of their existing automations will lose access, pause, or stay unbound before it happens.

User Impact

openclaw doctor (with or without --fix) now prints a read-only "Scheduled-run access review" under Cron. It lists:

  • automations that will lose access, with the lost fields (owner-only tools when the creator is no longer an owner; unsandboxed execution when the creating conversation requires a sandbox);
  • automations that will pause at the next run, with the conversation and the cause (removed, archived, or a missing worktree path);
  • automations that are unbound: linked by conversation key only, or to a conversation that was reset after the job was created;
  • automations on a CLI backend whose owner-only tools differ from embedded runs today and will match them once both runtimes read the scheduled-run authority;
  • linked automations whose creating conversation has no stored chat type (conversations created by 2026.10.6 or earlier), so their runs get no conversation memory.

The review writes nothing and sends nothing. It does not repair anything; the chat-type backfill is separate follow-up work.

Why This Change Was Made

The review reuses the same pieces occurrence admission uses: scheduledParentLinkOf, parentRowFactsFromEntry, assembleScheduledAdmissionFacts, the pure buildScheduledExecutionContext, and compareScheduledDecisions from the legacy projection. Doctor reads stored jobs with the existing read-only inventory (inspectCronJobsForDoctor), decodes them with the runtime row codec, and reads each named parent with readSessionEntryReadOnlyInWorker.

Owner checks that admission does through Gateway-resident state are done read-only here:

  • profile requesters and the creator-role sandbox read the stored profile row (role and GitHub login) through the existing state-read worker instead of the resident profile catalog, which Doctor does not load;
  • channel requesters use isConfiguredCommandOwner; a linked channel operator or an operator-source snapshot needs the running Gateway, so the review marks those losses "could not verify" rather than calling prepareCommandOwnerAuthority, which can write an authorization reference.

Shared-file change: assembleScheduledAdmissionFacts takes an optional creatorRoleSandbox that the caller already evaluated. Admission does not pass it and keeps its current behavior.

Accepted limits: the CLI backend is resolved from config (payload model or agent default, then resolveCliRuntimeExecutionProvider), not from a per-run session override. The chat-type check looks only at the parent row itself; a parent that is a spawned child is skipped because memory lineage resolves its root elsewhere. There is no openclaw automations bind command yet, so unbound jobs are told to recreate the automation from its conversation.

Evidence

Current-head unit tests (node scripts/run-vitest.mjs run src/commands/doctor/cron/execution-context-report.test.ts src/commands/doctor/cron/execution-context-check.test.ts): 20 passed (including linked main-target pause and command-payload exemption regressions). One or more cases per category: loss with lost fields, unverified loss, sandbox loss, no-loss owner; pause for removed, archived, missing worktree with path; unbound key-only and reset; runtime owner (only owner contexts on a CLI backend); missing chat type (root vs typed vs spawned parent); undecodable stored authority; collector profile and role rules, role sandbox, configured channel owner, archived parent read with readConsistency: "latest", malformed rows skipped; linked main-target pauses included, a failing parent read listed without aborting the review.

pnpm tsgo:core, pnpm tsgo:core:test, oxlint and oxfmt on changed files: clean.

Upgrade proof from v2026.10.6 (Crabbox, AWS)

  • Command: CRABBOX_AWS_REGION=us-east-1 CRABBOX_CAPACITY_REGIONS=us-east-1,us-east-2,us-west-2 crabbox run --provider aws --timing-json --ttl 90m --idle-timeout 45m --label 0d5.15-doctor-proof-2 --download /tmp/0d5.15-out.tgz=... --shell -- "bash proof-0d5.15/remote.sh" (local-only proof scripts, not committed)
  • Tested source: 60b92158a97e4b5ffc1291cfe1cef2695d1e813a working tree synced to the lease; remote sha256sum of the four changed source files matches the local head; the remote build rebuilt dist from that source (dist is stale: missing_build_stamp).
  • Provider aws, lease cbx_30739e0cce29 (c7a.8xlarge, us-east-1), run run_b62ef4d054fde236e5d6640230543ace: https://crabbox.openclaw.ai/portal/runs/run_b62ef4d054fde236e5d6640230543ace. Exit 0. Lease released (CRABBOX_AWS_REGION=us-east-1 crabbox stop --provider aws --id cbx_30739e0cce29 → released lease=cbx_30739e0cce29).

Steps on the lease:

  1. npm install [email protected]; its Gateway, on a fresh isolated state dir, creates five conversations (live, archived, removed, reset, managed worktree) and eight automations: six linked by sessionKey (two to the live parent, one with a claude-cli/... model), and two unlinked (one with a claude-cli/... model). It then archives, deletes and resets the matching parents, and the worktree directory is removed after the Gateway stops.
  2. The PR build runs openclaw doctor --fix --non-interactive --yes (the normal upgrade step), then plain openclaw doctor --non-interactive twice. Per-table content hashes of the state and agent databases are taken around each plain run.

Observed review (identical in all three runs):

Scheduled-run access review (read-only; nothing was changed).
2 automations will lose access because runs use the authority of the conversation and person that created them:
- linked-live (...): owner-only tools such as sessions, portal, nodes, gateway and plugins (the creator is not currently an owner)
- linked-cli (...): owner-only tools such as sessions, portal, nodes, gateway and plugins (the creator is not currently an owner)
3 automations will pause at the next run because the conversation that created them is unavailable:
- linked-archived (...): `<creating-conversation>` is archived
- linked-removed (...): `<creating-conversation>` was removed
- linked-worktree (...): `<creating-conversation>` has a missing worktree (`/tmp/0d5.15-up/state/worktrees/.../worktree-parent`)
1 automation is not bound to the conversation that created it:
- linked-reset (...): `<creating-conversation>` was reset after the automation was created
1 automation runs on a CLI backend, where scheduled runs get no owner-only tools today while embedded runs do:
- unlinked-cli (...): claude-cli
2 automations have a creating conversation with no stored chat type, so their runs get no conversation memory:
- linked-live (...), linked-cli (...): `<creating-conversation>`

Allowed vs refused cases: unlinked (no parent, embedded) produces no finding, while unlinked-cli (no parent, CLI backend, owner context) is listed as a runtime difference. linked-cli is a loss but not a runtime difference, because its context owner is false, which already matches today's CLI runs. The live-parent jobs were created over the Gateway token, so they record no creator profile; under the design's rule an unknown requester is not an owner, which is why both show the owner-only loss.

Read-only: in both plain runs no cron, session or profile table changed. On the first plain run after --fix, one agent-database schema_meta row was added (in the local reproduction its key is historical-transcript-directives-v1), which Doctor's transcript migration owns and completes on its first run after an upgrade (unrelated to this check). The second run changed no table at all. The same results reproduced in a local run of the same script.

Current-head readiness

ClawSweeper reviewed 60b92158a97e4b5ffc1291cfe1cef2695d1e813a: Ready for maintainer review, no actionable findings. The main-target exclusion is removed: main-target jobs report unavailable-parent pauses but not detached-context access changes. Command payloads honor the scheduler's no-pause exemption. Profile reads use the existing state-read worker; the mock-exports and database-worker ratchets pass. The new AWS proof above retested the final production source; remote hashes match all four changed production files. Current checks: 80 successful, 83 skipped, 1 neutral; none failing or pending. No production source changed after that proof. Lease inspection now reports state: released, cleanupStatus: complete, and provisioningResourceMayExist: false.

Static replay over the operator's stored state (online backups, no writes to live data): 105 jobs, no gain-unexpected. Labels (jobs can have multiple): 101 equal, 11 gain-intended, 3 retarget, 7 ownerEmbedded losses, 4 pauses. All four pauses name archived parents. All seven ownerEmbedded losses are marked owner-check unverified by the offline replay: their linked requester needs live Gateway authority, so these are conservative predictions rather than proof that the creator is not an owner. Private job names and conversation identifiers are retained only in local evidence, not published here. This is the replay script's scope (it excludes main-target jobs); new main-target behavior is covered by the focused regression.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: L labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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 clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Adds a read-only Doctor report identifying automations affected by conversation availability and scheduled-run access rules.

Example: Automation job-1 is linked to the removed conversation agent:main:dashboard:parent.

  • Before: Doctor does not identify that the automation will pause.
  • After: Doctor names job-1, explains that its creating conversation was removed, and describes recovery.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, coherent diagnostics with supplied CLI upgrade evidence and both previous blockers resolved; broad CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Supplied terminal output exercises the Doctor command on isolated state upgraded from v2026.10.6, including positive and negative report categories and repeated table-content checks. That proof is pinned to the prior head; its unchanged scenarios remain applicable, while current source and focused tests address main-target reporting and command exemptions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot identify existing automations that will pause or encounter changed access before their next run.
Reason: The maintainer-directed diagnostic provides actionable visibility while preserving runtime authority and stored data; its documented offline-check limits are reasonable for an advisory report.

Merge readiness

✅ Ready for maintainer review

This PR adds useful upgrade diagnostics, and both prior findings are addressed; no remaining actionable defect was found.

Priority: P2
Reviewed head: 60b92158a97e4b5ffc1291cfe1cef2695d1e813a

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor reads stored automation definitions, parent session facts, profiles, and configuration, then uses the scheduler's existing execution-context builder to produce advisory terminal output.

flowchart TD
  A[Doctor command] --> B[Stored automation inventory]
  B --> C[Read parent and requester facts]
  C --> D[Scheduled execution context builder]
  D --> E[Classify access changes]
  E --> F[Cron diagnostic output]
Loading

Technical review

Best possible solution:

Keep the advisory report on the existing scheduler decision owners and land it through the normal CI gates.

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

This is a diagnostic feature; source inspection confirms the report is absent from fetched main, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

The collector and formatter form a coherent addition using existing inventory, decoding, worker-read, and scheduler decision owners; the simplification review found no unnecessary production machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Scheduled admission fact assembly keeps the original intent (240a90e: Establish one pure execution-context builder from stored jobs and admission facts; occurrence-wide admission was subsequently centralized in refactor(cron): admit each scheduled occurrence once #179834.)
  • Doctor Cron health orchestration keeps the original intent (48fcb8b: Reuse settled preflight work and shared reporting rather than repeat legacy scans; the new diagnostic consumes existing read-only owners without altering repair sequencing.)
  • Parent-pause documentation and command exemption keeps the original intent (71bbd18: Pause non-command automations when their exact creating conversation is unavailable, while resets retain legacy behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 240a90e adds src/cron/execution-context-admission.ts:161 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-admission.ts)
  • Peter Steinberger: Raw commit 48fcb8b adds src/flows/doctor-health-contribution-runners.state.ts:102 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 48fcb8be111c; files: src/flows/doctor-health-contribution-runners.state.ts)
  • Jason (Json): Raw commit 27aa074 adds src/flows/doctor-health-contribution-runners.state.ts:92 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 27aa0742fc28; files: src/flows/doctor-health-contribution-runners.state.ts)

PR surface

Source +514, Tests +434, Docs +2. Total +950 across 7 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 4 515 1 +514
Tests 2 434 0 +434
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 951 1 +950

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Useful, bounded diagnostics help operators anticipate automation access changes without changing execution or persisted settings.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-24T07:01:28.870Z sha 9c912c0 :: needs changes before merge. :: [P2] [P2] Review main-target automations instead of skipping them | [P2] [P2] Honor the command-payload exemption in the report

Reviewed October 24, 2026, 3:46 AM ET / 07:46 UTC (Revision 2).

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 24, 2026
@jalehman
jalehman merged commit c668bc0 into main Oct 25, 2026
173 checks passed
@jalehman
jalehman deleted the openclaw-0d5.15/doctor-cron-context-check branch October 25, 2026 03:23
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…claw#182328)

* feat(doctor): report scheduled jobs that lose access or pause

* fix(doctor): keep the scheduled-run review advisory when the store cannot be read

* docs(automation): describe Doctor's scheduled-run access review

* fix(doctor): review main-target jobs, exempt command jobs, read profiles through the state worker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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