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
@@ -0,0 +1,26 @@
1
+ /**
2
+ * R67 npm publish fence. Does not prove Windows release readiness by itself:
3
+ * only the independent release verifier may change these metadata gates.
4
+ * The package publisher must never interpret focused or package-only PASS as
5
+ * authority to make an immutable public release.
6
+ */
7
+ export function assertR67NpmPublishReady(release){
8
+ if(release?.version!=='0.15.44'||release?.train!=='R67')
9
+ throw new Error('PUBLISH_BLOCKED R67 release identity does not match candidate');
10
+ const state=release.r67_native_observation;
11
+ const gates={
12
+ status:'CANDIDATE_SEALED',
13
+ full_release_gate:'PASS',
14
+ current_source_full_shards:'PASS',
15
+ native_fault_injection:'PASS',
16
+ protocol_parity:'PASS',
17
+ isolated_activation_rollback_restore:'PASS',
18
+ independent_machine_observation:'PASS'
19
+ };
20
+ for(const [key,expected] of Object.entries(gates)){
21
+ if(state?.[key]!==expected)
22
+ throw new Error('PUBLISH_BLOCKED R67 '+key+' '+String(state?.[key]??'MISSING')+
23
+ '; require independently verified gate '+expected+' before npm publication');
24
+ }
25
+ return {status:'R67_METADATA_GATES_MATCH',policy:'PUBLISH_REQUIRES_INDEPENDENT_RELEASE_EVIDENCE'};
26
+ }
@@ -0,0 +1,95 @@
1
+ import https from 'node:https';
2
+ import {createHash} from 'node:crypto';
3
+ import {gunzipSync} from 'node:zlib';
4
+ import {mkdir,open,writeFile,readFile} from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import {fileURLToPath} from 'node:url';
7
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
8
+ const ref=path.resolve(root,'..','..','references','desktop-commander-0.3.1-alpha.2');
9
+ const version='0.3.1-alpha.2';
10
+ const packageName='@wonderwhy-er/desktop-commander';
11
+ const url='https://registry.npmjs.org/@wonderwhy-er%2fdesktop-commander/'+version;
12
+ const hash=(b,algo='sha256')=>createHash(algo).update(b).digest('hex');
13
+ async function fetchBounded(url,maxSize){
14
+ const parsed=new URL(url);
15
+ if(parsed.protocol!=='https:'||parsed.hostname!=='registry.npmjs.org'||parsed.username||parsed.password||parsed.port)throw new Error('untrusted npm endpoint');
16
+ return await new Promise((resolve,reject)=>{
17
+ const req=https.get(parsed,{timeout:20000,headers:{'Accept':'application/json','User-Agent':'deadbyte-reference-verifier/1.0'}},res=>{
18
+ if(res.statusCode!==200){res.resume();reject(new Error('npm GET HTTP '+res.statusCode));return;}
19
+ const parts=[];let size=0;
20
+ res.on('data',b=>{size+=b.length;if(size>maxSize){req.destroy(new Error('download exceeded declared safety cap'));return;}parts.push(b);});
21
+ res.on('end',()=>resolve(Buffer.concat(parts)));
22
+ res.on('error',reject);
23
+ });
24
+ req.on('timeout',()=>req.destroy(new Error('npm request timeout')));
25
+ req.on('error',reject);
26
+ });
27
+ }
28
+ async function saveNew(file,data){
29
+ const h=await open(file,'wx',0o600);
30
+ try{await h.writeFile(data);await h.sync();}finally{await h.close();}
31
+ }
32
+ const metadata=JSON.parse((await fetchBounded(url,1024*1024)).toString('utf8'));
33
+ if(metadata.name!==packageName||metadata.version!==version)throw new Error('npm metadata identity mismatch');
34
+ const tarball=metadata.dist?.tarball;
35
+ const expected='https://registry.npmjs.org/@wonderwhy-er/desktop-commander/-/desktop-commander-'+version+'.tgz';
36
+ if(tarball!==expected)throw new Error('registry tarball URL is not exact pinned package');
37
+ if(!/^sha512-[A-Za-z0-9+/]+=*$/.test(metadata.dist.integrity??''))throw new Error('missing registry SHA512 integrity');
38
+ const tar=await fetchBounded(tarball,32*1024*1024);
39
+ const integrity='sha512-'+createHash('sha512').update(tar).digest('base64');
40
+ if(integrity!==metadata.dist.integrity)throw new Error('npm SHA512 integrity mismatch');
41
+ if(metadata.dist.shasum&&hash(tar,'sha1')!==metadata.dist.shasum)throw new Error('npm SHA1 mismatch');
42
+ const expanded=gunzipSync(tar,{maxOutputLength:128*1024*1024});
43
+ const files=[];let offset=0,total=0;
44
+ const selected=[];
45
+ const names=new Set();
46
+ function cstr(b){return b.toString('utf8').split('\0')[0];}
47
+ while(offset+512<=expanded.length){
48
+ const header=expanded.subarray(offset,offset+512);
49
+ if(header.every(v=>v===0))break;
50
+ const filename=cstr(header.subarray(0,100));
51
+ const prefix=cstr(header.subarray(345,500));
52
+ const name=prefix?prefix+'/'+filename:filename;
53
+ const szText=cstr(header.subarray(124,136)).trim();
54
+ if(!/^[0-7]*$/.test(szText))throw new Error('non-octal tar entry size');
55
+ const size=parseInt(szText||'0',8);
56
+ const type=header[156];
57
+ if(!Number.isSafeInteger(size)||size<0||offset+512+size>expanded.length)throw new Error('corrupt archive boundary');
58
+ if(type===50||type===49)throw new Error('tar link entry denied');
59
+ if(type===0||type===48){
60
+ if(!name.startsWith('package/')||name.includes('\\')||name.includes(':')||
61
+ name.split('/').some(c=>!c||c==='.'||c==='..')||names.has(name))throw new Error('unsafe tar entry '+name);
62
+ names.add(name);files.push({path:name,size});total+=size;
63
+ if(files.length>1000||total>128*1024*1024)throw new Error('tar inventory budget exceeded');
64
+ const rel=name.slice('package/'.length);
65
+ if(/^(?:package\.json|README\.md|LICENSE|LICENCE|dist\/[a-zA-Z0-9_./-]+\.(?:js|mjs|cjs|json|map))$/.test(rel)&&size<=8*1024*1024)
66
+ selected.push({rel,content:Buffer.from(expanded.subarray(offset+512,offset+512+size))});
67
+ }else if(![53,120,103].includes(type))throw new Error('unsupported tar type '+type+' for '+name);
68
+ offset+=512+Math.ceil(size/512)*512;
69
+ }
70
+ const packageEntry=selected.find(e=>e.rel==='package.json');
71
+ if(!packageEntry)throw new Error('tarball has no package.json');
72
+ const packaged=JSON.parse(packageEntry.content.toString('utf8'));
73
+ if(packaged.name!==packageName||packaged.version!==version)throw new Error('tarball package version disagrees with registry metadata');
74
+ await mkdir(path.join(ref,'static'),{recursive:true});
75
+ const archivePath=path.join(ref,'desktop-commander-'+version+'.tgz');
76
+ await saveNew(archivePath,tar);
77
+ let selectedBytes=0;
78
+ for(const e of selected){
79
+ const target=path.join(ref,'static',...e.rel.split('/'));
80
+ await mkdir(path.dirname(target),{recursive:true});
81
+ await saveNew(target,e.content);selectedBytes+=e.content.length;
82
+ }
83
+ const receipt={
84
+ schema:'deadbyte.competitor-reference-acquisition.v1',status:'VERIFIED_STATIC_ONLY',
85
+ package:packageName,version,metadata_source:url,
86
+ source_archive:archivePath,archive_bytes:tar.length,archive_sha256:hash(tar),
87
+ archive_sha512_integrity:integrity,registry_shasum_sha1:metadata.dist.shasum??null,
88
+ files_total:files.length,files_size_bytes:total,files_selected: selected.length,selected_bytes:selectedBytes,
89
+ has_lifecycle_scripts:Boolean(packaged.scripts&&(packaged.scripts.preinstall||packaged.scripts.install||packaged.scripts.postinstall)),
90
+ lifecycle_scripts_executed:false,dependencies_installed:false,remote_started:false,network_action:'registry_https_download_only',
91
+ selected_files_sha256:selected.map(e=>({path:e.rel,sha256:hash(e.content)})),
92
+ full_archive_inventory_sha256:hash(Buffer.from(JSON.stringify(files)))
93
+ };
94
+ await saveNew(path.join(ref,'ACQUISITION.json'),JSON.stringify(receipt,null,2)+'\n');
95
+ console.log(JSON.stringify({status:receipt.status,version,archive_sha256:receipt.archive_sha256,archive_bytes:tar.length,files_total:files.length,files_selected:selected.length,lifecycle_scripts_executed:false,reference_path:ref,source:metadata.dist.tarball},null,2));
@@ -0,0 +1,39 @@
1
+ import {readFile,readdir,open,mkdir} from 'node:fs/promises';
2
+ import {createHash} from 'node:crypto';
3
+ import path from 'node:path';
4
+ import {fileURLToPath} from 'node:url';
5
+ const root=path.resolve(fileURLToPath(new URL('..',import.meta.url)));
6
+ const evidence=path.resolve(root,'..','..','testing','0.15.44-r67','regression-shards');
7
+ const operation='r67audit-20261011c';
8
+ const cases=[];
9
+ const files=(await readdir(path.join(root,'test'))).filter(n=>n.endsWith('.test.mjs'));
10
+ const texts=new Map();for(const file of files)texts.set(file,(await readFile(path.join(root,'test',file),'utf8')).split(/\r?\n/));
11
+ const fileSha=b=>createHash('sha256').update(b).digest('hex');
12
+ for(let index=0;index<32;index++){
13
+ const p=path.join(evidence,operation+'-shard-'+String(index).padStart(2,'0'),'result.json');
14
+ const r=JSON.parse(await readFile(p,'utf8'));
15
+ for(const c of r.nonpass_cases??[]){
16
+ const name=c.name;
17
+ const matches=[];
18
+ for(const [file,lines] of texts){
19
+ for(let line=0;line<lines.length;line++){
20
+ const hay=lines[line];
21
+ const short=name.replace(/^R\d+ /,'').slice(0,40);
22
+ if(hay.includes(name)||hay.includes(short)){
23
+ matches.push({file,line:line+1,context:lines.slice(Math.max(0,line-3),Math.min(lines.length,line+4)).join(' ').slice(0,780)});
24
+ if(matches.length>=5)break;
25
+ }
26
+ }
27
+ if(matches.length>=5)break;
28
+ }
29
+ cases.push({shard:index,name,reason:c.reason,source_matches:matches});
30
+ }
31
+ }
32
+ const summary={schema:'deadbyte.r67-nonpass-source-audit.v1',operation,
33
+ count:cases.length,with_reason:cases.filter(c=>c.reason).length,
34
+ without_reason:cases.filter(c=>!c.reason).length,unmatched:cases.filter(c=>!c.source_matches.length).length,
35
+ cases};
36
+ const out=path.resolve(root,'..','..','testing','0.15.44-r67','R67-NONPASS-SOURCE-AUDIT-20261011.json');
37
+ const h=await open(out,'wx',0o600);try{await h.writeFile(JSON.stringify(summary,null,2)+'\n');await h.sync();}finally{await h.close();}
38
+ console.log(JSON.stringify({count:summary.count,with_reason:summary.with_reason,without_reason:summary.without_reason,
39
+ unmatched:summary.unmatched,findings:cases.filter(c=>!c.reason).map(c=>({shard:c.shard,name:c.name,matches:c.source_matches}))},null,2));
@@ -0,0 +1,48 @@
1
+ import {readdir,readFile,writeFile,mkdir,open} from 'node:fs/promises';
2
+ import {createHash} from 'node:crypto';
3
+ import path from 'node:path';
4
+ import {fileURLToPath} from 'node:url';
5
+ const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..','..','..');
6
+ const refs=path.join(root,'references');
7
+ const stable=path.join(refs,'desktop-commander','dist');
8
+ const alpha=path.join(refs,'desktop-commander-0.3.1-alpha.2','static','dist');
9
+ const output=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..','docs','R67-ALPHA-STATIC-COMPARISON.json');
10
+ const sha=b=>createHash('sha256').update(b).digest('hex');
11
+ async function inventory(dir,prefix=''){
12
+ const items=await readdir(path.join(dir,prefix),{withFileTypes:true});
13
+ const out=[];
14
+ for(const x of items){
15
+ const sub=[prefix,x.name].filter(Boolean).join('/');
16
+ if(x.isDirectory())out.push(...await inventory(dir,sub));
17
+ else if(x.isFile()&&/\.(?:js|mjs|cjs|json)$/.test(sub)){
18
+ const b=await readFile(path.join(dir,sub));
19
+ out.push({path:sub,sha256:sha(b),bytes:b.length});
20
+ }
21
+ }
22
+ return out;
23
+ }
24
+ const older=await inventory(stable),newer=await inventory(alpha);
25
+ const map=new Map(older.map(f=>[f.path,f]));
26
+ const changes=[];
27
+ for(const f of newer){
28
+ const old=map.get(f.path);
29
+ changes.push({path:f.path,status:!old?'ADDED':old.sha256===f.sha256?'UNCHANGED':'CHANGED',
30
+ stable_sha256:old?.sha256??null,alpha_sha256:f.sha256,delta_bytes:old?f.bytes-old.bytes:null});
31
+ }
32
+ const relevant=changes.filter(x=>/diagnostic|remote-device|annotations|schema|mcp|pdf|process|reconnect|terminal/i.test(x.path));
33
+ const report={
34
+ schema:'deadbyte.r67-competitor-static-compare.v1',
35
+ scope:'static npm archives only; do not execute or install competitor',
36
+ stable_version:'0.2.52',alpha_version:'0.3.1-alpha.2',
37
+ alpha_tarball_sha256:'faaf3f34f114589c0630ce4eaa7114ecc628ce2030822dfe67feac0e17fedc4b',
38
+ stable_compared_files:older.length,alpha_selected_compared_files:newer.length,
39
+ added:changes.filter(x=>x.status==='ADDED').length,
40
+ changed:changes.filter(x=>x.status==='CHANGED').length,
41
+ unchanged:changes.filter(x=>x.status==='UNCHANGED').length,
42
+ removed_from_selected_scope:0,
43
+ relevant_changes:relevant,
44
+ caveat:'Alpha was selectively extracted; do not treat missing alpha inventory as deleted without checking full archive.'
45
+ };
46
+ const handle=await open(output,'wx');
47
+ try{await handle.writeFile(JSON.stringify(report,null,2)+'\n');await handle.sync();}finally{await handle.close();}
48
+ console.log(JSON.stringify({status:'STATIC_DIFFERENTIAL_PASS',stable_files:report.stable_compared_files,alpha_files:report.alpha_selected_compared_files,added:report.added,changed:report.changed,unchanged:report.unchanged,relevant:relevant.filter(x=>x.status!=='UNCHANGED').map(x=>({path:x.path,status:x.status,delta:x.delta_bytes})).slice(0,60)},null,2));
@@ -0,0 +1,23 @@
1
+ import {readFile} from 'node:fs/promises';
2
+ import {spawnSync} from 'node:child_process';
3
+ import path from 'node:path';
4
+ import {fileURLToPath} from 'node:url';
5
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
6
+ const op=process.argv[2],shard=process.argv[3];
7
+ if(!/^[a-z0-9._-]{6,64}$/.test(op??'')||!/^(0|[1-9]\d?)$/.test(shard??''))throw new Error('operation and shard required');
8
+ const file=path.resolve(root,'..','..','testing','0.15.44-r67','regression-shards',op+'-shard-'+String(shard).padStart(2,'0'),'intent.json');
9
+ const intent=JSON.parse(await readFile(file,'utf8'));
10
+ if(intent.operation!==op||intent.shard_index!==Number(shard))throw new Error('historical intent mismatch');
11
+ const r=spawnSync(process.execPath,['--test','--test-reporter=tap','--test-concurrency=2',...intent.files],{
12
+ cwd:root,encoding:'utf8',windowsHide:true,shell:false,timeout:60000,maxBuffer:8*1024*1024,
13
+ env:Object.fromEntries(Object.entries(process.env).filter(([k])=>k!=='NODE_TEST_CONTEXT'))
14
+ });
15
+ const output=String(r.stdout??'');
16
+ const lines=output.split(/\r?\n/);
17
+ const failures=[];
18
+ for(let i=0;i<lines.length;i++){
19
+ if(/^(?:not ok |# (?:error|failure)|✖ )/.test(lines[i]))failures.push(lines.slice(Math.max(0,i-1),Math.min(lines.length,i+28)).join('\n').slice(0,4200));
20
+ }
21
+ console.log(JSON.stringify({schema:'deadbyte.r67-diagnostic-replay.v1',role:'NON_RELEASE_TEST_DIAGNOSIS_ONLY',
22
+ from_historical_operation:op,shard:Number(shard),exit_code:r.status,child_error:r.error?.code??null,
23
+ failures:failures.slice(0,20),tail:output.slice(-1800),stderr:String(r.stderr??'').slice(-1000)},null,2));
@@ -0,0 +1,42 @@
1
+ import {readdir,mkdir,open,readFile,rename} from 'node:fs/promises';
2
+ import {spawnSync} from 'node:child_process';
3
+ import {createHash} from 'node:crypto';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
7
+ const evidence=path.resolve(root,'../../testing/0.15.44-r67/full-batches');
8
+ const tests=(await readdir(path.join(root,'test'))).filter(n=>n.endsWith('.test.mjs')).sort();
9
+ const size=27;
10
+ const indexRaw=process.argv[2];
11
+ if(!/^(?:0|[1-9]\d*)$/.test(indexRaw??''))throw new Error('batch index required');
12
+ const index=Number(indexRaw);
13
+ const total=Math.ceil(tests.length/size);
14
+ if(!Number.isInteger(index)||index<0||index>=total)throw new Error('batch index out of range');
15
+ await mkdir(evidence,{recursive:true});
16
+ const attempt=process.argv[3]??'initial';
17
+ if(!/^[a-zA-Z0-9_-]{1,24}$/.test(attempt))throw new Error('invalid attempt label');
18
+ const suffix=attempt==='initial'?'':'-'+attempt;
19
+ const file=path.join(evidence,'batch-'+String(index).padStart(2,'0')+suffix+'.json');
20
+ const start=new Date().toISOString();
21
+ const mode=process.argv[4]??'all';
22
+ if(!['all','core','remote'].includes(mode)||(mode!=='all'&&index!==10))throw new Error('invalid batch split mode');
23
+ const window=tests.slice(index*size,(index+1)*size);
24
+ const selected=mode==='core'?window.filter(n=>n!=='remote-session-cli.test.mjs'):mode==='remote'?window.filter(n=>n==='remote-session-cli.test.mjs'):window;
25
+ if(selected.length===0)throw new Error('batch split is empty');
26
+ const sha=s=>createHash('sha256').update(s).digest('hex');
27
+ const identity={schema:'deadbyte.r67-durable-test-batch.v1',batch_index:index,batch_count:total,total_test_files:tests.length,test_files:selected,split_mode:mode,candidate_root:root,started_at_utc:start};
28
+ const staged=await open(file,'wx',0o600);
29
+ try{await staged.writeFile(JSON.stringify({...identity,status:'RUNNING'})+'\n');await staged.sync();}finally{await staged.close();}
30
+ const cmd=['--test','--test-concurrency=4',...selected.map(f=>'test/'+f)];
31
+ const result=spawnSync(process.execPath,cmd,{cwd:root,shell:false,windowsHide:true,encoding:'utf8',timeout:mode==='remote'?180000:90000,maxBuffer:24*1024*1024});
32
+ const output=String(result.stdout??''),error=String(result.stderr??'');
33
+ const count=k=>{const matches=[...output.matchAll(new RegExp('(?:^|\n)[#ℹ ]*'+k+'\\s+(\\d+(?:\\.\\d+)?)','g'))];return matches.length?Number(matches[matches.length-1][1]):null;};
34
+ const testsCount=count('tests'),pass=count('pass'),fail=count('fail'),skip=count('skipped');
35
+ const status=result.status===0&&result.error===undefined&&testsCount!==null&&pass!==null&&fail===0?'PASS':(result.error?.code==='ETIMEDOUT'?'TIMED_OUT':'FAIL');
36
+ const completed={...identity,status,finished_at_utc:new Date().toISOString(),exit_code:result.status,timed_out:result.error?.code==='ETIMEDOUT',observed_test_count:testsCount,passed:pass,failed:fail,skipped:skip,stdout_sha256:sha(Buffer.from(output)),stderr_sha256:sha(Buffer.from(error)),...(status==='PASS'?{}:{failure_tail:(output+'\n'+error).slice(-3500)})};
37
+ const tmp=file+'.finished-'+process.pid;
38
+ const handle=await open(tmp,'wx',0o600);
39
+ try{await handle.writeFile(JSON.stringify(completed,null,2)+'\n');await handle.sync();}finally{await handle.close();}
40
+ await rename(tmp,file);
41
+ console.log(JSON.stringify({batch_index:index,batch_count:total,test_files:selected.length,status,passed:pass,failed:fail,skipped:skip,exit_code:result.status,evidence_path:file},null,2));
42
+ if(status!=='PASS')process.exitCode=1;
@@ -0,0 +1,58 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {readFile,lstat} from 'node:fs/promises';
3
+ import {spawnSync} from 'node:child_process';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {parseR67TapSummary} from '../src/r67-regression-shards.mjs';
7
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
8
+ const hash=b=>createHash('sha256').update(b).digest('hex');
9
+ const manifest=JSON.parse(await readFile(path.join(root,'docs','R67-NATIVE-INSPECT-BINARY.json'),'utf8'));
10
+ const binary=path.join(root,manifest.exe);
11
+ const info=await lstat(binary);
12
+ if(manifest.schema!=='deadbyte.r67-native-inspector-binary.v1'||!info.isFile()||info.isSymbolicLink()||hash(await readFile(binary))!==manifest.sha256)throw new Error('R67 native observer hash pin invalid');
13
+ const specs=[
14
+ 'test/r67-native-inspector.test.mjs',
15
+ 'test/r67-signed-receipt.test.mjs',
16
+ 'test/r67-cli-integration.test.mjs',
17
+ 'test/r67-diagnostics.test.mjs',
18
+ 'test/r67-diagnostics-cli.test.mjs',
19
+ 'test/r67-diagnostics-zip-oracle.test.mjs',
20
+ 'test/r67-diagnostics-verify.test.mjs',
21
+ 'test/r67-regression-shards.test.mjs',
22
+ 'test/r67-evidence-reconcile.test.mjs',
23
+ 'test/r67-skip-rationale.test.mjs',
24
+ 'test/r67-runtime-observation-binding.test.mjs',
25
+ 'test/r67-native-observation-authority.test.mjs',
26
+ 'test/r67-server-observation-wiring.test.mjs',
27
+ 'test/r67-machine-fs-smoke-epoch.test.mjs',
28
+ 'test/r67-isolated-slot-rollback-restore.test.mjs',
29
+ 'test/r65-epoch-native-activation-integration.test.mjs',
30
+ 'test/machine-identity.test.mjs',
31
+ 'test/r67-tool-annotations.test.mjs',
32
+ 'test/remote-live-log-r36.test.mjs',
33
+ 'test/remote-live-log-r37.test.mjs',
34
+ 'test/r67-live-log-secret-canary.test.mjs',
35
+ 'test/r51-live-log-polling.test.mjs',
36
+ 'test/cli-entrypoint.test.mjs',
37
+ 'test/observation-runtime.test.mjs',
38
+ 'test/observation-mcp-tools.test.mjs',
39
+ 'test/windows-observation-r48.test.mjs',
40
+ 'test/r67-release-contract.test.mjs',
41
+ 'test/r67-npm-cross-volume.test.mjs',
42
+ 'test/r67-npm-publish-gate.test.mjs',
43
+ 'test/r65-npm-publication.test.mjs'
44
+ ];
45
+ const args=['--test','--test-concurrency=1',...specs];
46
+ const result=spawnSync(process.execPath,args,{cwd:root,encoding:'utf8',windowsHide:true,shell:false,timeout:180000,maxBuffer:16*1024*1024});
47
+ const stdout=String(result.stdout??'');
48
+ const stderr=String(result.stderr??'');
49
+ const tap=parseR67TapSummary(stdout);
50
+ const counts=tap?{tests:tap.tests,pass:tap.pass,fail:tap.fail,skipped:tap.skipped,cancelled:tap.cancelled,todo:tap.todo}:null;
51
+ const complete=Boolean(tap&&tap.tests>=specs.length&&tap.fail===0&&tap.skipped===0&&tap.cancelled===0&&tap.todo===0&&result.status===0&&!result.error);
52
+ const receipt={schema:'deadbyte.r67-focused-gate.v1',status:complete?'pass':'fail',
53
+ candidate_version:'0.15.44-draft',predecessor_manifest_sha256:'4c4a64a4c8e9f5a6e9eecce85fd0007ebcac99121b29c07f1a1fc81d1643cd33',
54
+ native_exe_sha256:manifest.sha256,tests:specs,summary:counts,exit_code:result.status,timed_out:result.error?.code==='ETIMEDOUT',
55
+ stdout_sha256:hash(Buffer.from(stdout,'utf8')),stderr_sha256:hash(Buffer.from(stderr,'utf8'))};
56
+ console.log(JSON.stringify(receipt,null,2));
57
+ if(result.status!==0){console.error('TEST_OUTPUT_TAIL\n'+stdout.slice(-15000));console.error('TEST_ERROR_TAIL\n'+stderr.slice(-4000));}
58
+ if(!complete)process.exitCode=1;
@@ -0,0 +1,28 @@
1
+ import {readdir,mkdir,open,rename,lstat} from 'node:fs/promises';
2
+ import {spawnSync} from 'node:child_process';
3
+ import {createHash} from 'node:crypto';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
7
+ const operationId=process.argv[2];
8
+ if(!/^[a-z0-9][a-z0-9._-]{4,63}$/.test(operationId??''))throw new Error('unique operation ID required');
9
+ const evidence=path.resolve(root,'..','..','testing','0.15.44-r67','regression');
10
+ await mkdir(evidence,{recursive:true});
11
+ const finalFile=path.join(evidence,operationId+'.json');
12
+ try{await lstat(finalFile);throw new Error('operation already completed; reconcile receipt, never rerun');}
13
+ catch(e){if(e.code!=='ENOENT')throw e;}
14
+ const names=(await readdir(path.join(root,'test'))).filter(s=>s.endsWith('.test.mjs')).sort();
15
+ const args=['--test','--test-concurrency=4',...names.map(n=>'test/'+n)];
16
+ const started=Date.now();
17
+ const r=spawnSync(process.execPath,args,{cwd:root,shell:false,windowsHide:true,encoding:'utf8',maxBuffer:32*1024*1024,timeout:220000});
18
+ const out=String(r.stdout??''),err=String(r.stderr??'');
19
+ const parse=k=>{const m=[...out.matchAll(new RegExp('(?:^|\n)[#ℹ ]*'+k+'\\s+(\\d+(?:\\.\\d+)?)','g'))];return m.length?Number(m[m.length-1][1]):null};
20
+ const sha=b=>createHash('sha256').update(b).digest('hex');
21
+ const body={schema:'deadbyte.r67-full-source-regression.v1',status:r.status===0&&!r.error?'passed':'failed',tests_files:names.length,test_count:parse('tests'),passed:parse('pass'),failed:parse('fail'),skipped:parse('skipped'),exit_code:r.status,timed_out:r.error?.code==='ETIMEDOUT',elapsed_ms:Date.now()-started,stdout_sha256:sha(Buffer.from(out)),stderr_sha256:sha(Buffer.from(err))};
22
+ const receipt={...body,operation_id:operationId,started_at_utc:new Date(started).toISOString(),finished_at_utc:new Date().toISOString(),test_names_sha256:sha(Buffer.from(JSON.stringify(names)))};
23
+ const tmp=path.join(evidence,operationId+'.tmp-'+process.pid);
24
+ const handle=await open(tmp,'wx');
25
+ try{await handle.writeFile(JSON.stringify(receipt,null,2)+'\\n');await handle.sync();}finally{await handle.close();}
26
+ await rename(tmp,finalFile);
27
+ console.log(JSON.stringify({receipt,receipt_path:finalFile},null,2));
28
+ if(body.status!=='passed'){console.error('FULL_TEST_OUTPUT_TAIL\n'+out.slice(-18000));console.error('FULL_TEST_ERROR_TAIL\n'+err.slice(-4000));process.exitCode=1;}
@@ -0,0 +1,36 @@
1
+ import {createHash,createPublicKey,verify as edVerify} from 'node:crypto';
2
+ const h=b=>createHash('sha256').update(b).digest('hex');
3
+ function stable(v){
4
+ if(v===null||typeof v!=='object')return JSON.stringify(v);
5
+ if(Array.isArray(v))return '['+v.map(stable).join(',')+']';
6
+ return '{'+Object.keys(v).sort().map(k=>JSON.stringify(k)+':'+stable(v[k])).join(',')+'}';
7
+ }
8
+ const hex=x=>typeof x==='string'&&/^[a-f0-9]{64}$/.test(x);
9
+ const canonicalHash=v=>h(Buffer.from(stable(v),'utf8'));
10
+ export function independentlyVerifyR67Receipt({receipt,result,trustedPublicSpkiBase64,requestArgs,expectedExecutableSha256}){
11
+ try{
12
+ if(!receipt||receipt.schema!=='deadbyte.native-observation-receipt.r67.v1')return {ok:false,reason:'invalid receipt schema'};
13
+ if(typeof trustedPublicSpkiBase64!=='string')return {ok:false,reason:'trusted public key required'};
14
+ const spki=Buffer.from(trustedPublicSpkiBase64,'base64');
15
+ if(spki.toString('base64')!==trustedPublicSpkiBase64)return {ok:false,reason:'bad base64 public key'};
16
+ const trust=h(spki);
17
+ if(receipt.signer_key_id!==trust||receipt.attestation?.key_id!==trust||receipt.attestation.algorithm!=='ed25519')return {ok:false,reason:'signer is not trusted'};
18
+ if(!hex(receipt.request_sha256)||!hex(receipt.executable_sha256)||!hex(receipt.result_sha256)||!hex(receipt.receipt_sha256))return {ok:false,reason:'binding malformed'};
19
+ if(!['process','identity','map','pe'].includes(receipt.operation))return {ok:false,reason:'invalid operation'};
20
+ if(!Array.isArray(requestArgs)||requestArgs.some(x=>typeof x!=='string')||receipt.request_sha256!==h(Buffer.from(JSON.stringify(requestArgs),'utf8')))return {ok:false,reason:'request args mismatch'};
21
+ if(!hex(expectedExecutableSha256)||receipt.executable_sha256!==expectedExecutableSha256)return {ok:false,reason:'trusted executable mismatch'};
22
+ if(!['ok','failed'].includes(receipt.result_status)||receipt.result_status!==result?.status)return {ok:false,reason:'result status mismatch'};
23
+ if(result.schema!=='deadbyte.native-inspect.r67.v1'||(result.status==='ok'&&(result.operation!==receipt.operation||result.data_sha256!==h(Buffer.from(JSON.stringify(result.data),'utf8')))))return {ok:false,reason:'result invalid'};
24
+ if(receipt.result_sha256!==canonicalHash(result))return {ok:false,reason:'result SHA mismatch'};
25
+ const {attestation,...signed}=receipt;
26
+ const {receipt_sha256,...body}=signed;
27
+ if(canonicalHash(body)!==receipt_sha256)return {ok:false,reason:'receipt SHA mismatch'};
28
+ const signature=Buffer.from(attestation.signature_base64,'base64');
29
+ if(signature.length!==64||signature.toString('base64')!==attestation.signature_base64)return {ok:false,reason:'signature encoding invalid'};
30
+ const pub=createPublicKey({key:spki,format:'der',type:'spki'});
31
+ if(pub.asymmetricKeyType!=='ed25519')return {ok:false,reason:'not Ed25519'};
32
+ const message=Buffer.concat([Buffer.from('DEADBYTE-R67-OBSERVATION-V1\0','utf8'),Buffer.from(stable(signed),'utf8')]);
33
+ if(!edVerify(null,message,pub,signature))return {ok:false,reason:'signature invalid'};
34
+ return {ok:true,signature_valid:true,receipt_sha256,result_sha256:receipt.result_sha256,signer_key_id:trust};
35
+ }catch(error){return {ok:false,reason:String(error?.message||error)};}
36
+ }
@@ -0,0 +1,63 @@
1
+ import {createHash,createPublicKey,verify as ed25519Verify} from 'node:crypto';
2
+ import {nativeInspectArgs} from '../src/native-inspector-r67.mjs';
3
+ const sha=b=>createHash('sha256').update(b).digest('hex');
4
+ const hex64=x=>typeof x==='string'&&/^[a-f0-9]{64}$/.test(x);
5
+ const domain=Buffer.from('DEADBYTE-R67-MACHINE-OBSERVATION-V1\0','utf8');
6
+ function serialize(v){
7
+ const canon=value=>Array.isArray(value)?value.map(canon):
8
+ value!==null&&typeof value==='object'?Object.fromEntries(Object.keys(value).sort().map(k=>[k,canon(value[k])])):value;
9
+ return JSON.stringify(canon(v));
10
+ }
11
+ export function independentlyVerifyR67RuntimeObservation({
12
+ receipt,result,requestArgs,machinePublicSpkiBase64,expectedMachineStatus,
13
+ expectedPolicySha256,expectedGrantId
14
+ }={}){
15
+ try{
16
+ if(!receipt||!result||!Array.isArray(requestArgs)||!expectedMachineStatus)return {ok:false,reason:'missing binding'};
17
+ if(receipt.schema!=='deadbyte.native-observation-runtime-r67.v1')return {ok:false,reason:'schema'};
18
+ if(!hex64(receipt.machine_id)||!hex64(receipt.request_sha256)||!hex64(receipt.result_sha256)||
19
+ !hex64(receipt.executable_sha256)||!hex64(receipt.generation_manifest_sha256)||
20
+ !hex64(receipt.release_manifest_sha256)||!hex64(receipt.online_epoch))return {ok:false,reason:'digest or generation'};
21
+ if(!Number.isInteger(receipt.identity_generation)||receipt.identity_generation<1||
22
+ !Number.isFinite(new Date(receipt.observed_at_utc).getTime())||
23
+ new Date(receipt.observed_at_utc).toISOString()!==receipt.observed_at_utc)return {ok:false,reason:'identity generation or timestamp'};
24
+ if(typeof machinePublicSpkiBase64!=='string'||Buffer.from(machinePublicSpkiBase64,'base64').toString('base64')!==machinePublicSpkiBase64)
25
+ return {ok:false,reason:'public key encoding'};
26
+ const der=Buffer.from(machinePublicSpkiBase64,'base64');
27
+ const key=createPublicKey({key:der,format:'der',type:'spki'});
28
+ if(key.asymmetricKeyType!=='ed25519'||sha(der)!==receipt.machine_id)return {ok:false,reason:'wrong machine key'};
29
+ for(const field of ['machine_id','identity_generation','online_epoch','release_id','release_manifest_sha256','generation_manifest_sha256'])
30
+ if(receipt[field]!==expectedMachineStatus[field])return {ok:false,reason:'runtime identity, release or generation changed'};
31
+ if(expectedMachineStatus.public_key_spki_base64!==machinePublicSpkiBase64)return {ok:false,reason:'status key changed'};
32
+ if(!hex64(expectedPolicySha256)||receipt.authority?.policy_sha256!==expectedPolicySha256||
33
+ receipt.authority?.grant_id!==expectedGrantId||
34
+ receipt.authority?.scope!=='native-observe-readonly'||
35
+ !Number.isSafeInteger(receipt.authority?.authority_generation)||
36
+ receipt.authority.authority_generation<1)return {ok:false,reason:'authority'};
37
+ if(Object.keys(receipt.authority).sort().join('|')!==['authority_generation','grant_id','policy_sha256','scope'].sort().join('|'))
38
+ return {ok:false,reason:'unexpected authority fields'};
39
+ const nativeArgs=nativeInspectArgs(requestArgs);
40
+ if(receipt.operation!==nativeArgs[0]||receipt.request_sha256!==sha(Buffer.from(JSON.stringify(nativeArgs),'utf8')))
41
+ return {ok:false,reason:'wrong native request'};
42
+ if(result.schema!=='deadbyte.native-inspect.r67.v1'||!['ok','failed'].includes(result.status)||
43
+ receipt.result_status!==result.status||receipt.result_sha256!==sha(Buffer.from(serialize(result),'utf8')))
44
+ return {ok:false,reason:'native result hash'};
45
+ if(result.status==='ok'&&(result.operation!==nativeArgs[0]||!result.data||
46
+ result.data_sha256!==sha(Buffer.from(JSON.stringify(result.data),'utf8'))))
47
+ return {ok:false,reason:'invalid native data digest'};
48
+ const att=receipt.attestation;
49
+ if(att?.algorithm!=='ed25519'||att.key_id!==receipt.machine_id||
50
+ typeof att.signature_base64!=='string')return {ok:false,reason:'attestation'};
51
+ const signature=Buffer.from(att.signature_base64,'base64');
52
+ if(signature.length!==64||signature.toString('base64')!==att.signature_base64)return {ok:false,reason:'signature encoding'};
53
+ const {attestation,...body}=receipt;
54
+ const keys=['schema','observed_at_utc','machine_id','identity_generation','online_epoch','release_id',
55
+ 'release_manifest_sha256','generation_manifest_sha256','authority','operation','request_sha256',
56
+ 'executable_sha256','result_status','result_sha256'];
57
+ if(Object.keys(body).sort().join('|')!==keys.sort().join('|'))return {ok:false,reason:'unexpected body fields'};
58
+ const valid=ed25519Verify(null,Buffer.concat([domain,Buffer.from(serialize(body),'utf8')]),key,signature);
59
+ if(!valid)return {ok:false,reason:'signature invalid'};
60
+ return {ok:true,signature_valid:true,signer_key_id:receipt.machine_id,
61
+ release_id:receipt.release_id,generation_manifest_sha256:receipt.generation_manifest_sha256};
62
+ }catch(e){return {ok:false,reason:'verification failed: '+String(e?.message||e)};}
63
+ }
@@ -0,0 +1,20 @@
1
+ import {readFile,writeFile,mkdir} from 'node:fs/promises';
2
+ import {createHash} from 'node:crypto';
3
+ import path from 'node:path';
4
+ const base=process.cwd();
5
+ const source=path.resolve(base,'..','..','testing','0.15.44-r67','R67-NONPASS-SOURCE-AUDIT-20261011.json');
6
+ const output=path.resolve(base,'..','..','testing','0.15.44-r67','R67-NONPASS-ADJUDICATION-CANDIDATE.json');
7
+ const x=JSON.parse(await readFile(source,'utf8'));
8
+ if(x.schema!=='deadbyte.r67-nonpass-source-audit.v1'||x.count!==42||x.cases.length!==42)throw Error('Unexpected source audit');
9
+ const rows=x.cases.map((item,index)=>{
10
+ const candidates=(item.source_matches??[]).filter(m=>typeof m.context==='string');
11
+ const conditions=candidates.map(m=>({file:m.file,line:m.line,version_guard:/skip:\s*currentPackage\.version\s*!==\s*['"]([0-9.]+)['"]/.exec(m.context)?.[1]??null,explicit_skip:/\btest\.skip\s*\(/.test(m.context),historical_skip:/skipHistorical\s*\(/.test(m.context)}));
12
+ const reason=item.reason?{kind:'SOURCE_REPORTED',text:item.reason}:{kind:'UNCLASSIFIED',text:null};
13
+ return {index,shard:item.shard,name:item.name,source_reported_reason:reason,source_matches:conditions,
14
+ evidence_level:item.reason?'SOURCE_LOG_REASON_ONLY':'NO_PER_CASE_REASON',
15
+ release_gate:'BLOCKED_UNTIL_CASE_LEVEL_PROVENANCE'};
16
+ });
17
+ const counts={cases:rows.length,source_reported_reasons:rows.filter(r=>r.source_reported_reason.kind==='SOURCE_REPORTED').length,unclassified:rows.filter(r=>r.source_reported_reason.kind==='UNCLASSIFIED').length,version_guard_candidates:rows.filter(r=>r.source_matches.some(m=>m.version_guard)).length,explicit_skip_candidates:rows.filter(r=>r.source_matches.some(m=>m.explicit_skip)).length};
18
+ const data={schema:'deadbyte.r67-nonpass-adjudication.v1',status:'BLOCKED_NONPASS_CLASSIFICATION',source_audit_sha256:createHash('sha256').update(await readFile(source)).digest('hex'),counts,rows};
19
+ await writeFile(output,JSON.stringify(data,null,2)+'\n',{flag:'wx'});
20
+ console.log(JSON.stringify({status:data.status,counts,output}));
@@ -0,0 +1,32 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {readFile,lstat} from 'node:fs/promises';
3
+ import {resolveStateRoot} from '../src/state-root.mjs';
4
+ import {fileURLToPath} from 'node:url';
5
+ import path from 'node:path';
6
+
7
+ const root=path.resolve(fileURLToPath(new URL('..',import.meta.url)));
8
+ const version=JSON.parse(await readFile(path.join(root,'package.json'),'utf8')).version;
9
+ const basename='deadbyte-mcp-'+version+'.tgz';
10
+ const pubDir=path.join(resolveStateRoot(),'evidence','npm-publication',version);
11
+ const paths={
12
+ source:path.join(root,basename),
13
+ preserved:path.join(pubDir,basename),
14
+ claim:path.join(pubDir,'claim.json')
15
+ };
16
+ const outputs={};
17
+ for(const [kind,p] of Object.entries(paths)){
18
+ try{
19
+ const s=await lstat(p);
20
+ if(!s.isFile()||s.isSymbolicLink()){outputs[kind]={state:'NON_REGULAR_OR_LINK'};continue;}
21
+ const bytes=await readFile(p);
22
+ outputs[kind]={state:'EXISTS',bytes:bytes.length,sha256:createHash('sha256').update(bytes).digest('hex')};
23
+ if(kind==='claim'){
24
+ try{const j=JSON.parse(bytes.toString('utf8'));outputs[kind].schema=j.schema;outputs[kind].version=j.version;outputs[kind].manifest_sha256=j.manifest_sha256;outputs[kind].tarball_sha256=j.tarball_sha256;}
25
+ catch{outputs[kind].parse_error=true;}
26
+ }
27
+ }catch(e){if(e?.code==='ENOENT')outputs[kind]={state:'ABSENT'};else throw e;}
28
+ }
29
+ console.log(JSON.stringify({schema:'deadbyte.r67-publication-boundary-audit.v1',
30
+ version,production_mutation:false,network_access:false,publication_dispatch:false,
31
+ artifacts:outputs,conclusion:outputs.claim.state==='EXISTS'?'CLAIM_EXISTS_RECONCILE_BEFORE_ANY_DISPATCH':
32
+ 'NO_LOCAL_CLAIM_OBSERVED_DO_NOT_ASSUME_REGISTRY_STATE'},null,2));
@@ -0,0 +1,10 @@
1
+ import path from 'node:path';
2
+ import {fileURLToPath} from 'node:url';
3
+ import {reconcileR67Evidence} from '../src/r67-evidence-reconcile.mjs';
4
+
5
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
6
+ const operationId=process.argv[2];
7
+ const evidenceRoot=path.resolve(root,'..','..','testing','0.15.44-r67','regression-shards');
8
+ const result=await reconcileR67Evidence({root,evidenceRoot,operationId});
9
+ console.log(JSON.stringify(result,null,2));
10
+ if(result.status!=='PASS')process.exitCode=2;
@@ -0,0 +1,70 @@
1
+ import {readdir,mkdir,open,readFile,rename} from 'node:fs/promises';
2
+ import {spawnSync} from 'node:child_process';
3
+ import {createHash} from 'node:crypto';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {createR67ShardPlan,r67ShardTimeoutMs,r67RegressionTreeHash,parseR67TapSummary,parseR67NonpassCases,parseR67FailedCases} from '../src/r67-regression-shards.mjs';
7
+
8
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
9
+ const action=process.argv[2],operation=process.argv[3],number=process.argv[4];
10
+ if(!['run','status'].includes(action)||!/^[a-z0-9][a-z0-9._-]{5,63}$/.test(operation??'')||!/^(?:0|[1-9][0-9]?)$/.test(number??''))throw new Error('usage: run|status uniqueOperationId index');
11
+ const index=Number(number);
12
+ if(index>=32)throw new Error('R67 shard index must be 0..31');
13
+ const names=(await readdir(path.join(root,'test'))).filter(n=>n.endsWith('.test.mjs')).map(n=>'test/'+n).sort();
14
+ const plan=createR67ShardPlan(names,32),shard=plan.shards[index];
15
+ const hash=b=>createHash('sha256').update(b).digest('hex');
16
+ const evidenceRoot=path.resolve(root,'..','..','testing','0.15.44-r67','regression-shards');
17
+ const directory=path.join(evidenceRoot,operation+'-shard-'+String(index).padStart(2,'0'));
18
+ const intentPath=path.join(directory,'intent.json'),resultPath=path.join(directory,'result.json');
19
+ if(action==='status'){
20
+ let intent,result;
21
+ try{intent=JSON.parse(await readFile(intentPath,'utf8'));}catch(error){if(error.code==='ENOENT'){console.log(JSON.stringify({status:'NOT_STARTED',operation,shard_index:index}));process.exit(0);}throw error;}
22
+ try{result=JSON.parse(await readFile(resultPath,'utf8'));}catch(error){if(error.code==='ENOENT'){console.log(JSON.stringify({status:'RUNNING_OR_OUTCOME_UNKNOWN',operation,shard_index:index,intent}));process.exit(0);}throw error;}
23
+ const {receipt_sha256,...body}=result;
24
+ if(receipt_sha256!==hash(Buffer.from(JSON.stringify(body),'utf8')))throw new Error('durable result receipt hash mismatch');
25
+ console.log(JSON.stringify({status:'COMPLETED_RECORD',operation,shard_index:index,result},null,2));
26
+ process.exit(0);
27
+ }
28
+ await mkdir(evidenceRoot,{recursive:true});
29
+ await mkdir(directory,{recursive:false}); // EEXIST means NEVER rerun: reconcile existing intent/result
30
+ const startedAt=new Date().toISOString();
31
+ const fileHashes=[];
32
+ for(const name of names)fileHashes.push([name,hash(await readFile(path.join(root,name)))]);
33
+ const test_tree_sha256=hash(Buffer.from(JSON.stringify(fileHashes),'utf8'));
34
+ const sourceTree=await r67RegressionTreeHash(root);
35
+ const intent={schema:'deadbyte.r67-shard-intent.v1',operation,shard_index:index,plan_sha256:plan.plan_sha256,
36
+ files_sha256:shard.files_sha256,test_tree_sha256,source_tree_sha256:sourceTree.sha256,
37
+ source_file_count:sourceTree.file_count,started_at_utc:startedAt,files:shard.files};
38
+ const intentHandle=await open(intentPath,'wx',0o600);
39
+ try{await intentHandle.writeFile(JSON.stringify(intent,null,2)+'\n');await intentHandle.sync();}finally{await intentHandle.close();}
40
+ const began=Date.now();
41
+ const configuredTimeoutMs=r67ShardTimeoutMs(shard);
42
+ const child=spawnSync(process.execPath,['--test','--test-reporter=tap','--test-concurrency=2',...shard.files],{
43
+ cwd:root,encoding:'utf8',windowsHide:true,shell:false,timeout:configuredTimeoutMs,maxBuffer:16*1024*1024
44
+ });
45
+ const output=String(child.stdout||''),stderr=String(child.stderr||'');
46
+ const tap=parseR67TapSummary(output);
47
+ const nonpass=parseR67NonpassCases(output);
48
+ const failures=parseR67FailedCases(output);
49
+ const testCount=tap?.tests??null,passed=tap?.pass??null,failed=tap?.fail??null;
50
+ let status='OUTCOME_UNKNOWN';
51
+ if(!child.error&&Number.isInteger(child.status)&&tap!==null){
52
+ status=(child.status===0&&failed===0&&testCount>=shard.files.length)?'PASS':'FAILED';
53
+ }
54
+ const body={schema:'deadbyte.r67-shard-result.v2',operation_id:operation,shard_index:index,
55
+ plan_sha256:plan.plan_sha256,files_sha256:shard.files_sha256,test_tree_sha256,
56
+ source_tree_sha256:sourceTree.sha256,source_file_count:sourceTree.file_count,
57
+ status,exit_code:child.status,test_count:testCount,passed,failed,
58
+ skipped:tap?.skipped??null,cancelled:tap?.cancelled??null,todo:tap?.todo??null,
59
+ ...(nonpass?{nonpass_cases:nonpass.cases,nonpass_fully_classified:nonpass.fully_classified}:{}),
60
+ failure_cases:failures.cases,failure_cases_complete:failures.complete,
61
+ timed_out:child.error?.code==='ETIMEDOUT',failure_reason:child.error?.code??null,
62
+ elapsed_ms:Date.now()-began,configured_timeout_ms:configuredTimeoutMs,finished_at_utc:new Date().toISOString(),
63
+ stdout_sha256:hash(Buffer.from(output,'utf8')),stderr_sha256:hash(Buffer.from(stderr,'utf8'))};
64
+ const receipt={...body,receipt_sha256:hash(Buffer.from(JSON.stringify(body),'utf8'))};
65
+ const temporary=path.join(directory,'result.tmp-'+process.pid);
66
+ const h=await open(temporary,'wx',0o600);
67
+ try{await h.writeFile(JSON.stringify(receipt,null,2)+'\n');await h.sync();}finally{await h.close();}
68
+ await rename(temporary,resultPath);
69
+ console.log(JSON.stringify({status,receipt_path:resultPath,receipt},null,2));
70
+ if(status!=='PASS')process.exitCode=1;