Skip to content

test(cli): stabilize entry failure output assertion - #127048

Closed
RomneyDa wants to merge 0 commit into
mainfrom
fix/entry-run-main-output-test
Closed

RomneyDa wants to merge 0 commit into
mainfrom
fix/entry-run-main-output-test

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

Summary

  • establish the production console-capture owner before the entry failure-output spy
  • keep the expected-condition assertion independent of prior test-file logging state

Root cause

runMainOrRootHelp enables console capture on its error path. The test installed its
console.error spy first, so a worker where another test had reset
loggingState.consolePatched allowed the production capture call to replace that spy.
The operator-visible message was still emitted, but the assertion observed no call.

The owner boundary is console capture. Initializing that owner before observing its
public console.error surface makes the test stable in either fresh or already-patched
workers without changing production behavior.

Observed twice in checks-node-compact-large-3 on #127002; the log showed the expected
message immediately before the empty-spy assertion failure.

Proof

  • pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts — 4 consecutive passes, 8/8 tests
  • pnpm exec oxfmt --check src/entry.run-main.test.ts
  • git diff --check
  • autoreview: clean, correctness 0.99, no actionable findings

Production LOC delta: 0. Test LOC delta: +4/-0.

No production paths, contracts, or behavior changed.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@RomneyDa

Copy link
Copy Markdown
Member Author

Exact-head rank-up evidence for 3e21b5740e928d9634faa5f00ee6a516c23b581b:

  • Original shared-order reproduction: the same checks-node-compact-large-3 shard failed twice on fix(ci): support frozen target tooling #127002 while visibly emitting the expected operator message but recording an empty console.error spy (failed shard).
  • Focused repaired-owner proof: pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts passed four consecutive runs (8/8 tests).
  • Original-order CI proof: the exact same checks-node-compact-large-3 shard passed on this exact head (passing shard).
  • Exact-head full CI is terminal green; openclaw/ci-gate passed (gate).
  • Production LOC remains +0/-0; test LOC +4/-0. No product, runtime, config, dependency, or public-contract change.
  • The completed exact review artifact reports no findings, no maintainer decision, high-confidence source reproduction, and names this owner-ordering fix as the best possible solution.

No code changes were made for rating. @clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 1:58 AM ET / 05:58 UTC.

ClawSweeper review

What this changes

The PR initializes console capture before a console.error spy so the CLI entry failure-output test remains stable when test workers reuse logging state.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking findings. This maintainer-authored, test-only patch correctly initializes the process-wide console-capture owner before observing its console.error surface; keep it open for exact-head CI.

Priority: P3
Reviewed head: 3e21b5740e928d9634faa5f00ee6a516c23b581b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused owner-boundary setup and reported repeat test passes support a normal good test-only repair.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR does not require external real-behavior proof; its body records focused passing test output.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR does not require external real-behavior proof; its body records focused passing test output.
Evidence reviewed 6 items Focused PR diff: The branch changes only the entry failure-output test: it imports the existing logging facade and initializes capture before installing the spy; production files are unchanged.
Current-main entry behavior: The unchanged entry error handler enables capture before it formats and emits each failure line through console.error.
Console-capture owner contract: When the shared patch flag is false, the capture owner records current console methods and replaces console.error with its forwarding wrapper; initializing it before an observer avoids that lifecycle interaction.
Findings None None.
Security None None.

Live Verification

Command: pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts

Result: FAIL (partial) — step 2 expect_output Tests 2 passed: expected terminal output was not visible within 30 seconds: "Tests 2 passed"

pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127048-cw41Rd/target$ pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.te
st.ts
pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127048-cw41Rd/target

 ✓  unit-src  src/entry.run-main.test.ts (2 tests) 1542ms
     ✓ keeps expected conditions at exit 1 without crash framing  1444ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  05:59:30
   Duration  3.05s (transform 2.38s, setup 933ms, import 268ms, tests 1.54s, environment 0ms)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-127048-cw41Rd/target$ pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.te
st.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127048-cw41Rd/target

 ✓  unit-src  src/entry.run-main.test.ts (2 tests) 759ms
     ✓ keeps expected conditions at exit 1 without crash framing  711ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  05:59:40
   Duration  1.53s (transform 810ms, setup 449ms, import 128ms, tests 759ms, environment 0ms)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-127048-cw41Rd/target$






















