Skip to content

fix(cpu): account late-discovered session processes - #112

Merged
RomneyDa merged 1 commit into
mainfrom
fix/linux-cpu-late-session-process-baseline
Sep 8, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/linux-cpu-late-session-process-baseline

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

  • distinguish product processes that predate a measurement session from processes born during it
  • use complete Linux lifetime counters for a session-born process discovered after a later role lookup
  • preserve fail-closed behavior for truly preexisting product processes without a baseline

Why

OpenClaw 2026.7.33 performance validation twice produced a single blocked repeat while all product CPU/RSS budgets passed. The resource sampler began before ocm service start, but the Gateway PID became discoverable several samples later. /proc/<pid>/stat proved the Gateway was born after the sampler's initial Linux clock, yet the accountant rejected it as an unbaselined historical process.

For a process born after the session baseline, its cumulative Linux CPU counters cover its complete lifetime inside the measurement session. Dividing those counters by its measured lifetime gives valid evidence without importing pre-session work.

Validation

  • npm run test:cpu-accounting — 19 passed, 8 platform skips
  • npm run check:full advanced through all CPU-accounting tests; the subsequent self-check isolation test hit an unrelated local JSON timeout on Node 24.15.0
  • git diff --check

Release evidence

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

🦞👀
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 commented Sep 7, 2026

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 7, 2026, 7:52 PM ET / 23:52 UTC.

ClawSweeper review

What this changes

The Linux CPU collector accepts processes born during sampling but discovered later, using their lifetime counters and elapsed lifetime to calculate CPU usage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 3 items remain

The reported discovery gap remains on main, so this PR is still useful. However, its lifetime averaging can incorrectly certify CPU budget compliance and needs a focused correction.

Priority: P2
Reviewed head: 9e821b3b6bf0366e97ea4b4e25c3bd7aecf9b61c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused repair with useful regression coverage, but the new arithmetic violates the qualification contract.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its supplied validation concerns the Linux CPU accountant and the original delayed Gateway discovery failure; the linked run was unavailable for inspection, so no after-fix runtime result is asserted.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its supplied validation concerns the Linux CPU accountant and the original delayed Gateway discovery failure; the linked run was unavailable for inspection, so no after-fix runtime result is asserted.
Evidence reviewed 8 items Applicable repository policy: Read the complete root AGENTS.md. It distinguishes OpenClaw product failures from Kova provisioning or evidence failures. No nested AGENTS.md files were found under the changed source/test paths, and no maintainer-notes directory was present.
Introduced lifetime denominator: Late-discovered session processes now use clock.ticks minus startTicks rather than the common sampling interval. Their resulting percentages still enter ordinary interval summaries, and coverageComplete does not track the missing temporal baseline.
Existing measurement contract: The documented contract requires common inner monotonic intervals, conservative upper/lower bounds, and BLOCKED qualification for inconclusive evidence; it explicitly separates interval evidence from lifetime averages.
Findings 1 actionable finding [P2] Preserve interval bounds for late-discovered CPU
Security None None.

How this fits together

Kova samples OpenClaw processes and their wait owners to measure product resource usage. Its CPU accountant feeds per-process and aggregate measurements into release qualification thresholds.

flowchart TD
  A[OpenClaw processes] --> B[Process discovery]
  B --> C[Linux counters and clocks]
  C --> D[CPU baseline accounting]
  D --> E[Resource summaries]
  E --> F[CPU budget evaluation]
  F --> G[Pass fail or blocked]
Loading

Before merge

  • Preserve interval bounds for late-discovered CPU (P2) - The lifetime denominator can turn an over-budget interval into a passing result. Using the added test's clocks (10s, 11s, 15s) and birth time (10.2s), a Gateway that consumes 900 ticks entirely between 11s and 15s uses 225% CPU in that interval, but this expression reports 187.5%. The collector still marks coverage complete and emits linux-process-interval-v1; checkCpuThreshold then accepts the value against 200%. Preserve conservative interval bounds and mark unresolved temporal coverage inconclusive instead of certifying a lifetime average. Add a regression through resource summarization and threshold evaluation.
  • Resolve merge risk (P1) - Release qualification could silently accept a CPU burst because the newly admitted lifetime average is smaller than the actual interval usage; mixing it with other interval measurements can also distort aggregate bounds.
  • Complete next step (P2) - Repair late-discovery CPU bounds and add qualification regressions before merge.

Findings

  • [P2] Preserve interval bounds for late-discovered CPU — src/collectors/linux-cpu.mjs:151-162
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +13/-4, tests +10/-0 The small production expansion addresses a concrete discovery failure, but its single added test does not exercise threshold qualification.

Merge-risk options

Maintainer options:

  1. Preserve conservative qualification (recommended)
    Repair late-discovery bounds and coverage tracking so missing intervals cannot become a passing release result.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve the common interval CPU contract for late-discovered processes, exclude temporally unproven work from lower bounds, and keep unresolved coverage BLOCKED; add burst and mixed-process qualification regressions without changing thresholds.

