feat(ql3): add strong local run stop

This commit is contained in:
whyour
2026-08-12 10:36:38 +08:00
parent dd370b2842
commit 86eb0f1eb3
16 changed files with 1430 additions and 133 deletions
+60 -2
View File
@@ -119,6 +119,65 @@ test('accepts package-local and declared forward source imports', (t) => {
assert.deepEqual(findings, []);
});
test('confines local Run management authority to reviewed retry and stop commands', (t) => {
const root = fs.mkdtempSync(
path.join(os.tmpdir(), 'ql3-run-management-boundary-'),
);
const sourceDirectory = path.join(
root,
'packages/ql3-local-owner-cli/src/run-management',
);
fs.mkdirSync(sourceDirectory, { recursive: true });
fs.writeFileSync(
path.join(sourceDirectory, 'runRetryCommand.ts'),
[
"import { authenticate } from '@qinglong/local-owner-console/authenticated-command';",
"import { fence } from '@qinglong/local-sqlite/authenticated-management';",
"import { database } from '@qinglong/local-sqlite/run-management';",
"import { policy } from '@qinglong/runtime-core/project-policy';",
"import { retry } from '@qinglong/runtime-core/run-manual-retry';",
"import { audit } from '@qinglong/runtime-core/security-audit';",
].join('\n'),
);
fs.writeFileSync(
path.join(sourceDirectory, 'runStopCommand.ts'),
[
"import { authenticate } from '@qinglong/local-owner-console/authenticated-command';",
"import { fence } from '@qinglong/local-sqlite/authenticated-management';",
"import { database } from '@qinglong/local-sqlite/run-management';",
"import { policy } from '@qinglong/runtime-core/project-policy';",
"import { stop } from '@qinglong/runtime-core/run-cancellation';",
"import { audit } from '@qinglong/runtime-core/security-audit';",
].join('\n'),
);
fs.writeFileSync(
path.join(sourceDirectory, 'widenedRunCommand.ts'),
[
"import { database } from '@qinglong/local-sqlite/run-management';",
"import { stop } from '@qinglong/runtime-core/run-cancellation';",
].join('\n'),
);
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
const findings = [];
auditSourceImports(root, 'packages/ql3-local-owner-cli', findings);
assert.deepEqual(
findings.map(({ code, file, specifier }) => ({ code, file, specifier })),
[
{
code: 'FORBIDDEN_LOCAL_ADOPTION_CLI_AUTHORITY_IMPORT',
file: 'packages/ql3-local-owner-cli/src/run-management/widenedRunCommand.ts',
specifier: '@qinglong/local-sqlite/run-management',
},
{
code: 'FORBIDDEN_PACKAGE_SOURCE_IMPORT',
file: 'packages/ql3-local-owner-cli/src/run-management/widenedRunCommand.ts',
specifier: '@qinglong/runtime-core/run-cancellation',
},
],
);
});
test('confines local MCP to its reviewed protocol and read-authority subpaths', (t) => {
const root = fixture(
t,
@@ -1973,8 +2032,7 @@ test('confines Local API identity authentication to its exact read-only adapter'
[
{
code: 'FORBIDDEN_LOCAL_OWNER_PEPPER_DESTRUCTIVE_ENTRYPOINT',
file:
'packages/ql3-local-api/src/authentication/destructive.ts',
file: 'packages/ql3-local-api/src/authentication/destructive.ts',
},
{
code: 'FORBIDDEN_LOCAL_IDENTITY_AUTHORITY_IMPORT',
+2 -2
View File
@@ -207,10 +207,10 @@ test('current QL3 workspace has exactly eighteen reviewed package boundaries', (
rootSourceFileRoles: localOwnerCli.rootSourceFileRoles,
},
{
sourceFiles: 104,
sourceFiles: 105,
rootSourceFiles: 1,
rootSourceLines: 50,
nestedSourceFiles: 103,
nestedSourceFiles: 104,
rootSourceFileRoles: { 'cli.ts': 'binary_entry' },
},
);