Repository navigation
refactor(test-kit): one named-export entry, and pin its shape in R83 - #3667
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 464 files
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
View guided diff | Turn on auto-fix | Re-trigger cubic
Size Report
Startup median (7 runs, lower is better):
|
4c4e3ec to
3f68766
Compare
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
This PR is ready at 9bb17a7. The single test-kit entry and the R83 pin look correct. Not blocking, and you can take or leave these: docs/agents/testing.md:70 still says to import from the defining module and never through a barrel, so it should say shared helpers are named imports from CI is still pending: all 18 jobs were queued when I looked and none had failed. This diff rewrites imports in 458 test files and changes R83, so Typecheck & Package, unit, integration and Repo Guards (layering) must go green on this head before merge. I did not confirm that the rewritten imports typecheck, did not run the mutation that shows the namespace-spy pin makes the device-claims tests pass, and did not check the no-import-time-side-effects claim or the wall-time figures. The five cubic-dev-ai P2 threads are fixed at this head and no longer apply, so you can resolve them: #3667 (comment) (transitive cycles), #3667 (comment) (optionalDependencies), #3667 (comment) (import scan), #3667 (comment) (forbidden package set), #3667 (comment) (exports leaf check). |
8009ebe to
68bce17
Compare
|
Taken: the |
|
The PR is ready at 68bce17. The earlier concerns are fixed: the isolation check now follows transitive dependencies, counts optional and peer dependencies, includes Not blocking, and fine to take or leave: the new refusal at https://github.com/callstack/agent-device/blob/68bce17/scripts/layering/test-kit-isolation.ts#L148 is a regex, and it misses The five earlier inline threads are fixed at this commit, so you can resolve them: #3667 (comment) (transitive walk), #3667 (comment) (optional and peer deps), #3667 (comment) ( I did not run the layering gate or the test-kit-isolation tests locally, so this rests on reading the diff. I also did not confirm that the source map keys use the repo-relative |
@agent-device/test-kit exports exactly '.', pointing at src/index.ts, with every helper a named export (no export *). All 458 importers move to the entry. The eight tests that pinned the host process start time through a vi.mock factory importing test-kit now spy the host-kit process module in place: a factory that imports the entry deadlocks, because the entry loads host-kit/process while that module is still being mocked. R83 also pins test-kit's shape: one entry, no dependency on or import of platform-*, provider-*, the daemon or the root, and no package it builds on may declare it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e and walk the graph The isolation check moves to its own module and now takes the forbidden packages from the packages/platform-*, packages/provider-* and packages/daemon directories (so a provider published as @agent-device/testmu is covered), reads optionalDependencies, walks the workspace dependency graph transitively for both forbidden packages and a cycle back to test-kit, and scans test-kit sources with the shared specifierSites walk so vi.mock literals count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… src/index.ts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ved from the entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ath in an error message Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68bce17 to
f8358ee
Compare
Stacked on #3659 (R11 devDependencies) on #3645 (R83).
What
@agent-device/test-kitexports exactly"."→src/index.ts, with every helper a named export (54 names, noexport *). The 18 subpaths are gone; every importer (about 470 files across the daemon, rootsrc/,test/andscripts/; re-run over the daemon tests main gained since) now import@agent-device/test-kit. The rewrite is a mechanical codemod (merged same-file imports,import typekept); the hand-written parts areindex.ts,host-process-mock.ts, eight test edits and the R83 additions below.Why the eight
pinOwnProcessStartTimetests changedThey mocked
@agent-device/host-kit/processwith a factory that did(await import('@agent-device/test-kit')).pinOwnProcessStartTime(importOriginal). With one eager entry that import deadlocks: the entry loadshost-kit/command,host-kit/fileandcapture-kit, which loadhost-kit/process, which is still being mocked. The helper now takes the module namespace and spies it in place (pinOwnProcessStartTime(hostProcess), registered withbeforeEachsovi.restoreAllMockscannot unpin it); no module is mocked, so no test-kit import happens during a mock factory.Proof the pin still takes effect: with
readCurrentOwnerIdentitymade to return a different start time,device-claims.test.tsfails 6 of 28 tests; restored, all 28 pass. The eight tests pass together (103 tests). Rule for future tests: never import test-kit inside avi.mockfactory.Import-time side effects
None. Each of the 18 modules imports cleanly in plain Node with no top-level effects (the
fs.writeFileSync/setIntervallines inlegacy-daemon-fixture.tsare inside a template string that becomes a child script). The entry loads in plain Node in ~160 ms (54 exports). The sixnode:testscripts that import test-kit still pass; the entry pullsvitestinto them, which loads harmlessly outside a runner.Wall time,
vitest run --project unit-core(1647 files, 14,222 tests, same on both sides)Each test file now imports all of test-kit instead of one module, which shows as the larger import share; the total is unchanged within noise (single run each, shared host).
R83 additions: the shape of test-kit
checkTestKitIsolation(inside R83) pins:exportsis exactly.;dependencies/devDependencies/peerDependenciesentry onplatform-*,provider-*,@agent-device/daemonoragent-device(root), and no import of them or relative reach out ofpackages/test-kit/. A fixture that needs those packages' code is a test of that package and belongs in it;Planted in tests: an extra export, each forbidden dependency in all three fields, eight forbidden or escaping imports, and a
devDependencies/dependenciescycle through kernel. Only the daemon and the root consume test-kit today; the daemon already declares it indevDependencies(#3659). Every other package's worker adds it todevDependenciesandreferenceswhen its tests start importing it.Gates
pnpm check:quick,check:layering(373 node tests),check:fallow,check:gate-manifest,check:affected --run,vitest --project unit-corein full, repo-widepnpm format.🤖 Generated with Claude Code