Skip to content

Commit 954dd03

Browse files
thymikeeclaude
andcommitted
refactor(layering): check the root-package paths mapping against both dependency fields
A private package that declares agent-device only in devDependencies needs the same tsconfig paths mapping, so the project-references test reads one union for references and paths. The dev-only set is required on WorkspacePackage now that its only constructor always sets it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0f751ba commit 954dd03

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

‎scripts/layering/package-boundaries.test.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const kernel: WorkspacePackage = {
3434
['@agent-device/kernel/device', 'packages/kernel/src/device.ts'],
3535
]),
3636
workspaceDependencies: new Set(),
37+
workspaceDevDependencies: new Set(),
3738
workspaceDependencyField: 'dependencies',
3839
externalDependencies: new Map(),
3940
};
@@ -45,6 +46,7 @@ const contracts: WorkspacePackage = {
4546
['@agent-device/contracts/interaction', 'packages/contracts/src/interaction.ts'],
4647
]),
4748
workspaceDependencies: new Set(['@agent-device/kernel']),
49+
workspaceDevDependencies: new Set(),
4850
workspaceDependencyField: 'dependencies',
4951
externalDependencies: new Map(),
5052
};
@@ -763,15 +765,9 @@ test('the real tree parses, declares, and passes R11', () => {
763765
// daemon used to own (#2340). The per-file subpaths under `./interaction-*`,
764766
// `./selector-pipeline*`, `./press-retarget`, `./touch-semantics` are the
765767
// execution surface the core selector pipeline moved into this package —
766-
// one subpath per module so consumers pull only the stage they run; the
767-
// `-fixtures` entries are the test-fixture surface (host-kit's
768-
// `./audio-probe-fixtures` precedent) — `./interaction-targeting-fixtures`
769-
// for the interaction-targeting node trees and `./snapshot-geometry-fixtures`
770-
// for the geometry/touch-point builders both this package's and root's
771-
// tests build on (#2402, replacing the copy that used to live under root's
772-
// `src/__tests__/test-utils/`; it re-exports `makeSnapshotState` from
773-
// capture-kit's own `./snapshot-state-fixtures`, its canonical home). Any
774-
// other subpath, or the AST leaking into `.`, fails here.
768+
// one subpath per module so consumers pull only the stage they run. The `-fixtures`
769+
// entries are R83 burn-down, deleted with the export. Any other subpath, or the AST leaking
770+
// into `.`, fails here.
775771
assert.deepEqual([...selectorsPackage.exportTargets.keys()].sort(), [
776772
'@agent-device/selectors',
777773
'@agent-device/selectors/absence-observation',

‎scripts/layering/package-boundaries.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export type WorkspacePackage = {
6666
* `workspaceDependencyField`. A published package keeps every sibling in `devDependencies`
6767
* already, so this is empty there.
6868
*/
69-
workspaceDevDependencies?: ReadonlySet<string>;
69+
workspaceDevDependencies: ReadonlySet<string>;
7070
/** Where siblings are declared: a published package bundles them, so it lists them as dev-only. */
7171
workspaceDependencyField: 'dependencies' | 'devDependencies';
7272
/** Non-workspace dependencies that the root build must externalize. */
@@ -284,7 +284,7 @@ function undeclaredSiblingMessage(
284284
site: SpecifierSite,
285285
): string | undefined {
286286
if (name === pkg.name || pkg.workspaceDependencies.has(name)) return undefined;
287-
const declaredForTests = pkg.workspaceDevDependencies?.has(name) ?? false;
287+
const declaredForTests = pkg.workspaceDevDependencies.has(name);
288288
if (declaredForTests && !isProductionSourceFile(site.file)) return undefined;
289289
return declaredForTests
290290
? `${pkg.name} imports '${site.specifier}' from production source, but ${pkg.dir}/package.json ` +

‎scripts/layering/project-references.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,14 @@ test('every package tsconfig references exactly its manifest workspace dependenc
163163
`${pkg.dir}/tsconfig.json references ${dir}, which is not a workspace package`,
164164
);
165165
}
166+
const declared = new Set([...pkg.workspaceDependencies, ...pkg.workspaceDevDependencies]);
166167
assert.deepEqual(
167168
referencedDirs.map((dir) => nameByDir.get(dir)),
168-
[...new Set([...pkg.workspaceDependencies, ...(pkg.workspaceDevDependencies ?? [])])]
169-
.filter((name) => name !== rootPackageName)
170-
.sort(),
169+
[...declared].filter((name) => name !== rootPackageName).sort(),
171170
`${pkg.dir}/tsconfig.json references must equal its manifest workspace:* dependencies and ` +
172171
`devDependencies`,
173172
);
174-
if (pkg.workspaceDependencies.has(rootPackageName)) {
173+
if (declared.has(rootPackageName)) {
175174
const config = readTsconfig(`${pkg.dir}/tsconfig.json`);
176175
const paths = (config.compilerOptions?.paths ?? {}) as Record<string, unknown>;
177176
assert.ok(

0 commit comments

Comments
 (0)