deadbyte-mcp 0.11.2 → 0.12.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 +101 -39
- package/README.txt +10 -9
- package/acceptance/r40/desktop-live-drift.mjs +106 -0
- package/acceptance/r40/desktop-live-ground.mjs +110 -0
- package/acceptance/r40/desktop-live-input.mjs +128 -0
- package/acceptance/r40/desktop-live-observe.mjs +100 -0
- package/acceptance/r40/desktop-live-uia.mjs +121 -0
- package/bin/deadbyte-desktop-input-r40.exe +0 -0
- package/bin/deadbyte-desktop-input-r40.obj +0 -0
- package/bin/deadbyte-desktop-observer-r40.exe +0 -0
- package/bin/deadbyte-desktop-observer-r40.obj +0 -0
- package/bin/deadbyte-desktop-uia-r40.exe +0 -0
- package/bin/deadbyte-desktop-uia-r40.obj +0 -0
- package/controller/README.TXT +7 -5
- package/controller/deadbyte-controller.config.psd1.example +3 -0
- package/controller/deadbyte-controller.ps1 +149 -4
- package/controller/deadbyte-desktop-policy.json +41 -0
- package/docs/ARCHITECTURE.md +6 -1
- package/docs/superpowers/specs/2026-09-19-r40-desktop-computer-use-design.md +214 -0
- package/native/deadbyte-desktop-input.cpp +455 -0
- package/native/deadbyte-desktop-observer.cpp +253 -0
- package/native/deadbyte-desktop-uia.cpp +307 -0
- package/package.json +10 -8
- package/scripts/build-desktop-r40.ps1 +106 -0
- package/scripts/deferred-slot-operation-r39.mjs +124 -0
- package/scripts/deferred-slot-operation-r40.mjs +126 -0
- package/scripts/final-closure-r39.mjs +113 -0
- package/scripts/final-closure-r40.mjs +114 -0
- package/scripts/final-closure-verify-r39.mjs +208 -0
- package/scripts/final-closure-verify-r40.mjs +212 -0
- package/scripts/gate-windows-r39.ps1 +42 -0
- package/scripts/gate-windows-r40.ps1 +43 -0
- package/scripts/init-desktop-policy-r40.ps1 +79 -0
- package/scripts/r40-compact-ledger-probe.mjs +4 -0
- package/scripts/release-parity-r39.mjs +200 -0
- package/scripts/release-parity-r40.mjs +212 -0
- package/scripts/release-parity-tests-r39.ps1 +9 -0
- package/scripts/release-parity-tests-r40.ps1 +9 -0
- package/scripts/windows-gate-evidence-r39.mjs +52 -0
- package/scripts/windows-gate-evidence-r40.mjs +52 -0
- package/src/autonomous-context-engine.mjs +2 -1
- package/src/autonomous-planner-contracts.mjs +19 -1
- package/src/autonomous-planner.mjs +22 -0
- package/src/autonomous-runtime.mjs +144 -24
- package/src/capability-ledger.mjs +6 -1
- package/src/compact-gateway-mcp-tools.mjs +14 -2
- package/src/deadbyte-cli.mjs +79 -47
- package/src/desktop-contract.mjs +263 -0
- package/src/desktop-input-r40.mjs +148 -0
- package/src/desktop-mcp-tools-r40.mjs +126 -0
- package/src/desktop-memory-r40.mjs +272 -0
- package/src/desktop-observer-r40.mjs +231 -0
- package/src/desktop-policy-r40.mjs +110 -0
- package/src/desktop-runtime-r40.mjs +318 -0
- package/src/desktop-uia-r40.mjs +123 -0
- package/src/mcp-server.mjs +74 -19
- package/src/r40-compact-disarmed-probe.mjs +71 -0
- package/src/r40-full-surface-probe.mjs +34 -0
- package/src/release-generation.mjs +38 -5
- package/src/remote-console.mjs +41 -0
- package/src/remote-live-log.mjs +215 -45
- package/src/remote-mcp-desktop-r40-smoke-client.mjs +70 -0
- package/src/remote-mcp-r40-parity-client.mjs +200 -0
- package/src/remote-mcp-smoke-client.mjs +20 -6
- package/src/remote-result-journal.mjs +10 -2
- package/src/runtime-update.mjs +55 -17
- package/src/tool-audit.mjs +29 -2
- package/src/version.mjs +1 -1
- package/test/autonomous-capability-r36.test.mjs +43 -1
- package/test/autonomous-desktop-r40.test.mjs +188 -0
- package/test/capability-ledger-r36.test.mjs +1 -0
- package/test/cli-entrypoint.test.mjs +1 -1
- package/test/compact-catalog-r36.test.mjs +2 -2
- package/test/compact-gateway-r36.test.mjs +56 -4
- package/test/compact-max-catalog-r40.test.mjs +95 -0
- package/test/controller-desktop-r40.test.mjs +85 -0
- package/test/core.test.mjs +1 -1
- package/test/desktop-adversarial-r40.test.mjs +62 -0
- package/test/desktop-contract-r40.test.mjs +200 -0
- package/test/desktop-input-r40.test.mjs +63 -0
- package/test/desktop-mcp-tools-r40.test.mjs +61 -0
- package/test/desktop-memory-r40.test.mjs +141 -0
- package/test/desktop-observer-r40.test.mjs +119 -0
- package/test/desktop-policy-r40.test.mjs +111 -0
- package/test/desktop-runtime-r40.test.mjs +278 -0
- package/test/desktop-uia-r40.test.mjs +42 -0
- package/test/full-max-catalog-r40.test.mjs +91 -0
- package/test/helpers/autonomous-r34-fixture.mjs +3 -3
- package/test/production-docs.test.mjs +3 -3
- package/test/r33-closeout-regression.test.mjs +8 -8
- package/test/r33-finalization.test.mjs +14 -14
- package/test/r37-remote-tool-call-timeline.test.mjs +7 -6
- package/test/r39-finalization.test.mjs +74 -0
- package/test/r40-finalization.test.mjs +118 -0
- package/test/release-generation.test.mjs +41 -9
- package/test/release-version.test.mjs +19 -58
- package/test/remote-console-r40.test.mjs +38 -0
- package/test/remote-live-log-r37.test.mjs +89 -32
- package/test/remote-r24-catalog.test.mjs +12 -3
- package/test/remote-result-journal.test.mjs +15 -0
- package/test/remote-session-cli.test.mjs +112 -55
- package/test/runtime-self-update.test.mjs +44 -0
|
@@ -0,0 +1,208 @@
|
|
|
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 HEX64=/^[0-9a-f]{64}$/;
|
|
8
|
+
const UPDATE_DOMAIN=Buffer.from('DEADBYTE-R27-SLOT-UPDATE-V1\0','utf8');
|
|
9
|
+
const CLOSURE_DOMAIN=Buffer.from('DEADBYTE-R39-FINAL-CLOSURE-V1\0','utf8');
|
|
10
|
+
const PING_DOMAIN=Buffer.from('DEADBYTE-MACHINE-PING-V1\0','utf8');
|
|
11
|
+
const R39_PREDECESSOR_RELEASE_ID='v0.11.2-058605dfccaa3035';
|
|
12
|
+
const R39_PREDECESSOR_MANIFEST='058605dfccaa3035a57c6393d53f2421c14e5a92bd145c2334477ba24d7cab8b';
|
|
13
|
+
const R39_FULL_TOOL_COUNT=76;
|
|
14
|
+
const R39_COMPACT_TOOL_LIMIT=42;
|
|
15
|
+
const REQUIRED_PARITY_KEYS=['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface'];
|
|
16
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
17
|
+
const canonical=value=>Array.isArray(value)?value.map(canonical):value&&typeof value==='object'
|
|
18
|
+
?Object.fromEntries(Object.keys(value).sort().map(key=>[key,canonical(value[key])])):value;
|
|
19
|
+
const canonicalJson=value=>JSON.stringify(canonical(value));
|
|
20
|
+
const same=(a,b)=>canonicalJson(a)===canonicalJson(b);
|
|
21
|
+
function insist(ok,msg){if(!ok) throw new Error(msg);}
|
|
22
|
+
function samePath(a,b){return path.resolve(String(a)).toLowerCase()===path.resolve(String(b)).toLowerCase();}
|
|
23
|
+
function isCandidateIdentity(value,manifest){
|
|
24
|
+
return value?.version==='0.11.3'&&value?.manifest_sha256===manifest&&value?.release_id===`v0.11.3-${manifest.slice(0,16)}`;
|
|
25
|
+
}
|
|
26
|
+
function isR39PredecessorIdentity(value){
|
|
27
|
+
return value?.version==='0.11.2'&&value?.manifest_sha256===R39_PREDECESSOR_MANIFEST&&value?.release_id===R39_PREDECESSOR_RELEASE_ID;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseManifest(text){
|
|
31
|
+
const out=new Map();
|
|
32
|
+
for(const [i,line] of text.split(/\r?\n/).entries()){
|
|
33
|
+
if(!line) continue;
|
|
34
|
+
const m=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);insist(m,`manifest line ${i+1} malformed`);
|
|
35
|
+
insist(!path.posix.isAbsolute(m[2])&&!m[2].split('/').includes('..')&&!out.has(m[2]),`unsafe/duplicate manifest path ${m[2]}`);
|
|
36
|
+
out.set(m[2],m[1]);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
async function walk(root,rel=''){
|
|
41
|
+
const dir=path.join(root,...(rel?rel.split('/'):[]));
|
|
42
|
+
const names=(await readdir(dir)).sort((a,b)=>a.localeCompare(b,'en'));
|
|
43
|
+
const files=[];
|
|
44
|
+
for(const name of names){
|
|
45
|
+
const childRel=rel?`${rel}/${name}`:name;
|
|
46
|
+
const full=path.join(root,...childRel.split('/'));
|
|
47
|
+
const st=await lstat(full);insist(!st.isSymbolicLink(),`symlink forbidden: ${childRel}`);
|
|
48
|
+
if(st.isDirectory()) files.push(...await walk(root,childRel));
|
|
49
|
+
else{insist(st.isFile(),`non-file forbidden: ${childRel}`);files.push(childRel);}
|
|
50
|
+
}
|
|
51
|
+
return files;
|
|
52
|
+
}
|
|
53
|
+
async function verifyTree(root,manifestName,expectedDigest){
|
|
54
|
+
const manifestBytes=await readFile(path.join(root,manifestName));
|
|
55
|
+
insist(sha256(manifestBytes)===expectedDigest,`${manifestName} digest mismatch`);
|
|
56
|
+
const entries=parseManifest(manifestBytes.toString('utf8'));
|
|
57
|
+
const actual=(await walk(root)).filter(rel=>rel!==manifestName).sort((a,b)=>a.localeCompare(b,'en'));
|
|
58
|
+
const expected=[...entries.keys()].sort((a,b)=>a.localeCompare(b,'en'));
|
|
59
|
+
insist(same(actual,expected),`${manifestName} exact tree mismatch`);
|
|
60
|
+
for(const [rel,digest] of entries) insist(sha256(await readFile(path.join(root,...rel.split('/'))))===digest,`${manifestName} file hash mismatch: ${rel}`);
|
|
61
|
+
return entries.size;
|
|
62
|
+
}
|
|
63
|
+
function publicKeyInfo(publicPem){
|
|
64
|
+
const key=createPublicKey(publicPem);insist(key.asymmetricKeyType==='ed25519','public key must be Ed25519');
|
|
65
|
+
const der=Buffer.from(key.export({type:'spki',format:'der'}));
|
|
66
|
+
return {key,key_id:sha256(der),spki_base64:der.toString('base64')};
|
|
67
|
+
}
|
|
68
|
+
function verifyUpdateEnvelope(env,keyInfo){
|
|
69
|
+
insist(env?.body&&env?.attestation,'update envelope malformed');
|
|
70
|
+
const bodyBytes=Buffer.from(canonicalJson(env.body),'utf8');
|
|
71
|
+
insist(sha256(bodyBytes)===env.body_sha256,'update body hash mismatch');
|
|
72
|
+
const {receipt_sha256,...unsigned}=env;
|
|
73
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===receipt_sha256,'update receipt hash mismatch');
|
|
74
|
+
insist(env.attestation.algorithm==='ed25519'&&env.attestation.domain==='DEADBYTE-R27-SLOT-UPDATE-V1','update attestation contract mismatch');
|
|
75
|
+
insist(env.attestation.key_id===keyInfo.key_id,'update signer mismatch');
|
|
76
|
+
insist(cryptoVerify(null,Buffer.concat([UPDATE_DOMAIN,bodyBytes]),keyInfo.key,Buffer.from(env.attestation.signature_base64,'base64')),'update signature invalid');
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
function verifyPing(ping,status,pointer){
|
|
80
|
+
insist(ping?.status==='ok'&&ping.schema==='deadbyte.machine-ping.v1','machine ping malformed');
|
|
81
|
+
insist(status?.status==='ok'&&typeof status.public_key_spki_base64==='string','machine status malformed');
|
|
82
|
+
const der=Buffer.from(status.public_key_spki_base64,'base64');
|
|
83
|
+
insist(der.toString('base64')===status.public_key_spki_base64,'machine SPKI base64 non-canonical');
|
|
84
|
+
const machineKey=createPublicKey({key:der,format:'der',type:'spki'});insist(machineKey.asymmetricKeyType==='ed25519','machine key must be Ed25519');
|
|
85
|
+
const machineId=sha256(der);
|
|
86
|
+
insist(status.machine_id===machineId&&ping.machine_id===machineId&&ping.attestation?.key_id===machineId,'machine id/key mismatch');
|
|
87
|
+
insist(ping.release_id===pointer.release_id&&ping.release_manifest_sha256===pointer.manifest_sha256,'machine ping release binding mismatch');
|
|
88
|
+
insist(ping.generation_manifest_sha256===pointer.generation_manifest_sha256,'machine ping generation binding mismatch');
|
|
89
|
+
const {status:_s,attestation:_a,...body}=ping;
|
|
90
|
+
const bytes=Buffer.from(canonicalJson(body),'utf8');
|
|
91
|
+
insist(cryptoVerify(null,Buffer.concat([PING_DOMAIN,bytes]),machineKey,Buffer.from(ping.attestation.signature_base64,'base64')),'machine ping signature invalid');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function verifyFinalClosureObject(envelope,{stateRoot=path.join(os.homedir(),'.deadbyte-mcp')}={}){
|
|
95
|
+
insist(envelope?.body?.schema==='deadbyte.r39-final-closure.v1','closure schema mismatch');
|
|
96
|
+
insist(envelope.body.version==='0.11.3','closure version mismatch');
|
|
97
|
+
insist(envelope.body.release_label==='R39 FINAL MACHINE BASELINE','closure release label mismatch');
|
|
98
|
+
const keyInfo=publicKeyInfo(await readFile(path.join(stateRoot,'trust','ed25519-public.pem')));
|
|
99
|
+
const bodyBytes=Buffer.from(canonicalJson(envelope.body),'utf8');
|
|
100
|
+
insist(sha256(bodyBytes)===envelope.body_sha256,'closure body hash mismatch');
|
|
101
|
+
const {closure_sha256,...unsigned}=envelope;
|
|
102
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===closure_sha256,'closure envelope hash mismatch');
|
|
103
|
+
insist(envelope.attestation?.algorithm==='ed25519'&&envelope.attestation?.domain==='DEADBYTE-R39-FINAL-CLOSURE-V1','closure attestation contract mismatch');
|
|
104
|
+
insist(envelope.attestation.key_id===keyInfo.key_id,'closure signer mismatch');
|
|
105
|
+
insist(cryptoVerify(null,Buffer.concat([CLOSURE_DOMAIN,bodyBytes]),keyInfo.key,Buffer.from(envelope.attestation.signature_base64,'base64')),'closure signature invalid');
|
|
106
|
+
|
|
107
|
+
const pointer=JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
|
|
108
|
+
insist(same(pointer,envelope.body.active_pointer),'active pointer drift');
|
|
109
|
+
insist(pointer.version==='0.11.3','active pointer version mismatch');
|
|
110
|
+
insist(isCandidateIdentity(pointer,pointer.manifest_sha256),'release id/content address mismatch');
|
|
111
|
+
const releaseFiles=await verifyTree(pointer.release_root,'MANIFEST.SHA256',pointer.manifest_sha256);
|
|
112
|
+
const generationFiles=await verifyTree(pointer.generation_root,'GENERATION.SHA256',pointer.generation_manifest_sha256);
|
|
113
|
+
insist(sha256(await readFile(path.join(stateRoot,'bin','DEADBYTE-MCP.ps1')))===pointer.launcher_sha256,'launcher hash mismatch');
|
|
114
|
+
|
|
115
|
+
const predecessor=envelope.body.predecessor;
|
|
116
|
+
insist(isR39PredecessorIdentity(predecessor),'closure predecessor is not exact sealed R39 predecessor');
|
|
117
|
+
const immutable=envelope.body.immutable_slot;
|
|
118
|
+
insist(immutable?.protected===true,'closure immutable-slot protection missing');
|
|
119
|
+
insist(samePath(immutable.release_root,pointer.release_root),'closure immutable release_root mismatch');
|
|
120
|
+
insist(!samePath(immutable.development_root,immutable.release_root),'closure development_root aliases immutable release_root');
|
|
121
|
+
|
|
122
|
+
const surfaces=envelope.body.surfaces;
|
|
123
|
+
insist(surfaces?.local_full?.status==='passed'&&surfaces.local_full.tool_count===R39_FULL_TOOL_COUNT&&surfaces.local_full.strict_output_schemas===true,'closure local full 76-tool proof invalid');
|
|
124
|
+
insist(HEX64.test(surfaces.local_full.catalog_sha256??''),'closure local full catalog hash missing');
|
|
125
|
+
insist(surfaces?.public_compact?.status==='passed'&&surfaces.public_compact.tool_count<=R39_COMPACT_TOOL_LIMIT&&surfaces.public_compact.capability_closure===true,'closure public compact capability proof invalid');
|
|
126
|
+
insist(surfaces.public_compact.coding_armed===false&&surfaces.public_compact.autonomous_armed===false,'closure compact authority is not DISARMED');
|
|
127
|
+
insist(HEX64.test(surfaces.public_compact.catalog_sha256??'')&&HEX64.test(surfaces.public_compact.ledger_sha256??''),'closure compact catalog/ledger hash missing');
|
|
128
|
+
|
|
129
|
+
const evidence=envelope.body.evidence;
|
|
130
|
+
insist(evidence&&evidence.parity&&evidence.activation&&evidence.rollback&&evidence.restore&&evidence.windows_gate,'closure evidence set incomplete');
|
|
131
|
+
for(const [name,item] of Object.entries(evidence)){
|
|
132
|
+
insist(item?.path&&HEX64.test(item.sha256??''),`${name} evidence identity malformed`);
|
|
133
|
+
insist(sha256(await readFile(item.path))===item.sha256,`${name} evidence hash mismatch`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const parity=JSON.parse(await readFile(evidence.parity.path,'utf8'));
|
|
137
|
+
insist(parity.schema==='deadbyte.r39-parity.v1'&&parity.status==='passed','R39 parity evidence invalid');
|
|
138
|
+
insist(parity.rdc_operation_count===0&&parity.execution_provider==='deadbyte_mcp','R39 parity execution provider mismatch');
|
|
139
|
+
insist(isCandidateIdentity(parity.candidate,pointer.manifest_sha256),'R39 parity candidate binding mismatch');
|
|
140
|
+
insist(isCandidateIdentity(parity.successor,pointer.manifest_sha256),'R39 parity successor binding mismatch');
|
|
141
|
+
insist(isR39PredecessorIdentity(parity.predecessor),'R39 parity predecessor binding mismatch');
|
|
142
|
+
insist(parity.local_full?.status==='passed'&&parity.local_full.tool_count===R39_FULL_TOOL_COUNT&&parity.local_full.strict_output_schemas===true,'R39 parity local full proof invalid');
|
|
143
|
+
insist(parity.local_full.catalog_sha256===surfaces.local_full.catalog_sha256,'R36 local full catalog drift between parity and closure');
|
|
144
|
+
insist(parity.public_compact?.status==='passed'&&parity.public_compact.tool_count<=R39_COMPACT_TOOL_LIMIT&&parity.public_compact.capability_closure===true&&parity.public_compact.gateway_count===5,'R39 parity public compact proof invalid');
|
|
145
|
+
insist(parity.successor_disarmed?.status==='passed'&&parity.successor_disarmed.tool_count<=R39_COMPACT_TOOL_LIMIT&&parity.successor_disarmed.capability_closure===true&&parity.successor_disarmed.coding_armed===false&&parity.successor_disarmed.autonomous_armed===false,'R39 parity successor disarmed proof invalid');
|
|
146
|
+
insist(parity.successor_disarmed.catalog_sha256===surfaces.public_compact.catalog_sha256,'R36 compact catalog drift between restore and closure');
|
|
147
|
+
insist(parity.successor_disarmed.ledger_sha256===surfaces.public_compact.ledger_sha256,'R36 capability ledger drift between restore and closure');
|
|
148
|
+
insist(parity.immutable_slot?.protected===true,'R39 parity immutable-slot proof missing');
|
|
149
|
+
insist(samePath(parity.immutable_slot.release_root,pointer.release_root),'R39 parity immutable release_root mismatch');
|
|
150
|
+
insist(samePath(parity.immutable_slot.development_root,immutable.development_root),'R39 parity/closure development_root mismatch');
|
|
151
|
+
insist(!samePath(parity.immutable_slot.development_root,pointer.release_root),'R36 mutable development_root aliases immutable release slot');
|
|
152
|
+
for(const key of REQUIRED_PARITY_KEYS) insist(parity.requirements?.[key]===true,`R39 parity requirement missing ${key}`);
|
|
153
|
+
|
|
154
|
+
const activation=JSON.parse(await readFile(evidence.activation.path,'utf8'));
|
|
155
|
+
const rollback=JSON.parse(await readFile(evidence.rollback.path,'utf8'));
|
|
156
|
+
const restore=JSON.parse(await readFile(evidence.restore.path,'utf8'));
|
|
157
|
+
verifyUpdateEnvelope(activation,keyInfo);verifyUpdateEnvelope(rollback,keyInfo);verifyUpdateEnvelope(restore,keyInfo);
|
|
158
|
+
insist(activation.body.schema==='deadbyte.r27-slot-update-receipt.v1'&&activation.body.rollback_performed===false,'R39 activation receipt invalid');
|
|
159
|
+
insist(activation.body.release_version==='0.11.3'&&activation.body.candidate_manifest_sha256===pointer.manifest_sha256,'R39 activation candidate identity invalid');
|
|
160
|
+
insist(isCandidateIdentity(activation.body.active_pointer,pointer.manifest_sha256),'R39 activation active pointer invalid');
|
|
161
|
+
insist(isR39PredecessorIdentity(activation.body.prior_pointer),'R39 activation predecessor is not exact 0.11.2 predecessor');
|
|
162
|
+
insist(samePath(activation.body.development_root,immutable.development_root),'R39 activation development_root mismatch');
|
|
163
|
+
insist(!samePath(activation.body.development_root,activation.body.active_pointer.release_root),'R39 activation development_root aliases release slot');
|
|
164
|
+
|
|
165
|
+
insist(rollback.body.schema==='deadbyte.r31-slot-rollback-receipt.v1'&&rollback.body.rollback_performed===true,'R39 rollback receipt invalid');
|
|
166
|
+
insist(isCandidateIdentity(rollback.body.from_pointer,pointer.manifest_sha256),'R39 rollback source is not exact candidate');
|
|
167
|
+
insist(isR39PredecessorIdentity(rollback.body.active_pointer),'R39 rollback target is not exact 0.11.2 predecessor');
|
|
168
|
+
insist(rollback.body.activation_receipt_sha256===activation.receipt_sha256,'R39 rollback not bound to activation receipt');
|
|
169
|
+
|
|
170
|
+
insist(restore.body.schema==='deadbyte.r27-slot-update-receipt.v1'&&restore.body.rollback_performed===false,'R39 restore receipt invalid');
|
|
171
|
+
insist(restore.body.release_version==='0.11.3'&&restore.body.candidate_manifest_sha256===pointer.manifest_sha256,'R39 restore candidate identity invalid');
|
|
172
|
+
insist(isR39PredecessorIdentity(restore.body.prior_pointer),'R39 restore predecessor is not exact 0.11.2 predecessor');
|
|
173
|
+
insist(isCandidateIdentity(restore.body.active_pointer,pointer.manifest_sha256)&&same(restore.body.active_pointer,pointer),'R39 restore/current pointer mismatch');
|
|
174
|
+
insist(samePath(restore.body.development_root,immutable.development_root),'R39 restore development_root mismatch');
|
|
175
|
+
insist(!samePath(restore.body.development_root,restore.body.active_pointer.release_root),'R39 restore development_root aliases release slot');
|
|
176
|
+
|
|
177
|
+
const windowsGate=JSON.parse(await readFile(evidence.windows_gate.path,'utf8'));
|
|
178
|
+
insist(windowsGate.schema==='deadbyte.r39-windows-gate.v1'&&windowsGate.status==='passed'&&windowsGate.exit_code===0,'R39 Windows gate evidence invalid');
|
|
179
|
+
insist(windowsGate.version==='0.11.3'&&windowsGate.manifest_sha256===pointer.manifest_sha256,'R39 Windows gate manifest/version binding mismatch');
|
|
180
|
+
insist(windowsGate.marker==='DEADBYTE V0.11.3 / R39 WINDOWS BATCH GATE: PASS','R39 Windows gate PASS marker mismatch');
|
|
181
|
+
|
|
182
|
+
const machine=envelope.body.machine;
|
|
183
|
+
insist(machine?.status?.release_id===pointer.release_id&&machine.status.release_manifest_sha256===pointer.manifest_sha256&&machine.status.generation_manifest_sha256===pointer.generation_manifest_sha256,'machine status binding mismatch');
|
|
184
|
+
verifyPing(machine.ping,machine.status,pointer);
|
|
185
|
+
insist(machine.ping.nonce===machine.nonce,'machine ping nonce binding mismatch');
|
|
186
|
+
|
|
187
|
+
const grantNames=['process-grant.json','coding-grant.json','autonomous-grant.json','host-grant.json'];
|
|
188
|
+
insist(envelope.body.authority?.all_disarmed===true,'closure authority not disarmed');
|
|
189
|
+
for(const name of grantNames){
|
|
190
|
+
let exists=true;try{await lstat(path.join(stateRoot,'runtime',name));}catch(error){if(error?.code==='ENOENT') exists=false;else throw error;}
|
|
191
|
+
insist(!exists,`authority grant still present: ${name}`);
|
|
192
|
+
insist(envelope.body.authority.grants_absent?.[name]===true,`closure grant absence not recorded: ${name}`);
|
|
193
|
+
}
|
|
194
|
+
return {ok:true,status:'passed',release_id:pointer.release_id,manifest_sha256:pointer.manifest_sha256,
|
|
195
|
+
generation_manifest_sha256:pointer.generation_manifest_sha256,release_files:releaseFiles,generation_files:generationFiles,
|
|
196
|
+
machine_id:machine.status.machine_id,parity_sha256:evidence.parity.sha256,closure_sha256:envelope.closure_sha256,
|
|
197
|
+
full_tool_count:R39_FULL_TOOL_COUNT,compact_tool_count:surfaces.public_compact.tool_count};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
|
|
201
|
+
if(invoked){
|
|
202
|
+
const file=process.argv[2];
|
|
203
|
+
if(!file) throw new Error('usage: node scripts/final-closure-verify-r39.mjs <closure.json>');
|
|
204
|
+
try{
|
|
205
|
+
const envelope=JSON.parse(await readFile(path.resolve(file),'utf8'));
|
|
206
|
+
console.log(JSON.stringify(await verifyFinalClosureObject(envelope),null,2));
|
|
207
|
+
}catch(error){console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;}
|
|
208
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
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 HEX64=/^[0-9a-f]{64}$/;
|
|
8
|
+
const UPDATE_DOMAIN=Buffer.from('DEADBYTE-R27-SLOT-UPDATE-V1\0','utf8');
|
|
9
|
+
const CLOSURE_DOMAIN=Buffer.from('DEADBYTE-R40-FINAL-CLOSURE-V1\0','utf8');
|
|
10
|
+
const PING_DOMAIN=Buffer.from('DEADBYTE-MACHINE-PING-V1\0','utf8');
|
|
11
|
+
const R40_PREDECESSOR_RELEASE_ID='v0.11.3-ce761dd6e014d42e';
|
|
12
|
+
const R40_PREDECESSOR_MANIFEST='ce761dd6e014d42eddb635855038e0ce049c63c6e3af7e63c3005bbe198bcf7b';
|
|
13
|
+
const R40_FULL_TOOL_COUNT=80;
|
|
14
|
+
const R40_COMPACT_TOOL_COUNT=42;
|
|
15
|
+
const REQUIRED_PARITY_KEYS=['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface','desktop_readonly','desktop_guarded_input'];
|
|
16
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
17
|
+
const canonical=value=>Array.isArray(value)?value.map(canonical):value&&typeof value==='object'
|
|
18
|
+
?Object.fromEntries(Object.keys(value).sort().map(key=>[key,canonical(value[key])])):value;
|
|
19
|
+
const canonicalJson=value=>JSON.stringify(canonical(value));
|
|
20
|
+
const same=(a,b)=>canonicalJson(a)===canonicalJson(b);
|
|
21
|
+
function insist(ok,msg){if(!ok) throw new Error(msg);}
|
|
22
|
+
function samePath(a,b){return path.resolve(String(a)).toLowerCase()===path.resolve(String(b)).toLowerCase();}
|
|
23
|
+
function isCandidateIdentity(value,manifest){
|
|
24
|
+
return value?.version==='0.12.0'&&value?.manifest_sha256===manifest&&value?.release_id===`v0.12.0-${manifest.slice(0,16)}`;
|
|
25
|
+
}
|
|
26
|
+
function isR40PredecessorIdentity(value){
|
|
27
|
+
return value?.version==='0.11.3'&&value?.manifest_sha256===R40_PREDECESSOR_MANIFEST&&value?.release_id===R40_PREDECESSOR_RELEASE_ID;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseManifest(text){
|
|
31
|
+
const out=new Map();
|
|
32
|
+
for(const [i,line] of text.split(/\r?\n/).entries()){
|
|
33
|
+
if(!line) continue;
|
|
34
|
+
const m=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);insist(m,`manifest line ${i+1} malformed`);
|
|
35
|
+
insist(!path.posix.isAbsolute(m[2])&&!m[2].split('/').includes('..')&&!out.has(m[2]),`unsafe/duplicate manifest path ${m[2]}`);
|
|
36
|
+
out.set(m[2],m[1]);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
async function walk(root,rel=''){
|
|
41
|
+
const dir=path.join(root,...(rel?rel.split('/'):[]));
|
|
42
|
+
const names=(await readdir(dir)).sort((a,b)=>a.localeCompare(b,'en'));
|
|
43
|
+
const files=[];
|
|
44
|
+
for(const name of names){
|
|
45
|
+
const childRel=rel?`${rel}/${name}`:name;
|
|
46
|
+
const full=path.join(root,...childRel.split('/'));
|
|
47
|
+
const st=await lstat(full);insist(!st.isSymbolicLink(),`symlink forbidden: ${childRel}`);
|
|
48
|
+
if(st.isDirectory()) files.push(...await walk(root,childRel));
|
|
49
|
+
else{insist(st.isFile(),`non-file forbidden: ${childRel}`);files.push(childRel);}
|
|
50
|
+
}
|
|
51
|
+
return files;
|
|
52
|
+
}
|
|
53
|
+
async function verifyTree(root,manifestName,expectedDigest){
|
|
54
|
+
const manifestBytes=await readFile(path.join(root,manifestName));
|
|
55
|
+
insist(sha256(manifestBytes)===expectedDigest,`${manifestName} digest mismatch`);
|
|
56
|
+
const entries=parseManifest(manifestBytes.toString('utf8'));
|
|
57
|
+
const actual=(await walk(root)).filter(rel=>rel!==manifestName).sort((a,b)=>a.localeCompare(b,'en'));
|
|
58
|
+
const expected=[...entries.keys()].sort((a,b)=>a.localeCompare(b,'en'));
|
|
59
|
+
insist(same(actual,expected),`${manifestName} exact tree mismatch`);
|
|
60
|
+
for(const [rel,digest] of entries) insist(sha256(await readFile(path.join(root,...rel.split('/'))))===digest,`${manifestName} file hash mismatch: ${rel}`);
|
|
61
|
+
return entries.size;
|
|
62
|
+
}
|
|
63
|
+
function publicKeyInfo(publicPem){
|
|
64
|
+
const key=createPublicKey(publicPem);insist(key.asymmetricKeyType==='ed25519','public key must be Ed25519');
|
|
65
|
+
const der=Buffer.from(key.export({type:'spki',format:'der'}));
|
|
66
|
+
return {key,key_id:sha256(der),spki_base64:der.toString('base64')};
|
|
67
|
+
}
|
|
68
|
+
function verifyUpdateEnvelope(env,keyInfo){
|
|
69
|
+
insist(env?.body&&env?.attestation,'update envelope malformed');
|
|
70
|
+
const bodyBytes=Buffer.from(canonicalJson(env.body),'utf8');
|
|
71
|
+
insist(sha256(bodyBytes)===env.body_sha256,'update body hash mismatch');
|
|
72
|
+
const {receipt_sha256,...unsigned}=env;
|
|
73
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===receipt_sha256,'update receipt hash mismatch');
|
|
74
|
+
insist(env.attestation.algorithm==='ed25519'&&env.attestation.domain==='DEADBYTE-R27-SLOT-UPDATE-V1','update attestation contract mismatch');
|
|
75
|
+
insist(env.attestation.key_id===keyInfo.key_id,'update signer mismatch');
|
|
76
|
+
insist(cryptoVerify(null,Buffer.concat([UPDATE_DOMAIN,bodyBytes]),keyInfo.key,Buffer.from(env.attestation.signature_base64,'base64')),'update signature invalid');
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
function verifyPing(ping,status,pointer){
|
|
80
|
+
insist(ping?.status==='ok'&&ping.schema==='deadbyte.machine-ping.v1','machine ping malformed');
|
|
81
|
+
insist(status?.status==='ok'&&typeof status.public_key_spki_base64==='string','machine status malformed');
|
|
82
|
+
const der=Buffer.from(status.public_key_spki_base64,'base64');
|
|
83
|
+
insist(der.toString('base64')===status.public_key_spki_base64,'machine SPKI base64 non-canonical');
|
|
84
|
+
const machineKey=createPublicKey({key:der,format:'der',type:'spki'});insist(machineKey.asymmetricKeyType==='ed25519','machine key must be Ed25519');
|
|
85
|
+
const machineId=sha256(der);
|
|
86
|
+
insist(status.machine_id===machineId&&ping.machine_id===machineId&&ping.attestation?.key_id===machineId,'machine id/key mismatch');
|
|
87
|
+
insist(ping.release_id===pointer.release_id&&ping.release_manifest_sha256===pointer.manifest_sha256,'machine ping release binding mismatch');
|
|
88
|
+
insist(ping.generation_manifest_sha256===pointer.generation_manifest_sha256,'machine ping generation binding mismatch');
|
|
89
|
+
const {status:_s,attestation:_a,...body}=ping;
|
|
90
|
+
const bytes=Buffer.from(canonicalJson(body),'utf8');
|
|
91
|
+
insist(cryptoVerify(null,Buffer.concat([PING_DOMAIN,bytes]),machineKey,Buffer.from(ping.attestation.signature_base64,'base64')),'machine ping signature invalid');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function verifyFinalClosureObject(envelope,{stateRoot=path.join(os.homedir(),'.deadbyte-mcp')}={}){
|
|
95
|
+
insist(envelope?.body?.schema==='deadbyte.r40-final-closure.v1','closure schema mismatch');
|
|
96
|
+
insist(envelope.body.version==='0.12.0','closure version mismatch');
|
|
97
|
+
insist(envelope.body.release_label==='R40 FINAL MACHINE BASELINE','closure release label mismatch');
|
|
98
|
+
const keyInfo=publicKeyInfo(await readFile(path.join(stateRoot,'trust','ed25519-public.pem')));
|
|
99
|
+
const bodyBytes=Buffer.from(canonicalJson(envelope.body),'utf8');
|
|
100
|
+
insist(sha256(bodyBytes)===envelope.body_sha256,'closure body hash mismatch');
|
|
101
|
+
const {closure_sha256,...unsigned}=envelope;
|
|
102
|
+
insist(sha256(Buffer.from(canonicalJson(unsigned),'utf8'))===closure_sha256,'closure envelope hash mismatch');
|
|
103
|
+
insist(envelope.attestation?.algorithm==='ed25519'&&envelope.attestation?.domain==='DEADBYTE-R40-FINAL-CLOSURE-V1','closure attestation contract mismatch');
|
|
104
|
+
insist(envelope.attestation.key_id===keyInfo.key_id,'closure signer mismatch');
|
|
105
|
+
insist(cryptoVerify(null,Buffer.concat([CLOSURE_DOMAIN,bodyBytes]),keyInfo.key,Buffer.from(envelope.attestation.signature_base64,'base64')),'closure signature invalid');
|
|
106
|
+
|
|
107
|
+
const pointer=JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
|
|
108
|
+
insist(same(pointer,envelope.body.active_pointer),'active pointer drift');
|
|
109
|
+
insist(pointer.version==='0.12.0','active pointer version mismatch');
|
|
110
|
+
insist(isCandidateIdentity(pointer,pointer.manifest_sha256),'release id/content address mismatch');
|
|
111
|
+
const releaseFiles=await verifyTree(pointer.release_root,'MANIFEST.SHA256',pointer.manifest_sha256);
|
|
112
|
+
const generationFiles=await verifyTree(pointer.generation_root,'GENERATION.SHA256',pointer.generation_manifest_sha256);
|
|
113
|
+
insist(sha256(await readFile(path.join(stateRoot,'bin','DEADBYTE-MCP.ps1')))===pointer.launcher_sha256,'launcher hash mismatch');
|
|
114
|
+
|
|
115
|
+
const predecessor=envelope.body.predecessor;
|
|
116
|
+
insist(isR40PredecessorIdentity(predecessor),'closure predecessor is not exact sealed R40 predecessor');
|
|
117
|
+
const immutable=envelope.body.immutable_slot;
|
|
118
|
+
insist(immutable?.protected===true,'closure immutable-slot protection missing');
|
|
119
|
+
insist(samePath(immutable.release_root,pointer.release_root),'closure immutable release_root mismatch');
|
|
120
|
+
insist(!samePath(immutable.development_root,immutable.release_root),'closure development_root aliases immutable release_root');
|
|
121
|
+
|
|
122
|
+
const surfaces=envelope.body.surfaces;
|
|
123
|
+
insist(surfaces?.local_full?.status==='passed'&&surfaces.local_full.tool_count===R40_FULL_TOOL_COUNT&&surfaces.local_full.strict_output_schemas===true,'closure local full 80-tool proof invalid');
|
|
124
|
+
insist(HEX64.test(surfaces.local_full.catalog_sha256??''),'closure local full catalog hash missing');
|
|
125
|
+
insist(surfaces?.public_compact?.status==='passed'&&surfaces.public_compact.tool_count===R40_COMPACT_TOOL_COUNT&&surfaces.public_compact.capability_closure===true,'closure public compact capability proof invalid');
|
|
126
|
+
insist(surfaces.public_compact.coding_armed===false&&surfaces.public_compact.autonomous_armed===false&&surfaces.public_compact.desktop_armed===false,'closure compact authority is not DISARMED');
|
|
127
|
+
insist(surfaces.public_compact.desktop_observation_receipt_verified===true&&surfaces.public_compact.desktop_grounding_receipt_verified===true,'closure Desktop read-only proof invalid');
|
|
128
|
+
insist(HEX64.test(surfaces.public_compact.catalog_sha256??'')&&HEX64.test(surfaces.public_compact.ledger_sha256??''),'closure compact catalog/ledger hash missing');
|
|
129
|
+
|
|
130
|
+
const evidence=envelope.body.evidence;
|
|
131
|
+
insist(evidence&&evidence.parity&&evidence.activation&&evidence.rollback&&evidence.restore&&evidence.windows_gate,'closure evidence set incomplete');
|
|
132
|
+
for(const [name,item] of Object.entries(evidence)){
|
|
133
|
+
insist(item?.path&&HEX64.test(item.sha256??''),`${name} evidence identity malformed`);
|
|
134
|
+
insist(sha256(await readFile(item.path))===item.sha256,`${name} evidence hash mismatch`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const parity=JSON.parse(await readFile(evidence.parity.path,'utf8'));
|
|
138
|
+
insist(parity.schema==='deadbyte.r40-parity.v1'&&parity.status==='passed','R40 parity evidence invalid');
|
|
139
|
+
insist(parity.rdc_operation_count===0&&parity.execution_provider==='deadbyte_mcp','R40 parity execution provider mismatch');
|
|
140
|
+
insist(isCandidateIdentity(parity.candidate,pointer.manifest_sha256),'R40 parity candidate binding mismatch');
|
|
141
|
+
insist(isCandidateIdentity(parity.successor,pointer.manifest_sha256),'R40 parity successor binding mismatch');
|
|
142
|
+
insist(isR40PredecessorIdentity(parity.predecessor),'R40 parity predecessor binding mismatch');
|
|
143
|
+
insist(parity.local_full?.status==='passed'&&parity.local_full.tool_count===R40_FULL_TOOL_COUNT&&parity.local_full.strict_output_schemas===true,'R40 parity local full proof invalid');
|
|
144
|
+
insist(parity.local_full.catalog_sha256===surfaces.local_full.catalog_sha256,'R36 local full catalog drift between parity and closure');
|
|
145
|
+
insist(parity.public_compact?.status==='passed'&&parity.public_compact.tool_count===R40_COMPACT_TOOL_COUNT&&parity.public_compact.capability_closure===true&&parity.public_compact.gateway_count===6&&parity.public_compact.desktop_armed===false&&parity.public_compact.desktop_observation_receipt_verified===true&&parity.public_compact.desktop_grounding_receipt_verified===true,'R40 parity public compact/Desktop proof invalid');
|
|
146
|
+
insist(parity.desktop_guarded?.status==='passed'&&parity.desktop_guarded.native_injected===true&&parity.desktop_guarded.replay_performed===false&&parity.desktop_guarded.action_receipts_verified===3,'R40 parity guarded Desktop proof invalid');
|
|
147
|
+
insist(parity.successor_disarmed?.status==='passed'&&parity.successor_disarmed.tool_count===R40_COMPACT_TOOL_COUNT&&parity.successor_disarmed.capability_closure===true&&parity.successor_disarmed.coding_armed===false&&parity.successor_disarmed.autonomous_armed===false&&parity.successor_disarmed.desktop_armed===false,'R40 parity successor disarmed proof invalid');
|
|
148
|
+
insist(parity.successor_disarmed.catalog_sha256===surfaces.public_compact.catalog_sha256,'R36 compact catalog drift between restore and closure');
|
|
149
|
+
insist(parity.successor_disarmed.ledger_sha256===surfaces.public_compact.ledger_sha256,'R36 capability ledger drift between restore and closure');
|
|
150
|
+
insist(parity.immutable_slot?.protected===true,'R40 parity immutable-slot proof missing');
|
|
151
|
+
insist(samePath(parity.immutable_slot.release_root,pointer.release_root),'R40 parity immutable release_root mismatch');
|
|
152
|
+
insist(samePath(parity.immutable_slot.development_root,immutable.development_root),'R40 parity/closure development_root mismatch');
|
|
153
|
+
insist(!samePath(parity.immutable_slot.development_root,pointer.release_root),'R36 mutable development_root aliases immutable release slot');
|
|
154
|
+
for(const key of REQUIRED_PARITY_KEYS) insist(parity.requirements?.[key]===true,`R40 parity requirement missing ${key}`);
|
|
155
|
+
|
|
156
|
+
const activation=JSON.parse(await readFile(evidence.activation.path,'utf8'));
|
|
157
|
+
const rollback=JSON.parse(await readFile(evidence.rollback.path,'utf8'));
|
|
158
|
+
const restore=JSON.parse(await readFile(evidence.restore.path,'utf8'));
|
|
159
|
+
verifyUpdateEnvelope(activation,keyInfo);verifyUpdateEnvelope(rollback,keyInfo);verifyUpdateEnvelope(restore,keyInfo);
|
|
160
|
+
insist(activation.body.schema==='deadbyte.r27-slot-update-receipt.v1'&&activation.body.rollback_performed===false,'R40 activation receipt invalid');
|
|
161
|
+
insist(activation.body.release_version==='0.12.0'&&activation.body.candidate_manifest_sha256===pointer.manifest_sha256,'R40 activation candidate identity invalid');
|
|
162
|
+
insist(isCandidateIdentity(activation.body.active_pointer,pointer.manifest_sha256),'R40 activation active pointer invalid');
|
|
163
|
+
insist(isR40PredecessorIdentity(activation.body.prior_pointer),'R40 activation predecessor is not exact 0.11.3 predecessor');
|
|
164
|
+
insist(samePath(activation.body.development_root,immutable.development_root),'R40 activation development_root mismatch');
|
|
165
|
+
insist(!samePath(activation.body.development_root,activation.body.active_pointer.release_root),'R40 activation development_root aliases release slot');
|
|
166
|
+
insist(activation.body.authority?.final?.desktop_armed===false,'R40 activation restored Desktop authority unexpectedly');
|
|
167
|
+
|
|
168
|
+
insist(rollback.body.schema==='deadbyte.r31-slot-rollback-receipt.v1'&&rollback.body.rollback_performed===true,'R40 rollback receipt invalid');
|
|
169
|
+
insist(isCandidateIdentity(rollback.body.from_pointer,pointer.manifest_sha256),'R40 rollback source is not exact candidate');
|
|
170
|
+
insist(isR40PredecessorIdentity(rollback.body.active_pointer),'R40 rollback target is not exact 0.11.3 predecessor');
|
|
171
|
+
insist(rollback.body.activation_receipt_sha256===activation.receipt_sha256,'R40 rollback not bound to activation receipt');
|
|
172
|
+
|
|
173
|
+
insist(restore.body.schema==='deadbyte.r27-slot-update-receipt.v1'&&restore.body.rollback_performed===false,'R40 restore receipt invalid');
|
|
174
|
+
insist(restore.body.release_version==='0.12.0'&&restore.body.candidate_manifest_sha256===pointer.manifest_sha256,'R40 restore candidate identity invalid');
|
|
175
|
+
insist(isR40PredecessorIdentity(restore.body.prior_pointer),'R40 restore predecessor is not exact 0.11.3 predecessor');
|
|
176
|
+
insist(isCandidateIdentity(restore.body.active_pointer,pointer.manifest_sha256)&&same(restore.body.active_pointer,pointer),'R40 restore/current pointer mismatch');
|
|
177
|
+
insist(samePath(restore.body.development_root,immutable.development_root),'R40 restore development_root mismatch');
|
|
178
|
+
insist(!samePath(restore.body.development_root,restore.body.active_pointer.release_root),'R40 restore development_root aliases release slot');
|
|
179
|
+
insist(restore.body.authority?.final?.desktop_armed===false,'R40 restore restored Desktop authority unexpectedly');
|
|
180
|
+
|
|
181
|
+
const windowsGate=JSON.parse(await readFile(evidence.windows_gate.path,'utf8'));
|
|
182
|
+
insist(windowsGate.schema==='deadbyte.r40-windows-gate.v1'&&windowsGate.status==='passed'&&windowsGate.exit_code===0,'R40 Windows gate evidence invalid');
|
|
183
|
+
insist(windowsGate.version==='0.12.0'&&windowsGate.manifest_sha256===pointer.manifest_sha256,'R40 Windows gate manifest/version binding mismatch');
|
|
184
|
+
insist(windowsGate.marker==='DEADBYTE V0.12.0 / R40 WINDOWS BATCH GATE: PASS','R40 Windows gate PASS marker mismatch');
|
|
185
|
+
|
|
186
|
+
const machine=envelope.body.machine;
|
|
187
|
+
insist(machine?.status?.release_id===pointer.release_id&&machine.status.release_manifest_sha256===pointer.manifest_sha256&&machine.status.generation_manifest_sha256===pointer.generation_manifest_sha256,'machine status binding mismatch');
|
|
188
|
+
verifyPing(machine.ping,machine.status,pointer);
|
|
189
|
+
insist(machine.ping.nonce===machine.nonce,'machine ping nonce binding mismatch');
|
|
190
|
+
|
|
191
|
+
const grantNames=['process-grant.json','coding-grant.json','autonomous-grant.json','desktop-grant.json','host-grant.json'];
|
|
192
|
+
insist(envelope.body.authority?.all_disarmed===true,'closure authority not disarmed');
|
|
193
|
+
for(const name of grantNames){
|
|
194
|
+
let exists=true;try{await lstat(path.join(stateRoot,'runtime',name));}catch(error){if(error?.code==='ENOENT') exists=false;else throw error;}
|
|
195
|
+
insist(!exists,`authority grant still present: ${name}`);
|
|
196
|
+
insist(envelope.body.authority.grants_absent?.[name]===true,`closure grant absence not recorded: ${name}`);
|
|
197
|
+
}
|
|
198
|
+
return {ok:true,status:'passed',release_id:pointer.release_id,manifest_sha256:pointer.manifest_sha256,
|
|
199
|
+
generation_manifest_sha256:pointer.generation_manifest_sha256,release_files:releaseFiles,generation_files:generationFiles,
|
|
200
|
+
machine_id:machine.status.machine_id,parity_sha256:evidence.parity.sha256,closure_sha256:envelope.closure_sha256,
|
|
201
|
+
full_tool_count:R40_FULL_TOOL_COUNT,compact_tool_count:surfaces.public_compact.tool_count};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
|
|
205
|
+
if(invoked){
|
|
206
|
+
const file=process.argv[2];
|
|
207
|
+
if(!file) throw new Error('usage: node scripts/final-closure-verify-r40.mjs <closure.json>');
|
|
208
|
+
try{
|
|
209
|
+
const envelope=JSON.parse(await readFile(path.resolve(file),'utf8'));
|
|
210
|
+
console.log(JSON.stringify(await verifyFinalClosureObject(envelope),null,2));
|
|
211
|
+
}catch(error){console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;}
|
|
212
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
Set-StrictMode -Version 2.0
|
|
3
|
+
|
|
4
|
+
function Invoke-GateStep {
|
|
5
|
+
param(
|
|
6
|
+
[Parameter(Mandatory = $true)][string]$Name,
|
|
7
|
+
[Parameter(Mandatory = $true)][string[]]$NpmArgs
|
|
8
|
+
)
|
|
9
|
+
Write-Host "==== $Name ===="
|
|
10
|
+
& npm.cmd @NpmArgs
|
|
11
|
+
if ($LASTEXITCODE -ne 0) {
|
|
12
|
+
throw "DEADBYTE V0.11.3 / R39 gate failed at $Name with exit code $LASTEXITCODE"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Invoke-GateStep -Name 'containment-build' -NpmArgs @('run', 'containment:build')
|
|
17
|
+
Invoke-GateStep -Name 'process-policy-refresh' -NpmArgs @('run', 'process:policy:refresh')
|
|
18
|
+
Invoke-GateStep -Name 'release-manifest-write' -NpmArgs @('run', 'manifest:write')
|
|
19
|
+
Invoke-GateStep -Name 'release-manifest' -NpmArgs @('run', 'manifest:verify')
|
|
20
|
+
Invoke-GateStep -Name 'tests' -NpmArgs @('test')
|
|
21
|
+
Invoke-GateStep -Name 'mcp-smoke' -NpmArgs @('run', 'mcp:smoke')
|
|
22
|
+
Invoke-GateStep -Name 'mcp-agent-smoke' -NpmArgs @('run', 'mcp:agent:smoke')
|
|
23
|
+
Invoke-GateStep -Name 'mcp-coding-smoke' -NpmArgs @('run', 'mcp:coding:smoke')
|
|
24
|
+
Invoke-GateStep -Name 'mcp-machine-fs-smoke' -NpmArgs @('run', 'mcp:machine-fs:smoke')
|
|
25
|
+
Invoke-GateStep -Name 'mcp-observation-smoke' -NpmArgs @('run', 'mcp:observation:smoke')
|
|
26
|
+
Invoke-GateStep -Name 'mcp-process-smoke' -NpmArgs @('run', 'mcp:process:smoke')
|
|
27
|
+
Invoke-GateStep -Name 'mcp-autonomous-smoke' -NpmArgs @('run', 'mcp:autonomous:smoke')
|
|
28
|
+
Invoke-GateStep -Name 'tunnel-stdio-compat-smoke' -NpmArgs @('run', 'mcp:tunnel-compat:smoke')
|
|
29
|
+
Invoke-GateStep -Name 'mcp-host-smoke' -NpmArgs @('run', 'mcp:host:smoke')
|
|
30
|
+
Invoke-GateStep -Name 'authority-smoke' -NpmArgs @('run', 'authority:smoke')
|
|
31
|
+
Invoke-GateStep -Name 'containment-smoke' -NpmArgs @('run', 'containment:smoke')
|
|
32
|
+
Invoke-GateStep -Name 'contained-smoke' -NpmArgs @('run', 'contained:smoke')
|
|
33
|
+
Invoke-GateStep -Name 'mcp-contained-smoke' -NpmArgs @('run', 'mcp:contained:smoke')
|
|
34
|
+
Invoke-GateStep -Name 'release-manifest-final' -NpmArgs @('run', 'manifest:verify')
|
|
35
|
+
|
|
36
|
+
Write-Host '==== windows-gate-evidence ===='
|
|
37
|
+
& node.exe (Join-Path $PSScriptRoot 'windows-gate-evidence-r39.mjs')
|
|
38
|
+
if ($LASTEXITCODE -ne 0) {
|
|
39
|
+
throw "DEADBYTE V0.11.3 / R39 gate failed at windows-gate-evidence with exit code $LASTEXITCODE"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Write-Host '==== DEADBYTE V0.11.3 / R39 WINDOWS BATCH GATE: PASS ===='
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
Set-StrictMode -Version 2.0
|
|
3
|
+
|
|
4
|
+
function Invoke-GateStep {
|
|
5
|
+
param(
|
|
6
|
+
[Parameter(Mandatory = $true)][string]$Name,
|
|
7
|
+
[Parameter(Mandatory = $true)][string[]]$NpmArgs
|
|
8
|
+
)
|
|
9
|
+
Write-Host "==== $Name ===="
|
|
10
|
+
& npm.cmd @NpmArgs
|
|
11
|
+
if ($LASTEXITCODE -ne 0) {
|
|
12
|
+
throw "DEADBYTE V0.12.0 / R40 gate failed at $Name with exit code $LASTEXITCODE"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Invoke-GateStep -Name 'containment-build' -NpmArgs @('run', 'containment:build')
|
|
17
|
+
Invoke-GateStep -Name 'process-policy-refresh' -NpmArgs @('run', 'process:policy:refresh')
|
|
18
|
+
Invoke-GateStep -Name 'desktop-policy-refresh' -NpmArgs @('run', 'desktop:policy:refresh')
|
|
19
|
+
Invoke-GateStep -Name 'release-manifest-write' -NpmArgs @('run', 'manifest:write')
|
|
20
|
+
Invoke-GateStep -Name 'release-manifest' -NpmArgs @('run', 'manifest:verify')
|
|
21
|
+
Invoke-GateStep -Name 'tests' -NpmArgs @('test')
|
|
22
|
+
Invoke-GateStep -Name 'mcp-smoke' -NpmArgs @('run', 'mcp:smoke')
|
|
23
|
+
Invoke-GateStep -Name 'mcp-agent-smoke' -NpmArgs @('run', 'mcp:agent:smoke')
|
|
24
|
+
Invoke-GateStep -Name 'mcp-coding-smoke' -NpmArgs @('run', 'mcp:coding:smoke')
|
|
25
|
+
Invoke-GateStep -Name 'mcp-machine-fs-smoke' -NpmArgs @('run', 'mcp:machine-fs:smoke')
|
|
26
|
+
Invoke-GateStep -Name 'mcp-observation-smoke' -NpmArgs @('run', 'mcp:observation:smoke')
|
|
27
|
+
Invoke-GateStep -Name 'mcp-process-smoke' -NpmArgs @('run', 'mcp:process:smoke')
|
|
28
|
+
Invoke-GateStep -Name 'mcp-autonomous-smoke' -NpmArgs @('run', 'mcp:autonomous:smoke')
|
|
29
|
+
Invoke-GateStep -Name 'tunnel-stdio-compat-smoke' -NpmArgs @('run', 'mcp:tunnel-compat:smoke')
|
|
30
|
+
Invoke-GateStep -Name 'mcp-host-smoke' -NpmArgs @('run', 'mcp:host:smoke')
|
|
31
|
+
Invoke-GateStep -Name 'authority-smoke' -NpmArgs @('run', 'authority:smoke')
|
|
32
|
+
Invoke-GateStep -Name 'containment-smoke' -NpmArgs @('run', 'containment:smoke')
|
|
33
|
+
Invoke-GateStep -Name 'contained-smoke' -NpmArgs @('run', 'contained:smoke')
|
|
34
|
+
Invoke-GateStep -Name 'mcp-contained-smoke' -NpmArgs @('run', 'mcp:contained:smoke')
|
|
35
|
+
Invoke-GateStep -Name 'release-manifest-final' -NpmArgs @('run', 'manifest:verify')
|
|
36
|
+
|
|
37
|
+
Write-Host '==== windows-gate-evidence ===='
|
|
38
|
+
& node.exe (Join-Path $PSScriptRoot 'windows-gate-evidence-r40.mjs')
|
|
39
|
+
if ($LASTEXITCODE -ne 0) {
|
|
40
|
+
throw "DEADBYTE V0.12.0 / R40 gate failed at windows-gate-evidence with exit code $LASTEXITCODE"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Write-Host '==== DEADBYTE V0.12.0 / R40 WINDOWS BATCH GATE: PASS ===='
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[CmdletBinding()]
|
|
2
|
+
param(
|
|
3
|
+
[string]$RuntimeRoot = '',
|
|
4
|
+
[string]$OutputPath = '',
|
|
5
|
+
[string[]]$AllowedActions = @('pointer_move','click_primary','click_secondary','double_click_primary','scroll','key_chord','text_input')
|
|
6
|
+
)
|
|
7
|
+
$ErrorActionPreference='Stop'
|
|
8
|
+
Set-StrictMode -Version Latest
|
|
9
|
+
|
|
10
|
+
$Root=Split-Path -Parent $PSScriptRoot
|
|
11
|
+
$Controller=Join-Path $Root 'controller'
|
|
12
|
+
if([string]::IsNullOrWhiteSpace($RuntimeRoot)){ $RuntimeRoot=Join-Path $Controller 'runtime' }
|
|
13
|
+
if([string]::IsNullOrWhiteSpace($OutputPath)){ $OutputPath=Join-Path $Controller 'deadbyte-desktop-policy.json' }
|
|
14
|
+
$RuntimeRoot=[System.IO.Path]::GetFullPath($RuntimeRoot)
|
|
15
|
+
$OutputPath=[System.IO.Path]::GetFullPath($OutputPath)
|
|
16
|
+
$Observer=[System.IO.Path]::GetFullPath((Join-Path $Root 'bin\deadbyte-desktop-observer-r40.exe'))
|
|
17
|
+
$Input=[System.IO.Path]::GetFullPath((Join-Path $Root 'bin\deadbyte-desktop-input-r40.exe'))
|
|
18
|
+
$Grounder=[System.IO.Path]::GetFullPath((Join-Path $Root 'bin\deadbyte-desktop-uia-r40.exe'))
|
|
19
|
+
if(-not (Test-Path -LiteralPath $Observer -PathType Leaf)){throw "observer binary missing: $Observer"}
|
|
20
|
+
if(-not (Test-Path -LiteralPath $Input -PathType Leaf)){throw "input binary missing: $Input"}
|
|
21
|
+
if(-not (Test-Path -LiteralPath $Grounder -PathType Leaf)){throw "UIA grounder binary missing: $Grounder"}
|
|
22
|
+
$Known=@('pointer_move','click_primary','click_secondary','double_click_primary','scroll','key_chord','text_input')
|
|
23
|
+
if($AllowedActions.Count -lt 1){throw 'AllowedActions cannot be empty'}
|
|
24
|
+
$Unique=@($AllowedActions | Sort-Object -Unique)
|
|
25
|
+
if($Unique.Count -ne $AllowedActions.Count -or @($AllowedActions | Where-Object { $_ -notin $Known }).Count -gt 0){throw 'AllowedActions invalid'}
|
|
26
|
+
New-Item -ItemType Directory -Force -Path $RuntimeRoot | Out-Null
|
|
27
|
+
$Evidence=Join-Path $RuntimeRoot 'desktop-evidence'
|
|
28
|
+
New-Item -ItemType Directory -Force -Path $Evidence | Out-Null
|
|
29
|
+
$Grant=Join-Path $RuntimeRoot 'desktop-grant.json'
|
|
30
|
+
Remove-Item -LiteralPath $Grant -Force -ErrorAction SilentlyContinue
|
|
31
|
+
$Policy=[ordered]@{
|
|
32
|
+
schema='deadbyte.desktop-policy.v1'
|
|
33
|
+
enabled=$true
|
|
34
|
+
grant_file=$Grant
|
|
35
|
+
evidence_dir=$Evidence
|
|
36
|
+
observer=[ordered]@{
|
|
37
|
+
executable=$Observer
|
|
38
|
+
sha256=(Get-FileHash -LiteralPath $Observer -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
39
|
+
backend='gdi-bitblt-fallback'
|
|
40
|
+
}
|
|
41
|
+
input=[ordered]@{
|
|
42
|
+
executable=$Input
|
|
43
|
+
sha256=(Get-FileHash -LiteralPath $Input -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
44
|
+
}
|
|
45
|
+
grounder=[ordered]@{
|
|
46
|
+
executable=$Grounder
|
|
47
|
+
sha256=(Get-FileHash -LiteralPath $Grounder -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
48
|
+
}
|
|
49
|
+
allowed_input_desktops=@('Default')
|
|
50
|
+
allowed_actions=@($AllowedActions)
|
|
51
|
+
limits=[ordered]@{
|
|
52
|
+
max_frame_age_ms=2000
|
|
53
|
+
max_frame_bytes=134217728
|
|
54
|
+
capture_timeout_ms=10000
|
|
55
|
+
input_timeout_ms=5000
|
|
56
|
+
ground_timeout_ms=5000
|
|
57
|
+
post_observe_timeout_ms=10000
|
|
58
|
+
max_preview_bytes=1048576
|
|
59
|
+
max_text_bytes=4096
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
$Parent=Split-Path -Parent $OutputPath
|
|
63
|
+
New-Item -ItemType Directory -Force -Path $Parent | Out-Null
|
|
64
|
+
$Json=$Policy | ConvertTo-Json -Depth 8
|
|
65
|
+
$Utf8=New-Object System.Text.UTF8Encoding($false)
|
|
66
|
+
$Tmp=$OutputPath+'.tmp'
|
|
67
|
+
[System.IO.File]::WriteAllText($Tmp,$Json,$Utf8)
|
|
68
|
+
Move-Item -LiteralPath $Tmp -Destination $OutputPath -Force
|
|
69
|
+
[pscustomobject]@{
|
|
70
|
+
status='created'
|
|
71
|
+
policy_path=$OutputPath
|
|
72
|
+
policy_sha256=(Get-FileHash -LiteralPath $OutputPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
73
|
+
observer_sha256=$Policy.observer.sha256
|
|
74
|
+
input_sha256=$Policy.input.sha256
|
|
75
|
+
grounder_sha256=$Policy.grounder.sha256
|
|
76
|
+
grant_file=$Grant
|
|
77
|
+
grant_state='DISARMED'
|
|
78
|
+
action_kinds=@($AllowedActions)
|
|
79
|
+
}|ConvertTo-Json -Depth 6
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { R36_CAPABILITY_LEDGER } from '../src/capability-ledger.mjs';
|
|
2
|
+
const names=new Set(['capability_manifest']);
|
|
3
|
+
for(const item of R36_CAPABILITY_LEDGER.entries) if(item.compact_tool) names.add(item.compact_tool);
|
|
4
|
+
console.log(JSON.stringify({count:names.size,names:[...names].sort(),ledger_sha256:R36_CAPABILITY_LEDGER.ledger_sha256},null,2));
|