Skip to content

improve(tests): reuse PowerShell completion process - #118381

Merged
steipete merged 1 commit into
mainfrom
codex/test-perf-completion-batch
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-perf-completion-batch

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The completion CLI tests launched a fresh PowerShell process for every live completion assertion. The two owner files made 48 real pwsh startups even though each case only needed a clean native completer inside the same shell runtime.

Why This Change Was Made

Use one explicit PowerShell runner per test file, serialize versioned base64-framed requests, and remove/re-register the openclaw completer before and after every case. Every generated script still comes from the production completion owner and every assertion still executes real PowerShell CommandCompletion. The two files remain in their existing isolated lanes; sharding and concurrency are unchanged.

User Impact

No runtime or user-visible behavior changes. Real-shell completion coverage finishes much faster with deterministic per-case diagnostics and strict timeout/exit handling.

Evidence

  • Real PowerShell startups: 48 -> 2.
  • Combined wrapper: 34.72s -> 10.74s (69.1% faster); real wall: 34.88s -> 10.91s.
  • Primary CLI file: 24.69s -> 3.72s; alias file: 3.67s -> 1.36s.
  • Max RSS: 439.8MB -> 337.6MB.
  • All 108 completion siblings pass; every live shell assertion is retained.
  • Formatting, typed targeted lint, git diff --check, and autoreview are clean.
  • Test-only diff: +355/-66; production LOC delta: 0.

Exact rebased real-shell proof

Exact head 337628b20827a4d83097a31ea0f4ef511b94511f:

  • src/cli/completion-cli.aliases.test.ts: 11 passed, including five real PowerShell alias requests; the persistent runner exited cleanly in afterAll.
  • src/cli/completion-cli.test.ts: 84 passed, including every real PowerShell value, quoting, injection-safety, nested-path, and option-form assertion; the persistent runner exited cleanly in afterAll.
  • Combined wrapper: 10.47s.
  • Final branch autoreview: clean.
  • Installed pwsh probe: Register-ArgumentCompleter -Native -CommandName openclaw -ScriptBlock $null printed OK and exited 0.
  • Upstream contract: PowerShell marks ScriptBlock [AllowNull] and removes the completer key when the value is null in ExtensibleCompletion.cs and its SetKeyValue helper.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete steipete self-assigned this Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR changes CLI completion tests to send serialized requests through one persistent PowerShell process per test file instead of launching PowerShell for every assertion.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal maintainer merge handling. Current main still starts a fresh PowerShell process for each completion assertion, while this branch replaces that repeated startup with a per-file queued runner, retains real CommandCompletion assertions, and includes exact-head real-shell results; no concrete patch defect was found in the inspected diff.

Priority: P3
Reviewed head: 337628b20827a4d83097a31ea0f4ef511b94511f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused test-only patch has credible exact-head real-shell proof and a coherent lifecycle design, with remaining confidence dependent on the in-progress exact-head automation.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.
Evidence reviewed 5 items Current-main baseline: Current main still calls spawnSync with PowerShell for each generated completion request, so the PR's central test-performance problem remains necessary.
Scoped runner implementation: The PR introduces one queued runner per test file, frames requests and responses, fails pending requests on process errors, and verifies clean shutdown in afterAll.
Retained real-shell coverage: The converted assertions still generate each production PowerShell completion script and await real completion results for values, quoting, nested paths, aliases, and option forms.
Findings None None.
Security None None.

How this fits together

OpenClaw generates shell-completion scripts from each CLI command tree, and the test harness runs those scripts through real PowerShell completion APIs. This PR changes only the test-side process lifecycle between generated completion scripts and assertion results.

flowchart LR
  A[Completion test cases] --> B[Per-file request queue]
  B --> C[Persistent PowerShell process]
  C --> D[Generated completion script]
  D --> E[Framed completion results]
  E --> F[Assertions and clean shutdown]
Loading

Before merge

  • Resolve merge risk (P2) - A long-lived child process changes test-worker lifecycle behavior; wait for the remaining exact-head process and artifact checks before merging, even though the runner has explicit queueing, timeout, failure, and shutdown paths.
  • Resolve merge risk (P1) - Independent local PowerShell contract verification was blocked because this read-only environment cannot create PowerShell's cache directory, and GitHub DNS was unavailable for fetching the linked upstream source; the review therefore relies on the PR's exact-head proof and linked upstream contract evidence for null completer cleanup.
  • Complete next step (P2) - No repair lane is needed: this maintainer-labeled PR has no supported code finding, but its new persistent test-process lifecycle should finish exact-head automation before normal human merge handling.
