Skip to content

docs(diagnostics): clarify whole-process CPU metrics - #138804

Merged
steipete merged 1 commit into
mainfrom
codex/clarify-process-cpu-metrics
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/clarify-process-cpu-metrics

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Operators can mistake the diagnostic CPU core ratio for main-thread utilization or a percentage capped at 100%. The existing metric measures CPU time across the whole process, including worker and native threads.

Why This Change Was Made

Clarify the Prometheus HELP text and OpenTelemetry description, with a shared health-guide explanation of core equivalents and values above one. Phase diagnostics also explain that concurrent work contributes to their process CPU totals.

Node's CPU usage contract and the existing diagnostic producers establish these semantics. Metric names, fields, measurements, thresholds, readiness behavior, and configuration stay unchanged. The production diff is description text only (+3/-2 lines, including formatting); documentation is +32/-1.

User Impact

Operators can distinguish whole-process CPU pressure from measured main-thread delay when reading metrics and health snapshots. A CPU degradation reason alone does not attribute CPU to a thread or prove a main-thread hang.

Evidence

  • Existing Prometheus and OpenTelemetry liveness-warning tests passed (2 selected tests), including export of a CPU ratio of 1.4.
  • MDX validation passed all 752 files; formatting and git diff --check passed.
  • Independent Codex review found no actionable P0–P2 issues.
  • The full anchor audit reported 12 existing broken links in ClawHub's plugin-validation-fixes.md, targeting unchanged manifest/SDK pages; no changed-page link failed.
  • The first remote changed-check attempt refused an unexpected source file before running checks and closed its Testbox lease. The supported local changed-file gate then passed all selected checks, including plugin production/test types, lint, owner tests, and static guards.

No runtime behavior changed, so the existing exporter tests and source contract review cover this wording repair; no additional production CPU workload was run.

Explain that diagnostic CPU ratios include worker and native threads,
use core equivalents, and can exceed one. Distinguish process pressure
from main-thread delay without changing measurements or readiness.
@clawsweeper

clawsweeper Bot commented Sep 5, 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.

@steipete steipete self-assigned this Sep 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel extensions: diagnostics-prometheus size: XS maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 10:59 PM ET / September 5, 2026, 02:59 UTC.

ClawSweeper review

What this changes

Clarifies that diagnostic CPU ratios measure whole-process CPU usage, including worker and native threads, in documentation and exporter descriptions.

Merge readiness

✅ Ready for maintainer review

Keep open. The clarification remains useful and is absent from fetched main and the latest release’s health guide. No actionable correctness or security defects were found.

Priority: P3
Reviewed head: 9ab68ee2ef2342425399348f27a80328693380e6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused clarification supported by producer contracts and existing exporter coverage, with no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer association exempts this wording-only change from contributor runtime proof; existing exporter tests are supplemental, and no live CPU workload was claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer association exempts this wording-only change from contributor runtime proof; existing exporter tests are supplemental, and no live CPU workload was claimed.
Evidence reviewed 9 items Introduced scope: The pinned introduction changes documentation and two metric-description strings. Metric names, units, buckets, values, configuration, and control flow remain unchanged; git diff --check passed.
CPU producers and dependency boundary: The health monitor divides process.cpuUsage user-plus-system milliseconds by elapsed wall milliseconds. Phase timing in src/logging/diagnostic-phase.ts uses the same process API around awaited work, supporting the concurrent-work caveat. These claims depend on Node’s CPU contract, not Codex.
Direct Node contract inspection: Locally installed @types/node 24.13.3 identifies this repository in package metadata. Its process.cpuUsage documentation specifies process-wide user/system microseconds and explicitly permits totals exceeding elapsed time when multiple cores work; threadCpuUsage is separately documented as thread-specific.
Findings None None.
Security None None.

How this fits together

Gateway diagnostics combine process CPU timing with separate event-loop measurements. Readiness snapshots and telemetry exporters expose these observations to operators.

