Skip to content

fix: keep the full Doctor timing line in update reports - #206290

Merged
fuller-stack-dev merged 3 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-sections-diagnostic-pending
Nov 27, 2026
Merged

fuller-stack-dev merged 3 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-sections-diagnostic-pending

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Related: #204775

What Problem This Solves

openclaw update records a "Doctor sections" diagnostic for each Doctor it runs: where the Doctor's time went, section by section, plus its five slowest contributions. Update reports and outage investigations rely on that line. Since #206152, each Doctor step also writes a doctor.pending.<step> decision to the startup trace (about 94 per run). The update's collector counted each decision as a 0.0 s section, so on a first update the line hit its 1024-character limit after about 17 decisions. Everything after config-flow was cut: contributions, external-config, maintenance-ready, sqlite-reclamation, maintenance.finish, maintenance.release, and the whole "slowest contributions" list.

User Impact

The update run record and update --json output carry the full Doctor timing line again, with the same content they had before #206152. No user-visible behavior changes otherwise. The startup trace still has every doctor.pending.<step> line when OPENCLAW_GATEWAY_STARTUP_TRACE=1 is set by the operator, and later Doctor work depends on that.

Update behavior. The collector runs in the release that owns the Doctor child: createUpdateDoctorSectionTiming is called by this release's package/fresh Doctor runners and by its finalization. A published driver (for example 2026.11.10) hands its Doctor run to the new release, so the first update onto a release with this fix already gets the full line. Nothing in the installed updater changes; no stored field, run-record shape, limit or config changes.

Why This Change Was Made

A pending decision is not a timing; its 0.0 ms duration is the cost of a read-only check. The section-timing owner (src/infra/update-doctor-section-timing.ts) now skips trace names that start with pending. when it collects phases, so they use neither the line's length budget nor its 256 phase slots. I did not raise the length limit, and I did not add a summary of decisions (no consumer for it exists). The Doctor's trace emitter (traceDoctorMaintenancePending) is untouched.

Competing explanation ruled out: the line was not already near its limit before #206152. The same captured trace with the pending lines removed (what the parent of d0f76989509 emits; the owner file has no commits in between) produces a 690-character line with every section.

Evidence

Tested commits: red on origin/main 2ab7b31a13d, green on this PR's head a93cc2d4bdc.

