Repository navigation
Expand file tree
/
Copy pathpackage-boundaries.test.ts
More file actions
996 lines (954 loc) · 46.4 KB
/
Copy pathpackage-boundaries.test.ts
File metadata and controls
996 lines (954 loc) · 46.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
// R11 package-boundaries fires on every bypass and holds on the one exception.
// Necessary for the same reason as zone-policy.test.ts: the real tree is clean,
// so a rule that stopped matching would look exactly like a rule being obeyed.
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { test } from 'node:test';
import { listSourceFiles } from './check.ts';
import { readNamedExports, readReExportSources } from './facade-exports.ts';
import {
checkPackageBoundaries,
checkPackageInternalSites,
checkRootSites,
insideCompiledSources,
readWorkspacePackages,
rootExternalDependencyRanges,
rootWorkspaceDependencyNames,
specifierSites,
workspacePackagesFromManifests,
type WorkspacePackage,
} from './package-boundaries.ts';
import { listTrackedTypeScriptFiles } from './tracked-sources.ts';
const repoRoot = path.resolve(import.meta.dirname, '../..');
const kernel: WorkspacePackage = {
dir: 'packages/kernel',
name: '@agent-device/kernel',
exportTargets: new Map([
['@agent-device/kernel/errors', 'packages/kernel/src/errors.ts'],
['@agent-device/kernel/device', 'packages/kernel/src/device.ts'],
]),
workspaceDependencies: new Set(),
workspaceDependencyField: 'dependencies',
externalDependencies: new Map(),
};
const contracts: WorkspacePackage = {
dir: 'packages/contracts',
name: '@agent-device/contracts',
exportTargets: new Map([
['@agent-device/contracts/interaction', 'packages/contracts/src/interaction.ts'],
]),
workspaceDependencies: new Set(['@agent-device/kernel']),
workspaceDependencyField: 'dependencies',
externalDependencies: new Map(),
};
const ALL = [kernel, contracts];
function rules(violations: { rule: string }[]): string[] {
return violations.map((violation) => violation.rule);
}
/**
* The manifest is its own inventory for two checks: every `exports` target must resolve to an
* existing, TRACKED source file, and every manifest entry must have produced exactly one
* `exportTargets` entry (nothing dropped, nothing collapsed by a duplicate key). Neither check
* catches the export SURFACE itself widening or shrinking -- `pkg.exportTargets` and
* `manifest.exports` are read from the same file, so adding or removing a subpath moves both
* counts together and the equality holds regardless (#2297 review). `snapshotFile`, an
* independently committed baseline regenerated by `generate-contracts-exports-snapshot.ts`,
* restores that guarantee: it changes only when a contributor deliberately reruns the generator
* and reviews the diff, so a subpath added or removed without doing so fails here.
*/
function assertExportTargetsMatchManifest(
pkg: WorkspacePackage,
manifestFile: string,
snapshotFile: string,
): void {
const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, manifestFile), 'utf8')) as {
exports?: Record<string, unknown>;
};
const trackedSources = new Set(listTrackedTypeScriptFiles(repoRoot));
for (const [specifier, target] of pkg.exportTargets) {
assert.ok(
trackedSources.has(target) && fs.existsSync(path.join(repoRoot, target)),
`${specifier} -> ${target} must resolve to an existing, tracked file`,
);
}
assert.equal(
pkg.exportTargets.size,
Object.keys(manifest.exports ?? {}).length,
`${pkg.name} exports map entries must each produce one resolved export target`,
);
const snapshot = JSON.parse(
fs.readFileSync(path.join(repoRoot, snapshotFile), 'utf8'),
) as string[];
assert.deepEqual(
[...pkg.exportTargets.keys()].sort(),
[...snapshot].sort(),
`${pkg.name}'s export surface no longer matches ${snapshotFile} -- regenerate it with ` +
`'node --experimental-strip-types scripts/layering/generate-contracts-exports-snapshot.ts' ` +
'and review the diff',
);
}
test('specifier sites carry 1-based lines for static and dynamic imports', () => {
const sites = specifierSites(
'src/a.ts',
["import { x } from './b.ts';", '', "void import('../c.ts');"].join('\n'),
);
assert.deepEqual(
sites.map(({ specifier, line }) => `${line}:${specifier}`),
['1:./b.ts', '3:../c.ts'],
);
});
test('the compiled set classifies every file region the R11 walk visits', () => {
// The compiler-owned/compiler-exempt split above is keyed on this predicate (#3279), so the
// mutation it must fail on is a file region joining or leaving `tsc -b`'s programs without
// the predicate following: package `src/`, root `src/` and root `test/` compile; `scripts/`
// and the package harness dirs are the fail-closed side.
assert.equal(insideCompiledSources('packages/kernel/src/errors.ts'), true);
assert.equal(insideCompiledSources('packages/maestro/src/index.ts'), true);
assert.equal(insideCompiledSources('src/cli.ts'), true);
assert.equal(insideCompiledSources('test/integration/smoke-web-platform.test.ts'), true);
assert.equal(insideCompiledSources('scripts/layering/check.ts'), false);
assert.equal(insideCompiledSources('packages/maestro/test/conformance/harness.ts'), false);
assert.equal(insideCompiledSources('packages/proxy/tsdown.config.ts'), false);
// The one scripts file the root program DOES compile is classified as uncompiled: R11
// keeps its full branch set there (redundant with tsc, never narrower). The exact root
// include list and the reference sets are pinned against the graph itself in
// project-references.test.ts, where the divergence is recorded rather than assumed absent.
assert.equal(insideCompiledSources('scripts/help-conformance-command-validator.ts'), false);
});
test('readWorkspacePackages reads tracked manifests only', () => {
// R11's own committed-state property, and the source-level half of the #1965 review finding.
// `readWorkspacePackages` used to enumerate `packages/` with `readdirSync`, so an uncommitted
// scratch package contributed a name, export targets, and dependency edges to every rule built
// on it — R11 could fail on work a contributor had not committed. Filtering the OUTPUT of
// façade discovery hides that from one caller; this closes it for all of them.
const repo = fs.mkdtempSync(path.join(os.tmpdir(), 'package-boundaries-tracked-manifests-'));
const committed = path.join(repo, 'packages/committed');
fs.mkdirSync(path.join(committed, 'src'), { recursive: true });
fs.writeFileSync(
path.join(committed, 'package.json'),
JSON.stringify({ name: '@agent-device/committed', exports: { '.': './src/index.ts' } }),
);
fs.writeFileSync(path.join(committed, 'src/index.ts'), 'export const a = 1;\n');
execFileSync('git', ['init', '-q'], { cwd: repo });
execFileSync('git', ['add', '.'], { cwd: repo });
execFileSync(
'git',
['-c', 'user.name=Gate', '-c', '[email protected]', 'commit', '-qm', 'base'],
{ cwd: repo },
);
const scratch = path.join(repo, 'packages/scratch');
fs.mkdirSync(path.join(scratch, 'src'), { recursive: true });
fs.writeFileSync(
path.join(scratch, 'package.json'),
JSON.stringify({
name: '@agent-device/scratch',
exports: { '.': './src/index.ts' },
dependencies: { '@agent-device/committed': 'workspace:*' },
}),
);
fs.writeFileSync(path.join(scratch, 'src/index.ts'), 'export const b = 2;\n');
const names = readWorkspacePackages(repo).map((pkg) => pkg.name);
assert.deepEqual(names, ['@agent-device/committed']);
assert.ok(
!names.includes('@agent-device/scratch'),
'an uncommitted package directory is not part of the committed state R11 describes',
);
});
test('published ESM plugins declare bundled workspace build dependencies without runtime dependencies', () => {
const [plugin] = workspacePackagesFromManifests(
new Map([
[
'packages/provider-example/package.json',
JSON.stringify({
name: '@agent-device/example',
exports: { '.': { import: './dist/plugin.mjs' } },
devDependencies: { '@agent-device/kernel': 'workspace:*', tsdown: '^0.21.0' },
}),
],
]),
);
assert.ok(plugin);
assert.equal(
plugin.exportTargets.get('@agent-device/example'),
'packages/provider-example/dist/plugin.mjs',
);
assert.deepEqual([...plugin.workspaceDependencies], ['@agent-device/kernel']);
assert.equal(plugin.externalDependencies.size, 0);
const sites = specifierSites(
'packages/provider-example/src/plugin.ts',
"import { AppError } from '@agent-device/kernel/errors';",
);
assert.deepEqual(checkPackageInternalSites(plugin, sites, [plugin, kernel]), []);
const undeclared = { ...plugin, workspaceDependencies: new Set<string>() };
const violations = checkPackageInternalSites(undeclared, sites, [undeclared, kernel]);
assert.equal(violations.length, 1);
assert.equal(violations[0]?.rule, 'R11 package-boundaries');
assert.match(violations[0]?.message ?? '', /without declaring/);
});
// These `src/utils` paths are in-memory arbitrary parser fixtures, not live repository paths.
test('double-quoted and re-export routes into packages are not invisible to R11', () => {
// The scanner is the layering parser, so quote style and statement form
// cannot carve out a bypass: a double-quoted import, a re-export, and a
// double-quoted dynamic import into packages/*/src all reach the rule.
const doubleQuoted = specifierSites(
'src/utils/exec.ts',
'import { AppError } from "../../packages/kernel/src/errors.ts";',
);
assert.equal(checkRootSites(doubleQuoted, ALL, new Set([kernel.name]), true).length, 1);
const reExport = specifierSites(
'src/utils/exec.ts',
'export { AppError } from "../../packages/kernel/src/errors.ts";',
);
assert.equal(checkRootSites(reExport, ALL, new Set([kernel.name]), true).length, 1);
const dynamic = specifierSites(
'src/utils/exec.ts',
'void import("../../packages/kernel/src/errors.ts");',
);
assert.equal(checkRootSites(dynamic, ALL, new Set([kernel.name]), true).length, 1);
const packageEscape = specifierSites(
'packages/kernel/src/errors.ts',
'export * from "../../../src/utils/exec.ts";',
);
// The escape is R11's own for EVERY package source, compiled or not (#3289 maintainer
// review): the compiled-only skip was retired with a planted proof, below.
assert.equal(checkPackageInternalSites(kernel, packageEscape, ALL, true).length, 1);
assert.equal(checkPackageInternalSites(kernel, packageEscape, ALL, false).length, 1);
});
test('a package vi.mock route into root src is an R11 escape, and a sibling route needs its declaration', () => {
// `vi.mock('./x')` is a call expression the AST import parser never visits, yet the loader
// resolves its specifier and instantiates that module — the same double-instance route the
// tunnels above name. Planted red: delete the scan in `specifierSites` and every assertion.
const kernelViolations = (compiled: boolean, source: string) =>
checkPackageInternalSites(
kernel,
specifierSites('packages/kernel/src/internal/thing.test.ts', source),
ALL,
compiled,
);
const rootMock = kernelViolations(true, "vi.mock('../../../../src/utils/exec.ts', () => ({}));");
assert.equal(rootMock.length, 1);
assert.match(rootMock[0]!.message, /escapes packages\/kernel/);
assert.equal(kernelViolations(true, "vi.doMock('../../../../src/utils/exec.ts');").length, 1);
assert.equal(
kernelViolations(true, 'vi.importActual("../../../../src/utils/exec.ts")').length,
1,
);
// Legitimate mock routes keep working: a declared sibling's exported subpath is not an
// escape, an undeclared sibling is still the undeclared-sibling branch, and a mock of the
// package's own module stays silent, so the scan cannot be read as flagging all mocks.
const declaredMock = specifierSites(
'packages/contracts/src/internal/thing.test.ts',
"vi.mock('@agent-device/kernel/errors', () => ({}));",
);
assert.deepEqual(checkPackageInternalSites(contracts, declaredMock, ALL, true), []);
const undeclaredMock = specifierSites(
'packages/kernel/src/internal/thing.test.ts',
"vi.mock('@agent-device/contracts/interaction', () => ({}));",
);
assert.equal(rules(checkPackageInternalSites(kernel, undeclaredMock, ALL, false)).length, 1);
assert.deepEqual(kernelViolations(true, "vi.mock('./exec.ts', () => ({}));"), []);
});
// This `src/utils` path is another in-memory arbitrary parser fixture, not a live repository path.
test('a package relative escape is R11-owned, compiled or not', () => {
// #3289 maintainer review restored this branch after a planted `tsc -b` run showed the
// compiler covers NEITHER package escape for a REFERENCED sibling:
// packages/host-kit/src/r11-planted-sibling-tunnel.ts
// import { AppError } from '../../kernel/src/errors.ts';
// pnpm exec tsc -b packages/host-kit --force -> exit 0, no diagnostics
// The reference redirects kernel's sources to their dist-types .d.ts, so nothing outside
// host-kit's rootDir is emitted and TS6059/TS6307 never fire; the earlier PR-#3279 proof
// (TS6059+TS6307) only held for the ROOT escape, where no project redirects. What both
// tunnels break instead is runtime identity: Node instantiates the tunnelled module once
// by path and once by specifier, so two AppError classes coexist and instanceof fails —
// invisible to any compiler, so R11 holds it for compiled files too.
const rootEscape = specifierSites(
'packages/kernel/src/errors.ts',
"import { helper } from '../../../src/utils/exec.ts';",
);
assert.deepEqual(rules(checkPackageInternalSites(kernel, rootEscape, ALL, true)), [
'R11 package-boundaries',
]);
assert.match(
checkPackageInternalSites(kernel, rootEscape, ALL, true)[0]!.message,
/escapes packages\/kernel/,
);
// The exact reviewer case: compiled=true with a sibling-relative specifier.
const siblingTunnel = specifierSites(
'packages/kernel/src/errors.ts',
"import { thing } from '../../xml/src/index.ts';",
);
assert.deepEqual(rules(checkPackageInternalSites(kernel, siblingTunnel, ALL, true)), [
'R11 package-boundaries',
]);
// Uncompiled package files keep the same branch (they never reach the compiler at all).
assert.deepEqual(rules(checkPackageInternalSites(kernel, rootEscape, ALL, false)), [
'R11 package-boundaries',
]);
});
test('intra-package relative imports hold', () => {
const sites = specifierSites(
'packages/kernel/src/daemon-error.ts',
"import { AppError } from './errors.ts';",
);
assert.deepEqual(checkPackageInternalSites(kernel, sites, ALL, true), []);
});
test('an exported package self-reference holds while a deep self-import is compiler-owned', () => {
const exported = specifierSites(
'packages/kernel/src/errors.test.ts',
"import { AppError } from '@agent-device/kernel/errors';",
);
assert.deepEqual(checkPackageInternalSites(kernel, exported, ALL, true), []);
// #3279: NodeNext resolution rejects the un-exported self subpath with TS2307 (planted proof);
// R11 keeps the branch only where the compiler cannot see the site.
const deep = specifierSites(
'packages/kernel/src/errors.test.ts',
"import { AppError } from '@agent-device/kernel/src/errors.ts';",
);
assert.equal(checkPackageInternalSites(kernel, deep, ALL, true).length, 0);
assert.equal(checkPackageInternalSites(kernel, deep, ALL, false).length, 1);
});
test('a cross-package import needs a workspace:* declaration; the exports map is compiler-owned', () => {
const declared = specifierSites(
'packages/contracts/src/gesture.ts',
"import { AppError } from '@agent-device/kernel/errors';",
);
assert.deepEqual(checkPackageInternalSites(contracts, declared, ALL, true), []);
// The undeclared-dep branch stays R11's own for compiled files: pnpm's root link farm makes
// the import resolve and typecheck anyway, and the declaration is what the published bundle
// externalizes against — no compiler check can express it (recorded in #3279).
const undeclared = specifierSites(
'packages/kernel/src/errors.ts',
"import { g } from '@agent-device/contracts/interaction';",
);
assert.equal(checkPackageInternalSites(kernel, undeclared, ALL, true).length, 1);
// The un-exported subpath is TS2307 for compiled files (planted proof in #3279).
const deep = specifierSites(
'packages/contracts/src/gesture.ts',
"import { internal } from '@agent-device/kernel/internal/secret';",
);
assert.equal(checkPackageInternalSites(contracts, deep, ALL, true).length, 0);
});
test('a root src file tunnelling into packages/*/src relatively is a violation', () => {
// This `src/utils` path is an in-memory arbitrary parser fixture, not a live repository path.
// It stays R11's own for every root file, compiled or not: #3279 planted the tunnel inside the
// compiled tree and tsc accepted it — the failure this rule prevents is the runtime one where
// Node's ESM loader instantiates the module twice.
const sites = specifierSites(
'src/utils/exec.ts',
"import { AppError } from '../../packages/kernel/src/errors.ts';",
);
const violations = checkRootSites(sites, ALL, new Set([kernel.name]), true);
assert.deepEqual(rules(violations), ['R11 package-boundaries']);
assert.match(violations[0]!.message, /instantiate the module twice/);
});
// The R8 zero-dep exception retired with R8 (#1781 A6). `scripts/` placement never
// proved anything about dual instantiation on its own, and there is no longer a job
// whose absent node_modules could prove it, so the route is closed to every caller —
// exports-named target or not.
test('a scripts/ file gets no relative route into a package either', () => {
const exportsNamed = specifierSites(
'scripts/some-tool/run.ts',
"import { AppError } from '../../packages/kernel/src/errors.ts';",
);
assert.equal(checkRootSites(exportsNamed, ALL, new Set([kernel.name]), false).length, 1);
const nonExported = specifierSites(
'scripts/some-tool/run.ts',
"import { hidden } from '../../packages/kernel/src/internal.ts';",
);
assert.equal(checkRootSites(nonExported, ALL, new Set([kernel.name]), false).length, 1);
});
test('root workspace specifiers need a root workspace:* entry; resolution is compiler-owned', () => {
const fine = specifierSites(
'src/cli.ts',
"import { AppError } from '@agent-device/kernel/errors';",
);
assert.deepEqual(checkRootSites(fine, ALL, new Set([kernel.name]), true), []);
// The root-declaration branch stays R11's own (#3279): the root link farm resolves an
// undeclared specifier anyway, and the published bundle externalizes against this entry.
const undeclared = checkRootSites(fine, ALL, new Set(), true);
assert.equal(undeclared.length, 1);
assert.match(undeclared[0]!.message, /workspace:\*/);
// #3279 planted both below inside the compiled tree and `tsc -b` failed them with TS2307
// (unknown package and non-exported subpath), so R11 stands down there; uncompiled sites,
// which the compiler never parses, keep both branches.
const deep = specifierSites(
'src/cli.ts',
"import { x } from '@agent-device/kernel/src/errors.ts';",
);
assert.equal(checkRootSites(deep, ALL, new Set([kernel.name]), true).length, 0);
assert.equal(checkRootSites(deep, ALL, new Set([kernel.name]), false).length, 1);
const unknown = specifierSites('src/cli.ts', "import { x } from '@agent-device/nope/thing';");
assert.equal(checkRootSites(unknown, ALL, new Set([kernel.name]), true).length, 0);
assert.equal(checkRootSites(unknown, ALL, new Set([kernel.name]), false).length, 1);
});
test('a published package declares its bundled workspace siblings as devDependencies', () => {
const manifest = (name: string, isPrivate: boolean) =>
JSON.stringify({
name,
private: isPrivate,
exports: { '.': './src/index.ts' },
devDependencies: { '@agent-device/kernel': 'workspace:*' },
});
const packages = workspacePackagesFromManifests(
new Map([
['packages/published/package.json', manifest('@agent-device/published', false)],
['packages/internal/package.json', manifest('@agent-device/internal', true)],
]),
);
const published = packages.find((pkg) => pkg.name === '@agent-device/published');
const internal = packages.find((pkg) => pkg.name === '@agent-device/internal');
assert.ok(published && internal);
assert.deepEqual([...published.workspaceDependencies], ['@agent-device/kernel']);
assert.deepEqual([...internal.workspaceDependencies], []);
const undeclared = specifierSites(
'packages/published/src/index.ts',
"import { g } from '@agent-device/contracts/interaction';",
);
const [violation] = checkPackageInternalSites(published, undeclared, [...ALL, published], true);
assert.match(violation?.message ?? '', /packages\/published\/package\.json devDependencies\.$/);
});
test('the real tree parses, declares, and passes R11', () => {
const packages = readWorkspacePackages(repoRoot);
assert.ok(packages.length >= 1, 'expected at least the kernel package');
const kernelPackage = packages.find((pkg) => pkg.name === '@agent-device/kernel');
assert.ok(kernelPackage, 'kernel package must exist');
assert.ok(kernelPackage.exportTargets.size >= 8, 'kernel exports its vocabulary subpaths');
const contractsPackage = packages.find((pkg) => pkg.name === '@agent-device/contracts');
assert.ok(contractsPackage, 'contracts package must exist');
assertExportTargetsMatchManifest(
contractsPackage,
'packages/contracts/package.json',
'scripts/layering/contracts-exports.snapshot.json',
);
assert.deepEqual([...contractsPackage.workspaceDependencies], ['@agent-device/kernel']);
const captureKitPackage = packages.find((pkg) => pkg.name === '@agent-device/capture-kit');
assert.ok(captureKitPackage, 'capture-kit package must exist');
assert.equal(
JSON.parse(fs.readFileSync(path.join(repoRoot, 'packages/capture-kit/package.json'), 'utf8'))
.private,
true,
'capture-kit stays a private implementation package',
);
assert.deepEqual([...captureKitPackage.exportTargets.keys()].sort(), [
'@agent-device/capture-kit',
'@agent-device/capture-kit/android-replacement-surface-occlusion',
'@agent-device/capture-kit/audio-probe-admission-ledger',
'@agent-device/capture-kit/audio-probe-descriptor-fixtures',
'@agent-device/capture-kit/audio-probe-recovery',
'@agent-device/capture-kit/audio-probe-resource-store',
'@agent-device/capture-kit/audio-probe-session-resource',
'@agent-device/capture-kit/durable-capture',
'@agent-device/capture-kit/durable-capture-admission-ledger',
'@agent-device/capture-kit/durable-capture-resource',
'@agent-device/capture-kit/durable-capture-runtime-recovery',
'@agent-device/capture-kit/durable-capture/session-binding',
'@agent-device/capture-kit/durable-json',
'@agent-device/capture-kit/ios-snapshot-acquisition',
'@agent-device/capture-kit/ios-snapshot-engine',
'@agent-device/capture-kit/ios-snapshot-planning',
'@agent-device/capture-kit/ios-snapshot-runtime',
'@agent-device/capture-kit/ios-snapshot-tree',
'@agent-device/capture-kit/mobile-snapshot-semantics',
'@agent-device/capture-kit/observe-until',
'@agent-device/capture-kit/perf-capture-admission-ledger',
'@agent-device/capture-kit/perf-capture-recovery',
'@agent-device/capture-kit/perf-capture-resource-store',
'@agent-device/capture-kit/perf-capture-session-resource',
'@agent-device/capture-kit/perf-runtime-plan',
'@agent-device/capture-kit/png',
'@agent-device/capture-kit/png-crop',
'@agent-device/capture-kit/png-resize',
'@agent-device/capture-kit/png-rgb-difference',
'@agent-device/capture-kit/png-size',
'@agent-device/capture-kit/png-worker-client',
'@agent-device/capture-kit/post-gesture-stability',
'@agent-device/capture-kit/quality-warnings',
'@agent-device/capture-kit/react-native-overlay',
'@agent-device/capture-kit/recording-artifact-fixtures',
'@agent-device/capture-kit/recording-contact-sheet',
'@agent-device/capture-kit/recording-facts',
'@agent-device/capture-kit/recording-mp4-duration',
'@agent-device/capture-kit/recording-mp4-fixtures',
'@agent-device/capture-kit/recording-output-path',
'@agent-device/capture-kit/recording-overlay',
'@agent-device/capture-kit/recording-stop-sequence',
'@agent-device/capture-kit/recording-telemetry',
'@agent-device/capture-kit/recording-video',
'@agent-device/capture-kit/repeated-nav-subtree',
'@agent-device/capture-kit/screen-recording-admission-ledger',
'@agent-device/capture-kit/screen-recording-recovery',
'@agent-device/capture-kit/screen-recording-resource-store',
'@agent-device/capture-kit/screen-recording-session-resource',
'@agent-device/capture-kit/screen-recording-stop-recovery',
'@agent-device/capture-kit/screen-recording-transport',
'@agent-device/capture-kit/screenshot-density',
'@agent-device/capture-kit/screenshot-diff-pixels',
'@agent-device/capture-kit/screenshot-overlay',
'@agent-device/capture-kit/scroll-edge-state',
'@agent-device/capture-kit/snapshot-chrome',
'@agent-device/capture-kit/snapshot-desktop-projection',
'@agent-device/capture-kit/snapshot-desktop-surface',
'@agent-device/capture-kit/snapshot-diff',
'@agent-device/capture-kit/snapshot-evidence',
'@agent-device/capture-kit/snapshot-freshness',
'@agent-device/capture-kit/snapshot-label-dedup',
'@agent-device/capture-kit/snapshot-lines',
'@agent-device/capture-kit/snapshot-node-lookup',
'@agent-device/capture-kit/snapshot-occlusion',
'@agent-device/capture-kit/snapshot-presentation-android-helper',
'@agent-device/capture-kit/snapshot-presentation-ios-transitions-fixtures',
'@agent-device/capture-kit/snapshot-quality-backend-capabilities',
'@agent-device/capture-kit/snapshot-quality-verdict',
'@agent-device/capture-kit/snapshot-rect-projection',
'@agent-device/capture-kit/snapshot-state',
'@agent-device/capture-kit/snapshot-state-fixtures',
'@agent-device/capture-kit/snapshot-timeout-policy',
'@agent-device/capture-kit/snapshot-visibility',
'@agent-device/capture-kit/text-surface',
'@agent-device/capture-kit/touch-reference-frame',
]);
const provisionKitPackage = packages.find((pkg) => pkg.name === '@agent-device/provision-kit');
assert.ok(provisionKitPackage, 'provision-kit package must exist');
assert.equal(
JSON.parse(fs.readFileSync(path.join(repoRoot, 'packages/provision-kit/package.json'), 'utf8'))
.private,
true,
'provision-kit stays a private implementation package',
);
assert.deepEqual([...provisionKitPackage.exportTargets.keys()].sort(), [
'@agent-device/provision-kit/app-resolution-cache',
'@agent-device/provision-kit/boot-diagnostics',
'@agent-device/provision-kit/install-artifact-archive-context',
'@agent-device/provision-kit/install-source',
'@agent-device/provision-kit/install-source-config',
'@agent-device/provision-kit/install-source-network',
'@agent-device/provision-kit/install-source-network-transport',
'@agent-device/provision-kit/toolchain-probe',
]);
assert.deepEqual([...provisionKitPackage.workspaceDependencies].sort(), [
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
]);
assert.deepEqual([...captureKitPackage.workspaceDependencies].sort(), [
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
]);
const hostKitPackage = packages.find((pkg) => pkg.name === '@agent-device/host-kit');
assert.ok(hostKitPackage, 'host-kit package must exist');
assert.equal(
JSON.parse(fs.readFileSync(path.join(repoRoot, 'packages/host-kit/package.json'), 'utf8'))
.private,
true,
'host-kit stays a private implementation package',
);
assert.deepEqual([...hostKitPackage.exportTargets.keys()].sort(), [
'@agent-device/host-kit/archive',
// Test-only entry: the zip/tar archive fixture writers shared with platform tests (#3461).
'@agent-device/host-kit/archive-fixtures',
// Test-only entry: the one inert audio-probe double the platform runtime fixtures share.
'@agent-device/host-kit/audio-probe-fixtures',
'@agent-device/host-kit/code-signature',
'@agent-device/host-kit/code-signature-cache',
'@agent-device/host-kit/command',
'@agent-device/host-kit/diagnostics',
'@agent-device/host-kit/doctor-lines',
'@agent-device/host-kit/file',
'@agent-device/host-kit/host-file',
'@agent-device/host-kit/interaction-outcome',
'@agent-device/host-kit/process',
'@agent-device/host-kit/project-runtime',
'@agent-device/host-kit/request',
'@agent-device/host-kit/retry',
'@agent-device/host-kit/runtime-transport-hints',
'@agent-device/host-kit/session-paths',
'@agent-device/host-kit/status-markers',
'@agent-device/host-kit/transport',
'@agent-device/host-kit/version',
]);
assert.deepEqual([...hostKitPackage.workspaceDependencies].sort(), [
'@agent-device/contracts',
'@agent-device/kernel',
]);
const platformApplePackage = packages.find((pkg) => pkg.name === '@agent-device/platform-apple');
assert.ok(platformApplePackage, 'platform-apple package must exist');
assert.deepEqual([...platformApplePackage.exportTargets.keys()].sort(), [
'@agent-device/platform-apple',
'@agent-device/platform-apple/app-lifecycle',
'@agent-device/platform-apple/app-resolution',
'@agent-device/platform-apple/debug-symbols',
'@agent-device/platform-apple/doctor',
'@agent-device/platform-apple/install-artifact',
'@agent-device/platform-apple/macos',
'@agent-device/platform-apple/perf',
'@agent-device/platform-apple/physical-device',
'@agent-device/platform-apple/runner',
'@agent-device/platform-apple/runner-owner',
'@agent-device/platform-apple/runner/operations',
// Test-only entry: the runner-requests.json check package and root tests share.
'@agent-device/platform-apple/runner/requests-fixtures',
'@agent-device/platform-apple/runner/test-host',
'@agent-device/platform-apple/session-observation',
'@agent-device/platform-apple/simctl',
'@agent-device/platform-apple/simctl-settings',
'@agent-device/platform-apple/simulator',
'@agent-device/platform-apple/simulator-boot',
'@agent-device/platform-apple/snapshot-source',
'@agent-device/platform-apple/tool-provider',
]);
assert.deepEqual([...platformApplePackage.workspaceDependencies].sort(), [
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
'@agent-device/provision-kit',
'@agent-device/xml',
]);
const platformAndroidPackage = packages.find(
(pkg) => pkg.name === '@agent-device/platform-android',
);
assert.ok(platformAndroidPackage, 'platform-android package must exist');
assert.deepEqual([...platformAndroidPackage.exportTargets.keys()].sort(), [
'@agent-device/platform-android',
'@agent-device/platform-android/adb-host',
'@agent-device/platform-android/device-boot',
'@agent-device/platform-android/mechanics',
]);
assert.deepEqual([...platformAndroidPackage.workspaceDependencies].sort(), [
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
'@agent-device/provision-kit',
'@agent-device/xml',
]);
const maestroPackage = packages.find((pkg) => pkg.name === '@agent-device/maestro');
assert.ok(maestroPackage, 'maestro package must exist');
// Locks the export surface: `.` (the engine) plus the two daemon-side port entries #2544
// moved out of `packages/daemon/src/adapters/maestro`. The eager-closure budget gate
// (scripts/__tests__/eager-closure-budgets.test.ts) is what keeps the port off `.`.
assert.deepEqual([...maestroPackage.exportTargets.keys()].sort(), [
'@agent-device/maestro',
'@agent-device/maestro/daemon-runtime-port',
'@agent-device/maestro/run-script-http',
]);
assert.deepEqual([...maestroPackage.workspaceDependencies].sort(), [
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
'@agent-device/provision-kit',
'@agent-device/selectors',
]);
const adScriptPackage = packages.find((pkg) => pkg.name === '@agent-device/ad-script');
assert.ok(adScriptPackage, 'ad-script package must exist');
// Locks the "exports only `.`" boundary: a future `/codec` (or any other)
// subpath widens this key list and fails the assertion (#1478 P5 dossier).
assert.deepEqual([...adScriptPackage.exportTargets.keys()], ['@agent-device/ad-script']);
assert.deepEqual([...adScriptPackage.workspaceDependencies].sort(), [
'@agent-device/contracts',
'@agent-device/kernel',
]);
const adReplayPackage = packages.find((pkg) => pkg.name === '@agent-device/ad-replay');
assert.ok(adReplayPackage, 'ad-replay package must exist');
// Locks the export surface: `.` (the engine) and `./divergence` (the
// divergence report/sanitization vocabulary, off the engine entry so CLI/MCP
// surfaces don't load the step loop). Any other subpath widens this key
// list and fails the assertion.
assert.deepEqual(
[...adReplayPackage.exportTargets.keys()],
['@agent-device/ad-replay', '@agent-device/ad-replay/divergence'],
);
assert.deepEqual([...adReplayPackage.workspaceDependencies].sort(), [
'@agent-device/ad-script',
'@agent-device/contracts',
'@agent-device/kernel',
'@agent-device/selectors',
]);
// #1555 review P1 ("add the reviewer-required exact exported-symbol
// gate"; second pass, "enforce the accepted two-entrypoint facade"; the
// structural-quality review, "typed façade replaces the zero-type rule"):
// the exports-subpath assertion above only proves the package exposes one
// `.` entry point — it says nothing about what that entry point actually
// NAMES. This pins the exact symbol list `packages/ad-replay/src/index.ts`
// exports: the binding design's two VALUE entrypoints, `inspectAdReplay`
// and `runAdReplay` (never a third value), plus the neutral vocabulary
// their signatures are built from, named explicitly instead of every root
// consumer hand-deriving `Parameters<...>`/`ReturnType<...>` off them (the
// shim `packages/daemon/src/ad-replay-facade-types.ts` used to centralize — since
// deleted). `formatReplaySuccessMessage` (presentation, not engine policy)
// stays out on purpose — it sits daemon-side beside its one caller. A
// stray export — intentional or not, including a form `readNamedExports`
// cannot enumerate a name for (`export *`, `export default` — see the
// rejection tests below) — must edit this list too, not just slip through
// the exports-subpath check.
assert.deepEqual(
readNamedExports(
fs.readFileSync(path.join(repoRoot, 'packages/ad-replay/src/index.ts'), 'utf8'),
),
[
'AdReplayDispatchGuard',
'AdReplayDispatchOutcome',
'AdReplayGuardMismatchEvidence',
'AdReplayLandmarkMismatchEvidence',
'AdReplayManifest',
'AdReplayScrubValue',
'AdReplayStepFailure',
'AdReplayStepRuntime',
'AdReplayTargetBindingEvidence',
'AdReplayTargetClassification',
'AdReplayTargetObservation',
'AdReplayVarSources',
'AdReplayVerificationEntry',
'inspectAdReplay',
'runAdReplay',
],
);
const selectorsPackage = packages.find((pkg) => pkg.name === '@agent-device/selectors');
assert.ok(selectorsPackage, 'selectors package must exist');
// Subpaths, and each split is the point: `.` is the string-only façade
// every in-repo consumer uses, `./ast` is the published parser surface that
// `agent-device/selectors` has shipped since before the engine moved into
// this package, `./engine` is the resolve/list surface reserved for the
// selector-pipeline owner (R19, #1656) — a route reaching it skips the
// structural stages its policy row declares — and
// `./parameterized-recorded-fill` is the recorded-fill parameterization the
// daemon used to own (#2340). The per-file subpaths under `./interaction-*`,
// `./selector-pipeline*`, `./press-retarget`, `./touch-semantics` are the
// execution surface the core selector pipeline moved into this package —
// one subpath per module so consumers pull only the stage they run; the
// `-fixtures` entries are the test-fixture surface (host-kit's
// `./audio-probe-fixtures` precedent) — `./interaction-targeting-fixtures`
// for the interaction-targeting node trees and `./snapshot-geometry-fixtures`
// for the geometry/touch-point builders both this package's and root's
// tests build on (#2402, replacing the copy that used to live under root's
// `src/__tests__/test-utils/`; it re-exports `makeSnapshotState` from
// capture-kit's own `./snapshot-state-fixtures`, its canonical home). Any
// other subpath, or the AST leaking into `.`, fails here.
assert.deepEqual([...selectorsPackage.exportTargets.keys()].sort(), [
'@agent-device/selectors',
'@agent-device/selectors/absence-observation',
'@agent-device/selectors/absence-observation-errors',
'@agent-device/selectors/absence-observation-resolution',
'@agent-device/selectors/ast',
'@agent-device/selectors/engine',
'@agent-device/selectors/interaction-error',
'@agent-device/selectors/interaction-positionals',
'@agent-device/selectors/interaction-targeting',
'@agent-device/selectors/interaction-targeting-fixtures',
'@agent-device/selectors/interaction-touch-point',
'@agent-device/selectors/parameterized-recorded-fill',
'@agent-device/selectors/press-retarget',
'@agent-device/selectors/selector-pipeline',
'@agent-device/selectors/selector-pipeline-policy',
'@agent-device/selectors/snapshot-geometry-fixtures',
'@agent-device/selectors/target-evidence',
'@agent-device/selectors/touch-semantics',
]);
assert.deepEqual([...selectorsPackage.workspaceDependencies].sort(), [
'@agent-device/ad-script',
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/kernel',
]);
assert.deepEqual(
readNamedExports(
fs.readFileSync(path.join(repoRoot, 'packages/selectors/src/index.ts'), 'utf8'),
).filter((name) =>
['Selector', 'SelectorChain', 'SelectorTerm', 'SelectorKey', 'parseSelectorChain'].includes(
name,
),
),
[],
'selectors façade keeps AST and grammar internals private',
);
// Named exports are not the whole boundary. A parser-side type reached
// through a NESTED field — `PolicyResolutionOutcome.resolution` typed as
// `AstSelectorResolution` — leaks the same objects while exporting none of
// their names, and the assertion above stays green on it (#1649). What
// separates the two is which module the type is re-exported FROM:
// `public-resolution-types.ts` holds the string-flattened shapes,
// `resolve-with-policy.ts` and `resolve.ts` hold the parser-side ones. A
// resolution type re-exported from either of the latter means a flattening
// step at the façade was skipped.
const selectorsReExports = readReExportSources(
fs.readFileSync(path.join(repoRoot, 'packages/selectors/src/index.ts'), 'utf8'),
);
assert.deepEqual(
['PolicyResolutionOutcome', 'SelectorResolution', 'SelectorChainMatchList'].filter(
(name) => selectorsReExports.get(name) !== './internal/public-resolution-types.ts',
),
[],
'selectors façade must publish resolution shapes from public-resolution-types.ts, not from the parser-side modules',
);
// The AST subpath's one in-repo consumer is the published SDK re-export.
// Anything else importing it means the string-only façade was bypassed.
assert.deepEqual(
listSourceFiles()
.filter((file) => !file.startsWith('packages/selectors/'))
.filter((file) => fs.existsSync(path.join(repoRoot, file)))
.filter((file) =>
fs.readFileSync(path.join(repoRoot, file), 'utf8').includes('@agent-device/selectors/ast'),
),
['src/sdk/selectors.ts'],
'only the published SDK subpath may import the selector AST',
);
const providerWebDriverPackage = packages.find(
(pkg) => pkg.name === '@agent-device/provider-webdriver',
);
assert.ok(providerWebDriverPackage, 'provider-webdriver package must exist');
assert.deepEqual([...providerWebDriverPackage.exportTargets.keys()].sort(), [
'@agent-device/provider-webdriver',
'@agent-device/provider-webdriver/connection-verification',
'@agent-device/provider-webdriver/plugin',
'@agent-device/provider-webdriver/providers',
]);
assert.deepEqual([...providerWebDriverPackage.workspaceDependencies].sort(), [
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/host-kit',
'@agent-device/kernel',
'@agent-device/xml',
]);
const providerLimrunPackage = packages.find(
(pkg) => pkg.name === '@agent-device/provider-limrun',
);
assert.ok(providerLimrunPackage, 'provider-limrun package must exist');
assert.deepEqual(
[...providerLimrunPackage.exportTargets.keys()],
['@agent-device/provider-limrun'],
);
assert.deepEqual([...providerLimrunPackage.workspaceDependencies].sort(), [
'@agent-device/capture-kit',
'@agent-device/contracts',
'@agent-device/kernel',
'@agent-device/platform-android',
]);
const rootExternalDependencies = rootExternalDependencyRanges(repoRoot);
for (const pkg of packages) {
for (const [name, range] of pkg.externalDependencies) {
assert.equal(
rootExternalDependencies.get(name),
range,
`${pkg.name} external dependency ${name} must match the root dependency range`,
);
}
}
const xmlPackage = packages.find((pkg) => pkg.name === '@agent-device/xml');
assert.ok(xmlPackage, 'xml package must exist');
assert.deepEqual([...xmlPackage.exportTargets.keys()], ['@agent-device/xml']);
assert.deepEqual([...xmlPackage.workspaceDependencies], []);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/capture-kit'),
'root must declare the capture-kit workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/kernel'),
'root must declare the kernel workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/contracts'),
'root must declare the contracts workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/maestro'),
'root must declare the maestro workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/ad-script'),
'root must declare the ad-script workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/ad-replay'),
'root must declare the ad-replay workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/selectors'),
'root must declare the selectors workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/provider-webdriver'),
'root must declare the provider-webdriver workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/provider-limrun'),
'root must declare the provider-limrun workspace dependency',
);
assert.ok(
rootWorkspaceDependencyNames(repoRoot).has('@agent-device/xml'),
'root must declare the xml workspace dependency',
);
assert.deepEqual(checkPackageBoundaries(repoRoot, new Set()), []);
});
test('Node resolution enforces the exports map at runtime', () => {
// Real resolver, not the gate's model: a deep import is a resolution error,
// and the legal subpath realpaths OUTSIDE node_modules (pnpm symlink), which
// is what lets --experimental-strip-types load package sources in dev.
const resolved = import.meta.resolve('@agent-device/kernel/errors');
assert.ok(resolved.endsWith('packages/kernel/src/errors.ts'), resolved);
for (const deep of [
'@agent-device/kernel/src/errors.ts',
'@agent-device/kernel/internal-not-exported',
'@agent-device/kernel',
'@agent-device/contracts/not-an-export',
'@agent-device/contracts/src/gesture-plan.ts',
'@agent-device/contracts',
'@agent-device/contracts/src/snapshot-text.ts',
'@agent-device/contracts/src/facades/snapshot.ts',
'@agent-device/provider-webdriver/runtime',
'@agent-device/provider-webdriver/src/runtime.ts',
'@agent-device/provider-limrun/runtime',
'@agent-device/provider-limrun/src/runtime.ts',
'@agent-device/xml/internal/parser',
'@agent-device/xml/src/index.ts',
'@agent-device/ad-script/codec',
'@agent-device/ad-script/internal/script.ts',
'@agent-device/ad-script/src/index.ts',
'@agent-device/ad-replay/testing',
'@agent-device/ad-replay/internal/target-verification.ts',
'@agent-device/ad-replay/src/index.ts',
'@agent-device/selectors/internal/parse.ts',
'@agent-device/selectors/src/index.ts',
]) {
assert.throws(
() => import.meta.resolve(deep),
/ERR_PACKAGE_PATH_NOT_EXPORTED|Package subpath|No "exports" main/,
`${deep} must not resolve`,
);
}
const contractsResolved = import.meta.resolve('@agent-device/contracts/interaction');
assert.ok(contractsResolved.endsWith('packages/contracts/src/interaction.ts'), contractsResolved);
const contractsSnapshotResolved = import.meta.resolve('@agent-device/contracts/snapshot');
assert.ok(
contractsSnapshotResolved.endsWith('packages/contracts/src/facades/snapshot.ts'),
contractsSnapshotResolved,
);
const contractsReactNativeOverlayResolved = import.meta
.resolve('@agent-device/contracts/react-native-overlay');
assert.ok(
contractsReactNativeOverlayResolved.endsWith('packages/contracts/src/react-native-overlay.ts'),
contractsReactNativeOverlayResolved,
);
const providerWebDriverResolved = import.meta.resolve('@agent-device/provider-webdriver');
assert.ok(
providerWebDriverResolved.endsWith('packages/provider-webdriver/src/index.ts'),
providerWebDriverResolved,
);
const providerLimrunResolved = import.meta.resolve('@agent-device/provider-limrun');
assert.ok(
providerLimrunResolved.endsWith('packages/provider-limrun/src/index.ts'),
providerLimrunResolved,
);
const xmlResolved = import.meta.resolve('@agent-device/xml');
assert.ok(xmlResolved.endsWith('packages/xml/src/index.ts'), xmlResolved);
const adScriptResolved = import.meta.resolve('@agent-device/ad-script');
assert.ok(adScriptResolved.endsWith('packages/ad-script/src/index.ts'), adScriptResolved);
const adReplayResolved = import.meta.resolve('@agent-device/ad-replay');
assert.ok(adReplayResolved.endsWith('packages/ad-replay/src/index.ts'), adReplayResolved);
const selectorsResolved = import.meta.resolve('@agent-device/selectors');
assert.ok(selectorsResolved.endsWith('packages/selectors/src/index.ts'), selectorsResolved);
});