Repository navigation
test: enforce declared launches for daemon fixtures - #4432
Conversation
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed across 17 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Apex SentinelVerdict: Since the last review: 0 new · 0 still open · 0 no longer raised No findings. 1 finding below 1 new finding away from what changed since Reviewed with this repository's own Sentinel configuration ( Feedback goes in the review comment threads, as a reply under the inline comment of a finding: Reply Useful? Reply Comment Earlier reviewsReview of
|
|
At a2dc655 the runtime design is sound, but seven open threads on the AST guard still apply and need an answer before this is ready. The runtime launch planner and the teardown join make a spawn inside a plan impossible, which is the #4416 failure mode. The Mutants kernel-errors-2, -3 and -4 shards were still running when I looked, not failed. Those Mutants shards run the migrated fixture family, so green results there, including the baseline stage with no untracked child or fixture-teardown abort, are what must happen before merge. I did not run the planted-fault experiments, the guard self-tests or check:affected, so I take those claims as unverified. Not blocking, and you can take or leave each: (1) The AST guard in daemon-fixture-launch-guard.ts is about 169 lines and will grow with every new way to spell a mock call. (2) The guard self-test lives in scripts/mutation/ but does not test the mutation harness, and daemon-fixture-launches.test.ts runs it through a node --test subprocess. It would fit better as a vitest test in scripts/tests/ listed in unit-core, and it would stop waking the mutation canary on every edit. (3) The violations list in registered-daemon-launch-plan.ts is scoped to the module and drained only by finishRegisteredDaemonFixture(s). A violation in a test that never calls finish is reported by a later test, or never. Asserting the plans once per test, in afterEach or when the next plan is installed, would close that gap. Could the guard be much smaller? Keep the roughly 105-line planner and the teardown changes. Let the two shared fixture modules, packages/daemon-client/src/tests/registered-daemon-fixture.ts and src/tests/test-utils/registered-daemon-fixture.ts, own the vi.mock of '@agent-device/host-kit/command'. Implement runCmdDetachedMonitored there with the planner on an empty plan, so any launch refuses and latches. Export planLaunches(steps) to swap the active plan, and assert plans in afterEach. Tests then never call mockImplementation, and the guard becomes a short rule: no mockImplementation, mockReturnValue or spyOn on runCmdDetachedMonitored outside those two modules. That needs no alias or closure analysis. The first step is to move the per-file vi.mock declarations in the daemon-client tests and daemon-client-host.test.ts into the shared modules, using a setup file or a re-exported factory because vitest hoists vi.mock per test file. Eight threads on the guard still apply, and a smaller guard would resolve most of them without patching each bypass. The seven that block: execFileSync stdout, duplicate observer error, relative import resolution, inline planner call, as-cast bypass, MockedFunction annotation, namespace destructuring bypass. The smaller one: no-daemon test drain. None of them is outdated. |
|
Pushed the review corrections at
On the smaller-design question: this round retains the existing fixture mock initialization and runtime planner ownership. The proposed centralized |
|
The unchanged-base comparison finished. At The release-publish timeout at |
|
Hosted CI for The jobs used GitHub merge checkout |
|
I found no defect in 18fad61, but I am holding approval until the evidence gaps below are closed. This follows my earlier review of a2dc655 (#4432 (comment)). The bypasses I reported there are now fixed: the Vitest-run guard suite, the single-violation planner path, Hosted CI is green: 26/26 checks pass. They ran on the merge ref eace8d4 (this head plus main 18dd00e), not on the exact head. Hosted Coverage and the mutation shards that run the migrated fixture family passed. I did not run the guard self-tests, the planner tests or the planted-fault experiments, so the before/after failure counts are the author's claim. The author's local exact-head Not blocking, and you can take or leave it: the guard grew from 169 to 221 lines by adding one special case per reported bypass, and similar spellings still pass. I found these by reading the code and did not run them. An assignment alias ( Could the shared fixture modules own The eight earlier review threads are fixed at this head, so you can resolve them: #4432 (comment), #4432 (comment), #4432 (comment), #4432 (comment), #4432 (comment), #4432 (comment), #4432 (comment) and #4432 (comment). No conflicts. Before merge, please answer the simplicity question and resolve the run-Z5Avmu timeout. |
|
I am retaining the bounded AST guard in this PR, and I am not adding assignment-alias or container-alias analysis. Those examples are valid limits of the guard; it is not a sound analysis of arbitrary JavaScript. The runtime planner owns the describe/observe boundary and rejects a child launch from those callbacks. The fixture separately owns every child it launches and joins it during teardown, including a CLI-only test that creates no HTTP daemon. The AST rule catches accidental direct replacement of the monitored launcher in the existing fixture consumers; it does not establish those runtime guarantees by itself. The shared hoisted mock factory is a reasonable smaller direction. It changes who initializes and resets the launcher across the existing consumers, including tests that inspect the mock's call history. I am keeping that API/hoisting migration separate from this correction of the reported bypasses and teardown gap. This PR retains the existing initialization, with no claim that the two additional spellings are rejected. All eight original threads are already resolved. The requested clean rerun passed at the unchanged head after frozen install/build: {
"head": "18fad61f628ce7744b672b880d94a8da5d3d6002",
"status": "passed",
"exactCommit": true,
"checkoutChanged": false,
"passed": 42,
"skipped": 25,
"failed": 0,
"not-run": 0
}The earlier |
There was a problem hiding this comment.
2 issues found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="test/repo-guards/daemon-fixture-launches.test.ts">
<violation number="1" location="test/repo-guards/daemon-fixture-launches.test.ts:16">
P3: The file list includes tracked files that were deleted from the working tree but not staged, so `readFileSync` throws ENOENT and the test crashes. Skip paths that no longer exist on disk, or list with `-z` and check existence first.</violation>
</file>
<file name="packages/test-kit/src/registered-daemon-launch-plan.ts">
<violation number="1" location="packages/test-kit/src/registered-daemon-launch-plan.ts:20">
P2: A companion's `exitGate` is silently ignored: `start()` discards the companion's result and never applies the gate. The type still accepts it, so a caller can declare a gate that does nothing. Remove `exitGate` from the companion type.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
Thanks, that answers the design question. Keeping the bounded guard here is reasonable: moving the launcher mock into shared hoisted factories changes how consumers initialize and reset it, including tests that read its call history, so it belongs in its own change. Please open a follow-up issue for that migration so the smaller design is not lost. The clean |
Summary
Follow up on #4416 with declared daemon-fixture launch plans and teardown joins. Eighteen files; test infrastructure, fixture consumers and Vitest discovery. Production daemon behavior and gate thresholds are unchanged.
Review corrections cover module resolution, wrapped/typed launchers, namespace destructuring, bound plans, duplicate observer diagnostics and no-daemon teardown. Guard tests run directly in Vitest. The guard remains bounded syntactic enforcement; assignment/container aliases are outside its coverage. Design answer and receipt.
Validation
Exact head:
18fad61f628ce7744b672b880d94a8da5d3d6002; previous head:a2dc6558ade4598585d1dd6d8dc56ac6a4ccfb60.check:affected --run --headpassed, receiptrun-7tAruR: 42 runnable passes, 25 skips, no failed/unrun checks; clean unchanged checkout. Unit: 19,080 Vitest/76 Node passed, three/six skipped.run-Z5Avmufailed a release-publish timeout; unchanged-base unit passed. That receipt remains failed, cause unproven. No source or timeout changes preceded this clean rerun.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.