Real capture. One doctor --fix trace from a real first update on Linux (npm global, systemd user Gateway): published 2026.11.10 as the driver, a candidate packed from main at fcc9a0648c2 (after #206152). 153 Doctor trace lines, 73 of them doctor.pending.*. The recordings replay that stderr through createUpdateDoctorSectionTiming().wrap(...) and annotate(...), the same calls the update's Doctor runners make, then run the owner's tests. I did not run a new update cell for this change: the fix is inside the line collector, and the capture already contains the exact Doctor output an update feeds it.

  • Red, base 2ab7b31a13d: line length 1024, truncated, 17 pending entries, 6 sections and the slowest contributions missing. The new regression test fails.
  • Green, head a93cc2d4bdc: line length 690, not truncated, no pending entries, every section present. Byte-identical to the line the same owner produces from the pre-refactor: record which doctor --fix steps have work before the Gateway stop can become conditional #206152 shape of the trace.
  • Negative control (test): 80 genuinely timed sections still produce a line of exactly 1024 characters ending in ….
  • Trace kept (test): with OPENCLAW_GATEWAY_STARTUP_TRACE=1 set by the operator, the wrapped Doctor stderr is returned unchanged, with every doctor.pending. line.

Red, base 2ab7b31a13d:

doctor-sections-red-base-2ab7b31a13d.mp4

Green, head a93cc2d4bdc:

doctor-sections-green-head-a93cc2d4bdc.mp4
Raw: red replay and tests on base
=== RED base origin/main 2ab7b31a13d (PR test file copied in): 2ab7b31a13d chore(ui): refresh control ui locales (#206274)
--- real capture: one 'doctor --fix' trace from an update (published 2026.11.10 -> main fcc9a0648c2 candidate)
$ grep -c 'startup trace: doctor\.' real-doctor-trace.txt; grep -c 'doctor.pending.' real-doctor-trace.txt
153
73
--- replay through createUpdateDoctorSectionTiming (wrap + annotate, as the update's Doctor runners call it)
input: 153 trace lines, 73 pending
length: 1024, truncated: true, pending entries in line: 17
  MISSING: contributions
  MISSING: external-config
  MISSING: maintenance-ready
  MISSING: sqlite-reclamation
  MISSING: maintenance.finish
  MISSING: maintenance.release
  MISSING: slowest contributions:
line: Doctor sections: startup 0.0 s, pending.retained-runtimes 0.0 s, retained-runtimes 0.2 s, maintenance.preserve-original-state 0.2 s, pending.l
egacy-state-dir 0.0 s, maintenance.begin 0.4 s, schema-admission 0.0 s, pending.client-credentials 0.0 s, pending.state-database-repair 0.0 s, state
-database-repair 0.0 s, pending.database-migrations 0.0 s, database-migrations 0.0 s, heartbeat-migration-backups 0.2 s, pending.state-schema 0.0 s,
 state-schema 0.0 s, pending.runtime-checks 0.0 s, pending.config-flow 0.0 s, config-flow 2.7 s, pending.contribution.doctor:write-config-migrations
 0.0 s, pending.contribution.doctor:agent-database-admission 0.0 s, pending.contribution.doctor:native-status 0.0 s, pending.contribution.doctor:nod
e-runtime 0.0 s, pending.contribution.doctor:runtime-capabilities 0.0 s, pending.contribution.doctor:gateway-config 0.0 s, pending.contribution.doct
or:auth-profile-migration 0.0 s, pending.contribution.doctor:gateway-auth 0.0 s, pending.contribution.doctor:node-hosting-preconditions 0.0 s…
--- owner tests
× |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > reports timed sections without the pending decisions that p
✓ |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > leaves every pending decision in an operator-enabled trace
✓ |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > still bounds a genuinely long list of timed sections 2ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 1-byte chunks 30ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 7-byte chunks 7ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 65536-byte chunks 2ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > preserves the original observer's stop after a synchron
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > preserves the original observer's throw after a synchro
Tests  1 failed | 7 passed (8)
 FAIL  |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > reports timed sections without the pending decisions that precede them
AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]

- Expected
+ Received

  [
-   "Doctor sections: startup 0.0 s, retained-runtimes 0.2 s, maintenance.begin 0.4 s, database-migrations 20.7 s, state-schema 0.2 s, config-flow 2.7 s, contributions 5.5 s, external-config 0.0 s, maintenance-ready 0.5 s, sqlite-reclamation 0.2 s, maintenance.release 0.0 s; slowest contributions: check-49 4.0 s, check-48 3.9 s, check-47 3.8 s, check-46 3.7 s, check-45 3.6 s",
+   "Doctor sections: startup 0.0 s, pending.retained-runtimes 0.0 s, retained-runtimes 0.2 s, pending.maintenance.begin 0.0 s, maintenance.begin 0.4 s, pending.database-migrations 0.0 s, database-migrations 20.7 s, pending.state-schema 0.0 s, state-schema 0.2 s, pending.config-flow 0.0 s, config-flow 2.7 s, pending.contribution.doctor:check-10 0.0 s, pending.contribution.doctor:check-11 0.0 s, pending.contribution.doctor:check-12 0.0 s, pending.contribution.doctor:check-13 0.0 s, pending.contribution.doctor:check-14 0.0 s, pending.contribution.doctor:check-15 0.0 s, pending.contribution.doctor:check-16 0.0 s, pending.contribution.doctor:check-17 0.0 s, pending.contribution.doctor:check-18 0.0 s, pending.contribution.doctor:check-19 0.0 s, pending.contribution.doctor:check-20 0.0 s, pending.contribution.doctor:check-21 0.0 s, pending.contribution.doctor:check-22 0.0 s, pending.contribution.doctor:check-23 0.0 s, pending.contribution.doctor:check-24 0.0 s, pending.contribution.doctor:check-25 0.0 s, pending.contri…",
  ]

 ❯ src/infra/update-doctor-section-timing.test.ts:52:25
     50|   it("reports timed sections without the pending decisions that preced…
     51|     const { diagnostics } = await replayDoctorStderr(stderr);
     52|     expect(diagnostics).toEqual([
       |                         ^
     53|       "Doctor sections: startup 0.0 s, retained-runtimes 0.2 s, mainte…
     54|         "database-migrations 20.7 s, state-schema 0.2 s, config-flow 2…
Raw: green replay and tests on head
=== GREEN head a93cc2d4bdc: a93cc2d4bdc fix(update): keep Doctor pending decisions out of the sections diagnostic
--- real capture: one 'doctor --fix' trace from an update (published 2026.11.10 -> main fcc9a0648c2 candidate)
$ grep -c 'startup trace: doctor\.' real-doctor-trace.txt; grep -c 'doctor.pending.' real-doctor-trace.txt
153
73
--- replay through createUpdateDoctorSectionTiming (wrap + annotate, as the update's Doctor runners call it)
input: 153 trace lines, 73 pending
length: 690, truncated: false, pending entries in line: 0
  present: contributions
  present: external-config
  present: maintenance-ready
  present: sqlite-reclamation
  present: maintenance.finish
  present: maintenance.release
  present: slowest contributions:
line: Doctor sections: startup 0.0 s, retained-runtimes 0.2 s, maintenance.preserve-original-state 0.2 s, maintenance.begin 0.4 s, schema-admission
0.0 s, state-database-repair 0.0 s, database-migrations 0.0 s, heartbeat-migration-backups 0.2 s, state-schema 0.0 s, config-flow 2.7 s, legacy-cron
.crontab 0.0 s, legacy-cron.store 0.0 s, legacy-cron.inference 0.8 s, legacy-cron.execution-context 0.0 s, contributions 5.5 s, external-config 0.0
s, maintenance-ready 0.5 s, sqlite-reclamation 0.2 s, maintenance.finish 0.0 s, maintenance.release 0.0 s; slowest contributions: session-transcript
s 1.6 s, legacy-cron 0.8 s, memory-search 0.7 s, workspace-status 0.7 s, structured-health-repairs 0.3 s
--- owner tests
✓ |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > reports timed sections without the pending decisions that
✓ |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > leaves every pending decision in an operator-enabled trace
✓ |infra| src/infra/update-doctor-section-timing.test.ts > Doctor sections diagnostic > still bounds a genuinely long list of timed sections 2ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 1-byte chunks 28ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 7-byte chunks 6ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > bounds and decodes stderr with 65536-byte chunks 2ms
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > preserves the original observer's stop after a synchron
✓ |infra| src/infra/update-doctor-section-timing.test.ts > delegated Doctor phase output > preserves the original observer's throw after a synchro
Tests  8 passed (8)

Test file audited: src/infra/update-doctor-section-timing.test.ts (whole file). Added three cases: the regression (fails on main with the truncated, pending-filled line), the operator-trace pass-through, and the bound on long timed lists (no prior test covered truncation). The two existing cases (chunked UTF-8 decoding with trace stripping and retirement widenings; observer stop/throw after a display failure) cover distinct behavior and stay unchanged. Nothing removed.

Commands and results (on a93cc2d4bdc; later commits on the branch type the test helper and merge main, head d21fce2d59a, owner test rerun there: 8 passed):

  • node scripts/run-vitest.mjs over the owner test and its consumers (update-command-package-doctor, update-command-fresh-doctor, update-finalization-lifecycle, progress): Test Files 2 passed (2); Tests 37 passed (37); Test Files 3 passed (3); Tests 162 passed (162).
  • node scripts/check-changed.mjs --base origin/main: exit 0 with OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 (core typecheck, core test typecheck, lint, guards). The dead-export scan fails on main itself for three exports this PR does not touch (readUpdateDatabaseEngineConfig, DoctorContributionPending, formatUpdateSnapshotCapacity).
  • Session identity ratchet: OK. git diff --check: clean. Autoreview (Codex): scoped-clean, no findings.

Not proven: no new end-to-end update cell on this head; macOS and Windows Doctor traces were not replayed (the collector is platform-independent).

…stic

Each Doctor step now traces a doctor.pending.<step> decision. The update's
section-timing collector counted those zero-length entries as timed
sections, so they filled the bounded "Doctor sections" line and cut off the
late sections and the slowest contributions. The collector now skips
pending decisions; the startup trace itself is unchanged.
@clawsweeper

clawsweeper Bot commented Nov 27, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. labels Nov 27, 2026
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) November 27, 2026 01:50
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR excludes Doctor pending decisions from update timing summaries while preserving operator-enabled traces.

Example: A captured Linux first-update trace contains 153 Doctor lines, including 73 pending decisions.

  • Before: The diagnostic reaches 1024 characters and loses later sections and the slowest contributions.
  • After: The supplied collector replay produces a complete 690-character diagnostic without pending entries.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused implementation with useful regression coverage, but limited real-behavior validation.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators lose later Doctor timings and the slowest contributions from bounded update reports.
Reason: This restores the established timing-report contract, and the maintainer-authored direction requires no further product decision.

Regression provenance

Regression provenance — verified: source commit d0f769895093 by Jason (Json); canonical PR #206152 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep open: current main still admits pending decisions into timing diagnostics, and this PR makes a focused correction with no blocking code findings.

Reviewed head: d21fce2d59a882ca2cb5402c9ba75ab3f0bc3c00

Before merge

None.

Findings

None.

Tests

  • Suggested test cut src/infra/update-doctor-section-timing.test.ts:66-68: The pending-line count adds no observation beyond the preceding exact stderr equality.
    • With operator tracing enabled, every pending decision in the fixture remains in returned stderr. Fault: The wrapper drops one pending-decision line only when operator tracing is enabled. src/infra/update-doctor-section-timing.test.ts:65: Dropping that line changes the returned string, so exact equality fails even after the count assertion is removed. Input: src/infra/update-doctor-section-timing.test.ts:6-7, src/infra/update-doctor-section-timing.test.ts:9-19, src/infra/update-doctor-section-timing.test.ts:25-50, src/infra/update-doctor-section-timing.test.ts:64-65
  • Missing end-to-end proof: Provide a redacted published-v2026.11.10-to-fixed-candidate update capture showing complete Doctor diagnostics in the resulting report with existing settings and data intact; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Update Doctor runners stream child stderr through the timing collector, which converts startup-trace durations into bounded step diagnostics for update reports.

flowchart LR
  A[Doctor maintenance] --> B[Startup trace on stderr]
  B --> C[Update timing collector]
  C --> D[Timed sections and contributions]
  D --> E[Update step diagnostics]
  E --> F[Run record and JSON report]
Loading

Technical review

Best possible solution:

Exclude pending decisions in the existing timing collector while preserving the producer's trace and existing bounds.

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

Current-main source admits doctor.pending entries as sections, and the supplied base failure trace demonstrates the resulting truncation; no target code was executed during this review.

Is this the best way to solve the issue?

The filter repairs classification at its existing owner without raising limits, removing producer evidence, or adding another diagnostic path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Doctor timing collection keeps the original intent (77224e7: Expose Doctor section durations and the five slowest contributions to explain otherwise silent update work.)
  • Trace classification keeps the original intent (7f6a904: Remove redundant containment around private bookkeeping while retaining external trace filtering and diagnostic bounds.)
  • Pending-decision tracing keeps the original intent (d0f7698: Record read-only work decisions for future conditional Doctor maintenance without changing which steps execute.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 77224e7 adds src/infra/update-doctor-section-timing.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 77224e7672cd; files: src/infra/update-doctor-section-timing.ts)
  • Peter Steinberger: Raw commit 7f6a904 adds src/infra/update-doctor-section-timing.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7f6a90441a21; files: src/infra/update-doctor-section-timing.ts)
  • Vincent Koc: Raw commit 11091f0 adds src/infra/update-doctor-section-timing.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 11091f0bf62f; files: src/infra/update-doctor-section-timing.ts)
  • Jason (Json): Raw commit d0f7698 adds src/commands/doctor-maintenance-pending.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d0f769895093; files: src/commands/doctor-maintenance-pending.ts)

PR surface

Source +3, Tests +77. Total +80 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 77 0 +77
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 81 1 +80

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.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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.

Reviewed November 26, 2026, 9:00 PM ET / November 27, 2026, 02:00 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 370ed12 into openclaw:main Nov 27, 2026
127 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/doctor-sections-diagnostic-pending branch November 27, 2026 02:06
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
)

* fix(update): keep Doctor pending decisions out of the sections diagnostic

Each Doctor step now traces a doctor.pending.<step> decision. The update's
section-timing collector counted those zero-length entries as timed
sections, so they filled the bounded "Doctor sections" line and cut off the
late sections and the slowest contributions. The collector now skips
pending decisions; the startup trace itself is unchanged.

* test(update): type the Doctor sections replay helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

1 participant