fix(engine): bound native history and preserve verified continuation context
This commit is contained in:
@@ -15,22 +15,24 @@ import { ownerBytes } from '../tests/fixtures/workers-project.mjs';
|
||||
import { desktopProjectQa } from './desktop-project-qa.mjs';
|
||||
import { specification } from '../tests/fixtures/engineering-specification.mjs';
|
||||
import { responsesEngineeringHttp } from '../tests/fixtures/responses-engineering-http.mjs';
|
||||
import { nativeContextSpecification } from '../tests/fixtures/native-context-project.mjs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
assert.ok(args.every(value => ['--help', '--purge-comparison', '--desktop', '--responses'].includes(value)), 'Unknown option; use --help.');
|
||||
assert.ok(args.every(value => ['--help', '--purge-comparison', '--desktop', '--responses', '--context-16k'].includes(value)), 'Unknown option; use --help.');
|
||||
if (args.includes('--help')) {
|
||||
console.log('node scripts/verify-controlled-projects.mjs [--purge-comparison | --desktop] [--responses] — actual pinned Harness and owned HTTP model fixture; default verifies Node/React/Python with approvals, Edge and Git. --responses uses actual Responses SSE and ModelHub routing with the same engineering algorithm. Comparison verifies eight independent Node projects. Set AGENT_WORKBENCH_DEEPSEEK_ROOT and AGENT_WORKBENCH_TEST_PYTHON; comparison requires both Purge source roots. No configured-model requests.'); process.exit(0);
|
||||
console.log('node scripts/verify-controlled-projects.mjs [--purge-comparison | --desktop | --context-16k] [--responses] — actual pinned Harness and owned HTTP model fixture; default verifies Node/React/Python with approvals, Edge and Git. --context-16k uses a new copy of the sealed three-module/nine-test pilot, original failure/log paging and a complete reviewed batch at 16K. --responses uses actual Responses SSE and ModelHub routing. Set AGENT_WORKBENCH_DEEPSEEK_ROOT and AGENT_WORKBENCH_TEST_PYTHON; context mode needs no Python. No configured-model requests.'); process.exit(0);
|
||||
}
|
||||
const comparisonMode = args.includes('--purge-comparison'), desktopMode = args.includes('--desktop');
|
||||
const contextMode = args.includes('--context-16k');assert.ok(!contextMode || !comparisonMode && !desktopMode, '16K bridge acceptance is a separate run.');
|
||||
const responsesMode = args.includes('--responses'); assert.ok(!responsesMode || !comparisonMode, 'Protocol acceptance and Purge comparison remain separate.');
|
||||
assert.ok(!comparisonMode || !desktopMode, 'Desktop engineering and prompt comparison are separate acceptance runs.');
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
||||
const directory = path.resolve('.qa', (desktopMode ? 'desktop-projects-' : comparisonMode ? 'controlled-purge-' : 'controlled-projects-') + randomUUID()), results = [], cases = [];
|
||||
const directory = path.resolve('.qa', (contextMode ? 'controlled-context-' : desktopMode ? 'desktop-projects-' : comparisonMode ? 'controlled-purge-' : 'controlled-projects-') + randomUUID()), results = [], cases = [];
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
const installation = resolveControlledInstallation(process.cwd(), process.env.AGENT_WORKBENCH_DEEPSEEK_ROOT);
|
||||
assert.equal(installation.controlledStatus, 'available', installation.message);
|
||||
const python = process.env.AGENT_WORKBENCH_TEST_PYTHON;
|
||||
if (!comparisonMode) assert.ok(python && path.isAbsolute(python) && fs.existsSync(python), 'Provide the existing isolated Python 3.10+ interpreter.');
|
||||
if (!comparisonMode && !contextMode) assert.ok(python && path.isAbsolute(python) && fs.existsSync(python), 'Provide the existing isolated Python 3.10+ interpreter.');
|
||||
const sources = comparisonMode ? ['1.1.78', '1.1.81'].map((expected, index) => {
|
||||
const root = process.env[index === 0 ? 'AGENT_WORKBENCH_PURGE_178_ROOT' : 'AGENT_WORKBENCH_PURGE_181_ROOT'];
|
||||
assert.ok(root && path.isAbsolute(root), 'Provide both existing Purge source directories.');
|
||||
@@ -52,7 +54,7 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
const disposers = [], t = { after: value => disposers.push(value) }, f = fixture(t), sample = path.join(directory, sampleName);
|
||||
fs.mkdirSync(sample); let runtime, group, result, desktopQa, cycledRequest = false, cycledApproval = false; const reviews = [], modelRequests = [];
|
||||
try {
|
||||
const baseline = kind === 'react' ? 'benchmarks/react-delivery-v1/baseline' : 'benchmarks/workers-delivery-v1/' + kind;
|
||||
const baseline = contextMode ? 'docs/live-model-purge-1.24-evidence/source-baselines/r1-off' : kind === 'react' ? 'benchmarks/react-delivery-v1/baseline' : 'benchmarks/workers-delivery-v1/' + kind;
|
||||
fs.cpSync(path.resolve(baseline), f.projectRoot, { recursive: true, filter: file => !file.split(path.sep).includes('node_modules') });
|
||||
write(f, '.gitignore', 'node_modules/\ndist/\n.awb-*\n__pycache__/\n.venv/\n.pytest_cache/\n');
|
||||
write(f, 'owner-staged.txt', 'Owner baseline\n'); write(f, 'owner-unstaged.txt', 'Owner baseline\n');
|
||||
@@ -61,7 +63,7 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
const baselineTree = git(f, ['rev-parse', 'HEAD^{tree}']).trim();
|
||||
write(f, 'owner-staged.txt', 'Owner staged change\n'); git(f, ['add', '--', 'owner-staged.txt']);
|
||||
write(f, 'owner-staged.txt', 'Owner working copy after staging\n'); write(f, 'owner-unstaged.txt', 'Owner unstaged change\n'); write(f, 'owner-untracked.txt', 'Owner untracked file\n');
|
||||
const spec = specification(kind, f.projectRoot), writable = [...new Set([...Object.keys(spec.initial ?? {}), ...Object.keys(spec.fixes)])].sort();
|
||||
const spec = contextMode ? nativeContextSpecification : specification(kind, f.projectRoot), writable = [...new Set([...Object.keys(spec.initial ?? {}), ...Object.keys(spec.fixes)])].sort();
|
||||
const original = ownerBytes(f), protectedNames = git(f, ['ls-files', '-z']).split('\0').filter(file => file && !writable.includes(file) && !file.startsWith('owner-'));
|
||||
const protectedFiles = Object.fromEntries(protectedNames.map(file => [file, fs.readFileSync(path.join(f.projectRoot, file))]));
|
||||
const verify = root => { for (const [file, bytes] of Object.entries(protectedFiles)) assert.deepEqual(fs.readFileSync(path.join(root, file)), bytes, 'Protected ' + file); };
|
||||
@@ -81,7 +83,22 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
const plan = [...f.store.core.check_plan.values()].filter(plan => plan.taskId === worker.taskId).at(-1);
|
||||
const propose = files => Object.entries(files).map(([file, content]) => call(randomUUID(), 'propose_file', { path: file, content, reason: 'Fixed local acceptance repair; retain all tests and declarations.' }));
|
||||
let calls = [];
|
||||
if (session.changes.some(change => change.status === 'pending')) { /* Explicit review follows native completion. */ }
|
||||
if(contextMode){
|
||||
const pending=session.changes.filter(change=>change.status==='pending');
|
||||
const batch=[...f.store.core.change_set.values()].findLast(set=>set.taskId===worker.taskId&&set.status==='prepared');
|
||||
if(pending.length){if(!batch)calls=[call(randomUUID(),'prepare_change_set',{change_ids:pending.map(change=>change.id)})];}
|
||||
else if(phase==='new'){
|
||||
calls=[...writable,'test/expense.test.mjs'].map(file=>call(randomUUID(),'read_file',{path:file,limit:16000}));phase='observed';
|
||||
}else if(phase!=='fixed'&&job){
|
||||
assert.equal(job.status,'failed');assert.equal(job.results[0].tests.failed,9);
|
||||
if(phase!=='failure-log-read'){
|
||||
calls=[call(randomUUID(),'read_artifact',{artifact_id:job.results[0].logArtifactId,offset:0,limit:16000})];phase='failure-log-read';
|
||||
}else{calls=propose(spec.fixes);phase='fixed';}
|
||||
}else if(phase==='fixed'&&job?.status==='passed')assert.equal(job.results[0].tests.passed,9);
|
||||
else if(!plan||job?.planId===plan.id)calls=[call(randomUUID(),'plan_checks',{names:spec.checks})];
|
||||
else calls=[call(randomUUID(),'run_checks',{plan_id:plan.id})];
|
||||
}
|
||||
else if (session.changes.some(change => change.status === 'pending')) { /* Explicit review follows native completion. */ }
|
||||
else if (phase === 'new' && spec.initial) { calls = propose(spec.initial); phase = 'initial'; }
|
||||
else if (phase !== 'fixed' && job) {
|
||||
assert.equal(job.status, 'failed', job.summary); assert.ok(job.results.some(result => result.tests?.failed > 0)); calls = propose(spec.fixes); phase = 'fixed';
|
||||
@@ -94,11 +111,12 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
return { choices: [{ message: { role: 'assistant', content: calls.length ? '' : 'Owned native run complete; host proof is still required.', ...(calls.length ? { tool_calls: calls } : {}) },
|
||||
finish_reason: calls.length ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 123, completion_tokens: 45, total_tokens: 168 } };
|
||||
});
|
||||
f.store.saveConfig({ mode: 'compatible', model: 'owned-controlled-engineering', baseUrl: model.baseUrl, contextLimit: 64000 });
|
||||
f.store.saveConfig({ mode: 'compatible', model: 'owned-controlled-engineering', baseUrl: model.baseUrl, contextLimit: contextMode ? 16000 : 64000,
|
||||
...(contextMode ? {maxOutputTokens:2048} : {}) });
|
||||
const provider = new Provider(); provider.setKey('self-owned-controlled-model-fixture');
|
||||
if (responsesMode) {
|
||||
const hub = provider.modelHub(f.store), connection = hub.upsert({ name: 'Owned Responses engineering', protocol: 'responses', model: 'owned-controlled-engineering', baseUrl: model.baseUrl,
|
||||
requiresKey: false, contextLimit: 64000, streaming: true, capabilityDeclarations: { streaming: 'supported' } });
|
||||
requiresKey: false, contextLimit: contextMode ? 16000 : 64000, ...(contextMode ? {maxOutputTokens:2048} : {}), streaming: true, capabilityDeclarations: { streaming: 'supported' } });
|
||||
hub.select({ type: 'connection', id: connection.id });
|
||||
}
|
||||
runtime = new Runtime(f.store, provider); f.onCleanup(() => runtime.stopAll());
|
||||
@@ -117,7 +135,10 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
for (let turn = 0; turn < 4 && group.status !== 'ready_to_collect'; turn++) {
|
||||
const session = f.store.session(child.sessionId), ids = session.changes.filter(change => change.status === 'pending').map(change => change.id);
|
||||
if (ids.length) {
|
||||
assert.equal(group.status, 'awaiting_review', group.summary); const set = desktopQa ? await desktopQa.review(session, ids) : await runtime.changeSetManager().prepare(session, ids);
|
||||
assert.equal(group.status, 'awaiting_review', group.summary);
|
||||
const nativeBatch=contextMode&&[...f.store.core.change_set.values()].findLast(set=>set.taskId===child.taskId&&set.status==='prepared');
|
||||
const set = nativeBatch || (desktopQa ? await desktopQa.review(session, ids) : await runtime.changeSetManager().prepare(session, ids));
|
||||
if(contextMode)assert.deepEqual(set.files.map(file=>file.path).sort(),writable);
|
||||
reviews.push({ operation: 'review child batch', id: set.id, fingerprint: set.fingerprint, paths: set.files.map(file => file.path) });
|
||||
if (!desktopQa) await (await runtime.changeSetManager().start(session, set.id, set.fingerprint)).promise; assert.equal(set.status, 'completed', set.summary);
|
||||
}
|
||||
@@ -161,6 +182,16 @@ async function runSample(kind, { sampleName = kind, strategy = null, comparison
|
||||
fs.writeFileSync(path.join(sample, 'original-responses-attempts.json'), JSON.stringify(attempts, null, 2));
|
||||
}
|
||||
mark(label + ': actual Harness uses owned model/tool bridges, retains failing tests, and completes reviewed repairs with one accounting entry per HTTP request');
|
||||
if(contextMode){
|
||||
const bounded=engineRuns.flatMap(job=>job.requests.map(request=>verifyEngineModelInput(f.store,childSession,job,request))).filter(input=>input.view.mode==='bounded');
|
||||
assert.ok(bounded.length>0,'The original long failure/log history must exercise the bounded bridge.');
|
||||
assert.ok(bounded.every(input=>input.view.beforeInputTokens>input.view.inputBudget&&input.plan.estimatedInputTokens<=input.view.inputBudget));
|
||||
const sent=JSON.stringify(bounded.map(input=>input.body));assert.ok(sent.includes('logArtifactId'));assert.ok(sent.includes('failed'));
|
||||
const failed=childChecks.find(job=>job.status==='failed'),log=f.store.core.artifact.get(failed.results[0].logArtifactId);
|
||||
assert.ok(f.store.artifactStore.read(log).includes('fail 9'));assert.ok(engineRuns.some(job=>job.calls.some(call=>call.name==='read_artifact')));
|
||||
assert.ok(engineRuns.some(job=>job.calls.some(call=>call.name==='prepare_change_set')));assert.ok(engineRuns.every(job=>!job.inputRejections?.length));
|
||||
mark('16K: original nine failures and paged log survive verified native compaction; all three proposals form one reviewed batch without replay');
|
||||
}
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise; assert.equal(group.status, 'collected', group.summary);
|
||||
const collection = await manager.readCollection(f.session, group); assert.deepEqual(collection.conflicts, []); assert.deepEqual(collection.paths, writable);
|
||||
await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise; assert.equal(group.status, 'merge_prepared', group.summary);
|
||||
@@ -241,9 +272,9 @@ try {
|
||||
mark(source.version + ' repetition ' + repetition + ': identical original task/baseline/tests/response algorithm and budgets; actual prompt overhead and host approvals recorded');
|
||||
}
|
||||
assert.equal(results.length, 8); assert.equal(comparisons.length, 4);
|
||||
} else for (const kind of ['node', 'react', 'python']) results.push(await runSample(kind));
|
||||
} else for (const kind of contextMode ? ['native-context'] : ['node', 'react', 'python']) results.push(await runSample(kind));
|
||||
assert.deepEqual(inputs(), frozen);
|
||||
report = { success: true, targetVersion: version, testedVersion: version, protocol: responsesMode ? 'responses-stream' : 'chat-completions', directory, installation, cases, results, comparisons, sources, inputs: frozen, realModelRequests: 0,
|
||||
scope: 'Pinned actual Harness and workbench execution with an owned HTTP model fixture. Checks, approvals, failures, parent merges, Edge and Git are real. Model reasoning and Purge benefit remain separate.' };
|
||||
} catch (error) { report = { success: false, targetVersion: version, testedVersion: version, directory, installation, cases, results, inputs: frozen, error: error.stack, realModelRequests: 0 }; process.exitCode = 1; }
|
||||
finally { fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(report, null, 2)); fs.writeFileSync('.qa/' + (responsesMode ? 'responses-engineering' : desktopMode ? 'desktop-projects' : comparisonMode ? 'controlled-purge' : 'controlled-projects') + '-location.json', JSON.stringify({ directory, result: path.join(directory, 'result.json') })); console.log('EVIDENCE ' + directory); console.log(JSON.stringify({ success: report.success, cases: cases.length, directory, realModelRequests: 0, error: report.error ?? null })); }
|
||||
finally { fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(report, null, 2)); fs.writeFileSync('.qa/' + (contextMode ? (responsesMode ? 'responses-context' : 'controlled-context') : responsesMode ? 'responses-engineering' : desktopMode ? 'desktop-projects' : comparisonMode ? 'controlled-purge' : 'controlled-projects') + '-location.json', JSON.stringify({ directory, result: path.join(directory, 'result.json') })); console.log('EVIDENCE ' + directory); console.log(JSON.stringify({ success: report.success, cases: cases.length, directory, realModelRequests: 0, error: report.error ?? null })); }
|
||||
|
||||
Reference in New Issue
Block a user