deadbyte-mcp 0.14.0 → 0.15.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/AGENTS.md +11 -18
- package/CONTEXT.md +3 -3
- package/MANIFEST.SHA256 +104 -53
- package/R43-PARENT.json +20 -0
- package/R44-DONORS.json +99 -0
- package/R44-PARENT.json +18 -0
- package/README.txt +7 -2
- package/controller/README.TXT +4 -5
- package/controller/deadbyte-controller.ps1 +1 -1
- package/docs/ARCHITECTURE.md +8 -1
- package/docs/R44-ARCHITECTURE.md +37 -0
- package/package.json +13 -8
- package/scripts/deferred-slot-operation-r43.mjs +126 -0
- package/scripts/deferred-slot-operation-r44.mjs +126 -0
- package/scripts/final-closure-r43.mjs +115 -0
- package/scripts/final-closure-r44.mjs +121 -0
- package/scripts/final-closure-verify-r43.mjs +213 -0
- package/scripts/final-closure-verify-r44.mjs +220 -0
- package/scripts/finalize-r43.mjs +217 -0
- package/scripts/finalize-r44.mjs +217 -0
- package/scripts/full-regression-r43.mjs +20 -0
- package/scripts/full-regression-r44.mjs +20 -0
- package/scripts/gate-windows-r43.ps1 +36 -0
- package/scripts/gate-windows-r44.ps1 +36 -0
- package/scripts/release-parity-r43.mjs +218 -0
- package/scripts/release-parity-r44.mjs +242 -0
- package/scripts/release-parity-tests-r43.ps1 +8 -0
- package/scripts/release-parity-tests-r44.ps1 +8 -0
- package/scripts/verify-r43-parent.mjs +126 -0
- package/scripts/verify-r44-parent.mjs +142 -0
- package/scripts/windows-gate-evidence-r43.mjs +55 -0
- package/scripts/windows-gate-evidence-r44.mjs +55 -0
- package/src/agent-backend-r44.mjs +254 -0
- package/src/autonomous-output-contracts.mjs +1 -1
- package/src/autonomous-policy.mjs +41 -4
- package/src/autonomous-runtime.mjs +25 -12
- package/src/autonomous-supervisor-host.mjs +12 -2
- package/src/capability-ledger.mjs +2 -1
- package/src/codex-app-server-r44.mjs +154 -0
- package/src/coding-plane.mjs +66 -19
- package/src/durable-job-r44.mjs +145 -0
- package/src/external-job-provider-r44.mjs +126 -0
- package/src/host-plane.mjs +27 -6
- package/src/job-supervisor-host-r44.mjs +112 -0
- package/src/machine-fs-smoke-client.mjs +1 -1
- package/src/machine-fs.mjs +21 -10
- package/src/mcp-host-smoke-client.mjs +1 -1
- package/src/mcp-server.mjs +20 -3
- package/src/mcp-smoke-client.mjs +1 -1
- package/src/native-diff-v2.mjs +3 -3
- package/src/native-diff.mjs +3 -2
- package/src/observation-smoke-client.mjs +1 -1
- package/src/operator-surface.mjs +2 -2
- package/src/process-policy.mjs +19 -0
- package/src/process-runtime.mjs +5 -2
- package/src/process-smoke-client.mjs +2 -2
- package/src/provider-circuit.mjs +8 -2
- package/src/r44-compact-disarmed-probe.mjs +74 -0
- package/src/r44-full-surface-probe.mjs +34 -0
- package/src/remote-device-r44.mjs +205 -0
- package/src/remote-mcp-autonomous-smoke-client.mjs +4 -4
- package/src/remote-mcp-r44-parity-client.mjs +203 -0
- package/src/remote-mcp-smoke-client.mjs +7 -4
- package/src/runtime-update.mjs +64 -31
- package/src/skill-mcp-tools-r44.mjs +37 -0
- package/src/skill-plane-r44.mjs +203 -0
- package/src/tunnel-stdio-compat-smoke.mjs +1 -1
- package/src/version.mjs +1 -1
- package/test/agent-backend-r44.test.mjs +115 -0
- package/test/agent-runtime.test.mjs +3 -3
- package/test/autonomous-loop.test.mjs +97 -11
- package/test/autonomous-runtime.test.mjs +2 -2
- package/test/capability-ledger-r36.test.mjs +3 -3
- package/test/cli-entrypoint.test.mjs +1 -1
- package/test/codex-app-server-r44.test.mjs +115 -0
- package/test/codex-autonomous-r44.test.mjs +87 -0
- package/test/coding-plane.test.mjs +2 -2
- package/test/coding-runtime.test.mjs +36 -1
- package/test/compact-catalog-r36.test.mjs +3 -3
- package/test/compact-max-catalog-r40.test.mjs +4 -2
- package/test/compact-max-catalog-r44.test.mjs +97 -0
- package/test/core.test.mjs +1 -1
- package/test/durable-job-r44.test.mjs +75 -0
- package/test/external-job-provider-r44.test.mjs +46 -0
- package/test/full-max-catalog-r40.test.mjs +5 -3
- package/test/full-max-catalog-r44.test.mjs +91 -0
- package/test/host-plane.test.mjs +15 -1
- package/test/native-diff.test.mjs +28 -0
- package/test/output-schema.test.mjs +2 -2
- package/test/process-policy.test.mjs +22 -1
- package/test/prompts-resources.test.mjs +1 -1
- package/test/r33-closeout-regression.test.mjs +13 -30
- package/test/r33-finalization.test.mjs +7 -7
- package/test/r43-finalization.test.mjs +31 -0
- package/test/r43-finalizer.test.mjs +34 -0
- package/test/r43-parent.test.mjs +29 -0
- package/test/r44-finalization.test.mjs +58 -0
- package/test/r44-finalizer.test.mjs +48 -0
- package/test/r44-parent.test.mjs +25 -0
- package/test/release-version.test.mjs +53 -19
- package/test/remote-device-r44.test.mjs +104 -0
- package/test/runtime-self-update.test.mjs +42 -0
- package/test/skill-mcp-r44.test.mjs +38 -0
- package/test/skill-plane-r44.test.mjs +93 -0
- package/test/standing-grants.test.mjs +5 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdir, readFile, realpath, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { loadPowerShellDataFile } from '../src/runtime-update.mjs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { probeR44FullSurface } from '../src/r44-full-surface-probe.mjs';
|
|
9
|
+
import { runR44CompactParity } from '../src/remote-mcp-r44-parity-client.mjs';
|
|
10
|
+
import { probeR44CompactDisarmed } from '../src/r44-compact-disarmed-probe.mjs';
|
|
11
|
+
import { probeR40CompactDisarmed } from '../src/r40-compact-disarmed-probe.mjs';
|
|
12
|
+
import { probeR36CompactDisarmed } from '../src/r36-compact-disarmed-probe.mjs';
|
|
13
|
+
import { runR40DesktopGuardedSmoke } from '../src/remote-mcp-desktop-r40-smoke-client.mjs';
|
|
14
|
+
import { verifyR41Memory } from './verify-memory-r41.mjs';
|
|
15
|
+
|
|
16
|
+
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const root=path.resolve(here,'..');
|
|
18
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
19
|
+
const deferred=path.join(root,'scripts','deferred-slot-operation-r44.mjs');
|
|
20
|
+
const ps='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe';
|
|
21
|
+
const launcher=path.join(stateRoot,'bin','DEADBYTE-MCP.ps1');
|
|
22
|
+
const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
23
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
24
|
+
|
|
25
|
+
export const R44_PREDECESSOR_RELEASE_ID='v0.14.1-0a5a833892593283';
|
|
26
|
+
export const R44_PREDECESSOR_MANIFEST='0a5a8338925932830986421dda60ec5643f62f600404de4992fda2a5e79d09a9';
|
|
27
|
+
|
|
28
|
+
function assert(condition,message){if(!condition) throw new Error(message);}
|
|
29
|
+
function parseFrozenManifest(text){
|
|
30
|
+
const entries=[];const seen=new Set();
|
|
31
|
+
for(const [index,line] of text.split(/\r?\n/).entries()){
|
|
32
|
+
if(!line) continue;
|
|
33
|
+
const match=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);
|
|
34
|
+
assert(match,`frozen manifest line ${index+1} malformed`);
|
|
35
|
+
const rel=match[2];
|
|
36
|
+
assert(!path.posix.isAbsolute(rel)&&!rel.split('/').includes('..')&&!seen.has(rel),`unsafe/duplicate frozen manifest path: ${rel}`);
|
|
37
|
+
seen.add(rel);entries.push({sha256:match[1],path:rel});
|
|
38
|
+
}
|
|
39
|
+
return entries;
|
|
40
|
+
}
|
|
41
|
+
// Restore the mutable development stage from the immutable active release after live parity work may drift it.
|
|
42
|
+
export async function restoreFrozenStage({developmentRoot,releaseRoot,expectedManifestSha256}){
|
|
43
|
+
const dev=path.resolve(developmentRoot);const release=path.resolve(releaseRoot);
|
|
44
|
+
const manifestBytes=await readFile(path.join(release,'MANIFEST.SHA256'));
|
|
45
|
+
const manifestSha256=sha256(manifestBytes);
|
|
46
|
+
assert(manifestSha256===expectedManifestSha256,`immutable release manifest drift: ${manifestSha256}`);
|
|
47
|
+
const entries=parseFrozenManifest(manifestBytes.toString('utf8'));
|
|
48
|
+
for(const entry of entries){
|
|
49
|
+
const source=path.join(release,...entry.path.split('/'));const bytes=await readFile(source);
|
|
50
|
+
assert(sha256(bytes)===entry.sha256,`immutable release file drift: ${entry.path}`);
|
|
51
|
+
const destination=path.join(dev,...entry.path.split('/'));await mkdir(path.dirname(destination),{recursive:true});
|
|
52
|
+
await writeFile(destination,bytes);assert(sha256(await readFile(destination))===entry.sha256,`development restore verification failed: ${entry.path}`);
|
|
53
|
+
}
|
|
54
|
+
await writeFile(path.join(dev,'MANIFEST.SHA256'),manifestBytes);
|
|
55
|
+
assert(sha256(await readFile(path.join(dev,'MANIFEST.SHA256')))===expectedManifestSha256,'development manifest restore verification failed');
|
|
56
|
+
return {status:'restored',file_count:entries.length,manifest_sha256:manifestSha256};
|
|
57
|
+
}
|
|
58
|
+
function parseJsonOutput(text,label){
|
|
59
|
+
const trimmed=String(text).trim();const starts=[...trimmed.matchAll(/\{/g)].map(match=>match.index);
|
|
60
|
+
for(const start of starts){try{return JSON.parse(trimmed.slice(start));}catch{}}
|
|
61
|
+
throw new Error(`${label} did not emit JSON`);
|
|
62
|
+
}
|
|
63
|
+
function run(command,args,{timeoutMs=900000,env=process.env,cwd=root}={}){
|
|
64
|
+
return new Promise((resolve,reject)=>{
|
|
65
|
+
const child=spawn(command,args,{cwd,shell:false,windowsHide:true,env,stdio:['ignore','pipe','pipe']});
|
|
66
|
+
const out=[],err=[];const timer=setTimeout(()=>{child.kill();reject(new Error(`command timeout: ${path.basename(command)}`));},timeoutMs);
|
|
67
|
+
child.stdout.on('data',chunk=>out.push(Buffer.from(chunk)));child.stderr.on('data',chunk=>err.push(Buffer.from(chunk)));
|
|
68
|
+
child.on('error',error=>{clearTimeout(timer);reject(error);});child.on('exit',code=>{
|
|
69
|
+
clearTimeout(timer);const stdout=Buffer.concat(out).toString('utf8');const stderr=Buffer.concat(err).toString('utf8');
|
|
70
|
+
if(code!==0) reject(new Error(`command failed exit=${code}: ${stderr||stdout}`));else resolve({stdout,stderr,exitCode:code});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function publicUrl(){
|
|
75
|
+
const value=(await readFile(path.join(stateRoot,'bridge','mcp-url.txt'),'utf8')).trim();const url=new URL(value);
|
|
76
|
+
if(url.protocol!=='https:') throw new Error('public MCP URL must be HTTPS');return value;
|
|
77
|
+
}
|
|
78
|
+
async function pointer(){return JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));}
|
|
79
|
+
async function disarmAll(){
|
|
80
|
+
for(const command of ['disarmdesktop','disarmautonomous','disarmcoding','disarmprocess','disarmhost']){
|
|
81
|
+
await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,command],{timeoutMs:60000});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function waitDeferred(statePath,timeoutMs=180000){
|
|
85
|
+
const deadline=Date.now()+timeoutMs;
|
|
86
|
+
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);}
|
|
87
|
+
throw new Error(`deferred operation timeout: ${statePath}`);
|
|
88
|
+
}
|
|
89
|
+
async function scheduleDeferred(mode,value,{bridgeRoot=null,bridgeScriptSha256=null}={}){
|
|
90
|
+
if((bridgeRoot===null)!==(bridgeScriptSha256===null)) throw new Error('deferred bridge override requires exact root + SHA pair');
|
|
91
|
+
const args=[deferred,mode,value];
|
|
92
|
+
if(bridgeRoot!==null) args.push('--bridge-root',bridgeRoot,'--bridge-script-sha256',bridgeScriptSha256);
|
|
93
|
+
const scheduled=parseJsonOutput((await run(process.execPath,args,{timeoutMs:30000})).stdout,`deferred ${mode}`);
|
|
94
|
+
assert(scheduled.status==='scheduled',`deferred ${mode} was not scheduled`);
|
|
95
|
+
assert(scheduled.execution_provider==='deadbyte_mcp'&&scheduled.rdc_operation_count===0,'deferred operation provider mismatch');
|
|
96
|
+
return {scheduled,completed:await waitDeferred(scheduled.state_path)};
|
|
97
|
+
}
|
|
98
|
+
async function publicR43PredecessorDisarmed(url){
|
|
99
|
+
const result=await probeR40CompactDisarmed(url);
|
|
100
|
+
assert(result.status==='passed'&&result.tool_count===42&&result.capability_closure===true,'R43 predecessor public compact catalog mismatch');
|
|
101
|
+
assert(result.release_id===R44_PREDECESSOR_RELEASE_ID&&result.release_manifest_sha256===R44_PREDECESSOR_MANIFEST,'R43 predecessor machine binding mismatch');
|
|
102
|
+
assert(result.coding_armed===false&&result.autonomous_armed===false&&result.desktop_armed===false,'R43 predecessor authority remained armed');
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async function mutableCore(pointerValue){
|
|
106
|
+
const policy=JSON.parse(await readFile(path.join(pointerValue.generation_root,'coding-policy.json'),'utf8'));
|
|
107
|
+
const raw=policy?.roots?.core?.path??policy?.roots?.core?.real_path;
|
|
108
|
+
assert(typeof raw==='string'&&raw,'R40 generation missing coding core root');
|
|
109
|
+
const core=path.resolve(raw);const release=path.resolve(pointerValue.release_root);
|
|
110
|
+
assert(core.toLowerCase()!==release.toLowerCase(),'R40 coding core must not point at immutable active release slot');
|
|
111
|
+
return core;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function validateFeatureGate(value,manifest){
|
|
115
|
+
assert(value?.schema==='deadbyte.r44-windows-gate.v1'&&value.status==='passed'&&value.exit_code===0,'R44 feature gate invalid');
|
|
116
|
+
assert(value.version==='0.15.0'&&value.manifest_sha256===manifest,'R44 feature gate candidate mismatch');
|
|
117
|
+
for(const key of ['skill_integrity','agent_backend_persistence','codex_protocol_contract','remote_device_identity','durable_job_supervisor','real_external_supervisor_smoke','full_regression_required']) {
|
|
118
|
+
assert(value.features?.[key]===true,`R44 feature gate missing ${key}`);
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
async function readFeatureGate(manifest){
|
|
123
|
+
const file=path.join(stateRoot,'evidence','release',`r44-windows-gate-${manifest.slice(0,16)}.json`);
|
|
124
|
+
const bytes=await readFile(file);const value=JSON.parse(bytes.toString('utf8').replace(/^\uFEFF/,''));
|
|
125
|
+
validateFeatureGate(value,manifest);
|
|
126
|
+
return {value,path:file,sha256:sha256(bytes)};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function validateParityEvidence(value){
|
|
130
|
+
assert(value?.schema==='deadbyte.r44-parity.v1','R44 parity schema mismatch');
|
|
131
|
+
assert(value.status==='passed','R40 parity status is not passed');
|
|
132
|
+
assert(value.rdc_operation_count===0&&value.execution_provider==='deadbyte_mcp','R40 parity used non-DEADBYTE execution');
|
|
133
|
+
assert(value.candidate?.version==='0.15.0'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R40 candidate identity missing');
|
|
134
|
+
assert(value.local_full?.status==='passed'&&value.local_full?.tool_count===81&&value.local_full?.strict_output_schemas===true,'R44 local full 81-tool proof missing');
|
|
135
|
+
assert(value.public_compact?.status==='passed'&&value.public_compact?.tool_count===43&&value.public_compact?.capability_closure===true&&value.public_compact?.gateway_count===6&&value.public_compact?.desktop_armed===false&&value.public_compact?.desktop_observation_receipt_verified===true&&value.public_compact?.desktop_grounding_receipt_verified===true,'R44 public compact/Desktop/skill closure missing');
|
|
136
|
+
assert(value.desktop_guarded?.status==='passed'&&value.desktop_guarded?.native_injected===true&&value.desktop_guarded?.replay_performed===false&&
|
|
137
|
+
Number.isInteger(value.desktop_guarded?.predispatch_retry_count)&&value.desktop_guarded.predispatch_retry_count>=0&&value.desktop_guarded.predispatch_retry_count<=2&&
|
|
138
|
+
value.desktop_guarded?.observation_receipts_verified===value.desktop_guarded.predispatch_retry_count+1&&value.desktop_guarded?.action_receipts_verified===3,
|
|
139
|
+
'R40 guarded Desktop proof missing');
|
|
140
|
+
assert(value.autonomous?.status==='passed'&&value.autonomous?.signed_release_verified===true,'R40 autonomous live proof missing');
|
|
141
|
+
assert(value.deterministic_memory?.status==='passed'&&value.deterministic_memory?.goal_count>=1&&value.deterministic_memory?.snapshot_count>=1&&value.deterministic_memory?.index_count>=1,'R41 deterministic memory proof missing');
|
|
142
|
+
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&&value.before_rollback_disarmed?.desktop_armed===false,'R40 pre-rollback disarm proof missing');
|
|
143
|
+
assert(value.rollback?.state==='completed'&&value.restore?.state==='completed','R40 rollback/restore not completed');
|
|
144
|
+
assert(value.stage_restore?.status==='restored'&&value.stage_restore?.manifest_sha256===value.candidate.manifest_sha256,'R40 stage restore proof missing');
|
|
145
|
+
assert(value.predecessor?.release_id===R44_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R44_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.14.1','R44 exact R43 predecessor identity mismatch');
|
|
146
|
+
assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count===42&&value.predecessor_disarmed?.capability_closure===true,'R43 predecessor public proof missing');
|
|
147
|
+
assert(value.successor?.version==='0.15.0'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R44 exact successor restore identity mismatch');
|
|
148
|
+
assert(value.successor_disarmed?.status==='passed'&&value.successor_disarmed?.capability_closure===true&&value.successor_disarmed?.coding_armed===false&&value.successor_disarmed?.autonomous_armed===false&&value.successor_disarmed?.desktop_armed===false,'R40 successor disarmed proof missing');
|
|
149
|
+
assert(value.immutable_slot?.protected===true&&value.immutable_slot?.development_root!==value.immutable_slot?.release_root,'R40 immutable-slot separation missing');
|
|
150
|
+
for(const key of ['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface','desktop_readonly','desktop_guarded_input','deterministic_memory','skill_integrity','agent_backend_persistence','codex_protocol_contract','remote_device_identity','durable_job_supervisor','real_external_supervisor_smoke']) assert(value.requirements?.[key]===true,`R44 parity requirement not proven: ${key}`);
|
|
151
|
+
validateFeatureGate(value.feature_gate,value.candidate.manifest_sha256);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function runReleaseParity(activationReceiptPath){
|
|
156
|
+
const active=await pointer();const candidateManifest=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
|
|
157
|
+
assert(active.version==='0.15.0','R44 parity requires active 0.15.0 candidate');
|
|
158
|
+
assert(active.manifest_sha256===candidateManifest,'active release is not canonical R40 candidate');
|
|
159
|
+
const activeConfig=await loadPowerShellDataFile(active.config_path);
|
|
160
|
+
const successorBridgeRootRaw=activeConfig?.Bridge?.WorkingDirectory;
|
|
161
|
+
const successorBridgeConfiguredSha=activeConfig?.Bridge?.ScriptSha256;
|
|
162
|
+
assert(typeof successorBridgeRootRaw==='string'&&path.isAbsolute(successorBridgeRootRaw),'R40 active bridge root missing');
|
|
163
|
+
assert(typeof successorBridgeConfiguredSha==='string'&&/^[0-9a-f]{64}$/.test(successorBridgeConfiguredSha),'R40 active bridge SHA missing');
|
|
164
|
+
const successorBridgeRoot=await realpath(path.resolve(successorBridgeRootRaw));
|
|
165
|
+
const successorBridgeActualSha=sha256(await readFile(path.join(successorBridgeRoot,'src','bridge.mjs')));
|
|
166
|
+
assert(successorBridgeActualSha===successorBridgeConfiguredSha,'R40 active bridge bytes do not match generation pin');
|
|
167
|
+
const successorBridge={root:successorBridgeRoot,sha256:successorBridgeActualSha};
|
|
168
|
+
const developmentRoot=await mutableCore(active);
|
|
169
|
+
const localFull=await probeR44FullSurface({packageRoot:active.release_root,generationRoot:active.generation_root,stateRoot});
|
|
170
|
+
const url=await publicUrl();
|
|
171
|
+
let publicCompact,autonomous,desktopGuarded;
|
|
172
|
+
try{
|
|
173
|
+
publicCompact=await runR44CompactParity(url);
|
|
174
|
+
autonomous=parseJsonOutput((await run(process.execPath,[path.join(root,'src','remote-mcp-autonomous-smoke-client.mjs'),url],{timeoutMs:900000})).stdout,'R40 autonomous compact parity');
|
|
175
|
+
assert(autonomous.status==='passed'&&autonomous.signed_release_verified===true,'R40 autonomous compact parity failed');
|
|
176
|
+
await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,'armdesktop'],{timeoutMs:60000});
|
|
177
|
+
try{desktopGuarded=await runR40DesktopGuardedSmoke(url);}
|
|
178
|
+
finally{await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,'disarmdesktop'],{timeoutMs:60000}).catch(()=>{});}
|
|
179
|
+
assert(desktopGuarded.status==='passed'&&desktopGuarded.native_injected===true&&desktopGuarded.action_receipts_verified===3,'R40 guarded Desktop public smoke failed');
|
|
180
|
+
}catch(error){await disarmAll().catch(()=>{});throw error;}
|
|
181
|
+
const deterministicMemory=await verifyR41Memory({memoryRoot:path.join(stateRoot,'evidence','autonomous','memory-r41',candidateManifest),
|
|
182
|
+
journalRoot:path.join(stateRoot,'evidence','autonomous','goals'),sourceReleaseManifest:candidateManifest,
|
|
183
|
+
publicKeyPath:path.join(stateRoot,'trust','ed25519-public.pem')});
|
|
184
|
+
assert(deterministicMemory.goal_count>=1&&deterministicMemory.snapshot_count>=1&&deterministicMemory.index_count>=1,'R41 live deterministic memory evidence missing');
|
|
185
|
+
await disarmAll();
|
|
186
|
+
const beforeRollback=await probeR44CompactDisarmed(url);
|
|
187
|
+
const rollbackPair=await scheduleDeferred('rollback',path.resolve(activationReceiptPath));
|
|
188
|
+
const predecessor=await pointer();
|
|
189
|
+
assert(predecessor.release_id===R44_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R44_PREDECESSOR_MANIFEST&&predecessor.version==='0.14.1','rollback did not reach exact sealed R43 predecessor');
|
|
190
|
+
const predecessorDisarmed=await publicR43PredecessorDisarmed(url);
|
|
191
|
+
const stageRestore=await restoreFrozenStage({developmentRoot,releaseRoot:active.release_root,expectedManifestSha256:candidateManifest});
|
|
192
|
+
const restorePair=await scheduleDeferred('activate',candidateManifest,{bridgeRoot:successorBridge.root,bridgeScriptSha256:successorBridge.sha256});
|
|
193
|
+
const successor=await pointer();
|
|
194
|
+
assert(successor.version==='0.15.0'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R44 candidate');
|
|
195
|
+
const successorDisarmed=await probeR44CompactDisarmed(url);
|
|
196
|
+
await disarmAll();
|
|
197
|
+
|
|
198
|
+
const featureGate=await readFeatureGate(candidateManifest);
|
|
199
|
+
const evidence={
|
|
200
|
+
schema:'deadbyte.r44-parity.v1',status:'passed',completed_at_utc:new Date().toISOString(),execution_provider:'deadbyte_mcp',rdc_operation_count:0,
|
|
201
|
+
candidate:{release_id:active.release_id,version:active.version,manifest_sha256:candidateManifest},
|
|
202
|
+
immutable_slot:{protected:true,release_root:path.resolve(active.release_root),development_root:developmentRoot},
|
|
203
|
+
local_full:localFull,public_compact:publicCompact,autonomous,deterministic_memory:deterministicMemory,desktop_guarded:desktopGuarded,feature_gate:featureGate.value,feature_gate_sha256:featureGate.sha256,before_rollback_disarmed:beforeRollback,
|
|
204
|
+
rollback:{...rollbackPair.completed,scheduled_operation_id:rollbackPair.scheduled.operation_id},
|
|
205
|
+
predecessor:{release_id:predecessor.release_id,version:predecessor.version,manifest_sha256:predecessor.manifest_sha256},predecessor_disarmed:predecessorDisarmed,
|
|
206
|
+
stage_restore:stageRestore,
|
|
207
|
+
restore:{...restorePair.completed,scheduled_operation_id:restorePair.scheduled.operation_id},
|
|
208
|
+
successor:{release_id:successor.release_id,version:successor.version,manifest_sha256:successor.manifest_sha256},successor_disarmed:successorDisarmed,
|
|
209
|
+
requirements:{
|
|
210
|
+
tree_read:publicCompact.tree_entries>=0&&publicCompact.coding_stat_verified===true,
|
|
211
|
+
precondition_mutation:publicCompact.machine_fs_receipts_verified>=3,
|
|
212
|
+
search:publicCompact.coding_search_result_count>=1&&publicCompact.observation_search_result_count>=1,
|
|
213
|
+
owned_process:typeof publicCompact.process_session_id==='string'&&publicCompact.process_output_bytes>0,
|
|
214
|
+
observation:publicCompact.observation_receipts_verified>=2,
|
|
215
|
+
coding_loop:publicCompact.coding_receipts_verified===2,
|
|
216
|
+
autonomy:autonomous.signed_release_verified===true&&autonomous.observed_failure_before_replan===true,
|
|
217
|
+
interrupted_recovery:rollbackPair.completed.state==='completed'&&restorePair.completed.state==='completed',
|
|
218
|
+
evidence_verification:publicCompact.machine_fs_receipts_verified>=3&&autonomous.signed_release_verified===true,
|
|
219
|
+
compact_closure:publicCompact.capability_closure===true&&successorDisarmed.capability_closure===true,
|
|
220
|
+
full_surface:localFull.tool_count===81&&localFull.strict_output_schemas===true,
|
|
221
|
+
desktop_readonly:publicCompact.desktop_armed===false&&publicCompact.desktop_observation_receipt_verified===true&&publicCompact.desktop_grounding_receipt_verified===true,
|
|
222
|
+
desktop_guarded_input:desktopGuarded.native_injected===true&&desktopGuarded.replay_performed===false&&desktopGuarded.action_receipts_verified===3,
|
|
223
|
+
deterministic_memory:deterministicMemory.status==='passed'&&deterministicMemory.goal_count>=1&&deterministicMemory.snapshot_count>=1,
|
|
224
|
+
skill_integrity:publicCompact.skill_catalog_verified===true&&successorDisarmed.skill_catalog_verified===true&&featureGate.value.features.skill_integrity===true,
|
|
225
|
+
agent_backend_persistence:featureGate.value.features.agent_backend_persistence===true,
|
|
226
|
+
codex_protocol_contract:featureGate.value.features.codex_protocol_contract===true,
|
|
227
|
+
remote_device_identity:featureGate.value.features.remote_device_identity===true,
|
|
228
|
+
durable_job_supervisor:featureGate.value.features.durable_job_supervisor===true,
|
|
229
|
+
real_external_supervisor_smoke:featureGate.value.features.real_external_supervisor_smoke===true
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
validateParityEvidence(evidence);
|
|
233
|
+
const evidenceDir=path.join(stateRoot,'evidence','release');await mkdir(evidenceDir,{recursive:true});
|
|
234
|
+
const evidencePath=path.join(evidenceDir,`r44-parity-${candidateManifest.slice(0,16)}.json`);
|
|
235
|
+
const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');await writeFile(evidencePath,bytes);
|
|
236
|
+
return {evidence,evidence_path:evidencePath,evidence_sha256:sha256(bytes)};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
240
|
+
const receipt=process.argv[2];if(!receipt) throw new Error('usage: node scripts/release-parity-r44.mjs <activation-receipt.json>');
|
|
241
|
+
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;});
|
|
242
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$ErrorActionPreference='Stop'
|
|
2
|
+
Set-StrictMode -Version 2.0
|
|
3
|
+
& node.exe --test test\r43-parent.test.mjs test\coding-runtime.test.mjs test\host-plane.test.mjs test\process-policy.test.mjs test\process-runtime.test.mjs test\native-diff.test.mjs test\native-diff-topology-r36.test.mjs test\autonomous-loop.test.mjs test\autonomous-adversarial.test.mjs test\standing-grants.test.mjs test\runtime-self-update.test.mjs test\r43-finalizer.test.mjs test\r43-finalization.test.mjs
|
|
4
|
+
if($LASTEXITCODE -ne 0){exit $LASTEXITCODE}
|
|
5
|
+
& node.exe --test test\provider-responses-r42.test.mjs test\task-contract-r42.test.mjs test\human-clarification-r42.test.mjs test\agent-governance-r42.test.mjs test\evidence-publisher-r42.test.mjs test\agent-eval-r42.test.mjs test\agent-eval-runner-r42.test.mjs test\r42-finalization.test.mjs
|
|
6
|
+
if($LASTEXITCODE -ne 0){exit $LASTEXITCODE}
|
|
7
|
+
& node.exe --test test\memory-snapshot-r41.test.mjs test\memory-projections-r41.test.mjs test\memory-retrieval-r41.test.mjs test\memory-history-r41.test.mjs test\memory-autonomous-integration-r41.test.mjs
|
|
8
|
+
exit $LASTEXITCODE
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$ErrorActionPreference='Stop'
|
|
2
|
+
Set-StrictMode -Version 2.0
|
|
3
|
+
& node.exe --test test\r44-parent.test.mjs test\skill-plane-r44.test.mjs test\skill-mcp-r44.test.mjs test\agent-backend-r44.test.mjs test\codex-app-server-r44.test.mjs test\codex-autonomous-r44.test.mjs test\remote-device-r44.test.mjs test\durable-job-r44.test.mjs test\external-job-provider-r44.test.mjs test\compact-max-catalog-r44.test.mjs test\coding-runtime.test.mjs test\host-plane.test.mjs test\process-policy.test.mjs test\process-runtime.test.mjs test\native-diff.test.mjs test\native-diff-topology-r36.test.mjs test\autonomous-loop.test.mjs test\autonomous-adversarial.test.mjs test\standing-grants.test.mjs test\runtime-self-update.test.mjs test\r44-finalizer.test.mjs test\r44-finalization.test.mjs
|
|
4
|
+
if($LASTEXITCODE -ne 0){exit $LASTEXITCODE}
|
|
5
|
+
& node.exe --test test\r43-finalization.test.mjs test\provider-responses-r42.test.mjs test\task-contract-r42.test.mjs test\human-clarification-r42.test.mjs test\agent-governance-r42.test.mjs test\evidence-publisher-r42.test.mjs test\agent-eval-r42.test.mjs test\agent-eval-runner-r42.test.mjs test\r42-finalization.test.mjs
|
|
6
|
+
if($LASTEXITCODE -ne 0){exit $LASTEXITCODE}
|
|
7
|
+
& node.exe --test test\memory-snapshot-r41.test.mjs test\memory-projections-r41.test.mjs test\memory-retrieval-r41.test.mjs test\memory-history-r41.test.mjs test\memory-autonomous-integration-r41.test.mjs
|
|
8
|
+
exit $LASTEXITCODE
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify as cryptoVerify } from 'node:crypto';
|
|
2
|
+
import { lstat, readFile, readdir } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
import { canonicalJson } from '../src/canonical-json.mjs';
|
|
7
|
+
|
|
8
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
9
|
+
const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
|
|
10
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
11
|
+
const insist=(ok,message)=>{if(!ok)throw new Error(message);};
|
|
12
|
+
const UPDATE_DOMAIN=Buffer.from('DEADBYTE-R27-SLOT-UPDATE-V1\0','utf8');
|
|
13
|
+
const HEX64=/^[0-9a-f]{64}$/;
|
|
14
|
+
|
|
15
|
+
function inputPath(value){
|
|
16
|
+
if(value instanceof URL) return fileURLToPath(value);
|
|
17
|
+
return path.resolve(String(value));
|
|
18
|
+
}
|
|
19
|
+
function parseManifest(bytes,label){
|
|
20
|
+
const entries=new Map();
|
|
21
|
+
for(const [index,line] of bytes.toString('utf8').split(/\r?\n/).entries()){
|
|
22
|
+
if(!line)continue;
|
|
23
|
+
const match=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);
|
|
24
|
+
insist(match,`${label} line ${index+1} malformed`);
|
|
25
|
+
const rel=match[2].replaceAll('\\','/');
|
|
26
|
+
insist(!path.posix.isAbsolute(rel)&&!rel.split('/').includes('..')&&!entries.has(rel),`unsafe/duplicate ${label} path ${rel}`);
|
|
27
|
+
entries.set(rel,match[1]);
|
|
28
|
+
}
|
|
29
|
+
insist(entries.size>0,`${label} has no entries`);
|
|
30
|
+
return entries;
|
|
31
|
+
}
|
|
32
|
+
async function walk(rootDir,manifestName,rel=''){
|
|
33
|
+
const dir=rel?path.join(rootDir,...rel.split('/')):rootDir;
|
|
34
|
+
const out=[];
|
|
35
|
+
for(const name of (await readdir(dir)).sort((a,b)=>a.localeCompare(b,'en'))){
|
|
36
|
+
const child=rel?`${rel}/${name}`:name;
|
|
37
|
+
if(child===manifestName)continue;
|
|
38
|
+
const full=path.join(rootDir,...child.split('/'));
|
|
39
|
+
const st=await lstat(full);
|
|
40
|
+
insist(!st.isSymbolicLink(),`parent tree symlink forbidden: ${child}`);
|
|
41
|
+
if(st.isDirectory())out.push(...await walk(rootDir,manifestName,child));
|
|
42
|
+
else{insist(st.isFile(),`parent tree non-file forbidden: ${child}`);out.push(child);}
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
async function verifyTree(dir,manifestName,expectedManifest,expectedCount){
|
|
47
|
+
const base=path.resolve(dir);
|
|
48
|
+
const rootStat=await lstat(base);
|
|
49
|
+
insist(rootStat.isDirectory()&&!rootStat.isSymbolicLink(),`${manifestName} root must be a real directory`);
|
|
50
|
+
const bytes=await readFile(path.join(base,manifestName));
|
|
51
|
+
insist(sha256(bytes)===expectedManifest,`${manifestName} digest mismatch`);
|
|
52
|
+
const entries=parseManifest(bytes,manifestName);
|
|
53
|
+
insist(entries.size===expectedCount,`${manifestName} entry count mismatch`);
|
|
54
|
+
const actual=(await walk(base,manifestName)).sort((a,b)=>a.localeCompare(b,'en'));
|
|
55
|
+
const expected=[...entries.keys()].sort((a,b)=>a.localeCompare(b,'en'));
|
|
56
|
+
insist(actual.length===expected.length&&actual.every((rel,index)=>rel===expected[index]),`${manifestName} exact tree mismatch`);
|
|
57
|
+
for(const [rel,digest] of entries){
|
|
58
|
+
insist(sha256(await readFile(path.join(base,...rel.split('/'))))===digest,`${manifestName} file hash mismatch: ${rel}`);
|
|
59
|
+
}
|
|
60
|
+
return entries.size;
|
|
61
|
+
}
|
|
62
|
+
function publicKeyInfo(publicPem){
|
|
63
|
+
const key=createPublicKey(publicPem);
|
|
64
|
+
insist(key.asymmetricKeyType==='ed25519','R43 parent trust key must be Ed25519');
|
|
65
|
+
const der=Buffer.from(key.export({type:'spki',format:'der'}));
|
|
66
|
+
return {key,key_id:sha256(der)};
|
|
67
|
+
}
|
|
68
|
+
function verifyActivationEnvelope(env,keyInfo,record){
|
|
69
|
+
insist(env?.body&&env?.attestation,'R42 activation envelope malformed');
|
|
70
|
+
const bodyBytes=Buffer.from(canonicalJson(env.body),'utf8');
|
|
71
|
+
insist(sha256(bodyBytes)===env.body_sha256,'R42 activation body hash mismatch');
|
|
72
|
+
const {receipt_sha256:claimed,...unsigned}=env;
|
|
73
|
+
insist(claimed===record.parent_activation_receipt_sha256,'R42 activation signed receipt identity mismatch');
|
|
74
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===claimed,'R42 activation receipt hash mismatch');
|
|
75
|
+
insist(env.attestation.algorithm==='ed25519'&&env.attestation.domain==='DEADBYTE-R27-SLOT-UPDATE-V1','R42 activation attestation contract mismatch');
|
|
76
|
+
insist(env.attestation.key_id===record.parent_activation_signer_key_id&&env.attestation.key_id===keyInfo.key_id,'R42 activation signer mismatch');
|
|
77
|
+
insist(cryptoVerify(null,Buffer.concat([UPDATE_DOMAIN,bodyBytes]),keyInfo.key,Buffer.from(env.attestation.signature_base64,'base64')),'R42 activation signature invalid');
|
|
78
|
+
const body=env.body;
|
|
79
|
+
insist(body.schema==='deadbyte.r27-slot-update-receipt.v1'&&body.rollback_performed===false,'R42 activation receipt state invalid');
|
|
80
|
+
insist(body.release_version===record.parent_version&&body.candidate_manifest_sha256===record.parent_manifest_sha256,'R42 activation candidate mismatch');
|
|
81
|
+
const active=body.active_pointer;
|
|
82
|
+
insist(active?.release_id===record.parent_release_id&&active?.version===record.parent_version&&active?.manifest_sha256===record.parent_manifest_sha256,'R42 activation active release mismatch');
|
|
83
|
+
insist(active?.generation_manifest_sha256===record.parent_generation_manifest_sha256,'R42 activation generation mismatch');
|
|
84
|
+
insist(path.resolve(active.release_root)===path.resolve(record.parent_release_root),'R42 activation release root mismatch');
|
|
85
|
+
insist(path.resolve(active.generation_root)===path.resolve(record.parent_generation_root),'R42 activation generation root mismatch');
|
|
86
|
+
const prior=body.prior_pointer;
|
|
87
|
+
insist(prior?.release_id===record.parent_predecessor_release_id&&prior?.manifest_sha256===record.parent_predecessor_manifest_sha256,'R42 activation predecessor mismatch');
|
|
88
|
+
insist(body.authority?.final?.coding_armed===false&&body.authority?.final?.autonomous_armed===false&&body.authority?.final?.desktop_armed===false&&body.authority?.final?.host_armed===false,'R42 activation final authority was not disarmed');
|
|
89
|
+
return body;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function verifyR43Parent(file=path.join(root,'R43-PARENT.json')){
|
|
93
|
+
const record=JSON.parse(await readFile(inputPath(file),'utf8'));
|
|
94
|
+
insist(record.schema==='deadbyte.r43-parent.v1','R43 parent schema mismatch');
|
|
95
|
+
insist(record.parent_release_id==='v0.14.0-08cd8f3b98c90e0e'&&record.parent_version==='0.14.0','R43 parent release identity mismatch');
|
|
96
|
+
insist(record.parent_manifest_sha256==='08cd8f3b98c90e0e250cf506ff396515065ff5457909f850b75b0b6e8ecc2dd1','R43 parent manifest mismatch');
|
|
97
|
+
insist(record.parent_generation_manifest_sha256==='df8ca9894a3e2ca9a9f145cfa3e4e23fd71f42c1988266a1591fc16261ab18a5','R43 parent generation mismatch');
|
|
98
|
+
insist(record.parent_manifest_file_count===1820&&record.parent_generation_file_count===7,'R43 parent file count mismatch');
|
|
99
|
+
insist(record.parent_final_closure_present===false&&!Object.prototype.hasOwnProperty.call(record,'parent_final_closure_path'),'R43 parent must not invent unavailable R42 final closure');
|
|
100
|
+
insist(record.parent_proof==='immutable-slot+generation+signed-activation','R43 parent proof class mismatch');
|
|
101
|
+
for(const key of ['parent_activation_receipt_file_sha256','parent_activation_receipt_sha256','parent_activation_signer_key_id']) insist(HEX64.test(record[key]??''),`R43 parent ${key} malformed`);
|
|
102
|
+
|
|
103
|
+
const [releaseFiles,generationFiles]=await Promise.all([
|
|
104
|
+
verifyTree(record.parent_release_root,'MANIFEST.SHA256',record.parent_manifest_sha256,record.parent_manifest_file_count),
|
|
105
|
+
verifyTree(record.parent_generation_root,'GENERATION.SHA256',record.parent_generation_manifest_sha256,record.parent_generation_file_count)
|
|
106
|
+
]);
|
|
107
|
+
const activationBytes=await readFile(path.resolve(record.parent_activation_receipt_path));
|
|
108
|
+
insist(sha256(activationBytes)===record.parent_activation_receipt_file_sha256,'R42 activation raw file hash mismatch');
|
|
109
|
+
const activation=JSON.parse(activationBytes.toString('utf8').replace(/^\uFEFF/,''));
|
|
110
|
+
const keyInfo=publicKeyInfo(await readFile(path.join(stateRoot,'trust','ed25519-public.pem')));
|
|
111
|
+
verifyActivationEnvelope(activation,keyInfo,record);
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
status:'passed',parent_release_id:record.parent_release_id,parent_manifest_sha256:record.parent_manifest_sha256,
|
|
115
|
+
parent_generation_manifest_sha256:record.parent_generation_manifest_sha256,release_files:releaseFiles,generation_files:generationFiles,
|
|
116
|
+
parent_activation_receipt_file_sha256:record.parent_activation_receipt_file_sha256,
|
|
117
|
+
parent_activation_receipt_sha256:record.parent_activation_receipt_sha256,parent_activation_signer_key_id:keyInfo.key_id,
|
|
118
|
+
parent_final_closure_present:false
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
123
|
+
const file=process.argv[2]??path.join(root,'R43-PARENT.json');
|
|
124
|
+
verifyR43Parent(file).then(value=>console.log(JSON.stringify(value,null,2)))
|
|
125
|
+
.catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|
|
126
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify as cryptoVerify } from 'node:crypto';
|
|
2
|
+
import { lstat, readFile, readdir } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const CLOSURE_DOMAIN=Buffer.from('DEADBYTE-R43-FINAL-CLOSURE-V1\0','utf8');
|
|
8
|
+
const HEX64=/^[0-9a-f]{64}$/;
|
|
9
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
10
|
+
const canonical=value=>Array.isArray(value)?value.map(canonical):value&&typeof value==='object'
|
|
11
|
+
?Object.fromEntries(Object.keys(value).sort().map(key=>[key,canonical(value[key])])):value;
|
|
12
|
+
const canonicalJson=value=>JSON.stringify(canonical(value));
|
|
13
|
+
const same=(a,b)=>canonicalJson(a)===canonicalJson(b);
|
|
14
|
+
const samePath=(a,b)=>path.resolve(String(a)).toLowerCase()===path.resolve(String(b)).toLowerCase();
|
|
15
|
+
function insist(ok,message){if(!ok) throw new Error(message);}
|
|
16
|
+
|
|
17
|
+
function parseManifest(text){
|
|
18
|
+
const out=new Map();
|
|
19
|
+
for(const [i,line] of text.split(/\r?\n/).entries()){
|
|
20
|
+
if(!line) continue;
|
|
21
|
+
const m=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);
|
|
22
|
+
insist(m,`manifest line ${i+1} malformed`);
|
|
23
|
+
const rel=m[2];
|
|
24
|
+
insist(!path.posix.isAbsolute(rel)&&!rel.split('/').includes('..')&&!out.has(rel),`unsafe/duplicate manifest path ${rel}`);
|
|
25
|
+
out.set(rel,m[1]);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
async function walk(root,rel=''){
|
|
30
|
+
const dir=path.join(root,...(rel?rel.split('/'):[]));
|
|
31
|
+
const names=(await readdir(dir)).sort((a,b)=>a.localeCompare(b,'en'));
|
|
32
|
+
const files=[];
|
|
33
|
+
for(const name of names){
|
|
34
|
+
const childRel=rel?`${rel}/${name}`:name;
|
|
35
|
+
const full=path.join(root,...childRel.split('/'));
|
|
36
|
+
const st=await lstat(full);
|
|
37
|
+
insist(!st.isSymbolicLink(),`symlink forbidden: ${childRel}`);
|
|
38
|
+
if(st.isDirectory()) files.push(...await walk(root,childRel));
|
|
39
|
+
else { insist(st.isFile(),`non-file forbidden: ${childRel}`); files.push(childRel); }
|
|
40
|
+
}
|
|
41
|
+
return files;
|
|
42
|
+
}
|
|
43
|
+
async function verifyTree(root,manifestName,expectedDigest,expectedCount){
|
|
44
|
+
const manifestBytes=await readFile(path.join(root,manifestName));
|
|
45
|
+
insist(sha256(manifestBytes)===expectedDigest,`${manifestName} digest mismatch`);
|
|
46
|
+
const entries=parseManifest(manifestBytes.toString('utf8'));
|
|
47
|
+
insist(entries.size===expectedCount,`${manifestName} file count mismatch`);
|
|
48
|
+
const actual=(await walk(root)).filter(rel=>rel!==manifestName).sort((a,b)=>a.localeCompare(b,'en'));
|
|
49
|
+
const expected=[...entries.keys()].sort((a,b)=>a.localeCompare(b,'en'));
|
|
50
|
+
insist(same(actual,expected),`${manifestName} exact tree mismatch`);
|
|
51
|
+
for(const [rel,digest] of entries){
|
|
52
|
+
insist(sha256(await readFile(path.join(root,...rel.split('/'))))===digest,`${manifestName} file hash mismatch: ${rel}`);
|
|
53
|
+
}
|
|
54
|
+
return entries.size;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function verifyR44Parent(parentFile,{stateRoot=path.join(os.homedir(),'.deadbyte-mcp')}={}){
|
|
58
|
+
const parentPath=path.resolve(parentFile);
|
|
59
|
+
const parent=JSON.parse(await readFile(parentPath,'utf8'));
|
|
60
|
+
insist(parent?.schema==='deadbyte.r44-parent.v1','R44 parent schema mismatch');
|
|
61
|
+
insist(parent.parent_release_id==='v0.14.1-0a5a833892593283','R44 parent release id mismatch');
|
|
62
|
+
insist(parent.parent_version==='0.14.1','R44 parent version mismatch');
|
|
63
|
+
insist(parent.parent_manifest_sha256==='0a5a8338925932830986421dda60ec5643f62f600404de4992fda2a5e79d09a9','R44 parent manifest mismatch');
|
|
64
|
+
insist(parent.parent_manifest_file_count===1834,'R44 parent file count mismatch');
|
|
65
|
+
insist(parent.parent_generation_manifest_sha256==='fcfcb5a47d55039b7bb5d42faa0739b57b13d8a420d4418ae09d96d2862967cb','R44 parent generation mismatch');
|
|
66
|
+
insist(parent.parent_generation_file_count===7,'R44 parent generation file count mismatch');
|
|
67
|
+
insist(parent.parent_final_closure_file_sha256==='f24100212b55d2016ea9c4ff47df5f026c8edc0b9b8643933ed8bf26fde3803f','R44 parent closure file hash mismatch');
|
|
68
|
+
insist(parent.parent_final_closure_sha256==='2f29e94dd726638c23b2e520a608dcf2a6919e43348855be3940599d557f920b','R44 parent closure hash mismatch');
|
|
69
|
+
insist(parent.parent_final_closure_signer_key_id==='c0727a7911e29a0f1edd3cd910e47f89f43edb484743988c89cd82bfd5e37936','R44 parent closure signer mismatch');
|
|
70
|
+
insist(parent.parent_proof==='immutable-slot+generation+signed-final-closure','R44 parent proof class mismatch');
|
|
71
|
+
|
|
72
|
+
const closureBytes=await readFile(path.resolve(parent.parent_final_closure_path));
|
|
73
|
+
insist(sha256(closureBytes)===parent.parent_final_closure_file_sha256,'R44 parent closure file bytes mismatch');
|
|
74
|
+
const envelope=JSON.parse(closureBytes.toString('utf8'));
|
|
75
|
+
insist(envelope?.body?.schema==='deadbyte.r43-final-closure.v1','R44 parent closure schema mismatch');
|
|
76
|
+
insist(envelope.body.version===parent.parent_version,'R44 parent closure version mismatch');
|
|
77
|
+
insist(envelope.body.release_label==='R43 AUTHORITY HARDENING PATCH','R44 parent closure label mismatch');
|
|
78
|
+
|
|
79
|
+
const publicKey=createPublicKey(await readFile(path.join(path.resolve(stateRoot),'trust','ed25519-public.pem')));
|
|
80
|
+
insist(publicKey.asymmetricKeyType==='ed25519','R44 parent trust key must be Ed25519');
|
|
81
|
+
const keyId=sha256(Buffer.from(publicKey.export({type:'spki',format:'der'})));
|
|
82
|
+
insist(keyId===parent.parent_final_closure_signer_key_id,'R44 parent trust key id mismatch');
|
|
83
|
+
const bodyBytes=Buffer.from(canonicalJson(envelope.body),'utf8');
|
|
84
|
+
insist(sha256(bodyBytes)===envelope.body_sha256,'R44 parent closure body hash mismatch');
|
|
85
|
+
const {closure_sha256,...unsigned}=envelope;
|
|
86
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===closure_sha256,'R44 parent closure envelope hash mismatch');
|
|
87
|
+
insist(closure_sha256===parent.parent_final_closure_sha256,'R44 parent closure content address mismatch');
|
|
88
|
+
insist(envelope.attestation?.algorithm==='ed25519'&&envelope.attestation?.domain==='DEADBYTE-R43-FINAL-CLOSURE-V1','R44 parent closure attestation contract mismatch');
|
|
89
|
+
insist(envelope.attestation.key_id===keyId,'R44 parent closure attestation signer mismatch');
|
|
90
|
+
insist(cryptoVerify(null,Buffer.concat([CLOSURE_DOMAIN,bodyBytes]),publicKey,Buffer.from(envelope.attestation.signature_base64,'base64')),'R44 parent closure signature invalid');
|
|
91
|
+
|
|
92
|
+
const pointer=envelope.body.active_pointer;
|
|
93
|
+
insist(pointer?.release_id===parent.parent_release_id&&pointer?.version===parent.parent_version&&pointer?.manifest_sha256===parent.parent_manifest_sha256,'R44 parent closure release binding mismatch');
|
|
94
|
+
insist(pointer.generation_manifest_sha256===parent.parent_generation_manifest_sha256,'R44 parent closure generation binding mismatch');
|
|
95
|
+
insist(pointer.launcher_sha256===parent.parent_launcher_sha256,'R44 parent launcher binding mismatch');
|
|
96
|
+
insist(samePath(pointer.release_root,parent.parent_release_root),'R44 parent release root mismatch');
|
|
97
|
+
insist(samePath(pointer.generation_root,parent.parent_generation_root),'R44 parent generation root mismatch');
|
|
98
|
+
insist(envelope.body.immutable_slot?.protected===true,'R44 parent immutable slot proof missing');
|
|
99
|
+
insist(samePath(envelope.body.immutable_slot.release_root,parent.parent_release_root),'R44 parent immutable release root mismatch');
|
|
100
|
+
insist(!samePath(envelope.body.immutable_slot.development_root,parent.parent_release_root),'R44 parent development root aliases release slot');
|
|
101
|
+
insist(samePath(envelope.body.immutable_slot.development_root,parent.development_root),'R44 parent development root mismatch');
|
|
102
|
+
insist(envelope.body.authority?.all_disarmed===true,'R44 parent closure did not record all-disarmed state');
|
|
103
|
+
for(const name of ['process-grant.json','coding-grant.json','autonomous-grant.json','desktop-grant.json','host-grant.json']){
|
|
104
|
+
insist(envelope.body.authority.grants_absent?.[name]===true,`R44 parent closure grant absence missing: ${name}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const evidence=envelope.body.evidence;
|
|
108
|
+
insist(evidence&&evidence.parity&&evidence.activation&&evidence.rollback&&evidence.restore&&evidence.windows_gate,'R44 parent closure evidence set incomplete');
|
|
109
|
+
for(const [name,item] of Object.entries(evidence)){
|
|
110
|
+
insist(typeof item?.path==='string'&&HEX64.test(item?.sha256??''),`R44 parent ${name} evidence identity malformed`);
|
|
111
|
+
insist(sha256(await readFile(item.path))===item.sha256,`R44 parent ${name} evidence hash mismatch`);
|
|
112
|
+
}
|
|
113
|
+
const parity=JSON.parse(await readFile(evidence.parity.path,'utf8'));
|
|
114
|
+
insist(parity?.schema==='deadbyte.r43-parity.v1'&&parity.status==='passed','R44 parent parity status mismatch');
|
|
115
|
+
insist(parity.candidate?.release_id===parent.parent_release_id&&parity.candidate?.manifest_sha256===parent.parent_manifest_sha256,'R44 parent parity candidate mismatch');
|
|
116
|
+
insist(parity.successor?.release_id===parent.parent_release_id&&parity.successor?.manifest_sha256===parent.parent_manifest_sha256,'R44 parent parity successor mismatch');
|
|
117
|
+
insist(parity.successor_disarmed?.status==='passed','R44 parent successor-disarmed proof missing');
|
|
118
|
+
|
|
119
|
+
const releaseFiles=await verifyTree(parent.parent_release_root,'MANIFEST.SHA256',parent.parent_manifest_sha256,parent.parent_manifest_file_count);
|
|
120
|
+
const generationFiles=await verifyTree(parent.parent_generation_root,'GENERATION.SHA256',parent.parent_generation_manifest_sha256,parent.parent_generation_file_count);
|
|
121
|
+
return {
|
|
122
|
+
ok:true,
|
|
123
|
+
status:'passed',
|
|
124
|
+
proof_class:parent.parent_proof,
|
|
125
|
+
release_id:parent.parent_release_id,
|
|
126
|
+
manifest_sha256:parent.parent_manifest_sha256,
|
|
127
|
+
generation_manifest_sha256:parent.parent_generation_manifest_sha256,
|
|
128
|
+
release_files:releaseFiles,
|
|
129
|
+
generation_files:generationFiles,
|
|
130
|
+
closure_sha256:parent.parent_final_closure_sha256,
|
|
131
|
+
closure_file_sha256:parent.parent_final_closure_file_sha256,
|
|
132
|
+
signer_key_id:keyId,
|
|
133
|
+
recorded_all_disarmed:true
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
|
|
138
|
+
if(invoked){
|
|
139
|
+
const file=process.argv[2]??path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..','R44-PARENT.json');
|
|
140
|
+
verifyR44Parent(file).then(result=>console.log(JSON.stringify(result,null,2)))
|
|
141
|
+
.catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|
|
142
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdir, open, readFile } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { verifyR43Parent } from './verify-r43-parent.mjs';
|
|
7
|
+
|
|
8
|
+
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const root=path.resolve(here,'..');
|
|
10
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
11
|
+
const marker='DEADBYTE V0.14.1 / R43 AUTHORITY HARDENING WINDOWS BATCH GATE: PASS';
|
|
12
|
+
function insist(ok,message){if(!ok)throw new Error(message);}
|
|
13
|
+
|
|
14
|
+
export async function writeWindowsGateEvidence({
|
|
15
|
+
candidateRoot=root,
|
|
16
|
+
stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp')),
|
|
17
|
+
clock=()=>new Date()
|
|
18
|
+
}={}){
|
|
19
|
+
const candidate=path.resolve(candidateRoot);
|
|
20
|
+
const manifestBytes=await readFile(path.join(candidate,'MANIFEST.SHA256'));
|
|
21
|
+
const manifestSha256=sha256(manifestBytes);
|
|
22
|
+
const pkg=JSON.parse(await readFile(path.join(candidate,'package.json'),'utf8'));
|
|
23
|
+
insist(pkg.version==='0.14.1',`Windows gate evidence requires V0.14.1, found ${pkg.version}`);
|
|
24
|
+
const parent=await verifyR43Parent(path.join(candidate,'R43-PARENT.json'));
|
|
25
|
+
const completed=clock();
|
|
26
|
+
insist(completed instanceof Date&&!Number.isNaN(completed.getTime()),'Windows gate evidence clock invalid');
|
|
27
|
+
const evidence={
|
|
28
|
+
schema:'deadbyte.r43-windows-gate.v1',status:'passed',exit_code:0,version:'0.14.1',
|
|
29
|
+
marker,completed_at_utc:completed.toISOString(),manifest_sha256:manifestSha256,
|
|
30
|
+
parent:{release_id:parent.parent_release_id,manifest_sha256:parent.parent_manifest_sha256,
|
|
31
|
+
generation_manifest_sha256:parent.parent_generation_manifest_sha256,
|
|
32
|
+
activation_receipt_sha256:parent.parent_activation_receipt_sha256},
|
|
33
|
+
hardening:{authority_toctou:true,absolute_execution_deadline:true,pre_spawn_authority_recheck:true,
|
|
34
|
+
full_regression_required:true,model_path_changed:false}
|
|
35
|
+
};
|
|
36
|
+
const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');
|
|
37
|
+
const dir=path.join(path.resolve(stateRoot),'evidence','release');
|
|
38
|
+
await mkdir(dir,{recursive:true});
|
|
39
|
+
const file=path.join(dir,`r43-windows-gate-${manifestSha256.slice(0,16)}.json`);
|
|
40
|
+
try{
|
|
41
|
+
const handle=await open(file,'wx',0o600);
|
|
42
|
+
try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}
|
|
43
|
+
return {status:'written',path:file,sha256:sha256(bytes),manifest_sha256:manifestSha256,parent:evidence.parent};
|
|
44
|
+
}catch(error){
|
|
45
|
+
if(error?.code!=='EEXIST')throw error;
|
|
46
|
+
const existingBytes=await readFile(file);
|
|
47
|
+
const existing=JSON.parse(existingBytes.toString('utf8').replace(/^\uFEFF/,''));
|
|
48
|
+
insist(existing.schema===evidence.schema&&existing.status==='passed'&&existing.exit_code===0,'existing R43 Windows gate evidence invalid');
|
|
49
|
+
insist(existing.version==='0.14.1'&&existing.marker===marker&&existing.manifest_sha256===manifestSha256,'existing R43 Windows gate identity mismatch');
|
|
50
|
+
insist(existing.parent?.release_id===parent.parent_release_id&&existing.parent?.activation_receipt_sha256===parent.parent_activation_receipt_sha256,'existing R43 parent evidence mismatch');
|
|
51
|
+
return {status:'existing',path:file,sha256:sha256(existingBytes),manifest_sha256:manifestSha256,parent:existing.parent};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
|
|
55
|
+
if(invoked)writeWindowsGateEvidence().then(value=>console.log(JSON.stringify(value))).catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|