Assertions:

  • FAIL expect_output: Tests 2 passed

How this fits together

The CLI entry point runs commands and formats failures; its error handler enables process-wide console capture before writing user-facing error lines. This test observes that output while simulating an expected CLI error.

flowchart LR
A[CLI command argv] --> B[CLI entry point]
B --> C[Command runner]
C --> D[Expected CLI error]
D --> E[Entry error handler]
E --> F[Console capture]
F --> G[User-facing error output]
H[Entry-point test] --> F
H --> G
Loading

Before merge

  • Complete next step (P2) - No repair work is needed; there are no actionable findings, and exact-head CI should complete before merge.
Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 1 file.

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

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0, tests +4/-0 The change only establishes existing logging state before the assertion; it does not alter a shipped CLI path.

Technical review

Best possible solution:

Keep console capture as the producer-owned setup and install the test observer only after that setup, preserving the existing CLI failure contract.

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

Yes—source establishes the lifecycle interaction: console capture may replace console methods when its shared patch state is reset, while the old test installed its observer first.

Is this the best way to solve the issue?

Yes—the best fix is to establish the real console owner before observing it; resetting global state or changing production capture timing would be more brittle or alter unrelated behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a contained test-stability repair with no user-facing behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a contained test-stability repair with no user-facing behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Focused PR diff: The branch changes only the entry failure-output test: it imports the existing logging facade and initializes capture before installing the spy; production files are unchanged. (src/entry.run-main.test.ts:4, 3e21b5740e92)
  • Current-main entry behavior: The unchanged entry error handler enables capture before it formats and emits each failure line through console.error. (src/entry.ts:315, 0e75204f0505)
  • Console-capture owner contract: When the shared patch flag is false, the capture owner records current console methods and replaces console.error with its forwarding wrapper; initializing it before an observer avoids that lifecycle interaction. (src/logging/console.ts:253, 0e75204f0505)
  • Sibling shared-state coverage: The console-capture suite explicitly snapshots console methods and resets loggingState.consolePatched, establishing the reused-worker state that this test must tolerate. (src/logging/console-capture.test.ts:33, 0e75204f0505)
  • Focused test routing: The claimed focused command selects all src/**/*.test.ts, including this file, in the unit-src Vitest project. (test/vitest/vitest.unit-src.config.ts:6, 0e75204f0505)
  • Feature-history routing: Recent CLI failure-output and console-capture work is attributable to Peter Steinberger; the current review-tree snapshot’s flat blame does not preserve more granular line provenance. (src/entry.ts:315, 6c66f48a7c11)

Likely related people:

  • Peter Steinberger: Recent merged history includes the CLI JSON failure contract and console-capture maintenance that own the lifecycle exercised here. (role: recent CLI failure-output and logging contributor; confidence: medium; commits: 6c66f48a7c11, d29a25e987f7; files: src/entry.ts, src/logging/console.ts)
  • Vincent Koc: The entry path under test is wrapped by CLI exit finalization, an adjacent behavior maintained in this history. (role: recent CLI finalization contributor; confidence: medium; commits: 3b3a64c32208; files: src/entry.ts, src/cli/one-shot-exit.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.

@RomneyDa

Copy link
Copy Markdown
Member Author

Reconciled against current main (782a7d7aed45ff708565374a403295e402ebf1fd). The exact functional repair is already present there via 32fb2fc766f8ecfee34299e367daf96b20318db6 / #127080, so the duplicate commit was dropped rather than preserving a second implementation. Focused proof on the reconciled source branch: pnpm exec vitest run --config test/vitest/vitest.unit-src.config.ts src/entry.run-main.test.ts (2/2 passed). The source branch now matches main; no product diff remains.

@RomneyDa RomneyDa closed this Aug 21, 2026
@RomneyDa
RomneyDa force-pushed the fix/entry-run-main-output-test branch from 3e21b57 to 782a7d7 Compare August 21, 2026 09:22
@vincentkoc
vincentkoc deleted the fix/entry-run-main-output-test branch September 25, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant