Repository navigation
Stabilize flaky tests and expand coverage - #1967
Conversation
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, duplication, and product behavior. Three review agents will work in parallel. I will also run focused tests and a browser check when this change affects a browser route. |
b4462ce to
d7419a7
Compare
| // and the kernel accepting the write. Node reports that race asynchronously | ||
| // on the stream; without a listener it becomes an uncaught EPIPE and can | ||
| // crash the bridge worker while the normal child-exit path is settling. | ||
| child.stdin?.on("error", handleAgentStdinError); |
There was a problem hiding this comment.
🚨 slopcop/review — This handler can leave ACP requests pending forever.
The handler ignores a closed input stream, but it leaves exited false. request() then adds an entry before writeLine() returns without a write. A child can close its input and remain alive. The pending request then has no timeout or exit event. I reproduced this result with a persistent child: still-pending. Please close the connection for these errors. Reject pending and future requests, then stop the child. Add a request rejection test for this path.
| @@ -0,0 +1,122 @@ | |||
| // @vitest-environment jsdom | |||
There was a problem hiding this comment.
🚨 slopcop/review — These pure logic tests load the complete GitHub panel.
This file starts JSDOM, installs the plugin runtime, and imports the 2,508-line app.tsx module. A focused run took 21.45 seconds. The import took 13.70 seconds, the environment took 6.31 seconds, and the tests took 8 milliseconds. Please move the route, query, and suggestion logic into a small Node-safe module. Import that module from the panel and this test. This change will also remove the test-only exports from the panel.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: This pull request adds tests for the GitHub plugin and the provider bridge. It also prevents two expected input errors from stopping the ACP bridge process. It adds optional V8 coverage data and removes a fragile button-size test.
I found one blocking defect and one important test cost.
- The new ACP input error handler can leave requests pending forever. A child can close its input but remain alive. I reproduced the unresolved request with a persistent child. The connection must reject pending and future requests, then stop the child.
- Five pure GitHub logic tests load the complete 2,508-line panel. A focused run took 21.45 seconds, but the tests used only 8 milliseconds. A small logic module will remove this cost and the test-only panel exports.
The security review found no new security risk. The dependency stays development-only and has lockfile integrity data.
The architecture scan found three duplicate patterns. The ACP closed-stream policy also exists in the provider bridge protocol. The new GitHub server test repeats the fake gh setup from server.auth-latch.test.ts. The GitHub query functions belong in a small shared logic module.
Verification passed for 275 focused tests: 86 protocol tests, 21 GitHub tests, and 168 ACP tests. git diff --check also passed. All GitHub CI jobs passed, including the build and type check. The local dev launcher did not finish its SDK declaration build, so I could not complete the browser check.
I used a comment review only. I did not approve the pull request or request changes.
## What was wrong The post-merge review on [#1967](#1967 (review)) identified two valid root causes. The ACP connection suppressed expected EPIPE / ERR_STREAM_DESTROYED events without changing connection state, so an agent that closed stdin but kept another handle alive could leave pending requests unresolved forever and continue accepting future requests. Separately, five pure GitHub route and query tests imported the 2,508-line panel entrypoint, initializing its React, plugin SDK, and UI dependency graph just to exercise synchronous logic. ## What changed - Treat a closed ACP stdin as a fatal transport closure: make the connection unavailable, reject pending requests, force-stop the child, and report the exit. The regression fixture closes fd 0 while deliberately keeping the process alive and checks both pending and future requests. - Move GitHub item, route, query, and suggestion logic into app-logic.ts. The pure module returns serializable icon descriptors; app.tsx alone renders them into the existing state-dot and avatar UI. - Point the logic tests directly at the pure module and remove their jsdom and plugin-runtime setup. - No server/daemon wire contract, CLI, user-facing configuration, guide, or protocol-version changes are involved. - I did not consolidate the two fake-gh fixtures noted by the review: they share only temporary PATH plumbing, while their command behavior and failure controls are intentionally different. ## How you verified - The new ACP persistent-child regression failed before the fix because the request remained pending past its deadline; it passes after the connection teardown change. - pnpm exec turbo run test typecheck --filter=bb-plugin-github --filter=bb-plugin-provider-acp — 21 GitHub tests and 169 ACP tests passed; both typechecks passed. - pnpm exec turbo run build --filter=bb-plugin-github — the production server, app JavaScript, and app CSS bundles built successfully. - git diff --check origin/main...HEAD passed. - In the focused GitHub logic test, Vitest import time dropped from 2.75 s to 27 ms and total file duration dropped from 3.53 s to 129 ms. Fixes: N/A — post-merge review follow-up to #1967. > AGENT GENERATED: by GPT-5
What was wrong
The test suite had three related quality problems: an ACP integration test used file existence as a proxy for completed output and could race with a confirmed child-process stdin teardown error (CI run 32188276525); package coverage reports omitted unimported runtime files, hiding substantial gaps; and high-risk JSON-RPC/GitHub behavior had little boundary coverage while presentation-only header sizing assertions added maintenance cost without protecting product behavior. Recent GitHub sync/auth fixes in #1282, #1758, and #1854 helped identify the missing regression surfaces. The first PR run also exposed a source-wrapper test that deep-compared the unrelated, evolving
bb statuspayload; Turbo did not model its hidden@bb/clidependency, so the stale assertion had previously remained cached green.What changed
EPIPE/ERR_STREAM_DESTROYEDchild-stdin teardown race.--coverageis passed, and no threshold is imposed.@bb/cli#buildTurbo dependency so CLI changes cannot reuse a stale test result.There are no server/daemon wire changes, CLI changes, or user-facing configuration changes, so no protocol-version or guide update is required.
How you verified
pnpm exec turbo run test --filter=@bb/scripts --force— 17 files and 92 tests passed; the command explicitly executes@bb/cli#buildfirst.pnpm exec turbo run test --filter=@bb/integration-tests --force— 55 tests passed.pnpm exec turbo run test typecheck --filter=@bb/provider-bridge-protocol --filter=bb-plugin-github --forceafter rebasing — 86 provider tests and 21 GitHub tests passed; both relevant typechecks passed.runtime-json-rpc.tsreaches 90.32%.server.tsincreased from 40.22% to 69.31%.Fixes: N/A — test-coverage audit without a single tracking issue.