Skip to content

fix(doctor): classify command-payload cron jobs as non-tool-bearing in the scheduled authority check - #166384

Merged
steipete merged 1 commit into
mainfrom
upd/upd-doctor-command-cron-provenance
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-doctor-command-cron-provenance

Conversation

@steipete

@steipete steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Closes #166242
Supersedes #166260

What Problem This Solves

Fixes: Doctor repeatedly reports invalid scheduled authority for a command cron job that retains an account policy, then suggests a tool-cap edit that cannot clear the warning.

User Impact

Command jobs without a condition script no longer receive an agent-tool authority warning. Agent turns, script payloads, and command jobs with condition scripts still receive the existing checks. Stored account restrictions and execution permissions remain unchanged; no migration, schema change, or new option is required during updates.

Why This Change Was Made

Doctor had its own tool-runtime classifier and treated any retained policy on a tool-free job as invalid. It now uses cronJobUsesToolRuntime, the same classifier used by cron reconciliation. A retained account policy stays dormant until the job uses tools again. The repair hint for genuinely tool-bearing jobs now names authenticated recreation or an explicit tool-cap replacement from a trusted operator shell using openclaw automations edit.

Thanks to @davidchyi-beep for the detailed report and @jayzhou2309 for the original patch and regression direction. This replacement removes the duplicate classifier instead of adding a Doctor-only dormant-policy exception.

Evidence

  • Final regression fails against the original migration owner with invalidScheduledToolPolicyJobs: ["Command"]; restoring the candidate passes 12/12. It also verifies that agent turns and command jobs with condition scripts still warn when authority is missing, and that the dormant account policy is preserved.
  • An isolated SQLite Doctor-boundary probe reproduced the original warning, then passed with the candidate while preserving all three stored fixture jobs. Its first unchanged-row assertion omitted the reader's default delivery field; explicitly setting fixture delivery resolved that fixture mismatch. The lasting regression uses the cheaper migration-owner boundary.
  • Owner suites passed three consecutive runs: 16/16 each, in 93.22s, 98.11s, and 50.27s wall time. The new regression took 3–11ms.
  • Importers and relevant siblings passed: 165 tests across 13 files, 1033.01s wall time.
  • node scripts/check-changed.mjs passed completely, including production types, all 27 test-type graphs, lint, and guards. Final line-cap, formatting, and git diff --check checks passed.

Commands used (all with an isolated OPENCLAW_STATE_DIR):

# Three consecutive runs
node scripts/run-vitest.mjs src/commands/doctor/cron/scheduled-tool-policy-migration.test.ts src/cron/service.scheduled-policy-preservation.test.ts --maxWorkers=1
# Importers and siblings, with the normal runner order
node scripts/run-vitest.mjs src/commands/doctor/cron src/commands/doctor-config-flow.cron-owners.test.ts src/cron/store.readonly-worker.test.ts src/cron/isolated-agent/run.tools-allow.test.ts --maxWorkers=1
node scripts/check-changed.mjs

Single-file cost, using the repository wrapper equivalent of pnpm test src/commands/doctor/cron/scheduled-tool-policy-migration.test.ts --maxWorkers=1: 12/12 passed in 128.24s wall time, including 91.6s of shared worker preparation; Vitest reported 99% transform time and the new regression took 3ms. CI timing is pending at authoring handoff.

Pre-existing integration costs were recorded without changing those suites: doctor/cron/index.test.ts 177.34s summed case time; doctor-config-flow.cron-owners.test.ts 320.80s (maximum case 38.01s); doctor/cron/legacy-repair.test.ts 163.50s (maximum case 30.40s); cron/store.readonly-worker.test.ts 71.80s; cron/isolated-agent/run.tools-allow.test.ts 83.89s, including 60.74s for the first accountless-legacy case. These exercise the existing full Doctor/store and isolated-agent fixtures.

P1 Codex autoreview was attempted but could not start: its isolation preflight rejected the temporary-directory location even with TMPDIR, TMP, and TEMP unset. No review verdict was produced; maintainer review of this head is still needed.

Production: +13/-21 lines. Tests: +40/-1 lines. Docs: +4/-0 lines. Auto-merge remains off.

