feat(runtime): default to passthrough and persist execution permissions
This commit is contained in:
@@ -18,13 +18,17 @@ async function until(predicate, timeout = 45000) {
|
||||
|
||||
// This verifier supplies a declared local response algorithm. The executing
|
||||
// Runtime/Store/permissions/native bridge all belong to the compiled host.
|
||||
export async function verifyControlledApi({ api, url, token, directory, appRoot, contained = false }) {
|
||||
export async function verifyControlledApi({ api, url, token, directory, appRoot, contained = false, openExecution = false }) {
|
||||
const origin = new URL(url);
|
||||
assert.equal(origin.hostname, '127.0.0.1'); assert.notEqual(origin.port, '4318');
|
||||
const expectedVersion = JSON.parse(fs.readFileSync(path.join(appRoot, fs.existsSync(path.join(appRoot, 'MANIFEST.json')) ? 'MANIFEST.json' : 'package.json'), 'utf8')).version;
|
||||
assert.ok(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.20.2', '1.20.3', '1.21.0', '1.22.0', '1.22.1', '1.23.0', '1.24.0', '1.24.1', '1.24.2', '1.24.3', '1.24.4', '1.24.5', '1.24.6', '1.24.7', '1.24.8', '1.24.9', '1.25.0', '1.25.1', '1.25.2', '1.25.3', '1.25.4', '1.25.5'].includes(expectedVersion));
|
||||
const bootstrap = await api('/bootstrap'); assert.equal(bootstrap.version, expectedVersion);
|
||||
assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
|
||||
// This legacy acceptance deliberately exercises its original review contract.
|
||||
// Default unrestricted execution is covered separately by the permissions UI.
|
||||
await api('/model-center/runtime-budgets', openExecution ? { executionMode: 'unrestricted' } : { executionMode: 'restricted', capacityMode: 'manual', historyPolicy: 'preserve', contextLimit: 64000, maxOutputTokens: 2048, maxRunTokens: 200000, maxTaskTokens: 200000, maxSteps: 64, maxRunDurationMs: 600000 });
|
||||
if (openExecution) await api('/model-center/permissions', { approvalMode: 'full' });
|
||||
const root = path.join(directory, 'compiled-controlled-node'), hooks = path.join(directory, 'disabled-hooks');
|
||||
fs.mkdirSync(root); fs.mkdirSync(hooks);
|
||||
fs.cpSync(path.join(appRoot, 'benchmarks/workers-delivery-v1/node'), root, { recursive: true });
|
||||
@@ -50,6 +54,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
assert.equal(request.url, '/v1/chat/completions'); assert.equal(request.headers.authorization, 'Bearer owned-compiled-engine-fixture');
|
||||
const chunks = []; for await (const chunk of request) chunks.push(chunk);
|
||||
const input = JSON.parse(Buffer.concat(chunks)); assert.equal(input.model, 'owned-compiled-engineering'); assertToolPairs(input.messages);
|
||||
if (openExecution) for (const key of ['max_tokens', 'max_output_tokens', 'max_completion_tokens']) assert.equal(Object.hasOwn(input, key), false);
|
||||
const session = await api(childRoute), job = session.execution.checks.at(-1), plan = session.execution.plans.at(-1);
|
||||
let calls = [];
|
||||
if (session.changes.some(value => value.status === 'pending')) { /* Host review follows native completion. */ }
|
||||
@@ -69,6 +74,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
await new Promise(resolve => modelServer.listen(0, '127.0.0.1', resolve));
|
||||
try {
|
||||
await api('/config', { mode: 'compatible', model: 'owned-compiled-engineering', baseUrl: 'http://127.0.0.1:' + modelServer.address().port + '/v1', apiKey: 'owned-compiled-engine-fixture', contextLimit: 64000 });
|
||||
if (openExecution) await api('/model-center/runtime-budgets', { executionMode: 'unrestricted' });
|
||||
const project = await api('/projects', { root }), parent = await api('/sessions', { projectId: project.id }); parentRoute = '/sessions/' + parent.id;
|
||||
const installation = await api('/engines/deepseek/controlled-availability'); assert.equal(installation.controlledStatus, 'available', installation.message);
|
||||
assert.equal(installation.version, '0.2.1-rc.2');
|
||||
@@ -87,7 +93,8 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
const childProject = (await api('/bootstrap')).projects.find(value => value.id === child.projectId);
|
||||
assert.notEqual(childProject.root, root); verifyProtected(childProject.root); assert.deepEqual(owner(), originalOwner); assert.equal(requests.length, 0);
|
||||
mark('compiled host seals actual Harness/source identities and prepares one owned worktree while retaining parent bytes and staging');
|
||||
const apply = async (route, set) => { reviews.push({ action: 'apply reviewed change set', id: set.id, fingerprint: set.fingerprint, paths: set.files.map(value => value.path) });
|
||||
const apply = async (route, set) => { if (openExecution) { assert.equal(set.status, 'completed', set.summary); return; }
|
||||
reviews.push({ action: 'apply reviewed change set', id: set.id, fingerprint: set.fingerprint, paths: set.files.map(value => value.path) });
|
||||
await api(route + '/change-sets/' + set.id + '/apply', { fingerprint: set.fingerprint });
|
||||
let state; await until(async () => { state = await api(route + '/change-sets/' + set.id); return !['prepared', 'applying'].includes(state.status); }); assert.equal(state.status, 'completed', state.summary); };
|
||||
for (let turn = 0; turn < 4 && group.status !== 'ready_to_collect'; turn++) {
|
||||
@@ -108,6 +115,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
const response = await fetch(url + '/api' + childRoute + '/engine-runs/' + run.id + '/download', { headers: { 'X-Workbench-Token': token, Connection: 'close' } });
|
||||
assert.equal(response.status, 200); const bytes = Buffer.from(await response.arrayBuffer()); assert.equal(sha(bytes), run.reportSha256);
|
||||
const original = JSON.parse(bytes); assert.equal(original.native.stderr, ''); assert.equal(original.native.cleanup.treeConfirmed, true);
|
||||
if (openExecution) assert.equal(Object.hasOwn(original.native.responses.find(value => value.method === 'initialize').params, 'maxTokens'), false);
|
||||
assert.equal(original.native.activity.endEvents[0].data.reason.kind, 'completed');
|
||||
assert.equal(original.native.readiness.promptExperimentSha256, run.installation.strategy.sha256);
|
||||
const saved = path.join(directory, 'compiled-engine-original-' + run.id + '.json'); fs.writeFileSync(saved, bytes); originalRuns.push({ run, original, reportPath: saved, sha256: sha(bytes) });
|
||||
@@ -118,7 +126,8 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
assert.equal(current.execution.task.usage.requests, requests.length); assert.equal(current.execution.task.usage.totalTokens, requests.length * 168);
|
||||
for (const request of requests) assert.equal(request.input.messages.filter(value => value.role === 'system').map(value => value.content).join('').split(group.children[0].engine.strategy.section.text).length - 1, 1);
|
||||
verifyProtected(childProject.root); assert.deepEqual(owner(), originalOwner);
|
||||
mark('compiled native execution retains failing tests, requires original check approvals, seals literal prompt/model/receipts/results and accounts each owned HTTP request once');
|
||||
if (openExecution) { assert.equal(reviews.length, 0); assert.ok(current.approvals.length > 0); assert.ok(current.approvals.every(value => value.status === 'approved' && value.decisionSource === 'full-access-policy')); }
|
||||
mark(openExecution ? 'actual native SDK applies changes and runs checks in full access, preserving failures, complete requests and actual usage without manual review' : 'compiled native execution retains failing tests, requires original check approvals, seals literal prompt/model/receipts/results and accounts each owned HTTP request once');
|
||||
await operation('collect'); await until(async () => { group = await groupState(); return group.status !== 'collecting'; }); assert.equal(group.status, 'collected', group.summary);
|
||||
const collection = await api(parentRoute + '/collaborations/' + group.id + '/collection'); assert.deepEqual(collection.conflicts, []); assert.deepEqual(collection.paths, writable);
|
||||
await operation('merge'); await until(async () => { group = await groupState(); return ['merge_prepared', 'unknown', 'stale'].includes(group.status); }); assert.equal(group.status, 'merge_prepared', group.summary);
|
||||
@@ -137,7 +146,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
assert.deepEqual(owner(), originalOwner); verifyProtected(root); await operation('finalize'); group = await groupState(); assert.equal(group.status, 'completed', group.summary);
|
||||
for (const route of [parentRoute, childRoute]) { const value = await api(route); const file = path.join(directory, value.id + '-session.json'); fs.writeFileSync(file, JSON.stringify(value, null, 2)); exports.push({ id: value.id, file, sha256: sha(fs.readFileSync(file)) }); }
|
||||
mark('compiled Git delivery contains only reviewed modules, preserves staged/unstaged/untracked owner bytes and completes the parent with sealed original evidence');
|
||||
return { success: true, version: bootstrap.version, appRoot, contained, cases, root, group, requests, reviews, originalRuns, exports,
|
||||
return { success: true, version: bootstrap.version, appRoot, contained, openExecution, cases, root, group, requests, reviews, originalRuns, exports,
|
||||
protectedFiles: Object.fromEntries(Object.entries(protectedFiles).map(([name, bytes]) => [name, sha(bytes)])), owner: originalOwner, installation, purgeSource: source,
|
||||
checks: check, delivery, fixtureModelRequests: requests.length, realModelRequests: 0,
|
||||
scope: 'Actual compiled host, local native Harness, checks/reviews/Git and an explicitly owned HTTP response fixture. No configured model or upstream Purge plugin executes; real inference benefit remains unmeasured.' };
|
||||
@@ -152,7 +161,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
|
||||
}
|
||||
}
|
||||
|
||||
export async function verifyControlledRelease(appRoot = process.cwd()) {
|
||||
export async function verifyControlledRelease(appRoot = process.cwd(), { openExecution = false } = {}) {
|
||||
appRoot = fs.realpathSync.native(appRoot);
|
||||
// Keep the synthetic Git project independent of the installation/extraction
|
||||
// depth. The production workspace path guard remains responsible for users'
|
||||
@@ -174,7 +183,7 @@ export async function verifyControlledRelease(appRoot = process.cwd()) {
|
||||
await until(() => url || child.exitCode !== null, 15000); assert.ok(url, errors);
|
||||
bootstrap = await (await fetch(url + '/api/bootstrap', { signal: AbortSignal.timeout(5000) })).json();
|
||||
const health = await api('/health'); assert.equal(health.pid, child.pid);
|
||||
result = await verifyControlledApi({ api, url, token: bootstrap.token, directory, appRoot, contained: node !== process.execPath });
|
||||
result = await verifyControlledApi({ api, url, token: bootstrap.token, directory, appRoot, contained: node !== process.execPath, openExecution });
|
||||
} catch (error) { result = { success: false, appRoot, directory, error: error.stack, realModelRequests: 0 }; throw error; }
|
||||
finally {
|
||||
try { if (url && bootstrap && child.exitCode === null) { await api('/shutdown', {}); await until(() => child.exitCode !== null || child.signalCode !== null, 15000); } }
|
||||
@@ -192,8 +201,9 @@ export async function verifyControlledRelease(appRoot = process.cwd()) {
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length === 1 && args[0] === '--help') { console.log('node scripts/verify-controlled-release.mjs [--app-root DIR] - run an actual compiled local host/native Harness/owned model/Node repair/check/review/Git/prompt acceptance in independent data. Requires explicit Harness and Purge source paths.'); process.exit(0); }
|
||||
assert.ok(!args.length || args.length === 2 && args[0] === '--app-root' && path.isAbsolute(args[1]), 'Unsupported argument; use --help.');
|
||||
const result = await verifyControlledRelease(args[1]); console.log(JSON.stringify({ success: result.success, version: result.version, directory: result.directory, cases: result.cases.length,
|
||||
if (args.length === 1 && args[0] === '--help') { console.log('node scripts/verify-controlled-release.mjs [--app-root DIR] [--open] - actual compiled host/native Harness/owned model/Node repair/check/Git acceptance in independent data; --open uses unlimited defaults and full access.'); process.exit(0); }
|
||||
const openExecution = args.includes('--open'), options = args.filter(value => value !== '--open');
|
||||
assert.ok(!options.length || options.length === 2 && options[0] === '--app-root' && path.isAbsolute(options[1]), 'Unsupported argument; use --help.');
|
||||
const result = await verifyControlledRelease(options[1], { openExecution }); console.log(JSON.stringify({ success: result.success, version: result.version, directory: result.directory, cases: result.cases.length,
|
||||
rootExited: result.rootExited, fixtureModelRequests: result.fixtureModelRequests, realModelRequests: 0 }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user