fix(sdk): enforce runtime dependency boundary

This commit is contained in:
2026-09-05 08:01:07 +08:00
parent 471e2e9479
commit dfaa4f0ef4
4 changed files with 45 additions and 11 deletions
@@ -187,6 +187,36 @@ test('scanner rejects sdk contracts importing a framework platform path', async
assert.match(scan(root)[0].message, /sdk.*platform/);
});
test('scanner rejects every sdk runtime dependency on framework implementation layers', async () => {
const layers = [
'core',
'platform',
'net',
'config',
'native',
'protocol',
'application',
'domain',
'presentation',
'ui',
'compat',
];
for (const layer of layers) {
const root = await createFixtureRoot();
await writeFixture(root, `framework/${layer}/internal.ts`, 'export const value = true\n');
await writeFixture(
root,
'framework/sdk/runtime/bad.ts',
`import { value } from '../../${layer}/internal.ts'; void value\n`,
);
const violations = scan(root);
assert.equal(violations.length, 1, layer);
assert.match(violations[0].message, /sdk.*framework implementation/, layer);
}
});
test('scanner rejects game imports of framework net internals', async () => {
const root = await createFixtureRoot();
await writeFixture(root, 'games/a/assets/game/bad.ts', "import '../../../framework/net/net-client.ts'\n");
@@ -122,14 +122,6 @@ test('Task 1 route validator is the shared authority for game-route admission',
for (const route of ['platform', 'agent', 'room']) {
assert.throws(() => assertGameRoute(route), /reserved.*route/i);
}
const validatorSource = readFileSync(new URL(
'../../YouleNexus/assets/framework/sdk/runtime/game-session-host.ts',
import.meta.url,
), 'utf8');
assert.match(validatorSource, /import \{ Route \} from '\.\.\/\.\.\/core\/constants\.ts';/);
assert.match(validatorSource, /new Set<string>\(Object\.values\(Route\)\)/);
assert.doesNotMatch(validatorSource, /new Set\(\[['"]platform['"]/);
});
test('execute exposes only the GameHost command union and delegates semantic commands', () => {