Skip to content

improve(cli): attribute startup phases in diagnostics - #117702

Merged
vincentkoc merged 1 commit into
mainfrom
perf/agent-cli-bootstrap-trace
Aug 2, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/agent-cli-bootstrap-trace

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Kova can measure local agent startup, but most pre-provider time is currently unattributed. On exact main at 4153451a9a1d2cab1040e548cb33033179c51e64, the mock lane attributed about 0.2s of roughly 3.2s, leaving about 3.0s opaque per cold or warm CLI process.

Why This Change Was Made

The existing entry and CLI startup tracer already owns the relevant phase boundaries. This change also emits those marks and measured phases into the canonical diagnostics timeline when timeline diagnostics are enabled. Normal startup remains on the existing path and does not import the timeline module.

User Impact

No user-visible behavior changes. Maintainers and performance tooling can attribute entry import, route, command registration, program construction, and parse time before choosing a runtime optimization.

Evidence

The broad changed-file/lint route could not complete locally because Testbox routing is unavailable and current main has an unrelated plugin-SDK declaration failure in packages/terminal-core/src/ansi.ts:194.

@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 1, 2026 23:55
@vincentkoc
vincentkoc force-pushed the perf/agent-cli-bootstrap-trace branch 2 times, most recently from 41c6c32 to 5fb33c2 Compare August 2, 2026 00:07
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 8:31 PM ET / August 2, 2026, 00:31 UTC.

ClawSweeper review

What this changes

The branch buffers CLI entry and command-registration startup marks until diagnostics configuration is known, then writes those phases into the existing JSONL diagnostics timeline while excluding command execution spans.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for ordinary maintainer review. Current main still has stderr-only startup tracing and does not contain the PR head; the revised patch routes early CLI startup phases into the existing diagnostics timeline without changing normal startup behavior, and this review found no discrete correctness or security defect.

Priority: P2
Reviewed head: 22185db98fa692a5791c57ffab34686ff38f599c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, contract-aligned, and covered by targeted tests plus reported exact-head diagnostics evidence, with no correctness finding in this review.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies exact-head Kova evidence and focused test results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies exact-head Kova evidence and focused test results.
Evidence reviewed 6 items Current main does not yet implement timeline attribution: Current main’s startup tracer only formats and writes stderr trace messages; it has no diagnostics-timeline import, activation state, or event emission. The PR head is not an ancestor of current main.
Activation follows the existing diagnostics contract: The proposed tracer loads the timeline module only when an output path exists, resolves activation from the existing diagnostics flags, buffers early events while config is unknown, and emits only after the existing enablement check succeeds.
Config-enabled diagnostics is handled for both startup tracers: The CLI dispatcher collects its own and entry-wrapper tracers, reads the existing best-effort config only when needed, and configures both before command routing; execution-owning route and parse measurements are explicitly excluded from startup attribution.
Findings None None.
Security None None.

How this fits together

OpenClaw’s entry wrapper and CLI dispatcher measure early process work before a command runs. The diagnostics timeline is an optional JSONL stream used by performance tooling, so the change connects existing startup measurements to that stream only when timeline diagnostics are enabled.

flowchart LR
  A[CLI process starts] --> B[Entry startup tracer]
  B --> C[CLI dispatcher]
  C --> D[Read diagnostics configuration]
  D --> E{Timeline enabled?}
  E -->|Yes| F[Emit startup timeline events]
  E -->|No| G[Normal CLI execution]
  F --> G
Loading

Before merge

  • Complete next step (P2) - The author is a repository member and the PR carries the protected maintainer label, so the remaining action is ordinary human review rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +226, Tests +101. Total +327 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 237 11 +226
Tests 1 101 0 +101
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 338 11 +327

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/cli/startup-trace.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain the existing diagnostics activation contract and merge this focused attribution path after normal maintainer review of the exact merge head.

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

Not applicable: this PR improves optional diagnostics attribution rather than repairing a reported user-facing failure. The changed behavior has focused source-level coverage for both environment and existing config activation.

Is this the best way to solve the issue?

Yes. The patch reuses the existing startup tracer, diagnostics enablement contract, and timeline writer instead of creating a second diagnostics path; it also avoids classifying route and parse command execution as startup work.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded maintainer-diagnostics improvement with no reported change to ordinary CLI behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; the PR body nevertheless supplies exact-head Kova evidence and focused test results.

Evidence

What I checked:

  • Current main does not yet implement timeline attribution: Current main’s startup tracer only formats and writes stderr trace messages; it has no diagnostics-timeline import, activation state, or event emission. The PR head is not an ancestor of current main. (src/cli/startup-trace.ts:8, 0e496843a8d4)
  • Activation follows the existing diagnostics contract: The proposed tracer loads the timeline module only when an output path exists, resolves activation from the existing diagnostics flags, buffers early events while config is unknown, and emits only after the existing enablement check succeeds. (src/cli/startup-trace.ts:53, 22185db98fa6)
  • Config-enabled diagnostics is handled for both startup tracers: The CLI dispatcher collects its own and entry-wrapper tracers, reads the existing best-effort config only when needed, and configures both before command routing; execution-owning route and parse measurements are explicitly excluded from startup attribution. (src/cli/run-main.ts:1195, 22185db98fa6)
  • Focused regression coverage covers environment and config activation: The added tests assert emitted entry marks and spans with environment activation, suppress command-execution attribution, and flush buffered phases when the existing config diagnostics flag enables the timeline. (src/cli/startup-trace.test.ts:21, 22185db98fa6)
  • Feature-history ownership: The current startup-trace and diagnostics-timeline baseline lines blame to the same earlier local-history commit by Vincent Koc; the proposed change extends that existing owner-boundary rather than introducing a parallel diagnostics path. (src/cli/startup-trace.ts:46, c4a9f59798d2)
  • Patch hygiene: The exact PR diff has no whitespace errors; its production changes are limited to CLI tracing, CLI orchestration, and the shared diagnostics timeline, plus one focused test file. (src/cli/startup-trace.ts:1, 22185db98fa6)

Likely related people:

  • Vincent Koc: Current-main blame for both the startup tracer and diagnostics timeline baseline resolves to this author’s local-history commit, and the PR extends those same files. (role: feature owner and recent area contributor; confidence: high; commits: c4a9f59798d2, 22185db98fa6; files: src/cli/startup-trace.ts, src/infra/diagnostics-timeline.ts, src/cli/run-main.ts)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-02T00:13:11.014Z sha 5fb33c2b76b08d934c73e911f6192fdc9d74ad87 :: needs changes before merge. :: [P1] Honor config-enabled timeline diagnostics
  • reviewed 2026-08-02T00:21:45.238Z sha 22185db :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the perf/agent-cli-bootstrap-trace branch from 5fb33c2 to 22185db Compare August 2, 2026 00:16
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 2, 2026
@vincentkoc
vincentkoc merged commit c1ee660 into main Aug 2, 2026
134 of 142 checks passed
@vincentkoc
vincentkoc deleted the perf/agent-cli-bootstrap-trace branch August 2, 2026 00:32
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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