mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
c5d9707196
* refactor(daemon): move the device selection cluster into a workspace package
git-rename src/core/dispatch-resolve.ts, src/core/device-selection-resolver.ts and src/request/device-inventory-context.ts (plus their tests and fixtures) into a new private package @agent-device/device-selection (deps: contracts, host-kit, kernel). One subpath per module points straight at the moved file; no index.ts, no re-export at the old path. Consumers switch to the owning specifier in the follow-up commit.
* refactor(daemon): install the installed-app probe on the inventory gateways and switch consumers to the device-selection package
The composition root (src/platform-runtime-device-inventory.ts) now attaches an optional findInstalledApp probe to the composed device inventory gateways, lazily importing the Apple simulator app-resolution mechanics. Device selection reads the probe from the request context instead of importing a platform package directly, so absent probes fall back to the ordinary inventory rules. All consumers switch to the @agent-device/device-selection/{dispatch-resolve,device-selection-resolver,device-inventory-context} subpaths; the moved tests carry a package-local inventory test util.
* chore(gates): re-point the layering gates at the device-selection zone
TARGET_DAG_RANK gains the device-selection leaf zone and drops the retired request zone; the back-edge fixture and the capture-kit ALS substrate fixture move to the package path.
* test(daemon): prove the factory-installed app probe narrows simulator selection
The moved selection tests inject their own probe, so nothing covered the
composition root actually attaching findInstalledApp to the gateways:
omitting it would leave those tests green while app-based selection
silently fell back to the generic local rules.
The new case runs two booted simulators through
createComposedDeviceInventoryGateways and the request context, fakes
only the leaf xcrun spawn (core tool-provider), and asserts the
single-app-installed-local selection plus both probe consults.
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import { substrateDomainShapeViolations } from './substrate-domain-shape.ts';
|
|
|
|
function messages(path: string, source: string): string[] {
|
|
return substrateDomainShapeViolations([{ path, source }]).map((violation) => violation.message);
|
|
}
|
|
|
|
test('capture-kit rejects request-scoped async_hooks dispatch', () => {
|
|
assert.match(
|
|
messages(
|
|
'packages/capture-kit/src/device-inventory-context.ts',
|
|
"import { AsyncLocalStorage } from 'node:async_hooks';\n",
|
|
)[0]!,
|
|
/request-scoped AsyncLocalStorage dispatch belongs in src\/request/,
|
|
);
|
|
assert.match(
|
|
messages(
|
|
'packages/capture-kit/src/device-inventory-context.ts',
|
|
'const store = new AsyncLocalStorage();\n',
|
|
)[0]!,
|
|
/request-scoped dispatch belongs in src\/request/,
|
|
);
|
|
});
|
|
|
|
test('capture-kit policy ignores types, prose, tests, and non-capture-kit ALS', () => {
|
|
assert.deepEqual(
|
|
messages(
|
|
'packages/capture-kit/src/app-log-live-handle.ts',
|
|
[
|
|
'export type Store = { AsyncLocalStorage: number };',
|
|
'const prose = "import { AsyncLocalStorage } from \'node:async_hooks\'";',
|
|
'// new AsyncLocalStorage();',
|
|
].join('\n'),
|
|
),
|
|
[],
|
|
);
|
|
assert.deepEqual(
|
|
messages(
|
|
'packages/capture-kit/src/device-inventory-context.test.ts',
|
|
"import { AsyncLocalStorage } from 'node:async_hooks';",
|
|
),
|
|
[],
|
|
);
|
|
assert.deepEqual(
|
|
messages(
|
|
'packages/device-selection/src/device-inventory-context.ts',
|
|
"import { AsyncLocalStorage } from 'node:async_hooks';\nconst store = new AsyncLocalStorage();\n",
|
|
),
|
|
[],
|
|
);
|
|
});
|
|
|
|
test('retired src/contracts/ production files fail closed', () => {
|
|
assert.match(
|
|
messages('src/contracts/interaction-outcome.ts', 'export const x = 1;\n')[0]!,
|
|
/src\/contracts\/ is retired/,
|
|
);
|
|
assert.deepEqual(messages('packages/contracts/src/interaction.ts', 'export type X = 1;\n'), []);
|
|
});
|