deadbyte-mcp 0.11.0 → 0.11.2

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.
Files changed (76) hide show
  1. package/MANIFEST.SHA256 +75 -59
  2. package/README.txt +7 -7
  3. package/bin/WORKER-REGISTRY.txt +3 -3
  4. package/bin/appcontainer-stage.exe +0 -0
  5. package/bin/appcontainer-stage.obj +0 -0
  6. package/bin/bootstrap-advapi32.exe +0 -0
  7. package/bin/bootstrap-advapi32.obj +0 -0
  8. package/bin/bootstrap-exitcode.exe +0 -0
  9. package/bin/bootstrap-exitcode.obj +0 -0
  10. package/bin/bootstrap-kernel32.exe +0 -0
  11. package/bin/bootstrap-kernel32.obj +0 -0
  12. package/bin/child-control-probe.exe +0 -0
  13. package/bin/child-control-probe.obj +0 -0
  14. package/bin/child-control-stage.exe +0 -0
  15. package/bin/child-control-stage.obj +0 -0
  16. package/bin/contained-reverse-worker.exe +0 -0
  17. package/bin/contained-reverse-worker.obj +0 -0
  18. package/bin/contained-transform-worker.exe +0 -0
  19. package/bin/contained-transform-worker.obj +0 -0
  20. package/bin/containment-probe.exe +0 -0
  21. package/bin/containment-probe.obj +0 -0
  22. package/bin/deadbyte-contain.exe +0 -0
  23. package/bin/deadbyte-contain.obj +0 -0
  24. package/bin/deadbyte-exec.exe +0 -0
  25. package/bin/deadbyte-exec.obj +0 -0
  26. package/bin/deadbyte-process-host.exe +0 -0
  27. package/bin/deadbyte-process-host.obj +0 -0
  28. package/bin/deadbyte-tunnel-host.exe +0 -0
  29. package/bin/deadbyte-tunnel-host.obj +0 -0
  30. package/controller/README.TXT +1 -1
  31. package/controller/deadbyte-controller.ps1 +4 -4
  32. package/controller/deadbyte-process-policy.json +1 -1
  33. package/docs/ARCHITECTURE.md +1 -1
  34. package/package.json +6 -6
  35. package/scripts/build-containment.ps1 +15 -15
  36. package/scripts/deferred-slot-operation-r37-0110.mjs +124 -0
  37. package/scripts/deferred-slot-operation-r38.mjs +124 -0
  38. package/scripts/deferred-slot-operation.mjs +1 -1
  39. package/scripts/final-closure-r37-0110.mjs +113 -0
  40. package/scripts/final-closure-r38.mjs +113 -0
  41. package/scripts/final-closure-verify-r37-0110.mjs +208 -0
  42. package/scripts/final-closure-verify-r38.mjs +208 -0
  43. package/scripts/final-closure-verify.mjs +16 -16
  44. package/scripts/final-closure.mjs +8 -8
  45. package/scripts/gate-windows-r37-0110.ps1 +42 -0
  46. package/scripts/gate-windows-r38.ps1 +42 -0
  47. package/scripts/gate-windows.ps1 +3 -3
  48. package/scripts/release-parity-r37-0110.mjs +200 -0
  49. package/scripts/release-parity-r38.mjs +200 -0
  50. package/scripts/release-parity-tests-r38.ps1 +9 -0
  51. package/scripts/release-parity-tests.ps1 +1 -1
  52. package/scripts/release-parity.mjs +14 -14
  53. package/scripts/windows-gate-evidence-r37-0110.mjs +52 -0
  54. package/scripts/windows-gate-evidence-r38.mjs +52 -0
  55. package/scripts/windows-gate-evidence.mjs +4 -4
  56. package/src/deadbyte-cli.mjs +58 -23
  57. package/src/release-generation.mjs +18 -1
  58. package/src/remote-live-log.mjs +23 -1
  59. package/src/remote-result-journal.mjs +23 -4
  60. package/src/version.mjs +1 -1
  61. package/test/cli-entrypoint.test.mjs +9 -0
  62. package/test/containment.test.mjs +18 -0
  63. package/test/controller.test.mjs +11 -0
  64. package/test/core.test.mjs +1 -1
  65. package/test/production-docs.test.mjs +3 -3
  66. package/test/r33-closeout-regression.test.mjs +8 -8
  67. package/test/r33-finalization.test.mjs +14 -14
  68. package/test/r36-release-identity.test.mjs +4 -4
  69. package/test/r37-0110-history.test.mjs +20 -0
  70. package/test/r37-finalization.test.mjs +14 -14
  71. package/test/r37-remote-tool-call-timeline.test.mjs +94 -0
  72. package/test/r38-finalization.test.mjs +74 -0
  73. package/test/release-generation.test.mjs +13 -3
  74. package/test/release-version.test.mjs +45 -33
  75. package/test/remote-live-log-r37.test.mjs +5 -2
  76. package/test/remote-session-cli.test.mjs +66 -25
@@ -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.2 / R38 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-r38.mjs')
38
+ if ($LASTEXITCODE -ne 0) {
39
+ throw "DEADBYTE V0.11.2 / R38 gate failed at windows-gate-evidence with exit code $LASTEXITCODE"
40
+ }
41
+
42
+ Write-Host '==== DEADBYTE V0.11.2 / R38 WINDOWS BATCH GATE: PASS ===='
@@ -9,7 +9,7 @@ function Invoke-GateStep {
9
9
  Write-Host "==== $Name ===="
10
10
  & npm.cmd @NpmArgs
11
11
  if ($LASTEXITCODE -ne 0) {
12
- throw "DEADBYTE V0.11.0 / R37 gate failed at $Name with exit code $LASTEXITCODE"
12
+ throw "DEADBYTE V0.11.1 / R37 gate failed at $Name with exit code $LASTEXITCODE"
13
13
  }
14
14
  }
15
15
 