flowchart LR
  A[Process CPU time] --> C[Diagnostic sampling]
  B[Wall time and event-loop measurements] --> C
  C --> D[Readiness diagnostics]
  C --> E[Prometheus and OpenTelemetry]
  D --> F[Operator interpretation]
  E --> F
  G[Health guide and metric descriptions] --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Docs +31. Total +32 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 2 +1
Tests 0 0 0 0
Docs 4 32 1 +31
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 35 3 +32

Review metrics

Metric Value Why it matters
Production versus test LOC Production net +1; tests 0; documentation net +31 Production growth is solely line wrapping of description text, with no executable logic added.

Technical review

Best possible solution:

Use the health guide as the shared semantic reference, with matching exporter descriptions that preserve established measurements.

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

Not applicable: this clarifies existing measurement semantics rather than repairing a runtime failure; source and existing exporter tests support the explanation.

Is this the best way to solve the issue?

Yes. Updating the existing descriptions resolves the ambiguity directly; changing measurement behavior or adding per-thread metrics would unnecessarily expand the scope.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c748cd5714b8.

Labels

Label changes:

  • add P3: This improves diagnostic interpretation without changing runtime behavior or configuration.
  • 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: The supplied maintainer association exempts this wording-only change from contributor runtime proof; existing exporter tests are supplemental, and no live CPU workload was claimed.

Label justifications:

  • P3: This improves diagnostic interpretation without changing runtime behavior or configuration.
  • 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: The supplied maintainer association exempts this wording-only change from contributor runtime proof; existing exporter tests are supplemental, and no live CPU workload was claimed.

Evidence

What I checked:

  • Introduced scope: The pinned introduction changes documentation and two metric-description strings. Metric names, units, buckets, values, configuration, and control flow remain unchanged; git diff --check passed. (extensions/diagnostics-otel/src/service-metrics.ts:309, 9ab68ee2ef23)
  • CPU producers and dependency boundary: The health monitor divides process.cpuUsage user-plus-system milliseconds by elapsed wall milliseconds. Phase timing in src/logging/diagnostic-phase.ts uses the same process API around awaited work, supporting the concurrent-work caveat. These claims depend on Node’s CPU contract, not Codex. (src/gateway/server/event-loop-health.ts:145, 9ab68ee2ef23)
  • Direct Node contract inspection: Locally installed @types/node 24.13.3 identifies this repository in package metadata. Its process.cpuUsage documentation specifies process-wide user/system microseconds and explicitly permits totals exceeding elapsed time when multiple cores work; threadCpuUsage is separately documented as thread-specific. (types/node/process.d.ts:1593)
  • Event-loop contract: The installed perf_hooks documentation distinguishes event-loop utilization from CPU usage and explains that monitorEventLoopDelay measures timer delays in the event loop. (types/node/perf_hooks.d.ts:842)
  • Readiness and liveness integration: Readiness appends eventLoop without changing ready; readiness.test.ts explicitly covers this. The health monitor requires delay co-evidence for CPU degradation, and server-lifecycle.ts feeds its persistent samples into liveness diagnostics. (src/gateway/server/readiness.ts:183, 9ab68ee2ef23)
  • Exporter coverage: Existing Prometheus and OpenTelemetry liveness tests explicitly preserve a CPU ratio of 1.4. The Prometheus store renders the changed string as HELP text; OpenTelemetry passes its description through the existing histogram factory. Tests were inspected, not executed. (extensions/diagnostics-prometheus/src/service.test.ts:414, 9ab68ee2ef23)

Likely related people:

  • 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 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Validated the six-file candidate at 9ab68ee2ef2342425399348f27a80328693380e6. The metric producer uses whole-process process.cpuUsage() divided by elapsed wall time. The repair changes the two exporter descriptions and links the four owning docs to one shared interpretation; names, values, labels, buckets, thresholds, readiness, and configuration are unchanged. Reversing only the two description edits restores byte-identical production files.

