Skip to content

test(wizard): restore stdin TTY state - #113345

Merged
steipete merged 1 commit into
mainfrom
steipete/test-wizard-stdin-tty
Aug 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-wizard-stdin-tty

Conversation

@steipete

@steipete steipete commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The post-install migration wizard tests redefine the process-global process.stdin.isTTY descriptor but did not restore it. Because the wizard Vitest shard runs with isolation disabled, later suites in the same worker could inherit a test-created TTY state.

Why This Change Was Made

The suite now captures the exact incoming descriptor once and restores it after every test. If isTTY was inherited rather than an own property, teardown deletes only the property created by the test. A suite-level invariant asserts that teardown returns stdin to the descriptor state the suite received.

This is the owner-boundary fix: the suite that mutates process-global state also restores it. A consumer-side override would only hide the leak. The implementation matches the established descriptor restore-or-delete pattern in src/commands/doctor-update.test.ts.

ClawSweeper's latest rank-up move said no separate repair lane was needed because this focused maintainer PR already owns the repair; no code action was required beyond completing and proving this PR.

User Impact

Developers get deterministic wizard shard behavior, including on non-isolated workers. Production behavior is unchanged.

The cleanup is cross-platform: it uses JavaScript property-descriptor operations only, with no Unix paths, signals, or filesystem deletion semantics. The focused before/after proof ran on macOS, and the changed-file gate ran on Linux. Exact-head CI supplies the repository's hosted platform coverage; no Windows-specific branch is involved.

Evidence

  • Regression, before the teardown fix (node scripts/run-vitest.mjs src/wizard/setup.post-install-migration.test.ts):
    • Test Files 1 failed (1)
    • Tests 11 passed (11)
    • Suite invariant received { value: true, configurable: true } for stdin.isTTY instead of the original undefined.
    • [vitest] FAILED (exit 1)
  • Regression, after the teardown fix (same command):
    • Test Files 1 passed (1)
    • Tests 11 passed (11)
    • [test] passed 1 Vitest shard in 22.82s on the rebased head
  • Changed-file gate (node scripts/check-changed.mjs):
  • git diff --check: passed.
  • Codex autoreview on rebased head 95a13d34a6e3545f2443d37a69cf960bd2c52faa: clean after one round; no accepted/actionable findings.
  • Exact-head CI (node scripts/watch-pr-ci.mjs 113345 95a13d34a6e3545f2443d37a69cf960bd2c52faa): GREEN on https://github.com/openclaw/openclaw/actions/runs/31308796636. The workflow was rerun once after GitHub left its first successful openclaw/ci-gate check-run nonterminal; the rerun completed with pending=0 and SUCCESS.

AI-assisted: yes.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jul 24, 2026
@steipete
steipete marked this pull request as ready for review July 24, 2026 14:31
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Jul 24, 2026
@clawsweeper

clawsweeper Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 6:44 AM ET / 10:44 UTC.

ClawSweeper review

What this changes

Restores the incoming stdin TTY property descriptor after each post-install migration wizard test so non-isolated workers cannot leak a test-created terminal state into later suites.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer review. Current main still has the test-global stdin TTY leak, and this focused suite-owned cleanup is the best fix; wait for the remaining exact-head checks before merge.

Priority: P3
Reviewed head: 95a13d34a6e3545f2443d37a69cf960bd2c52faa

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct test-isolation repair with credible before/after evidence and no actionable review finding.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored test-only PR is outside the external-contributor proof gate; its body nevertheless supplies before/after terminal evidence and a successful Testbox changed-file gate.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR is outside the external-contributor proof gate; its body nevertheless supplies before/after terminal evidence and a successful Testbox changed-file gate.
Evidence reviewed 4 items Current-main leak: The wizard suite defines an own configurable stdin TTY property and invokes that setup before each test without restoring it; the runtime reads the same property to decide whether to prompt interactively.
Owner-boundary repair: The supplied PR patch captures the exact descriptor, restores it after each test, deletes only test-created own properties, and asserts suite-exit equality; this matches the existing restore-or-delete pattern.
Shared-worker contract: The non-isolated test runner keeps a worker across files, so teardown belongs to the suite that mutates process-global state rather than to later consumers.
Findings None None.
Security None None.