Agent review details

Security

None.

PR surface

Source +261, Tests +28. Total +289 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 286 25 +261
Tests 2 69 41 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 355 66 +289

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +355/-66 The added code is confined to the completion-test harness and has a stated performance and process-ownership purpose, rather than expanding shipped runtime behavior.

Merge-risk options

Maintainer options:

  1. Complete exact-head automation first (recommended)
    Wait for the remaining process-execution and artifact checks on the current head before merging the new persistent test-process lifecycle.
  2. Accept the bounded harness risk
    Merge based on the submitted real-shell proof if maintainers accept the remaining CI lifecycle verification risk.

Technical review

Best possible solution:

Keep the generated-script and real CommandCompletion assertions, merge the per-file runner only after the exact-head automation completes, and retain its explicit cleanup and failure diagnostics as the sole PowerShell test path.

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

Not applicable as a user-facing bug: the requested outcome is a faster real-shell test harness. The PR body provides a concrete exact-head PowerShell run and timing comparison for the changed test behavior.

Is this the best way to solve the issue?

Yes. A single process per isolated test file preserves separate test-file lanes while avoiding the repeated startup cost; the queue and per-request re-registration make this a more maintainable approach than parallel ad hoc shell invocations.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is a test-performance and ergonomics improvement with no claimed runtime or user-visible behavior change.
  • merge-risk: 🚨 automation: The patch changes PowerShell process reuse, timeouts, request framing, and cleanup within the automated completion-test path.
  • 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. Sufficient (terminal): The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head real PowerShell completion results, retained assertion coverage, clean runner shutdown, and measured before/after timing; the provided checks also show a successful Real behavior proof job.

Evidence

What I checked:

  • Current-main baseline: Current main still calls spawnSync with PowerShell for each generated completion request, so the PR's central test-performance problem remains necessary. (src/cli/completion-cli.test-support.ts:112, d7ab20a72773)
  • Scoped runner implementation: The PR introduces one queued runner per test file, frames requests and responses, fails pending requests on process errors, and verifies clean shutdown in afterAll. (src/cli/completion-cli.test-support.ts:194, 337628b20827)
  • Retained real-shell coverage: The converted assertions still generate each production PowerShell completion script and await real completion results for values, quoting, nested paths, aliases, and option forms. (src/cli/completion-cli.test.ts:248, 337628b20827)
  • Feature provenance: The existing PowerShell completion helper and surrounding CLI completion work trace to the recent CLI reliability change, and current-main blame attributes the original per-invocation helper to Peter Steinberger. (src/cli/completion-cli.test-support.ts:105, 433bb3f954ed)
  • Submitted exact-head behavior proof: The PR body reports exact-head real PowerShell runs for both owner files, retained live assertions, clean afterAll shutdown, and a combined wrapper time of 10.47 seconds; the provided check context also records a successful Real behavior proof job. (337628b20827)

Likely related people:

  • steipete: Current-main blame attributes the original PowerShell helper to Peter Steinberger, and the history search ties the broader CLI completion reliability work to the same author. (role: CLI completion feature owner and recent area contributor; confidence: high; commits: 433bb3f954ed, 59cd041c37a9; files: src/cli/completion-cli.test-support.ts, src/cli/completion-cli.test.ts, src/cli/completion-cli.aliases.test.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 (1 earlier review cycle)
  • reviewed 2026-08-03T02:36:24.333Z sha 1a11169 :: needs real behavior proof before merge. :: [P2] Remove the null ScriptBlock registration calls

@steipete
steipete force-pushed the codex/test-perf-completion-batch branch from 1a11169 to 337628b Compare August 3, 2026 05:52
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 3, 2026
@steipete
steipete merged commit 6f6d501 into main Aug 3, 2026
103 of 115 checks passed
@steipete
steipete deleted the codex/test-perf-completion-batch branch August 3, 2026 06:03
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor 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 merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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