The exact local commands passed:

node --import ./scripts/tsx.mjs scripts/test-projects.mts extensions/diagnostics-prometheus/src/service.test.ts extensions/diagnostics-otel/src/service.test.ts -t 'liveness warning'
node scripts/check-docs-mdx.mjs docs README.md
node scripts/check-changed.mjs -- docs/gateway/health.md docs/gateway/diagnostics.md docs/gateway/prometheus.md docs/gateway/opentelemetry.md extensions/diagnostics-prometheus/src/service.ts extensions/diagnostics-otel/src/service-metrics.ts

The two selected exporter tests retain a CPU ratio of 1.4, MDX checked 752 files, and the supported local changed-file gate passed all selected guards. Independent P0–P2 review was clean. Production LOC is +3/-2 (description strings and wrapping), test LOC is unchanged, and docs are +32/-1. The six changed files and their six diagnostic producer/consumer owners have no drift between the proof base and the inspected main baseline 6e82d8aa095.

Proof limits remain explicit: the first Testbox attempt refused an unexpected source entry before running any checks; its lease is closed and no remote pass is claimed. The full anchor audit found 12 preexisting ClawHub links to unchanged manifest/SDK pages and no failing changed-page links. This wording-only repair does not claim a production performance improvement or thread-level CPU attribution.

Current-head CI run 33940357329 completed successfully. ClawSweeper reviewed this same head with no findings and no before-merge actions. The live PR rollup is 99 successful and 54 skipped checks, with a clean merge state.

@steipete
steipete merged commit 1b95161 into main Sep 5, 2026
153 checks passed
@steipete
steipete deleted the codex/clarify-process-cpu-metrics branch September 5, 2026 03:06
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
Explain that diagnostic CPU ratios include worker and native threads,
use core equivalents, and can exceed one. Distinguish process pressure
from main-thread delay without changing measurements or readiness.
vincentkoc added a commit to LiuwqGit/openclaw that referenced this pull request Sep 5, 2026
* refs/remotes/origin/main: (602 commits)
  fix(plugins): trace trust refusals and repair legacy provenance (openclaw#138746)
  perf(sqlite): reuse compiled plugin state point reads (openclaw#138758)
  refactor: type chat prefetch dependencies and clean loading tests (openclaw#138793)
  ci: reduce Doctor test startup and core lint jobs (openclaw#138796)
  feat(update): retain run history and share outcome reports (openclaw#138690)
  chore(deps): update @openclaw/fs-safe to 0.8.1 (openclaw#138500)
  fix: preserve global board ownership from pinning to notifications (openclaw#138675)
  fix(gateway): deliver session catalog updates from slow hosts (openclaw#138674)
  perf(sessions): index pending conversation replies (openclaw#127182)
  perf(auth): reuse ordered provider alias entries (openclaw#138805)
  docs(diagnostics): clarify whole-process CPU metrics (openclaw#138804)
  perf(memory): narrow source reads and stream embedding cache rows (openclaw#138766)
  fix: allow older source on newer Testbox checkouts (openclaw#138782)
  fix(agents): preserve recovered task progress and lifecycle ownership (openclaw#138785)
  perf(codex): reduce rollout tail scan CPU (openclaw#138784)
  perf(gateway): stop projecting history deltas at the byte budget (openclaw#138655)
  fix(build): bound native declaration inputs to checkout (openclaw#138742)
  fix(cli): preserve foreground Gateway argument handling (openclaw#138765)
  fix(ui): align task toolbar with side-panel tabs (openclaw#138769)
  fix(logbook): drain accepted work before closing SQLite (openclaw#138754)
  ...

# Conflicts:
#	src/agents/embedded-agent-runner/compact.queued.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: diagnostics-otel Extension: diagnostics-otel extensions: diagnostics-prometheus gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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