Skip to content

fix: avoid false Doctor budget failures on large upgrade fixtures - #167482

Merged
steipete merged 1 commit into
mainfrom
fix/doctor-idempotence-budget-from-state
Oct 8, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/doctor-idempotence-budget-from-state

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Related: #166526

This fixes the validation-budget failure only. Repeated guarded plugin captures and the broader Doctor performance optimization remain tracked in the issue.

What Problem This Solves

Fixes false idempotent-Doctor budget failures in the sqlite-volume published-upgrade survivor scenario when persisted state grows.

User Impact

This changes release-validation tooling; it does not change Doctor behavior or reduce its runtime. The independent command watchdog still defaults to 900 seconds and must be increased explicitly for fixtures whose computed budget exceeds that duration. Repeated plugin-capture cost remains outside this patch.

Why This Change Was Made

The harness applied the same 60-second limit to small states and the 4,800-session / 23,890-event / 2,200-job fixture, despite a measured 473-second AWS run. It now measures persisted session/event/job counts and distinct enabled plugin roots before timing Doctor, then assigns 60 seconds of fixed overhead plus 80 ms/session, 2 ms/event, 20 ms/job, and 20 seconds/plugin root, rounded up. Seven roots with the reported volume receive 676 seconds, still below a twofold slowdown.

The computed and effective limits are recorded in scenario output and an artifact, with the effective limit in the sanitized summary. Explicit overrides remain supported. The Docker launcher omits unset/empty overrides so frozen extended-stable runners retain their shipped defaults. No Doctor, fs-safe, schema, dependency, or public option changes.

Evidence

  • Current base 8879e5ef4b98e7ff17b0ac04e7695f66f3e143b2: the real shell budget assertion, with the recorded 473-second duration injected, rejects 473s > 60s. Restoring all changed implementation files to that base makes the new regression fail for exactly that reason.
  • The corrected shell regression accepts 473 seconds and rejects a simulated 946-second Doctor against 676 seconds; it also covers the small-state floor, explicit override, and duplicate/disabled plugin roots. It reads real SQLite fixture counts that deliberately disagree with the requested fixture-size environment variables. No sleeps or real timers.
  • pnpm test test/scripts/upgrade-survivor-doctor-budget.test.ts --maxWorkers=1: 5 passed; 4.04 seconds wall time, 1.23 seconds test execution. Hosted CI ran the same five tests in 0.311 seconds; the adapted config-parking file passed its 28 existing tests in 8.128 seconds (CI job).
  • All 51 upgrade-survivor test files passed on fresh AWS lease cbx_b1aae9de19cb: 934 Linux-applicable tests, 75.11 seconds wrapper wall time. pnpm tsgo:core and pnpm tsgo:core:test --root-stripe 2/4 passed there and locally.
  • The shipped v2026.8.35 budget reader, driven with the launcher's new forwarding block, selects 60 seconds for unset/empty overrides and 700 seconds for an explicit override.
  • Targeted script/test lint, formatting, and shell syntax checks passed. Deslop completed; independent Codex autoreview is clean through P2.

Fresh AWS live proof passed on lease cbx_b1aae9de19cb, run run_4a8f3ec91d43b4c1f4c583acbfcd151c (scenario 2,086 seconds, full command 44m59s):

GITHUB_ACTIONS=false \
[email protected] \
OPENCLAW_UPGRADE_SURVIVOR_SCENARIOS=sqlite-volume \
pnpm test:docker:published-upgrade-survivor
SQLite volume Doctor budget: {"counts":{"sessions":4803,"events":23893,"cronJobs":2203,"pluginRoots":9},"computedSeconds":717,"budgetSeconds":717}
SQLite volume idempotence doctor completed in 473s (budget 717s).
Upgrade survivor Docker E2E passed [email protected] scenario=sqlite-volume candidate=2026.9.9

The real isolated Gateway passed readiness/status and history checks before and after restart, preserving all 4,800 volume sessions, 23,890 volume events, and 2,200 volume jobs. /healthz and /readyz each took 1 second; RPC status took 4 seconds. Additional baseline records explain the larger measured totals. There was no manual budget override. Replaying the negative-control test with these exact measured counts also rejected a simulated 946-second Doctor against the 717-second limit; production code was unchanged and the transient test-data substitution was restored.

Native Crabbox source verification bound source commit 3f434f6d5405e673d016d09ca4da144115dbb0fd to tree 9bf15dc5ed7cca70c69e09fba56ba0699c2be679 and carrier commit 46e30166423c35c5a4595ea7dec8cebb430f29b0. The live command verified that carrier/tree/base and clean Git state. Earlier raw-sync preparation was rejected by the package provenance guard; the successful run used the native verified source capsule.

Validation limitations: the local 51-file run passed 937 tests but failed the unchanged service-lifetime test at upgrade-survivor-systemd.test.ts:621 (unknown versus running). Its isolated replay and the AWS suite passed; no flake fix is claimed. check:changed passed its preceding guards, formatting, and typechecks, then stopped on the existing unused ClientVoiceToolEffect export in unchanged src/talk/client-voice-session-store.ts. Neither result was hidden with a baseline exception or weaker assertion. The published-head CI run passed on 3f434f6d5405e673d016d09ca4da144115dbb0fd, including the new regression, types, lint, docs, and CI gate. The earlier local limitations remain recorded above rather than being presented as fixed.

LOC exception: harness/tooling +73/-7 (net +66), tests +148/-0, docs +14/-3. Measured state collection and budget evidence require the added harness code; no coherent behavior-preserving deletion offsets it without expanding scope or removing checks.

Measure persisted sessions, transcript events, cron jobs, and enabled plugin roots before the sqlite-volume Doctor pass. Record the computed limit and preserve explicit overrides and frozen extended-stable defaults. Doctor behavior and fs-safe remain unchanged.
@clawsweeper

clawsweeper Bot commented Oct 8, 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 scripts Repository scripts docker Docker and sandbox tooling size: M labels Oct 8, 2026
@steipete
steipete marked this pull request as ready for review October 8, 2026 22:14
@clawsweeper clawsweeper Bot added 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The upgrade test calculates Doctor’s time limit from persisted state size and enabled plugin roots, records the limit, and preserves explicit overrides and frozen-release defaults.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The bounded correction is clean and demonstrated through a real packaged upgrade, but addresses only the validation portion of the linked problem.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The recorded source-bound AWS Docker run exercises the changed shell owner through the published-upgrade entry point: [email protected] upgrades successfully, persisted counts select 717 seconds, and the real Doctor completes in 473 seconds without an override while preservation and restart-history checks pass. Frozen-reader evidence covers omitted and explicit overrides. No stored-data format or migration changes are introduced.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Release testers see a successfully preserved large upgrade fail because Doctor is judged against a small-state time limit.
Reason: The existing scenario owner supplies a measured calibration that preserves meaningful slowdown detection. The related issue also requests runtime performance work, which this deliberately bounded patch leaves open.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful, bounded correction to release validation that current main still needs. No actionable patch defect was found; the broader Doctor performance work remains separately tracked.

Priority: P2
Reviewed head: 3f434f6d5405e673d016d09ca4da144115dbb0fd

Before merge

None.

Findings

None.

Agent review details

How this fits together

The published-upgrade test installs an official baseline, upgrades it to a candidate package, and verifies that stored conversations, jobs, and plugin state survive. Its second Doctor run checks that repeating repairs preserves state and finishes within a calibrated time limit.

flowchart TD
  A[Published baseline and candidate package] --> B[Upgrade and preservation checks]
  B --> C[Count stored records and enabled plugin roots]
  C --> D[Calculate limit or use explicit override]
  D --> E[Run Doctor with independent watchdog]
  E --> F[Check elapsed time and preserved state]
  F --> G[Publish budget and upgrade results]
Loading

Technical review

Best possible solution:

Keep the state-derived validation limit while pursuing Doctor’s repeated capture cost through the separate performance issue.

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

Yes: current main compares the documented 473-second large-state Doctor run against a fixed 60-second limit, and the supplied base-failing shell regression exercises that exact assertion. This review did not execute the reproduction.

Is this the best way to solve the issue?