Technical review

Best possible solution:

Retain session-birth detection while admitting only conservative interval evidence, leaving unresolvable discovery gaps BLOCKED and lifetime averages diagnostic.

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

Yes, from source: main rejects delayed discovery after a process's birth, and the patch's new denominator admits a calculable false-pass case. These paths were inspected, not executed.

Is this the best way to solve the issue?

No. Session-birth detection is useful, but substituting a lifetime average violates the established interval-bound contract consumed by qualification.

Full review comments:

  • [P2] Preserve interval bounds for late-discovered CPU — src/collectors/linux-cpu.mjs:151-162
    The lifetime denominator can turn an over-budget interval into a passing result. Using the added test's clocks (10s, 11s, 15s) and birth time (10.2s), a Gateway that consumes 900 ticks entirely between 11s and 15s uses 225% CPU in that interval, but this expression reports 187.5%. The collector still marks coverage complete and emits linux-process-interval-v1; checkCpuThreshold then accepts the value against 200%. Preserve conservative interval bounds and mark unresolved temporal coverage inconclusive instead of certifying a lifetime average. Add a regression through resource summarization and threshold evaluation.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded CPU measurement repair affecting Kova validation rather than an active OpenClaw runtime outage.
  • add merge-risk: 🚨 automation: The changed measurement can cause automated release CPU qualification to pass on incomplete interval evidence.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Label justifications:

  • P2: This is a bounded CPU measurement repair affecting Kova validation rather than an active OpenClaw runtime outage.
  • merge-risk: 🚨 automation: The changed measurement can cause automated release CPU qualification to pass on incomplete interval evidence.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Evidence

Acceptance criteria:

  • [P1] npm run test:cpu-accounting.
  • [P1] npm run check:full.
  • [P1] git diff --check.

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md. It distinguishes OpenClaw product failures from Kova provisioning or evidence failures. No nested AGENTS.md files were found under the changed source/test paths, and no maintainer-notes directory was present. (AGENTS.md:1, 9e821b3b6bf0)
  • Introduced lifetime denominator: Late-discovered session processes now use clock.ticks minus startTicks rather than the common sampling interval. Their resulting percentages still enter ordinary interval summaries, and coverageComplete does not track the missing temporal baseline. (src/collectors/linux-cpu.mjs:151, 9e821b3b6bf0)
  • Existing measurement contract: The documented contract requires common inner monotonic intervals, conservative upper/lower bounds, and BLOCKED qualification for inconclusive evidence; it explicitly separates interval evidence from lifetime averages. (docs/REPORT_SCHEMA.md:1087, 9e821b3b6bf0)
  • Threshold consequence: checkCpuThreshold returns without a violation whenever the reported upper value is at or below the threshold. Thus a lifetime average below 200% can pass despite an unobserved interval exceeding 200%. (src/evaluation/violations.mjs:245, 9e821b3b6bf0)
  • Main still rejects the reported case: The pinned main implementation throws Missing CPU baseline for an unseen product process born before the previous sample. The new test covers admitting that process, but asserts a lifetime average rather than checking qualification against a burst workload. (src/collectors/linux-cpu.mjs:134, 8b30b95e12f3)
  • Collector history and release check: The collector was added by dfa25eb, authored by Peter Steinberger. Its raw parent is a945e24; the parent comparison shows the collector as a new file. No available release tag contains that commit. The requested behavior is absent from pinned main, so no implemented or shipped fix is established. (src/collectors/linux-cpu.mjs:100, dfa25ebb95c9)

Likely related people:

  • Peter Steinberger: Raw commit dfa25eb adds src/collectors/linux-cpu.mjs:95 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dfa25ebb95c9; files: src/collectors/linux-cpu.mjs)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve conservative interval bounds and unresolved-coverage handling for late discovery.
  • Add qualification regressions for delayed CPU bursts and mixed processes with different discovery times.

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.

@RomneyDa

RomneyDa commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Exact release proof is now green with the frozen target's schema-compatible fixture contract:

The previous proof run forced the newer canonical config fixture, causing the 7.33 gateway to reject agents.entries/mediaModels before measurement. That run was invalid for evaluating this CPU-accounting change.

@RomneyDa
RomneyDa merged commit 065d2ff into main Sep 8, 2026
7 checks passed
@RomneyDa
RomneyDa deleted the fix/linux-cpu-late-session-process-baseline branch September 8, 2026 01:10
steipete added a commit that referenced this pull request Sep 8, 2026
A late-discovered process could turn a 225% CPU interval into a passing
187.5% lifetime average. Preserve conservative interval bounds and block
qualification when earlier CPU evidence is missing.

Carry discovery gaps through later product-role assignment and child
counter transfers without invalidating fully observed product children
of external supervisors. Keep existing CPU thresholds unchanged.

Related: #112. Preserve @RomneyDa's session-birth discovery contribution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant