deadbyte-mcp 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.SHA256 +119 -91
- package/README.txt +16 -11
- package/bench/fixtures/corpus.json +32 -13
- package/bench/fixtures/r36/case-map.json +8 -0
- package/bin/WORKER-REGISTRY.txt +3 -3
- package/bin/appcontainer-stage.exe +0 -0
- package/bin/appcontainer-stage.obj +0 -0
- package/bin/bootstrap-advapi32.exe +0 -0
- package/bin/bootstrap-advapi32.obj +0 -0
- package/bin/bootstrap-exitcode.exe +0 -0
- package/bin/bootstrap-exitcode.obj +0 -0
- package/bin/bootstrap-kernel32.exe +0 -0
- package/bin/bootstrap-kernel32.obj +0 -0
- package/bin/child-control-probe.exe +0 -0
- package/bin/child-control-probe.obj +0 -0
- package/bin/child-control-stage.exe +0 -0
- package/bin/child-control-stage.obj +0 -0
- package/bin/contained-reverse-worker.exe +0 -0
- package/bin/contained-reverse-worker.obj +0 -0
- package/bin/contained-transform-worker.exe +0 -0
- package/bin/contained-transform-worker.obj +0 -0
- package/bin/containment-probe.exe +0 -0
- package/bin/containment-probe.obj +0 -0
- package/bin/deadbyte-contain.exe +0 -0
- package/bin/deadbyte-contain.obj +0 -0
- package/bin/deadbyte-exec.exe +0 -0
- package/bin/deadbyte-exec.obj +0 -0
- package/bin/deadbyte-process-host.exe +0 -0
- package/bin/deadbyte-process-host.obj +0 -0
- package/bin/deadbyte-tunnel-host.exe +0 -0
- package/bin/deadbyte-tunnel-host.obj +0 -0
- package/controller/README.TXT +8 -6
- package/controller/deadbyte-controller.ps1 +48 -2
- package/controller/deadbyte-process-policy.json +5 -5
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/R36-CAPABILITY-EVIDENCE.md +43 -0
- package/docs/superpowers/plans/2026-09-18-r36-zero-loss-autonomy.md +739 -0
- package/docs/superpowers/specs/2026-09-18-r36-zero-loss-autonomy-design.md +640 -0
- package/package.json +1 -1
- package/proof/CONTAINMENT-BUILD.txt +6 -6
- package/scripts/deferred-slot-operation.mjs +53 -15
- package/scripts/final-closure-verify.mjs +88 -39
- package/scripts/final-closure.mjs +63 -56
- package/scripts/gate-windows.ps1 +3 -3
- package/scripts/release-parity-tests.ps1 +9 -0
- package/scripts/release-parity.mjs +149 -139
- package/scripts/windows-gate-evidence.mjs +5 -5
- package/src/autonomous-context-engine.mjs +2 -1
- package/src/autonomous-mcp-tools.mjs +5 -1
- package/src/autonomous-output-contracts.mjs +4 -4
- package/src/autonomous-planner-contracts.mjs +36 -1
- package/src/autonomous-planner.mjs +25 -3
- package/src/autonomous-runtime.mjs +191 -21
- package/src/capability-benchmark-runner.mjs +86 -1
- package/src/capability-benchmark.mjs +45 -0
- package/src/capability-ledger.mjs +158 -0
- package/src/coding-mcp-tools.mjs +31 -17
- package/src/coding-output-contracts.mjs +48 -10
- package/src/coding-plane.mjs +45 -9
- package/src/coding-search.mjs +130 -47
- package/src/compact-gateway-mcp-tools.mjs +128 -0
- package/src/compact-gateway-output-contracts.mjs +16 -0
- package/src/deadbyte-cli.mjs +51 -28
- package/src/machine-fs-smoke-client.mjs +1 -1
- package/src/machine-fs.mjs +51 -8
- package/src/mcp-server.mjs +32 -9
- package/src/native-diff-v2.mjs +337 -0
- package/src/native-diff.mjs +50 -2
- package/src/observation-smoke-client.mjs +1 -1
- package/src/operator-surface.mjs +7 -1
- package/src/process-runtime.mjs +98 -11
- package/src/process-smoke-client.mjs +11 -3
- package/src/r36-compact-disarmed-probe.mjs +50 -0
- package/src/r36-full-surface-probe.mjs +56 -0
- package/src/remote-live-log.mjs +76 -0
- package/src/remote-mcp-autonomous-smoke-client.mjs +7 -3
- package/src/remote-mcp-coding-smoke-client.mjs +1 -1
- package/src/remote-mcp-r36-parity-client.mjs +175 -0
- package/src/remote-mcp-smoke-client.mjs +112 -56
- package/src/runtime-update.mjs +51 -1
- package/src/search-cursor.mjs +45 -0
- package/src/semantic-code.mjs +72 -5
- package/src/semantic-lsp-backend.mjs +39 -3
- package/src/version.mjs +1 -1
- package/test/autonomous-capability-r36.test.mjs +151 -0
- package/test/autonomous-runtime.test.mjs +2 -2
- package/test/capability-benchmark-r36.test.mjs +107 -0
- package/test/capability-benchmark-semantic-r36.test.mjs +52 -0
- package/test/capability-claims-r36.test.mjs +23 -0
- package/test/capability-ledger-r36.test.mjs +102 -0
- package/test/coding-catalog-consistency.test.mjs +2 -2
- package/test/coding-plane.test.mjs +2 -2
- package/test/coding-runtime.test.mjs +16 -0
- package/test/coding-search-r36.test.mjs +90 -0
- package/test/compact-catalog-r36.test.mjs +37 -0
- package/test/compact-gateway-r36.test.mjs +66 -0
- package/test/contained.test.mjs +1 -1
- package/test/core.test.mjs +1 -1
- package/test/deferred-slot-operation.test.mjs +9 -0
- package/test/fixtures/lsp-framed-server.mjs +2 -0
- package/test/helpers/autonomous-r34-fixture.mjs +5 -3
- package/test/multi-file-read.test.mjs +3 -0
- package/test/native-diff-topology-r36.test.mjs +105 -0
- package/test/package-boundary.test.mjs +6 -0
- package/test/process-longrun-r36.test.mjs +82 -0
- package/test/process-release-gate.test.mjs +9 -0
- package/test/production-docs.test.mjs +3 -3
- package/test/prompts-resources.test.mjs +7 -1
- package/test/r33-closeout-regression.test.mjs +4 -3
- package/test/r33-finalization.test.mjs +14 -9
- package/test/r36-finalization.test.mjs +104 -0
- package/test/r36-release-identity.test.mjs +52 -0
- package/test/release-version.test.mjs +18 -15
- package/test/remote-live-log-r36.test.mjs +37 -0
- package/test/remote-live-log-recovery-r36.test.mjs +41 -0
- package/test/remote-r24-catalog.test.mjs +13 -0
- package/test/remote-session-cli.test.mjs +40 -30
- package/test/runtime-self-update.test.mjs +58 -1
- package/test/semantic-lsp-backend.test.mjs +9 -0
- package/test/semantic-r36-rename.test.mjs +82 -0
- package/deadbyte-mcp-0.8.9.tgz +0 -0
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { mkdir, readFile, realpath, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { loadPowerShellDataFile } from '../src/runtime-update.mjs';
|
|
3
4
|
import os from 'node:os';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import { spawn } from 'node:child_process';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { probeR36FullSurface } from '../src/r36-full-surface-probe.mjs';
|
|
9
|
+
import { runR36CompactParity } from '../src/remote-mcp-r36-parity-client.mjs';
|
|
10
|
+
import { probeR36CompactDisarmed } from '../src/r36-compact-disarmed-probe.mjs';
|
|
7
11
|
|
|
8
|
-
const here
|
|
9
|
-
const root
|
|
10
|
-
const stateRoot
|
|
11
|
-
const deferred
|
|
12
|
-
const ps
|
|
13
|
-
const launcher
|
|
14
|
-
const sleep
|
|
15
|
-
const sha256
|
|
12
|
+
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const root=path.resolve(here,'..');
|
|
14
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
15
|
+
const deferred=path.join(root,'scripts','deferred-slot-operation.mjs');
|
|
16
|
+
const ps='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe';
|
|
17
|
+
const launcher=path.join(stateRoot,'bin','DEADBYTE-MCP.ps1');
|
|
18
|
+
const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
19
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
export const R35_PREDECESSOR_RELEASE_ID='v0.9.0-b95e1ec1d9a7e26a';
|
|
22
|
+
export const R35_PREDECESSOR_MANIFEST='b95e1ec1d9a7e26a96ef492306c1be4df18c883ff03ab3b6015f677d7429ec8d';
|
|
23
|
+
|
|
24
|
+
function assert(condition,message){if(!condition) throw new Error(message);}
|
|
25
|
+
function parseFrozenManifest(text){
|
|
19
26
|
const entries=[];const seen=new Set();
|
|
20
27
|
for(const [index,line] of text.split(/\r?\n/).entries()){
|
|
21
28
|
if(!line) continue;
|
|
@@ -27,164 +34,167 @@ function parseFrozenManifest(text) {
|
|
|
27
34
|
}
|
|
28
35
|
return entries;
|
|
29
36
|
}
|
|
30
|
-
|
|
37
|
+
// Restore the mutable development stage from the immutable active release after live parity work may drift it.
|
|
38
|
+
export async function restoreFrozenStage({developmentRoot,releaseRoot,expectedManifestSha256}){
|
|
31
39
|
const dev=path.resolve(developmentRoot);const release=path.resolve(releaseRoot);
|
|
32
40
|
const manifestBytes=await readFile(path.join(release,'MANIFEST.SHA256'));
|
|
33
41
|
const manifestSha256=sha256(manifestBytes);
|
|
34
42
|
assert(manifestSha256===expectedManifestSha256,`immutable release manifest drift: ${manifestSha256}`);
|
|
35
43
|
const entries=parseFrozenManifest(manifestBytes.toString('utf8'));
|
|
36
44
|
for(const entry of entries){
|
|
37
|
-
const source=path.join(release,...entry.path.split('/'));
|
|
38
|
-
const bytes=await readFile(source);
|
|
45
|
+
const source=path.join(release,...entry.path.split('/'));const bytes=await readFile(source);
|
|
39
46
|
assert(sha256(bytes)===entry.sha256,`immutable release file drift: ${entry.path}`);
|
|
40
|
-
const destination=path.join(dev,...entry.path.split('/'));
|
|
41
|
-
await
|
|
42
|
-
await writeFile(destination,bytes);
|
|
43
|
-
assert(sha256(await readFile(destination))===entry.sha256,`development restore verification failed: ${entry.path}`);
|
|
47
|
+
const destination=path.join(dev,...entry.path.split('/'));await mkdir(path.dirname(destination),{recursive:true});
|
|
48
|
+
await writeFile(destination,bytes);assert(sha256(await readFile(destination))===entry.sha256,`development restore verification failed: ${entry.path}`);
|
|
44
49
|
}
|
|
45
50
|
await writeFile(path.join(dev,'MANIFEST.SHA256'),manifestBytes);
|
|
46
51
|
assert(sha256(await readFile(path.join(dev,'MANIFEST.SHA256')))===expectedManifestSha256,'development manifest restore verification failed');
|
|
47
52
|
return {status:'restored',file_count:entries.length,manifest_sha256:manifestSha256};
|
|
48
53
|
}
|
|
49
|
-
function parseJsonOutput(text,
|
|
50
|
-
const trimmed
|
|
51
|
-
const starts
|
|
52
|
-
for (const start of starts) {
|
|
53
|
-
try { return JSON.parse(trimmed.slice(start)); } catch {}
|
|
54
|
-
}
|
|
54
|
+
function parseJsonOutput(text,label){
|
|
55
|
+
const trimmed=String(text).trim();const starts=[...trimmed.matchAll(/\{/g)].map(match=>match.index);
|
|
56
|
+
for(const start of starts){try{return JSON.parse(trimmed.slice(start));}catch{}}
|
|
55
57
|
throw new Error(`${label} did not emit JSON`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const timer
|
|
61
|
-
child.stdout.on('data',
|
|
62
|
-
child.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
clearTimeout(timer);
|
|
66
|
-
const stdout = Buffer.concat(out).toString('utf8');
|
|
67
|
-
const stderr = Buffer.concat(err).toString('utf8');
|
|
68
|
-
if (code !== 0) reject(new Error(`command failed exit=${code}: ${stderr || stdout}`));
|
|
69
|
-
else resolve({ stdout, stderr, exitCode:code });
|
|
58
|
+
}
|
|
59
|
+
function run(command,args,{timeoutMs=900000,env=process.env,cwd=root}={}){
|
|
60
|
+
return new Promise((resolve,reject)=>{
|
|
61
|
+
const child=spawn(command,args,{cwd,shell:false,windowsHide:true,env,stdio:['ignore','pipe','pipe']});
|
|
62
|
+
const out=[],err=[];const timer=setTimeout(()=>{child.kill();reject(new Error(`command timeout: ${path.basename(command)}`));},timeoutMs);
|
|
63
|
+
child.stdout.on('data',chunk=>out.push(Buffer.from(chunk)));child.stderr.on('data',chunk=>err.push(Buffer.from(chunk)));
|
|
64
|
+
child.on('error',error=>{clearTimeout(timer);reject(error);});child.on('exit',code=>{
|
|
65
|
+
clearTimeout(timer);const stdout=Buffer.concat(out).toString('utf8');const stderr=Buffer.concat(err).toString('utf8');
|
|
66
|
+
if(code!==0) reject(new Error(`command failed exit=${code}: ${stderr||stdout}`));else resolve({stdout,stderr,exitCode:code});
|
|
70
67
|
});
|
|
71
68
|
});
|
|
72
69
|
}
|
|
73
|
-
async function publicUrl()
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
if (url.protocol !== 'https:') throw new Error('public MCP URL must be HTTPS');
|
|
77
|
-
return text;
|
|
70
|
+
async function publicUrl(){
|
|
71
|
+
const value=(await readFile(path.join(stateRoot,'bridge','mcp-url.txt'),'utf8')).trim();const url=new URL(value);
|
|
72
|
+
if(url.protocol!=='https:') throw new Error('public MCP URL must be HTTPS');return value;
|
|
78
73
|
}
|
|
79
|
-
async function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}async function waitDeferred(statePath, timeoutMs = 180000) {
|
|
84
|
-
const deadline = Date.now() + timeoutMs;
|
|
85
|
-
while (Date.now() < deadline) {
|
|
86
|
-
const state = JSON.parse(await readFile(statePath, 'utf8'));
|
|
87
|
-
if (state.state === 'completed') return state;
|
|
88
|
-
if (state.state === 'failed') throw new Error(`deferred ${state.mode} failed: ${state.error}`);
|
|
89
|
-
await sleep(500);
|
|
74
|
+
async function pointer(){return JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));}
|
|
75
|
+
async function disarmAll(){
|
|
76
|
+
for(const command of ['disarmautonomous','disarmcoding','disarmprocess','disarmhost']){
|
|
77
|
+
await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,command],{timeoutMs:60000});
|
|
90
78
|
}
|
|
79
|
+
}
|
|
80
|
+
async function waitDeferred(statePath,timeoutMs=180000){
|
|
81
|
+
const deadline=Date.now()+timeoutMs;
|
|
82
|
+
while(Date.now()<deadline){const state=JSON.parse(await readFile(statePath,'utf8'));if(state.state==='completed') return state;if(state.state==='failed') throw new Error(`deferred ${state.mode} failed: ${state.error}`);await sleep(500);}
|
|
91
83
|
throw new Error(`deferred operation timeout: ${statePath}`);
|
|
92
84
|
}
|
|
93
|
-
async function scheduleDeferred(mode,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
async function scheduleDeferred(mode,value,{bridgeRoot=null,bridgeScriptSha256=null}={}){
|
|
86
|
+
if((bridgeRoot===null)!==(bridgeScriptSha256===null)) throw new Error('deferred bridge override requires exact root + SHA pair');
|
|
87
|
+
const args=[deferred,mode,value];
|
|
88
|
+
if(bridgeRoot!==null) args.push('--bridge-root',bridgeRoot,'--bridge-script-sha256',bridgeScriptSha256);
|
|
89
|
+
const scheduled=parseJsonOutput((await run(process.execPath,args,{timeoutMs:30000})).stdout,`deferred ${mode}`);
|
|
90
|
+
assert(scheduled.status==='scheduled',`deferred ${mode} was not scheduled`);
|
|
91
|
+
assert(scheduled.execution_provider==='deadbyte_mcp'&&scheduled.rdc_operation_count===0,'deferred operation provider mismatch');
|
|
92
|
+
return {scheduled,completed:await waitDeferred(scheduled.state_path)};
|
|
98
93
|
}
|
|
99
|
-
async function
|
|
100
|
-
const script
|
|
101
|
-
const result
|
|
102
|
-
assert(result.status
|
|
103
|
-
assert(result.coding_armed
|
|
94
|
+
async function publicR35Disarmed(url){
|
|
95
|
+
const script=path.join(root,'src','remote-mcp-r24-disarmed-smoke-client.mjs');
|
|
96
|
+
const result=parseJsonOutput((await run(process.execPath,[script,url],{timeoutMs:90000})).stdout,'R35 predecessor disarmed gate');
|
|
97
|
+
assert(result.status==='passed'&&result.tool_count===73,'R35 predecessor public catalog mismatch');
|
|
98
|
+
assert(result.coding_armed===false&&result.autonomous_armed===false,'R35 predecessor authority remained armed');
|
|
104
99
|
return result;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
assert(
|
|
110
|
-
|
|
111
|
-
assert(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
}
|
|
101
|
+
async function mutableCore(pointerValue){
|
|
102
|
+
const policy=JSON.parse(await readFile(path.join(pointerValue.generation_root,'coding-policy.json'),'utf8'));
|
|
103
|
+
const raw=policy?.roots?.core?.path??policy?.roots?.core?.real_path;
|
|
104
|
+
assert(typeof raw==='string'&&raw,'R36 generation missing coding core root');
|
|
105
|
+
const core=path.resolve(raw);const release=path.resolve(pointerValue.release_root);
|
|
106
|
+
assert(core.toLowerCase()!==release.toLowerCase(),'R36 coding core must not point at immutable active release slot');
|
|
107
|
+
return core;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function validateParityEvidence(value){
|
|
111
|
+
assert(value?.schema==='deadbyte.r36-parity.v1','R36 parity schema mismatch');
|
|
112
|
+
assert(value.status==='passed','R36 parity status is not passed');
|
|
113
|
+
assert(value.rdc_operation_count===0&&value.execution_provider==='deadbyte_mcp','R36 parity used non-DEADBYTE execution');
|
|
114
|
+
assert(value.candidate?.version==='0.10.0'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R36 candidate identity missing');
|
|
115
|
+
assert(value.local_full?.status==='passed'&&value.local_full?.tool_count===76&&value.local_full?.strict_output_schemas===true,'R36 local full 76-tool proof missing');
|
|
116
|
+
assert(value.public_compact?.status==='passed'&&value.public_compact?.tool_count<=42&&value.public_compact?.capability_closure===true&&value.public_compact?.gateway_count===5,'R36 public compact closure missing');
|
|
117
|
+
assert(value.autonomous?.status==='passed'&&value.autonomous?.signed_release_verified===true,'R36 autonomous live proof missing');
|
|
118
|
+
assert(value.before_rollback_disarmed?.status==='passed'&&value.before_rollback_disarmed?.capability_closure===true&&value.before_rollback_disarmed?.coding_armed===false&&value.before_rollback_disarmed?.autonomous_armed===false,'R36 pre-rollback disarm proof missing');
|
|
119
|
+
assert(value.rollback?.state==='completed'&&value.restore?.state==='completed','R36 rollback/restore not completed');
|
|
120
|
+
assert(value.stage_restore?.status==='restored'&&value.stage_restore?.manifest_sha256===value.candidate.manifest_sha256,'R36 stage restore proof missing');
|
|
121
|
+
assert(value.predecessor?.release_id===R35_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R35_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.9.0','R35 exact predecessor identity mismatch');
|
|
122
|
+
assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count===73,'R35 predecessor public proof missing');
|
|
123
|
+
assert(value.successor?.version==='0.10.0'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R36 exact successor restore identity mismatch');
|
|
124
|
+
assert(value.successor_disarmed?.status==='passed'&&value.successor_disarmed?.capability_closure===true&&value.successor_disarmed?.coding_armed===false&&value.successor_disarmed?.autonomous_armed===false,'R36 successor disarmed proof missing');
|
|
125
|
+
assert(value.immutable_slot?.protected===true&&value.immutable_slot?.development_root!==value.immutable_slot?.release_root,'R36 immutable-slot separation missing');
|
|
126
|
+
for(const key of ['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface']) assert(value.requirements?.[key]===true,`R36 parity requirement not proven: ${key}`);
|
|
117
127
|
return true;
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
export async function runReleaseParity(activationReceiptPath)
|
|
121
|
-
const pointer =
|
|
122
|
-
|
|
123
|
-
assert(
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if(restoreError) throw restoreError;
|
|
143
|
-
}
|
|
130
|
+
export async function runReleaseParity(activationReceiptPath){
|
|
131
|
+
const active=await pointer();const candidateManifest=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
|
|
132
|
+
assert(active.version==='0.10.0','R36 parity requires active 0.10.0 candidate');
|
|
133
|
+
assert(active.manifest_sha256===candidateManifest,'active release is not canonical R36 candidate');
|
|
134
|
+
const activeConfig=await loadPowerShellDataFile(active.config_path);
|
|
135
|
+
const successorBridgeRootRaw=activeConfig?.Bridge?.WorkingDirectory;
|
|
136
|
+
const successorBridgeConfiguredSha=activeConfig?.Bridge?.ScriptSha256;
|
|
137
|
+
assert(typeof successorBridgeRootRaw==='string'&&path.isAbsolute(successorBridgeRootRaw),'R36 active bridge root missing');
|
|
138
|
+
assert(typeof successorBridgeConfiguredSha==='string'&&/^[0-9a-f]{64}$/.test(successorBridgeConfiguredSha),'R36 active bridge SHA missing');
|
|
139
|
+
const successorBridgeRoot=await realpath(path.resolve(successorBridgeRootRaw));
|
|
140
|
+
const successorBridgeActualSha=sha256(await readFile(path.join(successorBridgeRoot,'src','bridge.mjs')));
|
|
141
|
+
assert(successorBridgeActualSha===successorBridgeConfiguredSha,'R36 active bridge bytes do not match generation pin');
|
|
142
|
+
const successorBridge={root:successorBridgeRoot,sha256:successorBridgeActualSha};
|
|
143
|
+
const developmentRoot=await mutableCore(active);
|
|
144
|
+
const localFull=await probeR36FullSurface({packageRoot:active.release_root,generationRoot:active.generation_root,stateRoot});
|
|
145
|
+
const url=await publicUrl();
|
|
146
|
+
let publicCompact,autonomous;
|
|
147
|
+
try{
|
|
148
|
+
publicCompact=await runR36CompactParity(url);
|
|
149
|
+
autonomous=parseJsonOutput((await run(process.execPath,[path.join(root,'src','remote-mcp-autonomous-smoke-client.mjs'),url],{timeoutMs:900000})).stdout,'R36 autonomous compact parity');
|
|
150
|
+
assert(autonomous.status==='passed'&&autonomous.signed_release_verified===true,'R36 autonomous compact parity failed');
|
|
151
|
+
}catch(error){await disarmAll().catch(()=>{});throw error;}
|
|
144
152
|
|
|
145
153
|
await disarmAll();
|
|
146
|
-
const beforeRollback
|
|
147
|
-
const rollbackPair
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
154
|
+
const beforeRollback=await probeR36CompactDisarmed(url);
|
|
155
|
+
const rollbackPair=await scheduleDeferred('rollback',path.resolve(activationReceiptPath));
|
|
156
|
+
const predecessor=await pointer();
|
|
157
|
+
assert(predecessor.release_id===R35_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R35_PREDECESSOR_MANIFEST&&predecessor.version==='0.9.0','rollback did not reach exact sealed R35 predecessor');
|
|
158
|
+
const predecessorDisarmed=await publicR35Disarmed(url);
|
|
159
|
+
const stageRestore=await restoreFrozenStage({developmentRoot,releaseRoot:active.release_root,expectedManifestSha256:candidateManifest});
|
|
160
|
+
const restorePair=await scheduleDeferred('activate',candidateManifest,{bridgeRoot:successorBridge.root,bridgeScriptSha256:successorBridge.sha256});
|
|
161
|
+
const successor=await pointer();
|
|
162
|
+
assert(successor.version==='0.10.0'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R36 candidate');
|
|
163
|
+
const successorDisarmed=await probeR36CompactDisarmed(url);
|
|
164
|
+
await disarmAll();
|
|
153
165
|
|
|
154
|
-
const evidence
|
|
155
|
-
schema:'deadbyte.
|
|
156
|
-
release_id:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
restore:{...restorePair.completed,
|
|
163
|
-
successor_disarmed:successorDisarmed,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
const evidence={
|
|
167
|
+
schema:'deadbyte.r36-parity.v1',status:'passed',completed_at_utc:new Date().toISOString(),execution_provider:'deadbyte_mcp',rdc_operation_count:0,
|
|
168
|
+
candidate:{release_id:active.release_id,version:active.version,manifest_sha256:candidateManifest},
|
|
169
|
+
immutable_slot:{protected:true,release_root:path.resolve(active.release_root),development_root:developmentRoot},
|
|
170
|
+
local_full:localFull,public_compact:publicCompact,autonomous,before_rollback_disarmed:beforeRollback,
|
|
171
|
+
rollback:{...rollbackPair.completed,scheduled_operation_id:rollbackPair.scheduled.operation_id},
|
|
172
|
+
predecessor:{release_id:predecessor.release_id,version:predecessor.version,manifest_sha256:predecessor.manifest_sha256},predecessor_disarmed:predecessorDisarmed,
|
|
173
|
+
stage_restore:stageRestore,
|
|
174
|
+
restore:{...restorePair.completed,scheduled_operation_id:restorePair.scheduled.operation_id},
|
|
175
|
+
successor:{release_id:successor.release_id,version:successor.version,manifest_sha256:successor.manifest_sha256},successor_disarmed:successorDisarmed,
|
|
176
|
+
requirements:{
|
|
177
|
+
tree_read:publicCompact.tree_entries>=0&&publicCompact.coding_stat_verified===true,
|
|
178
|
+
precondition_mutation:publicCompact.machine_fs_receipts_verified>=3,
|
|
179
|
+
search:publicCompact.coding_search_result_count>=1&&publicCompact.observation_search_result_count>=1,
|
|
180
|
+
owned_process:typeof publicCompact.process_session_id==='string'&&publicCompact.process_output_bytes>0,
|
|
181
|
+
observation:publicCompact.observation_receipts_verified>=2,
|
|
182
|
+
coding_loop:publicCompact.coding_receipts_verified===2,
|
|
183
|
+
autonomy:autonomous.signed_release_verified===true&&autonomous.observed_failure_before_replan===true,
|
|
184
|
+
interrupted_recovery:rollbackPair.completed.state==='completed'&&restorePair.completed.state==='completed',
|
|
185
|
+
evidence_verification:publicCompact.machine_fs_receipts_verified>=3&&autonomous.signed_release_verified===true,
|
|
186
|
+
compact_closure:publicCompact.capability_closure===true&&successorDisarmed.capability_closure===true,
|
|
187
|
+
full_surface:localFull.tool_count===76&&localFull.strict_output_schemas===true
|
|
173
188
|
}
|
|
174
189
|
};
|
|
175
190
|
validateParityEvidence(evidence);
|
|
176
|
-
const evidenceDir
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
await writeFile(evidencePath, bytes);
|
|
181
|
-
return { evidence, evidence_path:evidencePath, evidence_sha256:sha256(bytes) };
|
|
191
|
+
const evidenceDir=path.join(stateRoot,'evidence','release');await mkdir(evidenceDir,{recursive:true});
|
|
192
|
+
const evidencePath=path.join(evidenceDir,`r36-parity-${candidateManifest.slice(0,16)}.json`);
|
|
193
|
+
const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');await writeFile(evidencePath,bytes);
|
|
194
|
+
return {evidence,evidence_path:evidencePath,evidence_sha256:sha256(bytes)};
|
|
182
195
|
}
|
|
183
196
|
|
|
184
|
-
if
|
|
185
|
-
const receipt
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
.then(result => console.log(JSON.stringify({ status:'passed', ...result }, null, 2)))
|
|
189
|
-
.catch(error => { console.error(error instanceof Error ? error.stack : String(error)); process.exitCode = 1; });
|
|
190
|
-
}
|
|
197
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
198
|
+
const receipt=process.argv[2];if(!receipt) throw new Error('usage: node scripts/release-parity.mjs <activation-receipt.json>');
|
|
199
|
+
runReleaseParity(receipt).then(result=>console.log(JSON.stringify({status:'passed',...result},null,2))).catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|
|
200
|
+
}
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const root=path.resolve(here,'..');
|
|
9
9
|
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
10
|
-
const marker='DEADBYTE V0.
|
|
10
|
+
const marker='DEADBYTE V0.10.0 / R36 WINDOWS BATCH GATE: PASS';
|
|
11
11
|
function insist(ok,message){if(!ok) throw new Error(message);}
|
|
12
12
|
|
|
13
13
|
export async function writeWindowsGateEvidence({
|
|
@@ -19,17 +19,17 @@ export async function writeWindowsGateEvidence({
|
|
|
19
19
|
const manifestBytes=await readFile(path.join(candidate,'MANIFEST.SHA256'));
|
|
20
20
|
const manifestSha256=sha256(manifestBytes);
|
|
21
21
|
const pkg=JSON.parse(await readFile(path.join(candidate,'package.json'),'utf8'));
|
|
22
|
-
insist(pkg.version==='0.
|
|
22
|
+
insist(pkg.version==='0.10.0',`Windows gate evidence requires V0.10.0, found ${pkg.version}`);
|
|
23
23
|
const completed=clock();
|
|
24
24
|
insist(completed instanceof Date&&!Number.isNaN(completed.getTime()),'Windows gate evidence clock invalid');
|
|
25
25
|
const evidence={
|
|
26
|
-
schema:'deadbyte.
|
|
26
|
+
schema:'deadbyte.r36-windows-gate.v1',status:'passed',exit_code:0,version:'0.10.0',
|
|
27
27
|
marker,completed_at_utc:completed.toISOString(),manifest_sha256:manifestSha256
|
|
28
28
|
};
|
|
29
29
|
const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');
|
|
30
30
|
const dir=path.join(path.resolve(stateRoot),'evidence','release');
|
|
31
31
|
await mkdir(dir,{recursive:true});
|
|
32
|
-
const file=path.join(dir,`
|
|
32
|
+
const file=path.join(dir,`r36-windows-gate-${manifestSha256.slice(0,16)}.json`);
|
|
33
33
|
try{
|
|
34
34
|
const handle=await open(file,'wx',0o600);
|
|
35
35
|
try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}
|
|
@@ -39,7 +39,7 @@ export async function writeWindowsGateEvidence({
|
|
|
39
39
|
const existingBytes=await readFile(file);
|
|
40
40
|
const existing=JSON.parse(existingBytes.toString('utf8'));
|
|
41
41
|
insist(existing.schema===evidence.schema&&existing.status==='passed'&&existing.exit_code===0,'existing Windows gate evidence invalid');
|
|
42
|
-
insist(existing.version==='0.
|
|
42
|
+
insist(existing.version==='0.10.0'&&existing.marker===marker&&existing.manifest_sha256===manifestSha256,'existing Windows gate evidence binding mismatch');
|
|
43
43
|
return {status:'existing',path:file,sha256:sha256(existingBytes),manifest_sha256:manifestSha256};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -213,7 +213,7 @@ function historicalEvidence({ contexts, observations, loopState }) {
|
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
export function buildLoopContext({ goal, policy, loopState = {}, tree = [], contexts = [], observations = [], decisions = [], projectMemory = null }) {
|
|
216
|
+
export function buildLoopContext({ goal, policy, loopState = {}, tree = [], contexts = [], observations = [], decisions = [], projectMemory = null, capabilities = null }) {
|
|
217
217
|
if (!policy?.limits || !Number.isInteger(policy.limits.max_context_bytes)) throw new Error('loop context policy byte limit missing');
|
|
218
218
|
const relevanceEpoch=Number.isInteger(loopState?.mutation_epoch)&&loopState.mutation_epoch>=0?loopState.mutation_epoch:0;
|
|
219
219
|
const retainedContexts=normalizeEvidence(contexts,{kind:'context',relevanceEpoch});
|
|
@@ -249,6 +249,7 @@ export function buildLoopContext({ goal, policy, loopState = {}, tree = [], cont
|
|
|
249
249
|
},
|
|
250
250
|
historical_evidence:historicalEvidence({contexts:retainedContexts,observations:retainedObservations,loopState}),
|
|
251
251
|
project_memory:memory,
|
|
252
|
+
capabilities:capabilities===null?null:structuredClone(capabilities),
|
|
252
253
|
profiles
|
|
253
254
|
};
|
|
254
255
|
return compactLoopContext(state,policy.limits.max_context_bytes);
|
|
@@ -18,7 +18,11 @@ const replaceOperation = z.strictObject({ kind:z.literal('replace'), path:relPat
|
|
|
18
18
|
expected_sha256:hex64, old_string:z.string().min(1).max(262144), new_string:z.string().max(524288),
|
|
19
19
|
expected_replacements:z.number().int().min(1).max(64).default(1) });
|
|
20
20
|
const deleteOperation = z.strictObject({ kind:z.literal('delete'), path:relPath, expected_sha256:hex64 });
|
|
21
|
-
const
|
|
21
|
+
const mkdirOperation = z.strictObject({ kind:z.literal('mkdir'), path:relPath });
|
|
22
|
+
const moveOperation = z.strictObject({ kind:z.literal('move'), source_path:relPath, destination_path:relPath,
|
|
23
|
+
expected_source_identity:hex64, expected_destination_identity:z.union([z.literal('absent'),hex64]).default('absent') });
|
|
24
|
+
const rmdirOperation = z.strictObject({ kind:z.literal('rmdir'), path:relPath, expected_source_identity:hex64 });
|
|
25
|
+
const nativeOperation = z.union([writeOperation,replaceOperation,deleteOperation,mkdirOperation,moveOperation,rmdirOperation]);
|
|
22
26
|
const plannerResponse = z.strictObject({ request_id:hex64, raw_text:z.string().min(2).max(8*1024*1024),
|
|
23
27
|
model:z.string().min(1).max(128).default('client-model') });
|
|
24
28
|
function result(schema,value,isError=false) { return autonomousStructuredResult(schema,value,isError); }
|
|
@@ -58,21 +58,21 @@ export const autonomousSessionStatusOutputSchema = statusContract({
|
|
|
58
58
|
|
|
59
59
|
export const nativeDiffPreviewOutputSchema = statusContract({
|
|
60
60
|
statuses:['ready','failed'], success:['ready'], required:['diff_id','root_id','operation_count','payload_bytes','paths','operations'],
|
|
61
|
-
shape:{ diff_id:hex64.optional(), root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
|
|
62
|
-
payload_bytes:z.number().int().min(0).optional(), paths:z.array(z.string()).max(
|
|
61
|
+
shape:{ schema:z.enum(['deadbyte.native-diff.v1','deadbyte.native-diff.v2']).optional(), diff_id:hex64.optional(), root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
|
|
62
|
+
payload_bytes:z.number().int().min(0).optional(), paths:z.array(z.string()).max(64).optional(),
|
|
63
63
|
operations:z.array(jsonObject).max(32).optional() }
|
|
64
64
|
});
|
|
65
65
|
export const nativeDiffApplyOutputSchema = statusContract({
|
|
66
66
|
statuses:['committed','existing','failed'], success:['committed','existing'],
|
|
67
67
|
required:['diff_id','receipt_sha256','operation_count'],
|
|
68
68
|
shape:{ diff_id:hex64.optional(), receipt_sha256:hex64.optional(), operation_count:z.number().int().min(1).max(32).optional(),
|
|
69
|
-
current_state_matches:z.boolean().optional(), coding_receipts:z.array(jsonObject).max(32).optional() }
|
|
69
|
+
current_state_matches:z.boolean().optional(), coding_receipts:z.array(jsonObject).max(32).optional(), operation_receipts:z.array(jsonObject).max(32).optional() }
|
|
70
70
|
});
|
|
71
71
|
export const nativeDiffVerifyOutputSchema = z.strictObject({
|
|
72
72
|
status:z.literal('failed').optional(), error:z.string().optional(), ok:z.boolean().optional(), reason:z.string().optional(),
|
|
73
73
|
diff_id:hex64.optional(), receipt_sha256:hex64.optional(), signature_valid:z.literal(true).optional(),
|
|
74
74
|
root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
|
|
75
|
-
coding_receipts_verified:z.number().int().min(0).max(32).optional(), final_states:z.array(jsonObject).max(32).optional(),
|
|
75
|
+
coding_receipts_verified:z.number().int().min(0).max(32).optional(), operation_receipts_verified:z.number().int().min(0).max(32).optional(), final_states:z.array(jsonObject).max(32).optional(),
|
|
76
76
|
current_state_matches:z.boolean().optional(), journal_head_sha256:hex64.optional()
|
|
77
77
|
}).superRefine((value,ctx) => {
|
|
78
78
|
if (value.status === 'failed') { requireFields(value,ctx,['error']); return; }
|
|
@@ -89,10 +89,45 @@ const r34PatchOperationSchema = z.discriminatedUnion('kind',[
|
|
|
89
89
|
expected_replacements:z.number().int().min(1).max(64).default(1)}),
|
|
90
90
|
z.strictObject({kind:z.literal('delete'),path:relPath,expected_sha256:z.string().regex(HEX64)})
|
|
91
91
|
]);
|
|
92
|
+
const plannerCursor=z.string().max(4096).nullable().default(null);
|
|
93
|
+
const plannerFiles=z.array(z.strictObject({path:relPath,encoding:z.enum(['utf8','base64']).default('utf8')})).min(1).max(32);
|
|
94
|
+
const plannerSemanticPosition={path:relPath,line:z.number().int().min(0),column:z.number().int().min(0)};
|
|
95
|
+
const r36TypedActionSchemas=[
|
|
96
|
+
z.strictObject({kind:z.literal('search'),path:relPath.default('.'),target:z.enum(['content','path']).default('content'),mode:z.enum(['literal','regex']).default('literal'),pattern:z.string().min(1).max(256),case_sensitive:z.boolean().default(false),max_results:z.number().int().min(1).max(1000).default(200),max_file_bytes:z.number().int().min(1).max(4194304).default(262144),max_scan_bytes:z.number().int().min(1).max(67108864).default(4194304),page_size:z.number().int().min(1).max(500).default(100),cursor:plannerCursor}),
|
|
97
|
+
z.strictObject({kind:z.literal('stat'),path:relPath.default('.'),hash:z.boolean().default(false)}),
|
|
98
|
+
z.strictObject({kind:z.literal('multi_read'),files:plannerFiles,max_total_bytes:z.number().int().min(1).max(2097152).default(1048576)}),
|
|
99
|
+
z.strictObject({kind:z.literal('semantic_outline'),path:relPath,max_symbols:z.number().int().min(1).max(500).default(200)}),
|
|
100
|
+
z.strictObject({kind:z.literal('semantic_definition'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(200).default(50)}),
|
|
101
|
+
z.strictObject({kind:z.literal('semantic_references'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(500).default(200)}),
|
|
102
|
+
z.strictObject({kind:z.literal('semantic_diagnostics'),path:relPath,max_results:z.number().int().min(1).max(500).default(200)}),
|
|
103
|
+
z.strictObject({kind:z.literal('semantic_implementations'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(500).default(200)}),
|
|
104
|
+
z.strictObject({kind:z.literal('semantic_rename_preview'),...plannerSemanticPosition,new_name:z.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/)}),
|
|
105
|
+
z.strictObject({kind:z.literal('native_diff_apply'),diff_id:z.string().regex(HEX64),expected_operation_count:z.number().int().min(1).max(32)}),
|
|
106
|
+
z.strictObject({kind:z.literal('native_diff_verify'),diff_id:z.string().regex(HEX64)}),
|
|
107
|
+
z.strictObject({kind:z.literal('process_start'),profile_id:z.string().regex(ID),cwd:relPath.default('.'),args:z.array(z.string().max(2048)).max(64).default([])}),
|
|
108
|
+
z.strictObject({kind:z.literal('process_read'),session_id:z.string().regex(HEX64),offset:z.number().int().min(0).default(0),max_bytes:z.number().int().min(1).max(262144).default(65536)}),
|
|
109
|
+
z.strictObject({kind:z.literal('process_status'),session_id:z.string().regex(HEX64)}),
|
|
110
|
+
z.strictObject({kind:z.literal('process_list')}),
|
|
111
|
+
z.strictObject({kind:z.literal('process_action'),session_id:z.string().regex(HEX64),action_id:z.string().regex(ID)}),
|
|
112
|
+
z.strictObject({kind:z.literal('process_terminate'),session_id:z.string().regex(HEX64)}),
|
|
113
|
+
z.strictObject({kind:z.literal('machine_fs_stat'),path:relPath.default('.'),hash:z.boolean().default(false)}),
|
|
114
|
+
z.strictObject({kind:z.literal('machine_fs_list'),path:relPath.default('.'),cursor:plannerCursor,limit:z.number().int().min(1).max(1000).default(100),hash_files:z.boolean().default(false)}),
|
|
115
|
+
z.strictObject({kind:z.literal('machine_fs_read'),path:relPath,offset:z.number().int().min(0).default(0),max_bytes:z.number().int().min(1).max(4194304).default(65536),hash_file:z.boolean().default(false)}),
|
|
116
|
+
z.strictObject({kind:z.literal('machine_fs_mkdir'),path:relPath}),
|
|
117
|
+
z.strictObject({kind:z.literal('machine_fs_move'),source_path:relPath,destination_path:relPath,expected_source_identity:z.string().regex(HEX64)}),
|
|
118
|
+
z.strictObject({kind:z.literal('machine_fs_delete'),path:relPath,expected_source_identity:z.string().regex(HEX64)}),
|
|
119
|
+
z.strictObject({kind:z.literal('observation_search_start'),path:relPath.default('.'),pattern:z.string().min(1).max(256),case_sensitive:z.boolean().default(false),max_results:z.number().int().min(1).max(1000).default(200),max_files:z.number().int().min(1).max(10000).default(2000),max_bytes:z.number().int().min(1).max(67108864).default(4194304),max_file_bytes:z.number().int().min(1).max(4194304).default(262144)}),
|
|
120
|
+
z.strictObject({kind:z.literal('observation_search_status'),search_id:z.string().regex(HEX64)}),
|
|
121
|
+
z.strictObject({kind:z.literal('observation_search_page'),search_id:z.string().regex(HEX64),cursor:plannerCursor,limit:z.number().int().min(1).max(500).default(100)}),
|
|
122
|
+
z.strictObject({kind:z.literal('observation_search_cancel'),search_id:z.string().regex(HEX64)}),
|
|
123
|
+
z.strictObject({kind:z.literal('observation_process_list'),include_external:z.boolean().default(false),cursor:plannerCursor,limit:z.number().int().min(1).max(256).default(100)}),
|
|
124
|
+
z.strictObject({kind:z.literal('observation_system_status')})
|
|
125
|
+
];
|
|
92
126
|
const r34ActionSchema = z.discriminatedUnion('kind',[
|
|
93
127
|
z.strictObject({kind:z.literal('patch'),operations:z.array(r34PatchOperationSchema).min(1).max(32)}),
|
|
94
128
|
z.strictObject({kind:z.literal('run_profile'),profile_id:z.string().regex(ID)}),
|
|
95
|
-
z.strictObject({kind:z.literal('delegate'),operation:z.record(z.string(),z.json())})
|
|
129
|
+
z.strictObject({kind:z.literal('delegate'),operation:z.record(z.string(),z.json())}),
|
|
130
|
+
...r36TypedActionSchemas
|
|
96
131
|
]);
|
|
97
132
|
const r34ReadSchema = z.strictObject({
|
|
98
133
|
path:relPath,
|
|
@@ -119,6 +119,27 @@ function normalizeDelegatedOperation(raw) {
|
|
|
119
119
|
}
|
|
120
120
|
throw new Error('planner delegated operation kind invalid');
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
function legacyDelegatedToTyped(operation) {
|
|
124
|
+
if (operation.kind === 'machine_stat') return { kind:'machine_fs_stat', path:operation.path, hash:operation.hash };
|
|
125
|
+
if (operation.kind === 'machine_list') return { kind:'machine_fs_list', path:operation.path, cursor:operation.cursor, limit:operation.limit, hash_files:operation.hash_files };
|
|
126
|
+
if (operation.kind === 'machine_read') return { kind:'machine_fs_read', path:operation.path, offset:operation.offset, max_bytes:operation.max_bytes, hash_file:operation.hash };
|
|
127
|
+
return operation;
|
|
128
|
+
}
|
|
129
|
+
function validateR36TypedAction(action) {
|
|
130
|
+
const pathFields=[];
|
|
131
|
+
if (typeof action.path === 'string' && action.path !== '.') pathFields.push(action.path);
|
|
132
|
+
if (typeof action.cwd === 'string' && action.cwd !== '.') pathFields.push(action.cwd);
|
|
133
|
+
if (typeof action.source_path === 'string') pathFields.push(action.source_path);
|
|
134
|
+
if (typeof action.destination_path === 'string') pathFields.push(action.destination_path);
|
|
135
|
+
for (const item of action.files ?? []) if (typeof item?.path === 'string') pathFields.push(item.path);
|
|
136
|
+
for (const candidate of pathFields) validatePortableRelativePath(candidate);
|
|
137
|
+
return action;
|
|
138
|
+
}
|
|
139
|
+
function normalizeR36TypedAction(action) {
|
|
140
|
+
if (action.kind === 'delegate') return validateR36TypedAction(legacyDelegatedToTyped(normalizeDelegatedOperation(action.operation)));
|
|
141
|
+
return validateR36TypedAction(action);
|
|
142
|
+
}
|
|
122
143
|
function normalizePlan(raw) {
|
|
123
144
|
strictKeys(raw, ['title','reason','steps'], 'planner plan');
|
|
124
145
|
const title = text(raw.title, 'planner plan title', 160, 1);
|
|
@@ -226,9 +247,9 @@ export function parseR34PlannerDecision(rawText, policy) {
|
|
|
226
247
|
return decision;
|
|
227
248
|
}
|
|
228
249
|
if (decision.action.kind === 'delegate') {
|
|
229
|
-
return { ...decision, action:
|
|
250
|
+
return { ...decision, action:normalizeR36TypedAction(decision.action) };
|
|
230
251
|
}
|
|
231
|
-
|
|
252
|
+
return { ...decision, action:normalizeR36TypedAction(decision.action) };
|
|
232
253
|
}
|
|
233
254
|
if (decision.kind === 'step_complete') return decision;
|
|
234
255
|
if (decision.kind === 'replan') {
|
|
@@ -312,7 +333,8 @@ export function buildPlannerPrompt({ goal, policy, view }) {
|
|
|
312
333
|
contexts:view.contexts ?? [],
|
|
313
334
|
observations:view.observations ?? [],
|
|
314
335
|
decisions:view.recent_decisions ?? [],
|
|
315
|
-
projectMemory:view.project_memory ?? null
|
|
336
|
+
projectMemory:view.project_memory ?? null,
|
|
337
|
+
capabilities:view.capabilities ?? null
|
|
316
338
|
});
|
|
317
339
|
const stateJson = canonicalJson(state);
|
|
318
340
|
return [
|