Skip to content

Commit 1e9a0ab

Browse files
thymikeeclaude
andcommitted
chore(gates): R13 lets platform package tests import test-kit
Test support is not a platform substrate dependency; production source stays refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b8a618c commit 1e9a0ab

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎scripts/layering/platform-package-policy.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,25 @@ test('platform packages may use capture-kit but no unrelated workspace implement
518518
}
519519
});
520520

521+
test('platform package tests may import test-kit, production source may not', () => {
522+
const tests = validSources();
523+
tests.set(
524+
'packages/platform-apple/src/probe.test.ts',
525+
"import { mkdtempForTest } from '@agent-device/test-kit';",
526+
);
527+
assert.deepEqual(checkPlatformPackagePolicy(tests, declarations()), []);
528+
529+
const production = validSources();
530+
production.set(
531+
'packages/platform-apple/src/probe.ts',
532+
"import { mkdtempForTest } from '@agent-device/test-kit';",
533+
);
534+
assert.match(
535+
messages(production).join('\n'),
536+
/may import workspace code only from capture-kit, host-kit, provision-kit, contracts, kernel, or xml/,
537+
);
538+
});
539+
521540
test('package-owned tests may import their own public facade', () => {
522541
const sources = validSources();
523542
sources.set(

‎scripts/layering/platform-package-policy.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ function isWebPackageTestSelectorImport(file: string, family: string, specifier:
175175
);
176176
}
177177

178+
function isTestKitTestImport(file: string, specifier: string): boolean {
179+
return (
180+
specifier === '@agent-device/test-kit' &&
181+
(file.endsWith('.test.ts') || file.includes('/__tests__/') || file.includes('.fixtures.'))
182+
);
183+
}
184+
178185
function checkDeclarations(packages: readonly PlatformPackageDeclaration[]): LayeringViolation[] {
179186
const violations: LayeringViolation[] = [];
180187
for (const family of CANONICAL_PLATFORM_FAMILIES) {
@@ -318,7 +325,8 @@ function checkSource(file: string, source: string): LayeringViolation[] {
318325
site.spec !== '@agent-device/xml' &&
319326
!isAppleFacadeSubpathImport(site.spec) &&
320327
!isPackageOwnedFacadeTest(file, ownerFamily, site.spec) &&
321-
!isWebPackageTestSelectorImport(file, ownerFamily, site.spec)
328+
!isWebPackageTestSelectorImport(file, ownerFamily, site.spec) &&
329+
!isTestKitTestImport(file, site.spec)
322330
) {
323331
violations.push(
324332
violation(

0 commit comments

Comments
 (0)