deadbyte-mcp 0.15.42 → 0.15.44

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 (132) hide show
  1. package/MANIFEST.SHA256 +131 -68
  2. package/PROVENANCE.json +37 -13
  3. package/README.txt +18 -18
  4. package/RELEASE.json +40 -14
  5. package/SBOM.cdx.json +14 -2
  6. package/TEST-MATRIX.json +52 -10
  7. package/bin/appcontainer-stage.obj +0 -0
  8. package/bin/bootstrap-advapi32.obj +0 -0
  9. package/bin/bootstrap-exitcode.obj +0 -0
  10. package/bin/bootstrap-kernel32.obj +0 -0
  11. package/bin/child-control-probe.obj +0 -0
  12. package/bin/child-control-stage.obj +0 -0
  13. package/bin/contained-reverse-worker.obj +0 -0
  14. package/bin/contained-transform-worker.obj +0 -0
  15. package/bin/containment-probe.obj +0 -0
  16. package/bin/deadbyte-contain.obj +0 -0
  17. package/bin/deadbyte-desktop-input-r40.obj +0 -0
  18. package/bin/deadbyte-desktop-observer-r40.obj +0 -0
  19. package/bin/deadbyte-desktop-uia-r40.obj +0 -0
  20. package/bin/deadbyte-exec.obj +0 -0
  21. package/bin/deadbyte-hardware-observer-r45.obj +0 -0
  22. package/bin/deadbyte-native-inspect-r67.exe +0 -0
  23. package/bin/deadbyte-native-inspect-r67.obj +0 -0
  24. package/bin/deadbyte-process-host.obj +0 -0
  25. package/bin/deadbyte-tunnel-host.obj +0 -0
  26. package/bridge/package.json +1 -1
  27. package/controller/deadbyte-desktop-policy.json +5 -5
  28. package/controller/deadbyte-process-policy.json +4 -4
  29. package/docs/R67-ALPHA-REFERENCE-DIFFERENTIAL.md +42 -0
  30. package/docs/R67-ALPHA-STATIC-COMPARISON.json +205 -0
  31. package/docs/R67-CANDIDATE-PARENT.json +10 -0
  32. package/docs/R67-EVIDENCE-RECONCILE-CLOSEOUT-20261011.md +64 -0
  33. package/docs/R67-FULL-REGRESSION-UNKNOWN.json +27 -0
  34. package/docs/R67-NATIVE-INSPECT-BINARY.json +11 -0
  35. package/docs/R67-NPM-EXDEV-PRESERVATION-20261011.md +39 -0
  36. package/docs/R67-OBSERVATION-TRUTH.md +82 -0
  37. package/docs/R67-REFERENCE-GAP-MATRIX.json +57 -0
  38. package/docs/R67-REGRESSION-CLOSURE-20261011.md +24 -0
  39. package/native/deadbyte-native-inspect-r67.cpp +252 -0
  40. package/package.json +7 -3
  41. package/proof/CONTAINMENT-BUILD.txt +6 -6
  42. package/scripts/build-native-inspector-r67.ps1 +28 -0
  43. package/scripts/gate-windows-r66-prepublish.ps1 +65 -0
  44. package/scripts/gate-windows-r67.ps1 +56 -0
  45. package/scripts/npm-preserve-artifact-r67.mjs +99 -0
  46. package/scripts/npm-release-r48.mjs +10 -2
  47. package/scripts/npm-release-readiness-r67.mjs +26 -0
  48. package/scripts/r67-acquire-alpha-reference.mjs +95 -0
  49. package/scripts/r67-audit-nonpass-source.mjs +39 -0
  50. package/scripts/r67-compare-desktop-alpha.mjs +48 -0
  51. package/scripts/r67-diagnose-failed-shard.mjs +23 -0
  52. package/scripts/r67-durable-batch.mjs +42 -0
  53. package/scripts/r67-focused-gate.mjs +58 -0
  54. package/scripts/r67-full-regression.mjs +28 -0
  55. package/scripts/r67-independent-observation-verify.mjs +36 -0
  56. package/scripts/r67-independent-runtime-observation-verify.mjs +63 -0
  57. package/scripts/r67-nonpass-adjudicate.mjs +20 -0
  58. package/scripts/r67-publish-boundary-audit.mjs +32 -0
  59. package/scripts/r67-regression-reconcile.mjs +10 -0
  60. package/scripts/r67-regression-shard-run.mjs +70 -0
  61. package/scripts/r67-run-shard-batch.mjs +18 -0
  62. package/scripts/r67-stage-candidate.mjs +30 -0
  63. package/scripts/r67-verify-parent-ping.mjs +22 -0
  64. package/scripts/release-manifest.mjs +1 -0
  65. package/src/activation-continuity-engine-r65.mjs +2 -1
  66. package/src/autonomous-runtime.mjs +1 -1
  67. package/src/deadbyte-cli.mjs +33 -1
  68. package/src/doctor-runtime-r58.mjs +3 -1
  69. package/src/machine-fs-smoke-client.mjs +13 -5
  70. package/src/machine-identity.mjs +59 -2
  71. package/src/machine-mcp-tools.mjs +8 -0
  72. package/src/mcp-server.mjs +11 -2
  73. package/src/native-inspector-r67.mjs +66 -0
  74. package/src/r67-diagnostic-export.mjs +118 -0
  75. package/src/r67-diagnostics-verify.mjs +82 -0
  76. package/src/r67-evidence-reconcile.mjs +128 -0
  77. package/src/r67-native-observation-authority.mjs +45 -0
  78. package/src/r67-observation-receipt.mjs +43 -0
  79. package/src/r67-regression-shards.mjs +176 -0
  80. package/src/remote-live-log.mjs +14 -10
  81. package/src/tool-audit.mjs +1 -1
  82. package/src/version.mjs +1 -1
  83. package/test/agent-runtime.test.mjs +1 -1
  84. package/test/autonomous-loop.test.mjs +11 -6
  85. package/test/autonomous-runtime.test.mjs +1 -1
  86. package/test/coding-plane.test.mjs +1 -1
  87. package/test/full-max-catalog-r46.test.mjs +1 -1
  88. package/test/output-schema.test.mjs +1 -1
  89. package/test/r51-live-log-polling.test.mjs +12 -0
  90. package/test/r53-release-contract.test.mjs +1 -1
  91. package/test/r54-release-contract.test.mjs +1 -1
  92. package/test/r55-release-contract.test.mjs +1 -1
  93. package/test/r56-release-contract.test.mjs +1 -1
  94. package/test/r57-release-contract.test.mjs +1 -1
  95. package/test/r58-bundled-bridge.test.mjs +1 -1
  96. package/test/r58-doctor-runtime.test.mjs +18 -0
  97. package/test/r58-release-contract.test.mjs +2 -2
  98. package/test/r58-windows-gate.test.mjs +1 -1
  99. package/test/r59-tool-surface-compat.test.mjs +1 -1
  100. package/test/r60-release-contract.test.mjs +3 -3
  101. package/test/r61-release-contract.test.mjs +1 -1
  102. package/test/r62-release-contract.test.mjs +1 -1
  103. package/test/r63-release-contract.test.mjs +1 -1
  104. package/test/r64-release-contract.test.mjs +1 -1
  105. package/test/r65-epoch-native-activation-integration.test.mjs +4 -4
  106. package/test/r65-release-contract.test.mjs +2 -1
  107. package/test/r66-release-contract.test.mjs +57 -0
  108. package/test/r67-cli-integration.test.mjs +41 -0
  109. package/test/r67-diagnostics-cli.test.mjs +60 -0
  110. package/test/r67-diagnostics-verify.test.mjs +49 -0
  111. package/test/r67-diagnostics-zip-oracle.test.mjs +38 -0
  112. package/test/r67-diagnostics.test.mjs +60 -0
  113. package/test/r67-evidence-reconcile.test.mjs +186 -0
  114. package/test/r67-isolated-slot-rollback-restore.test.mjs +62 -0
  115. package/test/r67-live-log-secret-canary.test.mjs +44 -0
  116. package/test/r67-machine-fs-smoke-epoch.test.mjs +22 -0
  117. package/test/r67-native-inspector.test.mjs +131 -0
  118. package/test/r67-native-observation-authority.test.mjs +49 -0
  119. package/test/r67-npm-cross-volume.test.mjs +74 -0
  120. package/test/r67-npm-publish-gate.test.mjs +38 -0
  121. package/test/r67-regression-shards.test.mjs +184 -0
  122. package/test/r67-release-contract.test.mjs +44 -0
  123. package/test/r67-runtime-observation-binding.test.mjs +86 -0
  124. package/test/r67-server-observation-wiring.test.mjs +12 -0
  125. package/test/r67-signed-receipt.test.mjs +66 -0
  126. package/test/r67-skip-rationale.test.mjs +31 -0
  127. package/test/r67-tool-annotations.test.mjs +21 -0
  128. package/test/r67-windows-gate-argv.test.mjs +13 -0
  129. package/test/release-version.test.mjs +1 -1
  130. package/test/remote-live-log-r36.test.mjs +10 -0
  131. package/test/remote-live-log-r37.test.mjs +29 -0
  132. package/test/semantic-multilang.test.mjs +1 -1
