Repository navigation
improve(cli): attribute startup phases in diagnostics - #117702
Conversation
41c6c32 to
5fb33c2
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 8:31 PM ET / August 2, 2026, 00:31 UTC. ClawSweeper reviewWhat this changesThe 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 readinessKeep this PR open for ordinary maintainer review. Current Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’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
Before merge
Agent review detailsSecurityNone. PR surfaceSource +226, Tests +101. Total +327 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
5fb33c2 to
22185db
Compare
|
Merged via squash.
|
What Problem This Solves
Kova can measure local agent startup, but most pre-provider time is currently unattributed. On exact
mainat4153451a9a1d2cab1040e548cb33033179c51e64, 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
routeorparsespans were emitted as startup attributionnode scripts/run-vitest.mjs src/cli/startup-trace.test.ts src/entry.run-main.test.ts src/cli/run-main.test.ts src/infra/diagnostics-timeline.test.ts./node_modules/.bin/oxfmt --check src/cli/startup-trace.ts src/cli/startup-trace.test.tsgit diff --checkThe broad changed-file/lint route could not complete locally because Testbox routing is unavailable and current
mainhas an unrelated plugin-SDK declaration failure inpackages/terminal-core/src/ansi.ts:194.