Repository navigation
test: route every stdout/stderr write swap through stream-capture - #3473
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Size Report
Startup median (7 runs, lower is better):
|
8cd1d0a to
6e2c23c
Compare
6e2c23c to
1d3f3bb
Compare
1d3f3bb to
5d8e05c
Compare
|
This PR is ready at 5d8e05c. Not blocking: the title says "every stdout/stderr write swap", but seven vi.spyOn(process.stdout|stderr, 'write') mocks remain, for example in cloud-connect-auth.test.ts:84 and daemon-client-startup-race.test.ts:511, so you can narrow the title to assignment swaps or move those sites onto beginStdoutCapture and beginStderrCapture in a follow-up, or leave it as is. All 21 checks are green, including the fuzz lane, and I found no conflicts. I read the diff but did not run the tests locally. The mutation check on the discard regression is your claim, and I only confirmed from the diff that the old passthrough-first order would count the Buffer on the marker write. Nothing else stands between this PR and merge. On the open review thread: the cubic-dev-ai P2 on the write wrapper in stream-capture.ts no longer applies, because the discard branch now comes first and the marker-write regression test pins it. Please resolve it: #3473 (comment) |
|
The code verdict at 5d8e05c is unchanged and still clean. This branch now conflicts with main, so it cannot merge as is. Please rebase on main. If the rebase only resolves the conflict, I will check the resolution and nothing else. |
5d8e05c to
4ee03f2
Compare
|
Rebased onto Also took the maintainer's note: all seven Head: |
|
The code looks good at 4ee03f2, and the conflict from the earlier review at 5d8e05c is fixed after the rebase. All 21 checks are passing, and the change is test and tooling only, with production net +2/-1. I did not run the test suites, and I did not re-diff the other 30 migrated files line by line; they are unchanged from the earlier reviewed head apart from the rebase. The one resolved thread was not re-read, and no threads are open. Not blocking: the local Simplicity question: |
4ee03f2 to
b172198
Compare
|
Folded in two Codex review items on previously merged code, amended into the single commit:
Head: |
b172198 to
b1bd3c5
Compare
|
Rebased onto current Head: |
b1bd3c5 to
71f911b
Compare
|
Rebased onto Head: |
|
Coverage red on this head is not from this PR's diff — it has two failures:
|
|
This PR is ready at 71f911b. The conflict from the earlier review (#3473 (comment)) is fixed, and the code looks right to me: the discard branch now runs before the passthrough branch, and the marker-write regression test pins that order. I did not run tests or local gates, so the green counts in the PR description are the author's own. Not blocking, and fine to take or leave: Coverage is the only failing check. It fails on the On the review threads, the cubic-dev-ai P2 thread on the discard branch order no longer applies, because the code and the marker-write test cover it, so the author can resolve it: #3473 (comment) |
Makes stream-capture.ts the one place that changes process.stdout.write or process.stderr.write. Migrate the remaining hand-rolled swaps: the daemon-http-fixture captureStderr (its restore assigned a bound copy, leaving an own-property shadow on the real stream for the rest of the file) with its callers in daemon-client-lifecycle and daemon-client-newer-daemon, the stdout captures in generic and screenshot, the scripts lanes (check-affected, coverage-changed, coverage-crap, fuzz worker, help-conformance sample producers), and the first-round consumers updated to the slimmed surface. The seven vi.spyOn(process.stdout|stderr, 'write') sites move too: a spyOn write fake has the same leak shape as the assignment swaps. Shrink the helper surface per review: beginStdoutCapture and beginStderrCapture stay the primitives; withCapturedStderr gains an interactive option and absorbs withInteractiveStderr/Async; withStreamTtyAsync (no caller outside its own test) is gone; the fuzz worker's full-life suppression becomes the discard option. After this, no test changes process.stdout/stderr.write by assignment or spy. Covers #3421
71f911b to
4a723e3
Compare
|
Head Head: |
|
The PR is ready at 4a723e3. The earlier review at 71f911b was clean, and the new delta also holds up: the stream-capture helper now checks the discard case before the passthrough branch, and its test covers that. The cubic-dev-ai P2 thread on that ordering is fixed at this head, so please resolve it: #3473 (comment) Not blocking: the change to https://github.com/callstack/agent-device/blob/4a723e3/scripts/__tests__/eager-closure-budgets.ts#L133 deletes three stale approval rows left by #3483. #3502 already landed the same fix, so a rebase should drop these rows from this PR and bring it back under the 1,000-line budget. I did not run any test lane, so the 838/838 and 13,434 counts are your numbers, not mine. I also did not read all 33 changed test files. I checked the delta, the helper, and a search for remaining hand-rolled stdout/stderr swaps at this commit. CI is still pending, with two Smoke Tests jobs queued and none failed. The diff is test files, a test-only budget table, and a 2-line change in scripts/fuzz/worker.ts. The smoke route only touches test/integration/smoke-open-remote-config.test.ts, which just swaps to the helper. There are no conflicts. Before merge, the Smoke Tests need to finish green. |
|
What
Makes
stream-capture.tsthe one place that changesprocess.stdout.write/process.stderr.write(done-check:git grep -E 'std(out|err)\.write =|vi\.spyOn\(process\.(stdout|stderr), .write.\)'is empty outside the helper and its own leak test).captureStderrfromdaemon-http-fixture.ts(its restore assigned a bound copy, leaving an own-property shadow for the rest of the file); callers usebeginStdoutCapture/beginStderrCapture.generic/screenshotstdout captures, the scripts lanes (check-affected,coverage-changed,coverage-crapincl. the new blocking-suitecapture()helper,fuzz/worker.tsvia thediscardoption, help-conformance sample producers).vi.spyOn(process.stdout|stderr, 'write')sites (per review): a spyOn write fake has the same own-property leak shape as the assignment swaps.beginStdoutCapture/beginStderrCaptureare the primitives; scopedwith*forms derive from them;withInteractiveStderr(Async)fold into{ interactive: true };withStreamTtyAsyncis deleted.Verification
4a723e346, 33 files, +409/−604 (1,013 gross; the 13-line overshoot is retiring the three deadAPPROVED_OVER_CEILINGrows refactor(move): extract generic test helpers into @agent-device/test-kit #3483 left onmain, which keeps the blocking Coverage job green).node:testlanes,fuzz:parsers, harness, andcheck:affected --runall green locally.Closes #3421