@@ -123,7 +123,7 @@ test('R24 autonomous goal diagnoses a failing test, replans with native diff, be
123
123
  maxIterations:10 });
124
124
  assert.equal(submitted.status,'accepted');
125
125
  const result = await f.runtime.run({ goalId:submitted.goal_id, maxCycles:16 });
126
- assert.equal(result.status,'completed');
126
+ assert.equal(result.status,'completed',JSON.stringify({status:result.status,reason:result.reason??null,loop_phase:result.loop?.phase??null}));
127
127
  assert.equal(await readFile(f.program,'utf8'),"export const value = 'fixed';\n");
128
128
  const status = await f.runtime.status({ goalId:submitted.goal_id });
129
129
  assert.equal(status.state,'succeeded');
@@ -154,7 +154,7 @@ test('historical autonomous release verification survives source drift and disar
154
154
  title:'repair program', goal:'make exported value equal fixed', acceptance:'release evidence must remain verifiable',
155
155
  maxIterations:10 });
156
156
  const result = await f.runtime.run({ goalId:submitted.goal_id, maxCycles:16 });
157
- assert.equal(result.status,'completed');
157
+ assert.equal(result.status,'completed',JSON.stringify({status:result.status,reason:result.reason??null,loop_phase:result.loop?.phase??null}));
158
158
  assert.equal((await f.runtime.verify({ goalId:submitted.goal_id })).ok,true);
159
159
 
160
160
  await writeFile(f.program,"export const value = 'rolled-back';\n");
@@ -196,7 +196,7 @@ test('autonomous profile execution is capped by the absolute autonomous lease wi
196
196
  title:'deadline-bound profiles',goal:'make exported value equal fixed',
197
197
  acceptance:'build, test, and benchmark must pass',maxIterations:10});
198
198
  const result=await f.runtime.run({goalId:submitted.goal_id,maxCycles:16});
199
- assert.equal(result.status,'completed');
199
+ assert.equal(result.status,'completed',JSON.stringify({status:result.status,reason:result.reason??null,loop_phase:result.loop?.phase??null}));
200
200
  assert.ok(calls.length>=3);
201
201
  assert.ok(calls.every(call=>typeof call.deadline==='string'&&Number.isFinite(Date.parse(call.deadline))));
202
202
  assert.ok(calls.every(call=>call.has_precheck===true));
@@ -239,7 +239,12 @@ test('autonomous profile nonce rotation immediately before spawn fails closed wi
239
239
  const started=journal.events.find(event=>event.type==='profile_started'&&event.payload?.profile_id==='build');
240
240
  assert.ok(started);
241
241
  assert.match(started.payload.authority_instance_nonce,/^[0-9a-f]{64}$/);
242
- assert.ok(journal.events.some(event=>event.type==='goal_paused'&&event.payload?.reason==='profile_execution_without_receipt'));
242
+ const pause=journal.events.find(event=>event.type==='goal_paused'&&event.payload?.reason==='profile_execution_without_receipt');
243
+ assert.ok(pause);
244
+ assert.equal(pause.payload.receipt_id,started.payload.receipt_id);
245
+ assert.equal(pause.payload.request_sha256,started.payload.request_sha256);
246
+ assert.equal(typeof pause.payload.detail,'string');
247
+ assert.ok(pause.payload.detail.length>0&&pause.payload.detail.length<=512);
243
248
  assert.equal(journal.events.some(event=>event.type==='profile_completed'&&event.payload?.profile_id==='build'),false);
244
249
  assert.equal((await f.codingRuntime.verifyReceiptDetailed(started.payload.receipt_id)).ok,false);
245
250
  } finally {
@@ -255,7 +260,7 @@ test('provider planner repairs an invalid structured decision inside the same ru
255
260
  title:'repair after planner contract error', goal:'make exported value equal fixed',
256
261
  acceptance:'build, test, and benchmark must pass', maxIterations:10 });
257
262
  const result = await f.runtime.run({ goalId:submitted.goal_id, maxCycles:16 });
258
- assert.equal(result.status,'completed');
263
+ assert.equal(result.status,'completed',JSON.stringify({status:result.status,reason:result.reason??null,loop_phase:result.loop?.phase??null}));
259
264
  assert.equal(await readFile(f.program,'utf8'),"export const value = 'fixed';\n");
260
265
  assert.equal(f.planner.prompts.length,6);
261
266
  assert.match(f.planner.prompts[1],/PREVIOUS_RESPONSE_REJECTED/);