Co-authored-by: Jay Zhou [email protected]

Reuse cron's tool-runtime classifier so retained account policies on command
jobs do not produce an unrepairable Doctor warning. Preserve dormant policy
and keep checks for agent turns and condition scripts. Update the recovery
hint to the current automation CLI and authenticated recreation path.

Fixes #166242. Supersedes #166260.
Thanks to @jayzhou2309 for the original patch and @davidchyi-beep for the report.

Co-authored-by: Jay Zhou <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 7, 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 commands Command implementations size: S labels Oct 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 01:55
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 6, 2026, 10:01 PM ET / October 7, 2026, 02:01 UTC.

ClawSweeper review

What this changes

Doctor reuses cron’s tool-runtime classification to stop authority warnings for command jobs without condition scripts, preserves their stored restrictions, and updates recovery guidance.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused fix: current main and the latest release still produce the false warning. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 9f911eab023d443fd7a7cc7f220aae51bb570c7e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no concrete introduced blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies this as MEMBER-authored, so ordinary external-contributor proof is exempt. The captured body reports an isolated SQLite Doctor-boundary probe removing the warning while preserving fixture jobs; no material authority change triggers additional final-effect proof. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies this as MEMBER-authored, so ordinary external-contributor proof is exempt. The captured body reports an isolated SQLite Doctor-boundary probe removing the warning while preserving fixture jobs; no material authority change triggers additional final-effect proof. No stored-data contract changes require migration.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head diff removes Doctor’s duplicate classifier and returns a nonmutating not-applicable result for tool-free jobs. The shared predicate preserves classification for valid agent-turn, script, and condition-trigger jobs.
Still necessary on main: Fetched main still unconditionally classifies a tool-free job with any scheduledToolPolicy as invalid, before inspecting that policy.
Latest release remains affected: The same false-warning branch exists at the supplied v2026.9.8 release revision.
Findings None None.
Security None None.

How this fits together

Doctor inspects stored automation jobs and reports authority problems to operators. Cron’s shared classifier determines which jobs use agent tools, while the scheduler retains ownership of execution permissions.

flowchart TD
  A[Stored automation jobs] --> B[Doctor inspection]
  B --> C[Shared tool-runtime classifier]
  C --> D[Uses agent tools]
  C --> E[Tool-free command]
  D --> F[Validate scheduled authority]
  F --> G[Operator diagnostics]
  E --> H[Preserve dormant restriction]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -8, Tests +39, Docs +4. Total +35 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 13 21 -8
Tests 1 40 1 +39
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 57 22 +35

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/cron/scheduled-tool-policy-migration.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166242
Summary: This PR targets the reported Doctor false warning; the earlier open PR addresses the same diagnostic root cause with a different classification approach.

Members:

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

Technical review

Best possible solution:

Use one shared tool-runtime classifier for Doctor and cron while retaining dormant account ceilings and existing execution checks.

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

Yes, from source: current main and v2026.9.8 report any retained policy on a command job without a condition script as invalid. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Reusing cron’s existing classifier removes competing diagnostic logic without rewriting permissions or adding configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a persistent misleading Doctor warning; the affected command job already executes successfully.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as MEMBER-authored, so ordinary external-contributor proof is exempt. The captured body reports an isolated SQLite Doctor-boundary probe removing the warning while preserving fixture jobs; no material authority change triggers additional final-effect proof. No stored-data contract changes require migration.

Label justifications:

  • P2: This repairs a persistent misleading Doctor warning; the affected command job already executes successfully.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as MEMBER-authored, so ordinary external-contributor proof is exempt. The captured body reports an isolated SQLite Doctor-boundary probe removing the warning while preserving fixture jobs; no material authority change triggers additional final-effect proof. No stored-data contract changes require migration.

Evidence

What I checked:

Likely related people:

  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

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

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

Workflow

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

@steipete
steipete merged commit ae6fdc2 into main Oct 7, 2026
198 of 199 checks passed
@steipete
steipete deleted the upd/upd-doctor-command-cron-provenance branch October 7, 2026 02:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: doctor "invalid or inconsistent scheduled authority provenance" on command-payload cron jobs — suggested remediation cannot clear it

1 participant