mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
ddb415a2c7
* refactor: sink package-closed src modules into existing packages Move closed modules into contracts, kernel, capture-kit, and ad-script, and declare DaemonCommandDescriptor in core so R6/R9 can pin the remaining provider-webdriver type cycle. Co-authored-by: Cursor <cursoragent@cursor.com> * refactor: keep contracts and capture-kit off generic sinks Move interaction-outcome, snapshot warning rendering, and inventory ALS behind focused owners, and plant R18/R70 domain-shape gates so they cannot return as package export-map growth. Co-authored-by: Cursor <cursoragent@cursor.com> * refactor: drop moved implementation comments from owner modules Names, types, and tests already carry those invariants; the relocated files should not keep review-history or control-flow narration. Co-authored-by: Cursor <cursoragent@cursor.com> * refactor: drop the empty snapshot-quality layering zone W1 moved the verdict into capture-kit and this PR moved warning rendering into snapshot-presentation, so the ranked zone no longer has production files. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
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 root-runtime 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(
|
|
'src/request/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'), []);
|
|
});
|