@@ -337,7 +342,7 @@ test('provider supervisor adopts an OPEN circuit after restart and resumes only
337
342
  if(status.state==='cancelled') throw new Error('provider circuit supervisor cancelled goal');
338
343
  await new Promise(resolve=>setTimeout(resolve,25));
339
344
  } while(Date.now()<deadline);
340
- assert.equal(status.state,'succeeded');
345
+ assert.equal(status.state,'succeeded',JSON.stringify({state:status.state,reason:status.reason??null,loop_phase:status.loop?.phase??null}));
341
346
  assert.ok(f.planner.prompts.length>3);
342
347
  const journal=await f.runtime.events({goalId:submitted.goal_id,fromSeq:1,limit:200});
343
348
  assert.equal(journal.events.filter(event=>event.type==='provider_probe_started').length,1);
@@ -76,7 +76,7 @@ async function fixture() {
76
76
  return { root, client, transport };
77
77
  }
78
78
 
79
- test.skip('R44 historical hermetic autonomous catalog is frozen at 50; current R47 runtime supersedes it', async () => {
79
+ test('R44 historical hermetic autonomous catalog is frozen at 50; current R47 runtime supersedes it',{skip:'Historical R44 autonomous catalog frozen at 50; current R47+ has a different catalog'}, async () => {
80
80
  const f = await fixture();
81
81
  try {
82
82
  await f.client.connect(f.transport);
@@ -70,7 +70,7 @@ async function fixture() {
70
70
  return { root, client, transport };
71
71
  }
72
72
 
73
- test.skip('R44 historical hermetic coding catalog is frozen at 38; current R47 runtime supersedes it', async () => {
73
+ test('R44 historical hermetic coding catalog is frozen at 38; current R47 runtime supersedes it',{skip:'Historical R44 coding catalog frozen at 38; current R47+ supersedes it'}, async () => {
74
74
  const f = await fixture();
75
75
  try {
76
76
  await f.client.connect(f.transport);
@@ -15,7 +15,7 @@ const desktopPolicyPath=path.join(repoRoot,'controller','deadbyte-desktop-policy
15
15
  const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
16
16
  const absent=async p=>{try{await access(p);return false;}catch(e){if(e?.code==='ENOENT')return true;throw e;}};
17
17
 
18
- test.skip('R46 historical max-runtime full stdio catalog contract is frozen at 84; current R47 runtime intentionally supersedes it',async()=>{
18
+ test('R46 historical max-runtime full stdio catalog contract is frozen at 84; current R47 runtime intentionally supersedes it',{skip:'Historical R46 max-runtime catalog frozen at 84; current R47+ intentionally supersedes it'},async()=>{
19
19
  const f=await createR34Fixture({authority:'disarmed'});
20
20
  const processPolicyPath=path.join(f.root,'process-policy.json');
21
21
  const processGrant=path.join(f.root,'process-grant.json');
@@ -48,7 +48,7 @@ async function fixture() {
48
48
  return { trust, client, transport };
49
49
  }
50
50
 
51
- test.skip('R44 historical base-plus-agent catalog is frozen at 13; current R47 runtime supersedes it', async () => {
51
+ test('R44 historical base-plus-agent catalog is frozen at 13; current R47 runtime supersedes it',{skip:'Historical R44 base-plus-agent catalog frozen at 13; current R47+ supersedes it'}, async () => {
52
52
  const f = await fixture();
53
53
  try {
54
54
  await f.client.connect(f.transport);
@@ -26,3 +26,15 @@ test('R51 live tail parses each audit line once and reuses the decoded event',as
26
26
  assert.match(cli,/auditTimelineRecord\(file,line,auditEvent\)/);
27
27
  assert.match(cli,/formatLogLine\(file,line,\{auditEvent,/);
28
28
  });
29
+
30
+ test('R67 live log selection is bounded, deduplicated and rejects path traversal/drive prefixes',()=>{
31
+ const runtimeNames=['bridge.stdout.log','bridge.stdout.log','../private.log','..\\private.log','C:\\token.log','.hidden.log',
32
+ ...Array.from({length:180},(_,i)=>'remote-'+String(i).padStart(3,'0')+'.log')];
33
+ const auditNames=['segment-00000001.jsonl','segment-00000002.jsonl','segment-00000002.jsonl','segment-00000003.jsonl'];
34
+ const selected=selectLiveLogNames({auditNames,runtimeNames});
35
+ assert.deepEqual(selected.audit,['segment-00000002.jsonl','segment-00000003.jsonl']);
36
+ assert.ok(selected.runtime.length<=64,'cap runtime readers to a finite budget');
37
+ assert.equal(new Set(selected.runtime).size,selected.runtime.length);
38
+ assert.ok(selected.runtime.every(name=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.log$/.test(name)));
39
+ assert.ok(selected.runtime.includes('remote-179.log'));
40
+ });
@@ -6,7 +6,7 @@ const root=new URL('../',import.meta.url);
6
6
  const read=rel=>readFile(new URL(rel,root),'utf8');
7
7
  const json=rel=>read(rel).then(JSON.parse);
8
8
  const currentPackage=await json('package.json');
9
- const r53test=currentPackage.version==='0.15.30'?test:test.skip;
9
+ const r53test=currentPackage.version==='0.15.30'?test:(name,fn)=>test(name,{skip:'Historical R53 release contract requires 0.15.30; current '+currentPackage.version},fn);
10
10
 
11
11
  r53test('R53 current release identity is coherent across package lock source metadata SBOM and gate',async()=>{
12
12
  const [pkg,lock,release,provenance,matrix,sbom,versionSource]=await Promise.all([
@@ -6,7 +6,7 @@ const root=new URL('../',import.meta.url);
6
6
  const read=rel=>readFile(new URL(rel,root),'utf8');
7
7
  const json=rel=>read(rel).then(JSON.parse);
8
8
  const currentPackage=await json('package.json');
9
- const r54test=currentPackage.version==='0.15.31'?test:test.skip;
9
+ const r54test=currentPackage.version==='0.15.31'?test:(name,fn)=>test(name,{skip:'Historical R54 release contract requires 0.15.31; current '+currentPackage.version},fn);
10
10
 
11
11
  r54test('R54 release identity is coherent across package lock source metadata SBOM and gate',async()=>{
12
12
  const [pkg,lock,release,provenance,matrix,sbom,versionSource]=await Promise.all([
@@ -6,7 +6,7 @@ const root=new URL('../',import.meta.url);
6
6
  const read=rel=>readFile(new URL(rel,root),'utf8');
7
7
  const json=rel=>read(rel).then(JSON.parse);
8
8
  const currentPackage=await json('package.json');
9
- const r55test=currentPackage.version==='0.15.32'?test:test.skip;
9
+ const r55test=currentPackage.version==='0.15.32'?test:(name,fn)=>test(name,{skip:'Historical R55 release contract requires 0.15.32; current '+currentPackage.version},fn);
10
10
 
11
11
  r55test('R55 release identity is coherent across package lock source metadata SBOM and gate',async()=>{
12
12
  const [pkg,lock,release,provenance,matrix,sbom,versionSource]=await Promise.all([
@@ -6,7 +6,7 @@ const root=new URL('../',import.meta.url);
6
6
  const read=rel=>readFile(new URL(rel,root),'utf8');
7
7
  const json=rel=>read(rel).then(JSON.parse);
8
8
  const currentPackage=await json('package.json');
9
- const r56test=currentPackage.version==='0.15.33'?test:test.skip;
9
+ const r56test=currentPackage.version==='0.15.33'?test:(name,fn)=>test(name,{skip:'Historical R56 release contract requires 0.15.33; current '+currentPackage.version},fn);
10
10
 
11
11
  r56test('R56 release identity is coherent across package lock source metadata SBOM and gate',async()=>{
12
12
  const [pkg,lock,release,provenance,matrix,sbom,versionSource]=await Promise.all([
@@ -6,7 +6,7 @@ const root=new URL('../',import.meta.url);
6
6
  const read=rel=>readFile(new URL(rel,root),'utf8');
7
7
  const json=rel=>read(rel).then(JSON.parse);
8
8
  const currentPackage=await json('package.json');
9
- const r57test=currentPackage.version==='0.15.34'?test:test.skip;
9
+ const r57test=currentPackage.version==='0.15.34'?test:(name,fn)=>test(name,{skip:'Historical R57 release contract requires 0.15.34; current '+currentPackage.version},fn);
10
10
 
11
11
  r57test('R57 release identity is coherent across package lock source metadata SBOM and gate',async()=>{
12
12
  const [pkg,lock,release,provenance,matrix,sbom,versionSource]=await Promise.all([
@@ -11,7 +11,7 @@ test('R58 deployment activates the bridge bundled inside the candidate release,
11
11
  assert.match(deploy,/const bridgeScript=path\.join\(bridgeRoot,'src','bridge\.mjs'\)/);
12
12
  });
13
13
 
14
- test('R58 bundled bridge package is present and version-bound to 0.15.35',{skip:currentPackage.version!=='0.15.35'},async()=>{
14
+ test('R58 bundled bridge package is present and version-bound to 0.15.35',{skip:currentPackage.version!=='0.15.35' ? 'Historical R58 bridge artifact requires 0.15.35; current '+currentPackage.version : false},async()=>{
15
15
  const [pkg,bridgePkg,bridge]=await Promise.all([
16
16
  readFile(new URL('../package.json',import.meta.url),'utf8').then(JSON.parse),
17
17
  readFile(new URL('../bridge/package.json',import.meta.url),'utf8').then(JSON.parse),
@@ -43,3 +43,21 @@ test('R58 doctor surfaces corrupt grants and authority dependency loss without s
43
43
  const report=classifyDoctorControllerObservation(host,coreRoot);assert.equal(report.status,'WARN');assert.equal(host.authority.host.armed,true);
44
44
  for(const finding of report.findings.filter(f=>f.level!=='PASS'))assert.ok(finding.what&&finding.evidence&&finding.next_action);
45
45
  });
46
+
47
+ test('R66 doctor accepts strict epoch metadata on armed authority observations',()=>{
48
+ const snapshot=online();
49
+ snapshot.authority.process={configured:true,armed:true,reason:'standing-grant',epoch_seq:1,epoch_sha256:'a'.repeat(64)};
50
+ const validated=validateDoctorControllerObservation(snapshot,coreRoot);
51
+ assert.equal(validated.authority.process.epoch_seq,1);
52
+ assert.equal(validated.authority.process.epoch_sha256,'a'.repeat(64));
53
+ for(const process of [
54
+ {configured:true,armed:true,reason:'standing-grant',epoch_seq:1},
55
+ {configured:true,armed:true,reason:'standing-grant',epoch_sha256:'a'.repeat(64)},
56
+ {configured:true,armed:true,reason:'standing-grant',epoch_seq:0,epoch_sha256:'a'.repeat(64)},
57
+ {configured:true,armed:true,reason:'standing-grant',epoch_seq:1,epoch_sha256:'not-a-sha'},
58
+ {configured:true,armed:false,reason:'disarmed',epoch_seq:1,epoch_sha256:'a'.repeat(64)},
59
+ {configured:true,armed:true,reason:'standing-grant',epoch_seq:1,epoch_sha256:'a'.repeat(64),injected:true}
60
+ ]){
61
+ assert.throws(()=>validateDoctorControllerObservation({...online(),authority:{...authority(),process}},coreRoot));
62
+ }
63
+ });
@@ -6,7 +6,7 @@ const read=rel=>readFile(new URL('../'+rel,import.meta.url),'utf8');
6
6
  const json=rel=>read(rel).then(JSON.parse);
7
7
  const currentPackage=await json('package.json');
8
8
 
9
- test('R58 identity is coherent and parent is exact production-accepted 0.15.34',{skip:currentPackage.version!=='0.15.35'},async()=>{
9
+ test('R58 identity is coherent and parent is exact production-accepted 0.15.34',{skip:currentPackage.version!=='0.15.35' ? 'Historical R58 release contract requires 0.15.35; current '+currentPackage.version : false},async()=>{
10
10
  const [pkg,lock,release,prov,matrix,sbom,version,bridgePkg]=await Promise.all([
11
11
  json('package.json'),json('package-lock.json'),json('RELEASE.json'),json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),json('bridge/package.json')
12
12
  ]);
@@ -29,7 +29,7 @@ test('R58 identity is coherent and parent is exact production-accepted 0.15.34',
29
29
  assert.equal(release.parent.tarball_sha256,'a6f7b21faf34793ca17dfb6d0e9ec03320f1468d011e75d8349098df82fc2639');
30
30
  });
31
31
 
32
- test('R58 consolidation evidence preserves fail-closed and non-final claims',{skip:currentPackage.version!=='0.15.35'},async()=>{
32
+ test('R58 consolidation evidence preserves fail-closed and non-final claims',{skip:currentPackage.version!=='0.15.35' ? 'Historical R58 release contract requires 0.15.35; current '+currentPackage.version : false},async()=>{
33
33
  const [release,prov,matrix]=await Promise.all([json('RELEASE.json'),json('PROVENANCE.json'),json('TEST-MATRIX.json')]);
34
34
  assert.equal(release.consolidation.bridge_bundled_inside_release,true);
35
35
  assert.equal(release.consolidation.bridge_recursive_local_dependency_binding,true);
@@ -5,7 +5,7 @@ import {readFile} from 'node:fs/promises';
5
5
  const read=rel=>readFile(new URL('../'+rel,import.meta.url),'utf8');
6
6
  const currentPackage=JSON.parse(await read('package.json'));
7
7
 
8
- test('R58 canonical Windows gate is final-candidate bound and leaves historical gates immutable',{skip:currentPackage.version!=='0.15.35'},async()=>{
8
+ test('R58 canonical Windows gate is final-candidate bound and leaves historical gates immutable',{skip:currentPackage.version!=='0.15.35' ? 'Historical R58 Windows gate requires 0.15.35; current '+currentPackage.version : false},async()=>{
9
9
  const [pkgText,gate,evidence,r57Gate,r57Evidence]=await Promise.all([
10
10
  read('package.json'),read('scripts/gate-windows-r58.ps1'),read('scripts/windows-gate-evidence-r58.mjs'),
11
11
  read('scripts/gate-windows-r57.ps1'),read('scripts/windows-gate-evidence-r57.mjs')
@@ -83,7 +83,7 @@ test('R59 compact baseline changes only at the explicitly authorized R64 read-of
83
83
  assert.deepEqual(diff.added,[]);
84
84
  assert.deepEqual(diff.removed,[]);
85
85
  const packageVersion=JSON.parse(await readFile(path.join(repoRoot,'package.json'),'utf8')).version;
86
- if(packageVersion==='0.15.41'||packageVersion==='0.15.42'){
86
+ if(['0.15.41','0.15.42','0.15.43','0.15.44'].includes(packageVersion)){
87
87
  assert.deepEqual(diff.schema_changed,['machine_fs']);
88
88
  assert.equal(diff.unchanged.length,42);
89
89
  const prior=baseline.tools.find(tool=>tool.name==='machine_fs');
@@ -13,7 +13,7 @@ const PARENT=Object.freeze({
13
13
  generation_manifest_sha256:'6134f9f26b680e13ed545da4ab5f3020f411ea2569062fb9c154c8a7e036c9dc'
14
14
  });
15
15
 
16
- test('R60 identity is coherent and binds the exact production-accepted 0.15.36 predecessor',{skip:currentPackage.version!=='0.15.37'},async()=>{
16
+ test('R60 identity is coherent and binds the exact production-accepted 0.15.36 predecessor',{skip:currentPackage.version!=='0.15.37' ? 'Historical R60 release contract requires 0.15.37; current '+currentPackage.version : false},async()=>{
17
17
  const [pkg,lock,release,prov,matrix,sbom,version,bridgePkg,contract]=await Promise.all([
18
18
  json('package.json'),json('package-lock.json'),json('RELEASE.json'),json('PROVENANCE.json'),
19
19
  json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),json('bridge/package.json'),
@@ -47,7 +47,7 @@ test('R60 identity is coherent and binds the exact production-accepted 0.15.36 p
47
47
  assert.match(contract,/0\.15\.37/);
48
48
  });
49
49
 
50
- test('R60 release contract exposes the proven remote truth semantics without widening dependencies',{skip:currentPackage.version!=='0.15.37'},async()=>{
50
+ test('R60 release contract exposes the proven remote truth semantics without widening dependencies',{skip:currentPackage.version!=='0.15.37' ? 'Historical R60 release contract requires 0.15.37; current '+currentPackage.version : false},async()=>{
51
51
  const [pkg,release,matrix]=await Promise.all([json('package.json'),json('RELEASE.json'),json('TEST-MATRIX.json')]);
52
52
  assert.equal(Object.keys(pkg.dependencies??{}).length,4);
53
53
  assert.equal(release.r60_remote_hardening.authority_truth_coherence,true);
@@ -70,7 +70,7 @@ test('R60 release contract exposes the proven remote truth semantics without wid
70
70
  assert.equal(matrix.observed_pre_release_evidence.r60_package.status,'PASS_VERIFY_ONLY_PRE_FINAL_SEAL');
71
71
  });
72
72
 
73
- test('R60 package scripts bind the new focused, full-regression and Windows-gate entrypoints',{skip:currentPackage.version!=='0.15.37'},async()=>{
73
+ test('R60 package scripts bind the new focused, full-regression and Windows-gate entrypoints',{skip:currentPackage.version!=='0.15.37' ? 'Historical R60 release contract requires 0.15.37; current '+currentPackage.version : false},async()=>{
74
74
  const [pkg,gate]=await Promise.all([json('package.json'),read('scripts/gate-windows-r60-prepublish.ps1')]);
75
75
  assert.match(pkg.scripts['r60:focused:test'],/r60-authority-coherence\.test\.mjs/);
76
76
  assert.match(pkg.scripts['r60:focused:test'],/r60-remote-call-recovery\.test\.mjs/);
@@ -11,7 +11,7 @@ const PARENT={
11
11
  generation_manifest_sha256:'54842021c75f01bf7ecbd5b10ab8a482ecf107765b45c46f9d39b12bab65eac4'
12
12
  };
13
13
 
14
- test('R61 identity binds exact sealed 0.15.37 predecessor without a public surface expansion',{skip:currentPackage.version!=='0.15.38'},async()=>{
14
+ test('R61 identity binds exact sealed 0.15.37 predecessor without a public surface expansion',{skip:currentPackage.version!=='0.15.38' ? 'Historical R61 release contract requires 0.15.38; current '+currentPackage.version : false},async()=>{
15
15
  const [pkg,lock,bridge,release,provenance,matrix,sbom,version,gate]=await Promise.all([
16
16
  json('package.json'),json('package-lock.json'),json('bridge/package.json'),json('RELEASE.json'),
17
17
  json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),
@@ -12,7 +12,7 @@ const PARENT={
12
12
  generation_manifest_sha256:'9d320a8af1ba8e9e6a23552f35263da2670c00af1355464820552d849d9033c6'
13
13
  };
14
14
 
15
- test('R62 identity binds exact sealed 0.15.38 parent and transaction reconciliation scope',{skip:currentPackage.version!=='0.15.39'},async()=>{
15
+ test('R62 identity binds exact sealed 0.15.38 parent and transaction reconciliation scope',{skip:currentPackage.version!=='0.15.39' ? 'Historical R62 release contract requires 0.15.39; current '+currentPackage.version : false},async()=>{
16
16
  const [pkg,lock,bridge,release,provenance,matrix,sbom,version,gate]=await Promise.all([
17
17
  json('package.json'),json('package-lock.json'),json('bridge/package.json'),json('RELEASE.json'),
18
18
  json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),
@@ -12,7 +12,7 @@ const PARENT={
12
12
  generation_manifest_sha256:'f47cb96083679e764725df1bde6eda53169a39f55772c173ab22f89a1dfaa7ab'
13
13
  };
14
14
 
15
- test('R63 identity binds exact active 0.15.39 parent and one-shot runtime coherence repair',{skip:currentPackage.version!=='0.15.40'},async()=>{
15
+ test('R63 identity binds exact active 0.15.39 parent and one-shot runtime coherence repair',{skip:currentPackage.version!=='0.15.40' ? 'Historical R63 release contract requires 0.15.40; current '+currentPackage.version : false},async()=>{
16
16
  const pkg=await json('package.json');
17
17
  assert.equal(pkg.version,'0.15.40');
18
18
  assert.match(pkg.scripts['r63:focused:test'],/r63-one-shot-coherence\.test\.mjs/);
@@ -12,7 +12,7 @@ const runtime={
12
12
  generation_manifest_sha256:'f47cb96083679e764725df1bde6eda53169a39f55772c173ab22f89a1dfaa7ab'
13
13
  };
14
14
 
15
- test('R64 release identity distinguishes unsealed source predecessor from active runtime predecessor',{skip:currentPackage.version!=='0.15.41'},async()=>{
15
+ test('R64 release identity distinguishes unsealed source predecessor from active runtime predecessor',{skip:currentPackage.version!=='0.15.41' ? 'Historical R64 release contract requires 0.15.41; current '+currentPackage.version : false},async()=>{
16
16
  const [pkg,lock,bridge,release,provenance,matrix,sbom,scope,gaps,version,gate]=await Promise.all([
17
17
  json('package.json'),json('package-lock.json'),json('bridge/package.json'),json('RELEASE.json'),
18
18
  json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),json('docs/R64-SCOPE.json'),
@@ -16,7 +16,7 @@ const dummy={coding:'2'.repeat(64),autonomous:'3'.repeat(64),desktop:'4'.repeat(
16
16
 
17
17
  async function optional(file){try{return await readFile(file);}catch(error){if(error?.code==='ENOENT')return null;throw error;}}
18
18
 
19
- test('epoch-native orchestrator uses transaction continuity engine instead of generic authority commands',async()=>{
19
+ test('epoch-native orchestrator handles BOM-encoded process grant with transaction continuity engine',async()=>{
20
20
  const root=await mkdtemp(path.join(os.tmpdir(),'deadbyte-r65-epoch-activation-'));
21
21
  try{
22
22
  const state=path.join(root,'state'),runtime=path.join(state,'runtime'),trust=path.join(state,'trust'),policies=path.join(root,'policies');
@@ -33,7 +33,7 @@ test('epoch-native orchestrator uses transaction continuity engine instead of ge
33
33
  await writeFile(beforePath,policyBytes);await writeFile(afterPath,policyBytes);
34
34
  const oldGrant={schema:'deadbyte.process-grant.v1',policy_sha256:sha(policyBytes),instance_nonce:'8'.repeat(64),
35
35
  profile_ids:['safe'],root_ids:['core'],granted_at_utc:'2026-10-07T00:00:00Z'};
36
- const oldBytes=Buffer.from(JSON.stringify(oldGrant));await writeFile(grantFile,oldBytes);
36
+ const oldBytes=Buffer.concat([Buffer.from([0xef,0xbb,0xbf]),Buffer.from(JSON.stringify(oldGrant))]);await writeFile(grantFile,oldBytes);
37
37
  const store=createAuthorityEpochStore({runtimeDir:runtime,policyBytes});
38
38
  await store.append({plane:'process',action:'grant',grantBytes:oldBytes,grantInstanceNonce:oldGrant.instance_nonce});
39
39
  let switched=false;
@@ -41,7 +41,7 @@ test('epoch-native orchestrator uses transaction continuity engine instead of ge
41
41
  const bytes=await optional(grantFile),head=await store.readHead({plane:'process'});
42
42
  let armed=false;
43
43
  if(bytes){
44
- const grant=JSON.parse(bytes);
44
+ const grant=JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
45
45
  armed=(await store.verifyGrant({plane:'process',grantBytes:bytes,grantInstanceNonce:grant.instance_nonce,policyBytes})).trusted;
46
46
  }
47
47
  return {state:'ONLINE',local_ready:true,...ids,supervisor:{running:true},authority:{
@@ -104,7 +104,7 @@ test('epoch-native explicit user revoke after transaction revoke wins over orche
104
104
  const bytes=await optional(grantFile),head=await store.readHead({plane:'process'});
105
105
  let armed=false;
106
106
  if(bytes){
107
- const grant=JSON.parse(bytes);
107
+ const grant=JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
108
108
  armed=(await store.verifyGrant({plane:'process',grantBytes:bytes,grantInstanceNonce:grant.instance_nonce,policyBytes})).trusted;
109
109
  }
110
110
  return {state:'ONLINE',local_ready:true,...ids,supervisor:{running:true},authority:{
@@ -4,6 +4,7 @@ import {readFile} from 'node:fs/promises';
4
4
 
5
5
  const read=rel=>readFile(new URL('../'+rel,import.meta.url),'utf8');
6
6
  const json=async rel=>JSON.parse((await read(rel)).replace(/^\uFEFF/,''));
7
+ const currentPackage=await json('package.json');
7
8
  const PARENT={
8
9
  version:'0.15.41',
9
10
  release_id:'v0.15.41-63a78ad159ad3003',
@@ -11,7 +12,7 @@ const PARENT={
11
12
  generation_manifest_sha256:'19ae2efcdcde9f80c474f0e55851d4ada51c22813d3e05af03b11acb28c3fca5'
12
13
  };
13
14
 
14
- test('R65 release identity binds exact production R64 parent and durable authority-continuity train',async()=>{
15
+ test('R65 release identity binds exact production R64 parent and durable authority-continuity train',{skip:currentPackage.version!=='0.15.42' ? 'Historical R65 release contract requires 0.15.42; current '+currentPackage.version : false},async()=>{
15
16
  const [pkg,lock,bridge,release,provenance,matrix,sbom,version,gate,gaps,design]=await Promise.all([
16
17
  json('package.json'),json('package-lock.json'),json('bridge/package.json'),json('RELEASE.json'),
17
18
  json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),
@@ -0,0 +1,57 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {readFile} from 'node:fs/promises';
4
+
5
+ const read=rel=>readFile(new URL('../'+rel,import.meta.url),'utf8');
6
+ const json=async rel=>JSON.parse((await read(rel)).replace(/^\uFEFF/,''));
7
+ const currentPackage=await json('package.json');
8
+ const PARENT={
9
+ version:'0.15.42',
10
+ release_id:'v0.15.42-1b4754103dd4ca43',
11
+ manifest_sha256:'1b4754103dd4ca43eb81f8e33cf188b36eee3051cb182396ccc6abe2a6e6c250',
12
+ generation_manifest_sha256:'62dc68be55ad627f8d872b8be8c1369ecca0edf08fdedc8336c9ccee2d2809fb'
13
+ };
14
+
15
+ test('R66 identity is an exact prepublish doctor hotfix of sealed R65',{skip:currentPackage.version!=='0.15.43' ? 'Historical R66 release contract requires 0.15.43; current '+currentPackage.version : false},async()=>{
16
+ const [pkg,lock,bridge,release,provenance,matrix,sbom,version,gate]=await Promise.all([
17
+ json('package.json'),json('package-lock.json'),json('bridge/package.json'),json('RELEASE.json'),
18
+ json('PROVENANCE.json'),json('TEST-MATRIX.json'),json('SBOM.cdx.json'),read('src/version.mjs'),
19
+ read('scripts/gate-windows-r66-prepublish.ps1')
20
+ ]);
21
+ assert.equal(pkg.version,'0.15.43');
22
+ assert.equal(lock.version,pkg.version);
23
+ assert.equal(lock.packages[''].version,pkg.version);
24
+ assert.equal(bridge.version,pkg.version);
25
+ assert.match(version,/DEADBYTE_VERSION = '0\.15\.43'/);
26
+ assert.equal(pkg.scripts['gate:windows'],'powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-windows-r66-prepublish.ps1');
27
+ assert.match(pkg.scripts['r66:focused:test'],/test\/r58-doctor-runtime\.test\.mjs/);
28
+ assert.equal(release.version,pkg.version);
29
+ assert.equal(release.train,'R66');
30
+ for(const [key,value] of Object.entries(PARENT))assert.equal(release.parent[key],value);
31
+ assert.deepEqual(release.runtime_predecessor,{
32
+ release_id:PARENT.release_id,
33
+ manifest_sha256:PARENT.manifest_sha256,
34
+ generation_manifest_sha256:PARENT.generation_manifest_sha256
35
+ });
36
+ assert.equal(release.source_predecessor.version,PARENT.version);
37
+ assert.equal(release.source_predecessor.manifest_file_sha256,PARENT.manifest_sha256);
38
+ assert.equal(release.r66_doctor_epoch_hotfix.doctor_epoch_observation_compatibility,true);
39
+ assert.equal(release.r66_doctor_epoch_hotfix.new_public_tools,0);
40
+ assert.equal(release.r66_doctor_epoch_hotfix.new_authority_scopes,0);
41
+ assert.equal(release.r66_doctor_epoch_hotfix.prepublish_only,true);
42
+ assert.equal(provenance.version,pkg.version);
43
+ assert.equal(provenance.parent_release_id,PARENT.release_id);
44
+ assert.equal(provenance.parent_manifest_sha256,PARENT.manifest_sha256);
45
+ assert.equal(provenance.parent_generation_manifest_sha256,PARENT.generation_manifest_sha256);
46
+ assert.equal(provenance.r66.new_public_tools,0);
47
+ assert.equal(provenance.r66.new_authority_scopes,0);
48
+ assert.equal(matrix.version,pkg.version);
49
+ assert.equal(matrix.train,'R66');
50
+ assert.ok(matrix.required.some(row=>row.id==='r66-focused'));
51
+ assert.equal(sbom.metadata.component.version,pkg.version);
52
+ assert.equal(sbom.serialNumber,'urn:cdx:deadbyte-mcp:r66:0.15.43');
53
+ assert.match(gate,/v0\.15\.42-1b4754103dd4ca43/);
54
+ assert.match(gate,/62dc68be55ad627f8d872b8be8c1369ecca0edf08fdedc8336c9ccee2d2809fb/);
55
+ assert.match(gate,/r66:focused:test/);
56
+ assert.doesNotMatch(gate,/npm\.cmd publish|--publish-only/);
57
+ });
@@ -0,0 +1,41 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {spawnSync} from 'node:child_process';
4
+ import {fileURLToPath} from 'node:url';
5
+ import path from 'node:path';
6
+ import {nativeInspectArgs} from '../src/native-inspector-r67.mjs';
7
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
8
+ const cli=path.join(root,'src','deadbyte-cli.mjs');
9
+ const exe=path.join(root,'bin','deadbyte-native-inspect-r67.exe');
10
+ function invoke(...args){
11
+ const r=spawnSync(process.execPath,[cli,'inspect',...args],{cwd:root,shell:false,windowsHide:true,encoding:'utf8',timeout:30000,maxBuffer:2097152});
12
+ assert.equal(r.error,undefined,r.error?.message);return {r,value:JSON.parse(r.stdout.trim())};
13
+ }
14
+ test('R67 CLI inspect exposes native process snapshot without MCP tool additions',()=>{
15
+ const {r,value}=invoke('process','4');
16
+ assert.equal(r.status,0,r.stderr);assert.equal(value.status,'ok');assert.equal(value.operation,'process');assert.ok(value.data.processes.length<=4);
17
+ });
18
+ test('R67 CLI inspect memory self is metadata-only and PE uses actual bytes',()=>{
19
+ const m=invoke('memory','self','4');
20
+ assert.equal(m.r.status,0,m.r.stderr);assert.equal(m.value.status,'ok');assert.ok(m.value.data.regions.length<=4);
21
+ const p=invoke('pe',exe);
22
+ assert.equal(p.r.status,0,p.r.stderr);assert.equal(p.value.status,'ok');assert.match(p.value.data.file_sha256,/^[a-f0-9]{64}$/);
23
+ });
24
+ test('R67 CLI typed input rejects invalid selectors before spawning native process',()=>{
25
+ for(const selector of [['process','0'],['process','999999'],['memory','0'],['memory','self','9999'],['memory','4148'],['identity'],['identity','0'],['memory','4148','0'],['memory','4148','18446744073709551616'],['pe'],['unknown']]){
26
+ assert.throws(()=>nativeInspectArgs(selector));
27
+ }
28
+ const error=spawnSync(process.execPath,[cli,'inspect','memory','0'],{cwd:root,shell:false,windowsHide:true,encoding:'utf8',timeout:30000});
29
+ assert.equal(error.status,1);assert.match(error.stderr,/invalid positive limit|limit out of range|creation_filetime/);
30
+ });
31
+ test('R67 CLI preserves raw Windows error instead of fabricating data',()=>{
32
+ const {r,value}=invoke('memory','4294967295','1','4');
33
+ assert.equal(r.status,2);assert.equal(value.status,'failed');assert.match(value.error,/win32|PID/);
34
+ });
35
+
36
+ test('R67 CLI rejects stale PID identity before successful region inspection',()=>{
37
+ const {r,value}=invoke('memory',String(process.pid),'1','4');
38
+ assert.equal(r.status,2);
39
+ assert.equal(value.error_code,'PROCESS_IDENTITY_MISMATCH');
40
+ assert.equal(value.win32_error,0);
41
+ });
@@ -0,0 +1,60 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {spawnSync} from 'node:child_process';
4
+ import {mkdtemp,mkdir,writeFile,readFile,rm} from 'node:fs/promises';
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import {fileURLToPath} from 'node:url';
8
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
9
+ const cli=path.join(root,'src','deadbyte-cli.mjs');
10
+ test('R67 offline diagnostic CLI exports without activating remote, uploading or revealing raw log bytes',async()=>{
11
+ const folder=await mkdtemp(path.join(os.tmpdir(),'r67-diagnostic-cli-'));
12
+ try{
13
+ const state=path.join(folder,'state');
14
+ const output=path.join(folder,'report.zip');
15
+ await mkdir(path.join(state,'runtime','logs'),{recursive:true});
16
+ await writeFile(path.join(state,'active-release.json'),JSON.stringify({release_id:'v0.15.43-'+'a'.repeat(16),manifest_sha256:'a'.repeat(64)}));
17
+ await writeFile(path.join(state,'runtime','logs','controller-start.stderr.log'),'WARN reconnect win32=109 SECRET_CANARY_52917\n');
18
+ const run=spawnSync(process.execPath,[cli,'diagnostics','export','--output',output],{
19
+ cwd:root,env:{...process.env,DEADBYTE_STATE_ROOT:state},encoding:'utf8',shell:false,windowsHide:true,timeout:20000
20
+ });
21
+ assert.equal(run.status,0,run.stderr);
22
+ const result=JSON.parse(run.stdout);
23
+ assert.equal(result.status,'written_local_only');
24
+ assert.equal(result.uploaded,false);
25
+ const b=await readFile(output);
26
+ assert.equal(b.includes(Buffer.from('SECRET_CANARY_52917')),false);
27
+ assert.equal(b.readUInt32LE(0),0x04034b50);
28
+ const reject=spawnSync(process.execPath,[cli,'diagnostics','export','--output',path.join(folder,'second.zip'),'--upload'],{
29
+ cwd:root,env:{...process.env,DEADBYTE_STATE_ROOT:state},encoding:'utf8',shell:false,windowsHide:true,timeout:20000
30
+ });
31
+ assert.equal(reject.status,1);
32
+ assert.match(reject.stderr,/upload|syntax|diagnostics/i);
33
+ }finally{await rm(folder,{recursive:true,force:true});}
34
+ });
35
+
36
+ test('R67 diagnostic CLI verify checks local ZIP without starting remote session',async()=>{
37
+ const {makeOfflineDiagnosticBundle}=await import('../src/r67-diagnostic-export.mjs');
38
+ const folder=await mkdtemp(path.join(os.tmpdir(),'r67-diagnostic-verify-cli-'));
39
+ try{
40
+ const file=path.join(folder,'report.zip');
41
+ const bundle=makeOfflineDiagnosticBundle({
42
+ releaseId:'v0.15.43-'+'a'.repeat(16),manifestSha256:'a'.repeat(64),logs:[]
43
+ });
44
+ await writeFile(file,bundle.zip);
45
+ const r=spawnSync(process.execPath,[cli,'diagnostics','verify','--input',file],{
46
+ cwd:root,encoding:'utf8',shell:false,windowsHide:true,timeout:20000
47
+ });
48
+ assert.equal(r.status,0,r.stderr);
49
+ const result=JSON.parse(r.stdout);
50
+ assert.equal(result.status,'VERIFIED_LOCAL_STRUCTURE');
51
+ assert.equal(result.archive_sha256,bundle.archive_sha256);
52
+ const broken=Buffer.from(bundle.zip);broken[50]^=1;
53
+ const brokenPath=path.join(folder,'corrupt.zip');await writeFile(brokenPath,broken);
54
+ const denial=spawnSync(process.execPath,[cli,'diagnostics','verify','--input',brokenPath],{
55
+ cwd:root,encoding:'utf8',shell:false,windowsHide:true,timeout:20000
56
+ });
57
+ assert.equal(denial.status,1);
58
+ assert.match(denial.stderr,/integrity|ZIP|unsafe/i);
59
+ }finally{await rm(folder,{recursive:true,force:true});}
60
+ });
@@ -0,0 +1,49 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {makeOfflineDiagnosticBundle} from '../src/r67-diagnostic-export.mjs';
4
+ import {verifyOfflineDiagnosticsZip} from '../src/r67-diagnostics-verify.mjs';
5
+ const sha='a'.repeat(64);
6
+ const archive=()=>makeOfflineDiagnosticBundle({releaseId:'v0.15.43-'+'a'.repeat(16),manifestSha256:sha,
7
+ logs:[{source:'controller-start.stderr.log',content:'2026-10-11T03:04:05.000Z WARN reconnect win32=109 PASSWORD_CANARY_91020'}]}).zip;
8
+ test('R67 offline diagnostic independently verifies ZIP CRC, bounded entries and fixed schemas',()=>{
9
+ const v=verifyOfflineDiagnosticsZip(archive());
10
+ assert.equal(v.status,'VERIFIED_LOCAL_STRUCTURE');
11
+ assert.equal(v.uploaded,false);
12
+ assert.equal(v.entry_count,2);
13
+ assert.equal(v.summary.redaction,'FIXED_FIELDS_ONLY');
14
+ assert.equal(v.summary.network_upload,'NEVER');
15
+ assert.match(v.archive_sha256,/^[a-f0-9]{64}$/);
16
+ assert.equal(v.summary.raw_log_lines_exported,0);
17
+ });
18
+ test('R67 verifier rejects byte tampering without an updated CRC',()=>{
19
+ const corrupted=Buffer.from(archive());
20
+ const phrase=Buffer.from('FIXED_FIELDS_ONLY');
21
+ const offset=corrupted.indexOf(phrase);
22
+ assert.ok(offset>0);
23
+ corrupted[offset]^=1;
24
+ assert.throws(()=>verifyOfflineDiagnosticsZip(corrupted),/CRC|hash|corrupt/i);
25
+ });
26
+ test('R67 verifier rejects trailing junk, extra archive entries and invalid size bounds',()=>{
27
+ const good=archive();
28
+ assert.throws(()=>verifyOfflineDiagnosticsZip(Buffer.concat([good,Buffer.alloc(20)])),/trailing|eocd|boundary|ZIP/i);
29
+ assert.throws(()=>verifyOfflineDiagnosticsZip(good.subarray(0,good.length-5)),/truncated|eocd|boundary|ZIP/i);
30
+ assert.throws(()=>verifyOfflineDiagnosticsZip(Buffer.alloc(4*1024*1024+1)),/size|large/i);
31
+ });
32
+ test('R67 verify rejects semantic tampering even when attacker recomputes all ZIP CRCs',()=>{
33
+ const buf=Buffer.from(archive());
34
+ const find=Buffer.from('FIXED_FIELDS_ONLY');
35
+ const at=buf.indexOf(find);
36
+ assert.ok(at>0);
37
+ buf.write('ALLOW_RAW_LOGS___',at,'utf8');
38
+ const dataStart=30+buf.readUInt16LE(26),dataLength=buf.readUInt32LE(18);
39
+ let crc=0xffffffff;
40
+ for(const byte of buf.subarray(dataStart,dataStart+dataLength)){
41
+ crc^=byte;
42
+ for(let j=0;j<8;j++)crc=(crc>>>1)^((crc&1)?0xedb88320:0);
43
+ }
44
+ crc=(crc^0xffffffff)>>>0;
45
+ const dir=buf.readUInt32LE(buf.length-22+16);
46
+ buf.writeUInt32LE(crc,14);
47
+ buf.writeUInt32LE(crc,dir+16);
48
+ assert.throws(()=>verifyOfflineDiagnosticsZip(buf),/unsafe diagnostic summary/i);
49
+ });