Yes for the validation defect: measuring persisted inputs before execution corrects the limit without changing Doctor or learning from its elapsed time. It intentionally does not solve the separately documented performance problem.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • scripts/e2e/lib/upgrade-survivor/run.sh: timed Doctor limit changes intended behavior with a stated reason (improve: stress packaged SQLite upgrade migration #125571: Detect preservation, idempotence, and performance regressions in realistic high-volume packaged upgrades.)
  • scripts/e2e/upgrade-survivor-docker.sh: budget override forwarding keeps the original intent (9de3ca5: Allow explicit calibration of the volume scenario’s Doctor limit.)
  • docs/help/testing-updates-plugins.md: volume validation contract keeps the original intent (test: verify automatic migration during stable upgrades #132975: Verify preservation immediately after the updater, before standalone Doctor can conceal incomplete migration; use the later Doctor pass for idempotence.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced patch: The pinned merge-base-to-head diff adds state measurement before Doctor starts, retains the independent command watchdog, and leaves preservation assertions after the time-limit check. (scripts/e2e/lib/upgrade-survivor/run.sh:1940, 3f434f6d5405)
  • Independent budget inputs: Read-only SQLite queries count sessions, transcript events, and cron jobs; the existing plugin-index reader supplies distinct enabled roots. The timed Doctor run does not determine its own allowance. (scripts/e2e/lib/upgrade-survivor/sqlite-volume.mjs:36, 3f434f6d5405)
  • Recorded packaged upgrade proof: The fully supplied PR body records native source verification for this head and an isolated AWS published-upgrade run from [email protected]. Measured counts were 4,803 sessions, 23,893 events, 2,203 jobs, and nine plugin roots; Doctor completed in 473 seconds under the calculated 717-second limit without an override. Gateway history and preservation checks passed before and after restart. Captured body source identity: 9f3b77df7a76e7562a297fc92267ebd937ce795fd9ff67899934d1ae4cd28afc. This review inspected the supplied trace and did not rerun target code. (3f434f6d5405)
  • Regression sensitivity: The new shell-boundary cases use real SQLite counts that disagree with fixture-size environment variables. They accept 473 seconds, reject 946 seconds, enforce the small-state floor, and preserve a 700-second explicit override. The body reports failure on the original 60-second limit and passing corrected cases. (test/scripts/upgrade-survivor-doctor-budget.test.ts:68, 3f434f6d5405)
  • Frozen-release compatibility: The Docker launcher forwards the existing override only when nonempty, through both invocation paths. Frozen extended-stable runners therefore retain their shipped defaults. The body also records the v2026.8.35 reader selecting 60 seconds for omitted overrides and 700 seconds for an explicit override. (scripts/e2e/upgrade-survivor-docker.sh:120, 3f434f6d5405)
  • Current main still needs the correction: Fetched main still uses the fixed 60-second fallback. The comparison from the PR merge base to fetched main shows no changes to the eight introduced paths, so there is no overlapping main change requiring additional integration work. (scripts/e2e/lib/upgrade-survivor/run.sh:1946, c78e6d46b639)

Likely related people:

  • Peter Steinberger: Raw commit 9de3ca5 adds scripts/e2e/lib/upgrade-survivor/run.sh:1499 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9de3ca5fc93d; files: scripts/e2e/lib/upgrade-survivor/run.sh)

PR surface

Tests +148, Docs +11, Other +66. Total +225 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 148 0 +148
Docs 1 14 3 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 5 73 7 +66
Total 8 235 10 +225

Root-cause cluster

Relationship: partial_overlap
Canonical: #166526
Summary: The linked issue owns the combined validation and Doctor performance report; this PR addresses only its validation-budget component.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This corrects a reproducible false failure in an opt-in release-validation scenario without changing installed Doctor behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T22:19:56.572Z sha 3f434f6 :: needs maintainer review before merge. :: none

Reviewed October 8, 2026, 6:28 PM ET / 22:28 UTC (Revision 2).

@steipete
steipete merged commit 9f8e3f6 into main Oct 8, 2026
185 of 188 checks passed
@steipete
steipete deleted the fix/doctor-idempotence-budget-from-state branch October 8, 2026 22:42
@steipete

steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Measure persisted sessions, transcript events, cron jobs, and enabled plugin roots before the sqlite-volume Doctor pass. Record the computed limit and preserve explicit overrides and frozen extended-stable defaults. Doctor behavior and fs-safe remain unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation 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. scripts Repository scripts size: M 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