How this fits together

The post-install migration wizard checks stdin TTY state to choose an interactive prompt or non-interactive guidance. Its tests temporarily force that process-global state, so teardown must return it to the state received by the shared test worker.

flowchart LR
  A[Wizard tests] --> B[Temporarily set stdin TTY]
  B --> C[Migration helper]
  C --> D[Prompt or guidance path]
  B --> E[Suite teardown]
  E --> F[Later tests retain original state]
Loading

Before merge

  • Resolve merge risk (P1) - Several exact-head checks were still in progress in the supplied PR state. Merge after required checks complete and GitHub accepts the current head; refresh only if the merge guard requires it.
  • Complete next step (P2) - The assigned maintainer PR already owns the concrete repair; no separate fix lane is needed while exact-head checks finish.
Agent review details

Security

None.

PR surface

Tests +16. Total +16 across 1 file.

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

Review metrics

Metric Value Why it matters
Production vs test LOC production +0/-0, tests +17/-1 The repair is confined to test lifecycle isolation and adds no runtime, configuration, or API surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the suite-local restore-or-delete cleanup after exact-head CI is green, keeping the production wizard behavior unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the suite-local restore-or-delete cleanup after exact-head CI is green, keeping the production wizard behavior unchanged.

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

Yes. Current main has a clear shared-worker leak path, and the PR body records the focused test failing before teardown and passing after it; this read-only review did not rerun the command.

Is this the best way to solve the issue?

Yes. Restoring the full descriptor in the mutating suite is the narrowest maintainable fix; runner-level or consumer cleanup would hide future leaks instead of repairing the owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: This is a narrow developer-facing test-isolation fix with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only PR is outside the external-contributor proof gate; its body nevertheless supplies before/after terminal evidence and a successful Testbox changed-file gate.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the focused repair and also appears in prior history around the onboarding migration surface. (role: recent area contributor; confidence: high; commits: 95a13d34a6e3, 0790d9f593ad; files: src/wizard/setup.post-install-migration.test.ts, src/wizard/setup.post-install-migration.ts)
  • Vincent Koc: Current-main blame attributes the present test helper lines to a recent tree-import commit, so this is routing context rather than regression attribution. (role: recent baseline contributor; confidence: medium; commits: 1b404a175548; files: src/wizard/setup.post-install-migration.test.ts)
  • Sarah Fortune: History traces the original post-install migration feature to this area; later test lifecycle work should remain coordinated with that feature boundary. (role: feature origin contributor; confidence: medium; commits: 48529f1; files: src/wizard/setup.post-install-migration.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 (6 earlier review cycles)
  • reviewed 2026-07-24T14:36:26.578Z sha a66bd45 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T15:08:39.126Z sha a66bd45 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T09:22:10.781Z sha a66bd45 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T14:22:58.370Z sha a66bd45 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T15:18:31.295Z sha a66bd45 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-09T07:46:01.345Z sha b9ea8de0bdc7bb722b076a1614fc02534432ec07 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 30, 2026
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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:

@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete steipete self-assigned this Aug 9, 2026
@steipete
steipete force-pushed the steipete/test-wizard-stdin-tty branch from a66bd45 to b9ea8de Compare August 9, 2026 07:39
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 9, 2026
@steipete
steipete force-pushed the steipete/test-wizard-stdin-tty branch from b9ea8de to 95a13d3 Compare August 9, 2026 10:37
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 9, 2026
@steipete
steipete merged commit e257683 into main Aug 9, 2026
155 of 156 checks passed
@steipete
steipete deleted the steipete/test-wizard-stdin-tty branch August 9, 2026 11:29
@steipete

steipete commented Aug 9, 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

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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