@@ -36,7 +36,7 @@ Invoke-GateStep -Name 'release-manifest-final' -NpmArgs @('run', 'manifest:verif
36
36
  Write-Host '==== windows-gate-evidence ===='
37
37
  & node.exe (Join-Path $PSScriptRoot 'windows-gate-evidence.mjs')
38
38
  if ($LASTEXITCODE -ne 0) {
39
- throw "DEADBYTE V0.11.0 / R37 gate failed at windows-gate-evidence with exit code $LASTEXITCODE"
39
+ throw "DEADBYTE V0.11.1 / R37 gate failed at windows-gate-evidence with exit code $LASTEXITCODE"
40
40
  }
41
41
 
42
- Write-Host '==== DEADBYTE V0.11.0 / R37 WINDOWS BATCH GATE: PASS ===='
42
+ Write-Host '==== DEADBYTE V0.11.1 / R37 WINDOWS BATCH GATE: PASS ===='
@@ -0,0 +1,200 @@
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 { probeR36FullSurface } from '../src/r36-full-surface-probe.mjs';
9
+ import { runR36CompactParity } from '../src/remote-mcp-r36-parity-client.mjs';
10
+ import { probeR36CompactDisarmed } from '../src/r36-compact-disarmed-probe.mjs';
11
+
12
+ const here=path.dirname(fileURLToPath(import.meta.url));
13
+ const root=path.resolve(here,'..');
14
+ const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
15
+ const deferred=path.join(root,'scripts','deferred-slot-operation.mjs');
16
+ const ps='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe';
17
+ const launcher=path.join(stateRoot,'bin','DEADBYTE-MCP.ps1');
18
+ const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
19
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
20
+
21
+ export const R36_PREDECESSOR_RELEASE_ID='v0.10.0-8d1e5f09745e7647';
22
+ export const R36_PREDECESSOR_MANIFEST='8d1e5f09745e764796b60e0a8a0168be7334ed4bf834fad5974a80eba295b4e8';
23
+
24
+ function assert(condition,message){if(!condition) throw new Error(message);}
25
+ function parseFrozenManifest(text){
26
+ const entries=[];const seen=new Set();
27
+ for(const [index,line] of text.split(/\r?\n/).entries()){
28
+ if(!line) continue;
29
+ const match=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);
30
+ assert(match,`frozen manifest line ${index+1} malformed`);
31
+ const rel=match[2];
32
+ assert(!path.posix.isAbsolute(rel)&&!rel.split('/').includes('..')&&!seen.has(rel),`unsafe/duplicate frozen manifest path: ${rel}`);
33
+ seen.add(rel);entries.push({sha256:match[1],path:rel});
34
+ }
35
+ return entries;
36
+ }
37
+ // Restore the mutable development stage from the immutable active release after live parity work may drift it.
38
+ export async function restoreFrozenStage({developmentRoot,releaseRoot,expectedManifestSha256}){
39
+ const dev=path.resolve(developmentRoot);const release=path.resolve(releaseRoot);
40
+ const manifestBytes=await readFile(path.join(release,'MANIFEST.SHA256'));
41
+ const manifestSha256=sha256(manifestBytes);
42
+ assert(manifestSha256===expectedManifestSha256,`immutable release manifest drift: ${manifestSha256}`);
43
+ const entries=parseFrozenManifest(manifestBytes.toString('utf8'));
44
+ for(const entry of entries){
45
+ const source=path.join(release,...entry.path.split('/'));const bytes=await readFile(source);
46
+ assert(sha256(bytes)===entry.sha256,`immutable release file drift: ${entry.path}`);
47
+ const destination=path.join(dev,...entry.path.split('/'));await mkdir(path.dirname(destination),{recursive:true});
48
+ await writeFile(destination,bytes);assert(sha256(await readFile(destination))===entry.sha256,`development restore verification failed: ${entry.path}`);
49
+ }
50
+ await writeFile(path.join(dev,'MANIFEST.SHA256'),manifestBytes);
51
+ assert(sha256(await readFile(path.join(dev,'MANIFEST.SHA256')))===expectedManifestSha256,'development manifest restore verification failed');
52
+ return {status:'restored',file_count:entries.length,manifest_sha256:manifestSha256};
53
+ }
54
+ function parseJsonOutput(text,label){
55
+ const trimmed=String(text).trim();const starts=[...trimmed.matchAll(/\{/g)].map(match=>match.index);
56
+ for(const start of starts){try{return JSON.parse(trimmed.slice(start));}catch{}}
57
+ throw new Error(`${label} did not emit JSON`);
58
+ }
59
+ function run(command,args,{timeoutMs=900000,env=process.env,cwd=root}={}){
60
+ return new Promise((resolve,reject)=>{
61
+ const child=spawn(command,args,{cwd,shell:false,windowsHide:true,env,stdio:['ignore','pipe','pipe']});
62
+ const out=[],err=[];const timer=setTimeout(()=>{child.kill();reject(new Error(`command timeout: ${path.basename(command)}`));},timeoutMs);
63
+ child.stdout.on('data',chunk=>out.push(Buffer.from(chunk)));child.stderr.on('data',chunk=>err.push(Buffer.from(chunk)));
64
+ child.on('error',error=>{clearTimeout(timer);reject(error);});child.on('exit',code=>{
65
+ clearTimeout(timer);const stdout=Buffer.concat(out).toString('utf8');const stderr=Buffer.concat(err).toString('utf8');
66
+ if(code!==0) reject(new Error(`command failed exit=${code}: ${stderr||stdout}`));else resolve({stdout,stderr,exitCode:code});
67
+ });
68
+ });
69
+ }
70
+ async function publicUrl(){
71
+ const value=(await readFile(path.join(stateRoot,'bridge','mcp-url.txt'),'utf8')).trim();const url=new URL(value);
72
+ if(url.protocol!=='https:') throw new Error('public MCP URL must be HTTPS');return value;
73
+ }
74
+ async function pointer(){return JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));}
75
+ async function disarmAll(){
76
+ for(const command of ['disarmautonomous','disarmcoding','disarmprocess','disarmhost']){
77
+ await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,command],{timeoutMs:60000});
78
+ }
79
+ }
80
+ async function waitDeferred(statePath,timeoutMs=180000){
81
+ const deadline=Date.now()+timeoutMs;
82
+ while(Date.now()<deadline){const state=JSON.parse(await readFile(statePath,'utf8'));if(state.state==='completed') return state;if(state.state==='failed') throw new Error(`deferred ${state.mode} failed: ${state.error}`);await sleep(500);}
83
+ throw new Error(`deferred operation timeout: ${statePath}`);
84
+ }
85
+ async function scheduleDeferred(mode,value,{bridgeRoot=null,bridgeScriptSha256=null}={}){
86
+ if((bridgeRoot===null)!==(bridgeScriptSha256===null)) throw new Error('deferred bridge override requires exact root + SHA pair');
87
+ const args=[deferred,mode,value];
88
+ if(bridgeRoot!==null) args.push('--bridge-root',bridgeRoot,'--bridge-script-sha256',bridgeScriptSha256);
89
+ const scheduled=parseJsonOutput((await run(process.execPath,args,{timeoutMs:30000})).stdout,`deferred ${mode}`);
90
+ assert(scheduled.status==='scheduled',`deferred ${mode} was not scheduled`);
91
+ assert(scheduled.execution_provider==='deadbyte_mcp'&&scheduled.rdc_operation_count===0,'deferred operation provider mismatch');
92
+ return {scheduled,completed:await waitDeferred(scheduled.state_path)};
93
+ }
94
+ async function publicR36Disarmed(url){
95
+ const result=await probeR36CompactDisarmed(url);
96
+ assert(result.status==='passed'&&result.tool_count<=42&&result.capability_closure===true,'R36 predecessor public compact catalog mismatch');
97
+ assert(result.release_id===R36_PREDECESSOR_RELEASE_ID&&result.release_manifest_sha256===R36_PREDECESSOR_MANIFEST,'R36 predecessor machine binding mismatch');
98
+ assert(result.coding_armed===false&&result.autonomous_armed===false,'R36 predecessor authority remained armed');
99
+ return result;
100
+ }
101
+ async function mutableCore(pointerValue){
102
+ const policy=JSON.parse(await readFile(path.join(pointerValue.generation_root,'coding-policy.json'),'utf8'));
103
+ const raw=policy?.roots?.core?.path??policy?.roots?.core?.real_path;
104
+ assert(typeof raw==='string'&&raw,'R37 generation missing coding core root');
105
+ const core=path.resolve(raw);const release=path.resolve(pointerValue.release_root);
106
+ assert(core.toLowerCase()!==release.toLowerCase(),'R37 coding core must not point at immutable active release slot');
107
+ return core;
108
+ }
109
+
110
+ export function validateParityEvidence(value){
111
+ assert(value?.schema==='deadbyte.r37-parity.v1','R37 parity schema mismatch');
112
+ assert(value.status==='passed','R37 parity status is not passed');
113
+ assert(value.rdc_operation_count===0&&value.execution_provider==='deadbyte_mcp','R37 parity used non-DEADBYTE execution');
114
+ assert(value.candidate?.version==='0.11.0'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R37 candidate identity missing');
115
+ assert(value.local_full?.status==='passed'&&value.local_full?.tool_count===76&&value.local_full?.strict_output_schemas===true,'R37 local full 76-tool proof missing');
116
+ assert(value.public_compact?.status==='passed'&&value.public_compact?.tool_count<=42&&value.public_compact?.capability_closure===true&&value.public_compact?.gateway_count===5,'R37 public compact closure missing');
117
+ assert(value.autonomous?.status==='passed'&&value.autonomous?.signed_release_verified===true,'R37 autonomous live proof missing');
118
+ assert(value.before_rollback_disarmed?.status==='passed'&&value.before_rollback_disarmed?.capability_closure===true&&value.before_rollback_disarmed?.coding_armed===false&&value.before_rollback_disarmed?.autonomous_armed===false,'R37 pre-rollback disarm proof missing');
119
+ assert(value.rollback?.state==='completed'&&value.restore?.state==='completed','R37 rollback/restore not completed');
120
+ assert(value.stage_restore?.status==='restored'&&value.stage_restore?.manifest_sha256===value.candidate.manifest_sha256,'R37 stage restore proof missing');
121
+ assert(value.predecessor?.release_id===R36_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R36_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.10.0','R36 exact predecessor identity mismatch');
122
+ assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count<=42&&value.predecessor_disarmed?.capability_closure===true,'R36 predecessor public proof missing');
123
+ assert(value.successor?.version==='0.11.0'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R37 exact successor restore identity mismatch');
124
+ assert(value.successor_disarmed?.status==='passed'&&value.successor_disarmed?.capability_closure===true&&value.successor_disarmed?.coding_armed===false&&value.successor_disarmed?.autonomous_armed===false,'R37 successor disarmed proof missing');
125
+ assert(value.immutable_slot?.protected===true&&value.immutable_slot?.development_root!==value.immutable_slot?.release_root,'R37 immutable-slot separation missing');
126
+ for(const key of ['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface']) assert(value.requirements?.[key]===true,`R37 parity requirement not proven: ${key}`);
127
+ return true;
128
+ }
129
+
130
+ export async function runReleaseParity(activationReceiptPath){
131
+ const active=await pointer();const candidateManifest=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
132
+ assert(active.version==='0.11.0','R37 parity requires active 0.11.0 candidate');
133
+ assert(active.manifest_sha256===candidateManifest,'active release is not canonical R37 candidate');
134
+ const activeConfig=await loadPowerShellDataFile(active.config_path);
135
+ const successorBridgeRootRaw=activeConfig?.Bridge?.WorkingDirectory;
136
+ const successorBridgeConfiguredSha=activeConfig?.Bridge?.ScriptSha256;
137
+ assert(typeof successorBridgeRootRaw==='string'&&path.isAbsolute(successorBridgeRootRaw),'R37 active bridge root missing');
138
+ assert(typeof successorBridgeConfiguredSha==='string'&&/^[0-9a-f]{64}$/.test(successorBridgeConfiguredSha),'R37 active bridge SHA missing');
139
+ const successorBridgeRoot=await realpath(path.resolve(successorBridgeRootRaw));
140
+ const successorBridgeActualSha=sha256(await readFile(path.join(successorBridgeRoot,'src','bridge.mjs')));
141
+ assert(successorBridgeActualSha===successorBridgeConfiguredSha,'R37 active bridge bytes do not match generation pin');
142
+ const successorBridge={root:successorBridgeRoot,sha256:successorBridgeActualSha};
143
+ const developmentRoot=await mutableCore(active);
144
+ const localFull=await probeR36FullSurface({packageRoot:active.release_root,generationRoot:active.generation_root,stateRoot});
145
+ const url=await publicUrl();
146
+ let publicCompact,autonomous;
147
+ try{
148
+ publicCompact=await runR36CompactParity(url);
149
+ autonomous=parseJsonOutput((await run(process.execPath,[path.join(root,'src','remote-mcp-autonomous-smoke-client.mjs'),url],{timeoutMs:900000})).stdout,'R37 autonomous compact parity');
150
+ assert(autonomous.status==='passed'&&autonomous.signed_release_verified===true,'R37 autonomous compact parity failed');
151
+ }catch(error){await disarmAll().catch(()=>{});throw error;}
152
+
153
+ await disarmAll();
154
+ const beforeRollback=await probeR36CompactDisarmed(url);
155
+ const rollbackPair=await scheduleDeferred('rollback',path.resolve(activationReceiptPath));
156
+ const predecessor=await pointer();
157
+ assert(predecessor.release_id===R36_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R36_PREDECESSOR_MANIFEST&&predecessor.version==='0.10.0','rollback did not reach exact sealed R36 predecessor');
158
+ const predecessorDisarmed=await publicR36Disarmed(url);
159
+ const stageRestore=await restoreFrozenStage({developmentRoot,releaseRoot:active.release_root,expectedManifestSha256:candidateManifest});
160
+ const restorePair=await scheduleDeferred('activate',candidateManifest,{bridgeRoot:successorBridge.root,bridgeScriptSha256:successorBridge.sha256});
161
+ const successor=await pointer();
162
+ assert(successor.version==='0.11.0'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R37 candidate');
163
+ const successorDisarmed=await probeR36CompactDisarmed(url);
164
+ await disarmAll();
165
+
166
+ const evidence={
167
+ schema:'deadbyte.r37-parity.v1',status:'passed',completed_at_utc:new Date().toISOString(),execution_provider:'deadbyte_mcp',rdc_operation_count:0,
168
+ candidate:{release_id:active.release_id,version:active.version,manifest_sha256:candidateManifest},
169
+ immutable_slot:{protected:true,release_root:path.resolve(active.release_root),development_root:developmentRoot},
170
+ local_full:localFull,public_compact:publicCompact,autonomous,before_rollback_disarmed:beforeRollback,
171
+ rollback:{...rollbackPair.completed,scheduled_operation_id:rollbackPair.scheduled.operation_id},
172
+ predecessor:{release_id:predecessor.release_id,version:predecessor.version,manifest_sha256:predecessor.manifest_sha256},predecessor_disarmed:predecessorDisarmed,
173
+ stage_restore:stageRestore,
174
+ restore:{...restorePair.completed,scheduled_operation_id:restorePair.scheduled.operation_id},
175
+ successor:{release_id:successor.release_id,version:successor.version,manifest_sha256:successor.manifest_sha256},successor_disarmed:successorDisarmed,
176
+ requirements:{
177
+ tree_read:publicCompact.tree_entries>=0&&publicCompact.coding_stat_verified===true,
178
+ precondition_mutation:publicCompact.machine_fs_receipts_verified>=3,
179
+ search:publicCompact.coding_search_result_count>=1&&publicCompact.observation_search_result_count>=1,
180
+ owned_process:typeof publicCompact.process_session_id==='string'&&publicCompact.process_output_bytes>0,
181
+ observation:publicCompact.observation_receipts_verified>=2,
182
+ coding_loop:publicCompact.coding_receipts_verified===2,
183
+ autonomy:autonomous.signed_release_verified===true&&autonomous.observed_failure_before_replan===true,
184
+ interrupted_recovery:rollbackPair.completed.state==='completed'&&restorePair.completed.state==='completed',
185
+ evidence_verification:publicCompact.machine_fs_receipts_verified>=3&&autonomous.signed_release_verified===true,
186
+ compact_closure:publicCompact.capability_closure===true&&successorDisarmed.capability_closure===true,
187
+ full_surface:localFull.tool_count===76&&localFull.strict_output_schemas===true
188
+ }
189
+ };
190
+ validateParityEvidence(evidence);
191
+ const evidenceDir=path.join(stateRoot,'evidence','release');await mkdir(evidenceDir,{recursive:true});
192
+ const evidencePath=path.join(evidenceDir,`r37-parity-${candidateManifest.slice(0,16)}.json`);
193
+ const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');await writeFile(evidencePath,bytes);
194
+ return {evidence,evidence_path:evidencePath,evidence_sha256:sha256(bytes)};
195
+ }
196
+
197
+ if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
198
+ const receipt=process.argv[2];if(!receipt) throw new Error('usage: node scripts/release-parity.mjs <activation-receipt.json>');
199
+ runReleaseParity(receipt).then(result=>console.log(JSON.stringify({status:'passed',...result},null,2))).catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
200
+ }
@@ -0,0 +1,200 @@
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 { probeR36FullSurface } from '../src/r36-full-surface-probe.mjs';
9
+ import { runR36CompactParity } from '../src/remote-mcp-r36-parity-client.mjs';
10
+ import { probeR36CompactDisarmed } from '../src/r36-compact-disarmed-probe.mjs';
11
+
12
+ const here=path.dirname(fileURLToPath(import.meta.url));
13
+ const root=path.resolve(here,'..');
14
+ const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
15
+ const deferred=path.join(root,'scripts','deferred-slot-operation-r38.mjs');
16
+ const ps='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe';
17
+ const launcher=path.join(stateRoot,'bin','DEADBYTE-MCP.ps1');
18
+ const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
19
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
20
+
21
+ export const R38_PREDECESSOR_RELEASE_ID='v0.11.1-220fac89dd82cdcd';
22
+ export const R38_PREDECESSOR_MANIFEST='220fac89dd82cdcdddb82cd7d0b71b768f84a5c87d57ebaca0f5383f33d97a76';
23
+
24
+ function assert(condition,message){if(!condition) throw new Error(message);}
25
+ function parseFrozenManifest(text){
26
+ const entries=[];const seen=new Set();
27
+ for(const [index,line] of text.split(/\r?\n/).entries()){
28
+ if(!line) continue;
29
+ const match=/^([0-9a-f]{64}) ([^\0]+)$/.exec(line);
30
+ assert(match,`frozen manifest line ${index+1} malformed`);
31
+ const rel=match[2];
32
+ assert(!path.posix.isAbsolute(rel)&&!rel.split('/').includes('..')&&!seen.has(rel),`unsafe/duplicate frozen manifest path: ${rel}`);
33
+ seen.add(rel);entries.push({sha256:match[1],path:rel});
34
+ }
35
+ return entries;
36
+ }
37
+ // Restore the mutable development stage from the immutable active release after live parity work may drift it.
38
+ export async function restoreFrozenStage({developmentRoot,releaseRoot,expectedManifestSha256}){
39
+ const dev=path.resolve(developmentRoot);const release=path.resolve(releaseRoot);
40
+ const manifestBytes=await readFile(path.join(release,'MANIFEST.SHA256'));
41
+ const manifestSha256=sha256(manifestBytes);
42
+ assert(manifestSha256===expectedManifestSha256,`immutable release manifest drift: ${manifestSha256}`);
43
+ const entries=parseFrozenManifest(manifestBytes.toString('utf8'));
44
+ for(const entry of entries){
45
+ const source=path.join(release,...entry.path.split('/'));const bytes=await readFile(source);
46
+ assert(sha256(bytes)===entry.sha256,`immutable release file drift: ${entry.path}`);
47
+ const destination=path.join(dev,...entry.path.split('/'));await mkdir(path.dirname(destination),{recursive:true});
48
+ await writeFile(destination,bytes);assert(sha256(await readFile(destination))===entry.sha256,`development restore verification failed: ${entry.path}`);
49
+ }
50
+ await writeFile(path.join(dev,'MANIFEST.SHA256'),manifestBytes);
51
+ assert(sha256(await readFile(path.join(dev,'MANIFEST.SHA256')))===expectedManifestSha256,'development manifest restore verification failed');
52
+ return {status:'restored',file_count:entries.length,manifest_sha256:manifestSha256};
53
+ }
54
+ function parseJsonOutput(text,label){
55
+ const trimmed=String(text).trim();const starts=[...trimmed.matchAll(/\{/g)].map(match=>match.index);
56
+ for(const start of starts){try{return JSON.parse(trimmed.slice(start));}catch{}}
57
+ throw new Error(`${label} did not emit JSON`);
58
+ }
59
+ function run(command,args,{timeoutMs=900000,env=process.env,cwd=root}={}){
60
+ return new Promise((resolve,reject)=>{
61
+ const child=spawn(command,args,{cwd,shell:false,windowsHide:true,env,stdio:['ignore','pipe','pipe']});
62
+ const out=[],err=[];const timer=setTimeout(()=>{child.kill();reject(new Error(`command timeout: ${path.basename(command)}`));},timeoutMs);
63
+ child.stdout.on('data',chunk=>out.push(Buffer.from(chunk)));child.stderr.on('data',chunk=>err.push(Buffer.from(chunk)));
64
+ child.on('error',error=>{clearTimeout(timer);reject(error);});child.on('exit',code=>{
65
+ clearTimeout(timer);const stdout=Buffer.concat(out).toString('utf8');const stderr=Buffer.concat(err).toString('utf8');
66
+ if(code!==0) reject(new Error(`command failed exit=${code}: ${stderr||stdout}`));else resolve({stdout,stderr,exitCode:code});
67
+ });
68
+ });
69
+ }
70
+ async function publicUrl(){
71
+ const value=(await readFile(path.join(stateRoot,'bridge','mcp-url.txt'),'utf8')).trim();const url=new URL(value);
72
+ if(url.protocol!=='https:') throw new Error('public MCP URL must be HTTPS');return value;
73
+ }
74
+ async function pointer(){return JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));}
75
+ async function disarmAll(){
76
+ for(const command of ['disarmautonomous','disarmcoding','disarmprocess','disarmhost']){
77
+ await run(ps,['-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',launcher,command],{timeoutMs:60000});
78
+ }
79
+ }
80
+ async function waitDeferred(statePath,timeoutMs=180000){
81
+ const deadline=Date.now()+timeoutMs;
82
+ while(Date.now()<deadline){const state=JSON.parse(await readFile(statePath,'utf8'));if(state.state==='completed') return state;if(state.state==='failed') throw new Error(`deferred ${state.mode} failed: ${state.error}`);await sleep(500);}
83
+ throw new Error(`deferred operation timeout: ${statePath}`);
84
+ }
85
+ async function scheduleDeferred(mode,value,{bridgeRoot=null,bridgeScriptSha256=null}={}){
86
+ if((bridgeRoot===null)!==(bridgeScriptSha256===null)) throw new Error('deferred bridge override requires exact root + SHA pair');
87
+ const args=[deferred,mode,value];
88
+ if(bridgeRoot!==null) args.push('--bridge-root',bridgeRoot,'--bridge-script-sha256',bridgeScriptSha256);
89
+ const scheduled=parseJsonOutput((await run(process.execPath,args,{timeoutMs:30000})).stdout,`deferred ${mode}`);
90
+ assert(scheduled.status==='scheduled',`deferred ${mode} was not scheduled`);
91
+ assert(scheduled.execution_provider==='deadbyte_mcp'&&scheduled.rdc_operation_count===0,'deferred operation provider mismatch');
92
+ return {scheduled,completed:await waitDeferred(scheduled.state_path)};
93
+ }
94
+ async function publicR38Disarmed(url){
95
+ const result=await probeR36CompactDisarmed(url);
96
+ assert(result.status==='passed'&&result.tool_count<=42&&result.capability_closure===true,'R38 predecessor public compact catalog mismatch');
97
+ assert(result.release_id===R38_PREDECESSOR_RELEASE_ID&&result.release_manifest_sha256===R38_PREDECESSOR_MANIFEST,'R38 predecessor machine binding mismatch');
98
+ assert(result.coding_armed===false&&result.autonomous_armed===false,'R38 predecessor authority remained armed');
99
+ return result;
100
+ }
101
+ async function mutableCore(pointerValue){
102
+ const policy=JSON.parse(await readFile(path.join(pointerValue.generation_root,'coding-policy.json'),'utf8'));
103
+ const raw=policy?.roots?.core?.path??policy?.roots?.core?.real_path;
104
+ assert(typeof raw==='string'&&raw,'R38 generation missing coding core root');
105
+ const core=path.resolve(raw);const release=path.resolve(pointerValue.release_root);
106
+ assert(core.toLowerCase()!==release.toLowerCase(),'R38 coding core must not point at immutable active release slot');
107
+ return core;
108
+ }
109
+
110
+ export function validateParityEvidence(value){
111
+ assert(value?.schema==='deadbyte.r38-parity.v1','R38 parity schema mismatch');
112
+ assert(value.status==='passed','R38 parity status is not passed');
113
+ assert(value.rdc_operation_count===0&&value.execution_provider==='deadbyte_mcp','R38 parity used non-DEADBYTE execution');
114
+ assert(value.candidate?.version==='0.11.2'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R38 candidate identity missing');
115
+ assert(value.local_full?.status==='passed'&&value.local_full?.tool_count===76&&value.local_full?.strict_output_schemas===true,'R38 local full 76-tool proof missing');
116
+ assert(value.public_compact?.status==='passed'&&value.public_compact?.tool_count<=42&&value.public_compact?.capability_closure===true&&value.public_compact?.gateway_count===5,'R38 public compact closure missing');
117
+ assert(value.autonomous?.status==='passed'&&value.autonomous?.signed_release_verified===true,'R38 autonomous live proof missing');
118
+ assert(value.before_rollback_disarmed?.status==='passed'&&value.before_rollback_disarmed?.capability_closure===true&&value.before_rollback_disarmed?.coding_armed===false&&value.before_rollback_disarmed?.autonomous_armed===false,'R38 pre-rollback disarm proof missing');
119
+ assert(value.rollback?.state==='completed'&&value.restore?.state==='completed','R38 rollback/restore not completed');
120
+ assert(value.stage_restore?.status==='restored'&&value.stage_restore?.manifest_sha256===value.candidate.manifest_sha256,'R38 stage restore proof missing');
121
+ assert(value.predecessor?.release_id===R38_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R38_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.11.1','R38 exact predecessor identity mismatch');
122
+ assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count<=42&&value.predecessor_disarmed?.capability_closure===true,'R38 predecessor public proof missing');
123
+ assert(value.successor?.version==='0.11.2'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R38 exact successor restore identity mismatch');
124
+ assert(value.successor_disarmed?.status==='passed'&&value.successor_disarmed?.capability_closure===true&&value.successor_disarmed?.coding_armed===false&&value.successor_disarmed?.autonomous_armed===false,'R38 successor disarmed proof missing');
125
+ assert(value.immutable_slot?.protected===true&&value.immutable_slot?.development_root!==value.immutable_slot?.release_root,'R38 immutable-slot separation missing');
126
+ for(const key of ['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface']) assert(value.requirements?.[key]===true,`R38 parity requirement not proven: ${key}`);
127
+ return true;
128
+ }
129
+
130
+ export async function runReleaseParity(activationReceiptPath){
131
+ const active=await pointer();const candidateManifest=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
132
+ assert(active.version==='0.11.2','R38 parity requires active 0.11.2 candidate');
133
+ assert(active.manifest_sha256===candidateManifest,'active release is not canonical R38 candidate');
134
+ const activeConfig=await loadPowerShellDataFile(active.config_path);
135
+ const successorBridgeRootRaw=activeConfig?.Bridge?.WorkingDirectory;
136
+ const successorBridgeConfiguredSha=activeConfig?.Bridge?.ScriptSha256;
137
+ assert(typeof successorBridgeRootRaw==='string'&&path.isAbsolute(successorBridgeRootRaw),'R38 active bridge root missing');
138
+ assert(typeof successorBridgeConfiguredSha==='string'&&/^[0-9a-f]{64}$/.test(successorBridgeConfiguredSha),'R38 active bridge SHA missing');
139
+ const successorBridgeRoot=await realpath(path.resolve(successorBridgeRootRaw));
140
+ const successorBridgeActualSha=sha256(await readFile(path.join(successorBridgeRoot,'src','bridge.mjs')));
141
+ assert(successorBridgeActualSha===successorBridgeConfiguredSha,'R38 active bridge bytes do not match generation pin');
142
+ const successorBridge={root:successorBridgeRoot,sha256:successorBridgeActualSha};
143
+ const developmentRoot=await mutableCore(active);
144
+ const localFull=await probeR36FullSurface({packageRoot:active.release_root,generationRoot:active.generation_root,stateRoot});
145
+ const url=await publicUrl();
146
+ let publicCompact,autonomous;
147
+ try{
148
+ publicCompact=await runR36CompactParity(url);
149
+ autonomous=parseJsonOutput((await run(process.execPath,[path.join(root,'src','remote-mcp-autonomous-smoke-client.mjs'),url],{timeoutMs:900000})).stdout,'R38 autonomous compact parity');
150
+ assert(autonomous.status==='passed'&&autonomous.signed_release_verified===true,'R38 autonomous compact parity failed');
151
+ }catch(error){await disarmAll().catch(()=>{});throw error;}
152
+
153
+ await disarmAll();
154
+ const beforeRollback=await probeR36CompactDisarmed(url);
155
+ const rollbackPair=await scheduleDeferred('rollback',path.resolve(activationReceiptPath));
156
+ const predecessor=await pointer();
157
+ assert(predecessor.release_id===R38_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R38_PREDECESSOR_MANIFEST&&predecessor.version==='0.11.1','rollback did not reach exact sealed R38 predecessor');
158
+ const predecessorDisarmed=await publicR38Disarmed(url);
159
+ const stageRestore=await restoreFrozenStage({developmentRoot,releaseRoot:active.release_root,expectedManifestSha256:candidateManifest});
160
+ const restorePair=await scheduleDeferred('activate',candidateManifest,{bridgeRoot:successorBridge.root,bridgeScriptSha256:successorBridge.sha256});
161
+ const successor=await pointer();
162
+ assert(successor.version==='0.11.2'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R38 candidate');
163
+ const successorDisarmed=await probeR36CompactDisarmed(url);
164
+ await disarmAll();
165
+
166
+ const evidence={
167
+ schema:'deadbyte.r38-parity.v1',status:'passed',completed_at_utc:new Date().toISOString(),execution_provider:'deadbyte_mcp',rdc_operation_count:0,
168
+ candidate:{release_id:active.release_id,version:active.version,manifest_sha256:candidateManifest},
169
+ immutable_slot:{protected:true,release_root:path.resolve(active.release_root),development_root:developmentRoot},
170
+ local_full:localFull,public_compact:publicCompact,autonomous,before_rollback_disarmed:beforeRollback,
171
+ rollback:{...rollbackPair.completed,scheduled_operation_id:rollbackPair.scheduled.operation_id},
172
+ predecessor:{release_id:predecessor.release_id,version:predecessor.version,manifest_sha256:predecessor.manifest_sha256},predecessor_disarmed:predecessorDisarmed,
173
+ stage_restore:stageRestore,
174
+ restore:{...restorePair.completed,scheduled_operation_id:restorePair.scheduled.operation_id},
175
+ successor:{release_id:successor.release_id,version:successor.version,manifest_sha256:successor.manifest_sha256},successor_disarmed:successorDisarmed,
176
+ requirements:{
177
+ tree_read:publicCompact.tree_entries>=0&&publicCompact.coding_stat_verified===true,
178
+ precondition_mutation:publicCompact.machine_fs_receipts_verified>=3,
179
+ search:publicCompact.coding_search_result_count>=1&&publicCompact.observation_search_result_count>=1,
180
+ owned_process:typeof publicCompact.process_session_id==='string'&&publicCompact.process_output_bytes>0,
181
+ observation:publicCompact.observation_receipts_verified>=2,
182
+ coding_loop:publicCompact.coding_receipts_verified===2,
183
+ autonomy:autonomous.signed_release_verified===true&&autonomous.observed_failure_before_replan===true,
184
+ interrupted_recovery:rollbackPair.completed.state==='completed'&&restorePair.completed.state==='completed',
185
+ evidence_verification:publicCompact.machine_fs_receipts_verified>=3&&autonomous.signed_release_verified===true,
186
+ compact_closure:publicCompact.capability_closure===true&&successorDisarmed.capability_closure===true,
187
+ full_surface:localFull.tool_count===76&&localFull.strict_output_schemas===true
188
+ }
189
+ };
190
+ validateParityEvidence(evidence);
191
+ const evidenceDir=path.join(stateRoot,'evidence','release');await mkdir(evidenceDir,{recursive:true});
192
+ const evidencePath=path.join(evidenceDir,`r38-parity-${candidateManifest.slice(0,16)}.json`);
193
+ const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');await writeFile(evidencePath,bytes);
194
+ return {evidence,evidence_path:evidencePath,evidence_sha256:sha256(bytes)};
195
+ }
196
+
197
+ if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
198
+ const receipt=process.argv[2];if(!receipt) throw new Error('usage: node scripts/release-parity-r38.mjs <activation-receipt.json>');
199
+ runReleaseParity(receipt).then(result=>console.log(JSON.stringify({status:'passed',...result},null,2))).catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
200
+ }
@@ -0,0 +1,9 @@
1
+ $ErrorActionPreference = 'Stop'
2
+ Set-StrictMode -Version 2.0
3
+ $root = Split-Path -Parent $PSScriptRoot
4
+ Push-Location $root
5
+ try {
6
+ & node.exe --test test\controller.test.mjs test\r38-finalization.test.mjs test\release-version.test.mjs test\r37-0110-history.test.mjs test\r37-agent-fabric.test.mjs test\remote-live-log-r37.test.mjs test\remote-session-cli.test.mjs test\r36-finalization.test.mjs test\r36-release-identity.test.mjs test\deferred-slot-operation.test.mjs
7
+ if ($LASTEXITCODE -ne 0) { throw "R38 release parity tests failed with exit code $LASTEXITCODE" }
8
+ Write-Output 'R38 RELEASE PARITY TEST PASS'
9
+ } finally { Pop-Location }
@@ -3,7 +3,7 @@ Set-StrictMode -Version 2.0
3
3
  $root = Split-Path -Parent $PSScriptRoot
4
4
  Push-Location $root
5
5
  try {
6
- & node.exe --test test\r37-finalization.test.mjs test\release-version.test.mjs test\r37-agent-fabric.test.mjs test\remote-live-log-r37.test.mjs test\remote-session-cli.test.mjs test\r36-finalization.test.mjs test\r36-release-identity.test.mjs test\deferred-slot-operation.test.mjs
6
+ & node.exe --test test\r37-finalization.test.mjs test\release-version.test.mjs test\r37-0110-history.test.mjs test\r37-agent-fabric.test.mjs test\remote-live-log-r37.test.mjs test\remote-session-cli.test.mjs test\r36-finalization.test.mjs test\r36-release-identity.test.mjs test\deferred-slot-operation.test.mjs
7
7
  if ($LASTEXITCODE -ne 0) { throw "release parity tests failed with exit code $LASTEXITCODE" }
8
8
  Write-Output 'R37 RELEASE PARITY TEST PASS'
9
9
  } finally { Pop-Location }
@@ -18,8 +18,8 @@ const launcher=path.join(stateRoot,'bin','DEADBYTE-MCP.ps1');
18
18
  const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
19
19
  const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
20
20
 
21
- export const R36_PREDECESSOR_RELEASE_ID='v0.10.0-8d1e5f09745e7647';
22
- export const R36_PREDECESSOR_MANIFEST='8d1e5f09745e764796b60e0a8a0168be7334ed4bf834fad5974a80eba295b4e8';
21
+ export const R37_PREDECESSOR_RELEASE_ID='v0.11.0-08c2a0008b1f84c9';
22
+ export const R37_PREDECESSOR_MANIFEST='08c2a0008b1f84c90f7ce7faa1e3decbd03f33612bc0fdc7d1ba591b548798e8';
23
23
 
24
24
  function assert(condition,message){if(!condition) throw new Error(message);}
25
25
  function parseFrozenManifest(text){
@@ -91,11 +91,11 @@ async function scheduleDeferred(mode,value,{bridgeRoot=null,bridgeScriptSha256=n
91
91
  assert(scheduled.execution_provider==='deadbyte_mcp'&&scheduled.rdc_operation_count===0,'deferred operation provider mismatch');
92
92
  return {scheduled,completed:await waitDeferred(scheduled.state_path)};
93
93
  }
94
- async function publicR36Disarmed(url){
94
+ async function publicR37Disarmed(url){
95
95
  const result=await probeR36CompactDisarmed(url);
96
- assert(result.status==='passed'&&result.tool_count<=42&&result.capability_closure===true,'R36 predecessor public compact catalog mismatch');
97
- assert(result.release_id===R36_PREDECESSOR_RELEASE_ID&&result.release_manifest_sha256===R36_PREDECESSOR_MANIFEST,'R36 predecessor machine binding mismatch');
98
- assert(result.coding_armed===false&&result.autonomous_armed===false,'R36 predecessor authority remained armed');
96
+ assert(result.status==='passed'&&result.tool_count<=42&&result.capability_closure===true,'R37 predecessor public compact catalog mismatch');
97
+ assert(result.release_id===R37_PREDECESSOR_RELEASE_ID&&result.release_manifest_sha256===R37_PREDECESSOR_MANIFEST,'R37 predecessor machine binding mismatch');
98
+ assert(result.coding_armed===false&&result.autonomous_armed===false,'R37 predecessor authority remained armed');
99
99
  return result;
100
100
  }
101
101
  async function mutableCore(pointerValue){
@@ -111,16 +111,16 @@ export function validateParityEvidence(value){
111
111
  assert(value?.schema==='deadbyte.r37-parity.v1','R37 parity schema mismatch');
112
112
  assert(value.status==='passed','R37 parity status is not passed');
113
113
  assert(value.rdc_operation_count===0&&value.execution_provider==='deadbyte_mcp','R37 parity used non-DEADBYTE execution');
114
- assert(value.candidate?.version==='0.11.0'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R37 candidate identity missing');
114
+ assert(value.candidate?.version==='0.11.1'&&/^[0-9a-f]{64}$/.test(value.candidate?.manifest_sha256??''),'R37 candidate identity missing');
115
115
  assert(value.local_full?.status==='passed'&&value.local_full?.tool_count===76&&value.local_full?.strict_output_schemas===true,'R37 local full 76-tool proof missing');
116
116
  assert(value.public_compact?.status==='passed'&&value.public_compact?.tool_count<=42&&value.public_compact?.capability_closure===true&&value.public_compact?.gateway_count===5,'R37 public compact closure missing');
117
117
  assert(value.autonomous?.status==='passed'&&value.autonomous?.signed_release_verified===true,'R37 autonomous live proof missing');
118
118
  assert(value.before_rollback_disarmed?.status==='passed'&&value.before_rollback_disarmed?.capability_closure===true&&value.before_rollback_disarmed?.coding_armed===false&&value.before_rollback_disarmed?.autonomous_armed===false,'R37 pre-rollback disarm proof missing');
119
119
  assert(value.rollback?.state==='completed'&&value.restore?.state==='completed','R37 rollback/restore not completed');
120
120
  assert(value.stage_restore?.status==='restored'&&value.stage_restore?.manifest_sha256===value.candidate.manifest_sha256,'R37 stage restore proof missing');
121
- assert(value.predecessor?.release_id===R36_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R36_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.10.0','R36 exact predecessor identity mismatch');
122
- assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count<=42&&value.predecessor_disarmed?.capability_closure===true,'R36 predecessor public proof missing');
123
- assert(value.successor?.version==='0.11.0'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R37 exact successor restore identity mismatch');
121
+ assert(value.predecessor?.release_id===R37_PREDECESSOR_RELEASE_ID&&value.predecessor?.manifest_sha256===R37_PREDECESSOR_MANIFEST&&value.predecessor?.version==='0.11.0','R37 exact predecessor identity mismatch');
122
+ assert(value.predecessor_disarmed?.status==='passed'&&value.predecessor_disarmed?.tool_count<=42&&value.predecessor_disarmed?.capability_closure===true,'R37 predecessor public proof missing');
123
+ assert(value.successor?.version==='0.11.1'&&value.successor?.manifest_sha256===value.candidate.manifest_sha256,'R37 exact successor restore identity mismatch');
124
124
  assert(value.successor_disarmed?.status==='passed'&&value.successor_disarmed?.capability_closure===true&&value.successor_disarmed?.coding_armed===false&&value.successor_disarmed?.autonomous_armed===false,'R37 successor disarmed proof missing');
125
125
  assert(value.immutable_slot?.protected===true&&value.immutable_slot?.development_root!==value.immutable_slot?.release_root,'R37 immutable-slot separation missing');
126
126
  for(const key of ['tree_read','precondition_mutation','search','owned_process','observation','coding_loop','autonomy','interrupted_recovery','evidence_verification','compact_closure','full_surface']) assert(value.requirements?.[key]===true,`R37 parity requirement not proven: ${key}`);
@@ -129,7 +129,7 @@ export function validateParityEvidence(value){
129
129
 
130
130
  export async function runReleaseParity(activationReceiptPath){
131
131
  const active=await pointer();const candidateManifest=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
132
- assert(active.version==='0.11.0','R37 parity requires active 0.11.0 candidate');
132
+ assert(active.version==='0.11.1','R37 parity requires active 0.11.1 candidate');
133
133
  assert(active.manifest_sha256===candidateManifest,'active release is not canonical R37 candidate');
134
134
  const activeConfig=await loadPowerShellDataFile(active.config_path);
135
135
  const successorBridgeRootRaw=activeConfig?.Bridge?.WorkingDirectory;
@@ -154,12 +154,12 @@ export async function runReleaseParity(activationReceiptPath){
154
154
  const beforeRollback=await probeR36CompactDisarmed(url);
155
155
  const rollbackPair=await scheduleDeferred('rollback',path.resolve(activationReceiptPath));
156
156
  const predecessor=await pointer();
157
- assert(predecessor.release_id===R36_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R36_PREDECESSOR_MANIFEST&&predecessor.version==='0.10.0','rollback did not reach exact sealed R36 predecessor');
158
- const predecessorDisarmed=await publicR36Disarmed(url);
157
+ assert(predecessor.release_id===R37_PREDECESSOR_RELEASE_ID&&predecessor.manifest_sha256===R37_PREDECESSOR_MANIFEST&&predecessor.version==='0.11.0','rollback did not reach exact sealed R37 predecessor');
158
+ const predecessorDisarmed=await publicR37Disarmed(url);
159
159
  const stageRestore=await restoreFrozenStage({developmentRoot,releaseRoot:active.release_root,expectedManifestSha256:candidateManifest});
160
160
  const restorePair=await scheduleDeferred('activate',candidateManifest,{bridgeRoot:successorBridge.root,bridgeScriptSha256:successorBridge.sha256});
161
161
  const successor=await pointer();
162
- assert(successor.version==='0.11.0'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R37 candidate');
162
+ assert(successor.version==='0.11.1'&&successor.manifest_sha256===candidateManifest,'restore did not return exact R37 candidate');
163
163
  const successorDisarmed=await probeR36CompactDisarmed(url);
164
164
  await disarmAll();
165
165
 
@@ -0,0 +1,52 @@
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
+
7
+ const here=path.dirname(fileURLToPath(import.meta.url));
8
+ const root=path.resolve(here,'..');
9
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
10
+ const marker='DEADBYTE V0.11.0 / R37 WINDOWS BATCH GATE: PASS';
11
+ function insist(ok,message){if(!ok) throw new Error(message);}
12
+
13
+ export async function writeWindowsGateEvidence({
14
+ candidateRoot=root,
15
+ stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp')),
16
+ clock=()=>new Date()
17
+ }={}){
18
+ const candidate=path.resolve(candidateRoot);
19
+ const manifestBytes=await readFile(path.join(candidate,'MANIFEST.SHA256'));
20
+ const manifestSha256=sha256(manifestBytes);
21
+ const pkg=JSON.parse(await readFile(path.join(candidate,'package.json'),'utf8'));
22
+ insist(pkg.version==='0.11.0',`Windows gate evidence requires V0.11.0, found ${pkg.version}`);
23
+ const completed=clock();
24
+ insist(completed instanceof Date&&!Number.isNaN(completed.getTime()),'Windows gate evidence clock invalid');
25
+ const evidence={
26
+ schema:'deadbyte.r37-windows-gate.v1',status:'passed',exit_code:0,version:'0.11.0',
27
+ marker,completed_at_utc:completed.toISOString(),manifest_sha256:manifestSha256
28
+ };
29
+ const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');
30
+ const dir=path.join(path.resolve(stateRoot),'evidence','release');
31
+ await mkdir(dir,{recursive:true});
32
+ const file=path.join(dir,`r37-windows-gate-${manifestSha256.slice(0,16)}.json`);
33
+ try{
34
+ const handle=await open(file,'wx',0o600);
35
+ try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}
36
+ return {status:'written',path:file,sha256:sha256(bytes),manifest_sha256:manifestSha256};
37
+ }catch(error){
38
+ if(error?.code!=='EEXIST') throw error;
39
+ const existingBytes=await readFile(file);
40
+ const existing=JSON.parse(existingBytes.toString('utf8'));
41
+ insist(existing.schema===evidence.schema&&existing.status==='passed'&&existing.exit_code===0,'existing Windows gate evidence invalid');
42
+ insist(existing.version==='0.11.0'&&existing.marker===marker&&existing.manifest_sha256===manifestSha256,'existing Windows gate evidence binding mismatch');
43
+ return {status:'existing',path:file,sha256:sha256(existingBytes),manifest_sha256:manifestSha256};
44
+ }
45
+ }
46
+
47
+ const invoked=process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url);
48
+ if(invoked){
49
+ writeWindowsGateEvidence()
50
+ .then(result=>console.log(JSON.stringify(result)))
51
+ .catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
52
+ }