deadbyte-mcp 0.15.43 → 0.15.45

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 (247) hide show
  1. package/MANIFEST.SHA256 +160 -161
  2. package/PROVENANCE.json +257 -232
  3. package/README.txt +18 -18
  4. package/RELEASE.json +348 -320
  5. package/SBOM.cdx.json +14 -2
  6. package/TEST-MATRIX.json +503 -460
  7. package/bin/deadbyte-native-inspect-r67.exe +0 -0
  8. package/bridge/package.json +1 -1
  9. package/controller/deadbyte-controller.ps1 +1857 -1769
  10. package/controller/deadbyte-desktop-policy.json +6 -6
  11. package/controller/deadbyte-process-policy.json +4 -4
  12. package/docs/R67-ALPHA-REFERENCE-DIFFERENTIAL.md +42 -0
  13. package/docs/R67-ALPHA-STATIC-COMPARISON.json +205 -0
  14. package/docs/R67-CANDIDATE-PARENT.json +10 -0
  15. package/docs/R67-EVIDENCE-RECONCILE-CLOSEOUT-20261011.md +64 -0
  16. package/docs/R67-FULL-REGRESSION-UNKNOWN.json +27 -0
  17. package/docs/R67-NATIVE-INSPECT-BINARY.json +11 -0
  18. package/docs/R67-NPM-EXDEV-PRESERVATION-20261011.md +39 -0
  19. package/docs/R67-OBSERVATION-TRUTH.md +82 -0
  20. package/docs/R67-REFERENCE-GAP-MATRIX.json +57 -0
  21. package/docs/R67-REGRESSION-CLOSURE-20261011.md +24 -0
  22. package/docs/R68-COMPAT-HOST-EXEC-CANDIDATE.md +63 -0
  23. package/docs/R69-LIVE-OUTCOME-R70-POLICY-TRANSFER.md +136 -0
  24. package/docs/R70-CODING-DIGEST-SUPERVISOR-CHECKPOINT-20261013.md +42 -0
  25. package/docs/R70-FINITE-GRANT-OWNER-BOUNDARY-20261013.md +80 -0
  26. package/docs/R70-OWNER-BOOTSTRAP-CHECKPOINT-20261013.md +60 -0
  27. package/docs/R70-REFERENCE-MECHANISMS.json +95 -0
  28. package/docs/R70-TRUST-GUARD-EXPIRY-CHECKPOINT-20261013.md +47 -0
  29. package/native/deadbyte-native-inspect-r67.cpp +252 -0
  30. package/package.json +6 -3
  31. package/scripts/benchmark-l0-r71.mjs +76 -0
  32. package/scripts/build-native-inspector-r67.ps1 +28 -0
  33. package/scripts/gate-windows-r67.ps1 +56 -0
  34. package/scripts/gate-windows-r71.ps1 +64 -0
  35. package/scripts/npm-preserve-artifact-r67.mjs +99 -0
  36. package/scripts/npm-release-r48.mjs +12 -2
  37. package/scripts/npm-release-readiness-r67.mjs +26 -0
  38. package/scripts/npm-release-readiness-r71.mjs +21 -0
  39. package/scripts/r67-acquire-alpha-reference.mjs +95 -0
  40. package/scripts/r67-audit-nonpass-source.mjs +39 -0
  41. package/scripts/r67-compare-desktop-alpha.mjs +48 -0
  42. package/scripts/r67-diagnose-failed-shard.mjs +23 -0
  43. package/scripts/r67-durable-batch.mjs +42 -0
  44. package/scripts/r67-focused-gate.mjs +58 -0
  45. package/scripts/r67-full-regression.mjs +28 -0
  46. package/scripts/r67-independent-observation-verify.mjs +36 -0
  47. package/scripts/r67-independent-runtime-observation-verify.mjs +63 -0
  48. package/scripts/r67-nonpass-adjudicate.mjs +20 -0
  49. package/scripts/r67-publish-boundary-audit.mjs +32 -0
  50. package/scripts/r67-regression-reconcile.mjs +10 -0
  51. package/scripts/r67-regression-shard-run.mjs +70 -0
  52. package/scripts/r67-run-shard-batch.mjs +18 -0
  53. package/scripts/r67-stage-candidate.mjs +30 -0
  54. package/scripts/r67-verify-parent-ping.mjs +22 -0
  55. package/scripts/release-manifest.mjs +1 -0
  56. package/scripts/verify-r70-full-regression.ps1 +72 -0
  57. package/src/activation-continuity-engine-r65.mjs +2 -1
  58. package/src/authority-continuity-r65.mjs +28 -8
  59. package/src/autonomous-mcp-tools.mjs +1 -1
  60. package/src/autonomous-output-contracts.mjs +4 -1
  61. package/src/autonomous-policy.mjs +54 -7
  62. package/src/autonomous-runtime.mjs +1 -1
  63. package/src/capability-ledger.mjs +1 -1
  64. package/src/capability-resolver.mjs +2 -1
  65. package/src/commander-compat-runtime.mjs +30 -2
  66. package/src/deadbyte-cli.mjs +41 -7
  67. package/src/machine-fs-smoke-client.mjs +13 -5
  68. package/src/machine-identity.mjs +59 -2
  69. package/src/machine-mcp-tools.mjs +8 -0
  70. package/src/mcp-server.mjs +11 -2
  71. package/src/native-diff-v2.mjs +18 -5
  72. package/src/native-diff.mjs +21 -5
  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/r70-owner-approval.mjs +78 -0
  81. package/src/remote-live-log.mjs +62 -24
  82. package/src/remote-result-journal.mjs +1 -1
  83. package/src/runtime-update.mjs +2051 -1891
  84. package/src/tool-audit.mjs +3 -1
  85. package/src/version.mjs +1 -1
  86. package/test/agent-runtime.test.mjs +1 -1
  87. package/test/autonomous-local-supervisor.test.mjs +2 -1
  88. package/test/autonomous-loop.test.mjs +11 -6
  89. package/test/autonomous-output-contract.test.mjs +17 -1
  90. package/test/autonomous-runtime.test.mjs +1 -1
  91. package/test/autonomous-supervisor-integration.test.mjs +2 -1
  92. package/test/capability-resolver.test.mjs +17 -0
  93. package/test/codex-autonomous-r44.test.mjs +1 -1
  94. package/test/coding-plane.test.mjs +1 -1
  95. package/test/commander-compat-runtime.test.mjs +42 -0
  96. package/test/controller-policy-preflight-r59.test.mjs +1 -0
  97. package/test/full-max-catalog-r46.test.mjs +1 -1
  98. package/test/native-diff-topology-r36.test.mjs +35 -2
  99. package/test/native-diff.test.mjs +83 -3
  100. package/test/output-schema.test.mjs +1 -1
  101. package/test/r51-live-log-polling.test.mjs +12 -0
  102. package/test/r53-release-contract.test.mjs +1 -1
  103. package/test/r54-release-contract.test.mjs +1 -1
  104. package/test/r55-release-contract.test.mjs +1 -1
  105. package/test/r56-release-contract.test.mjs +1 -1
  106. package/test/r57-release-contract.test.mjs +1 -1
  107. package/test/r58-bundled-bridge.test.mjs +1 -1
  108. package/test/r58-release-contract.test.mjs +2 -2
  109. package/test/r58-windows-gate.test.mjs +1 -1
  110. package/test/r59-tool-surface-compat.test.mjs +9 -5
  111. package/test/r60-release-contract.test.mjs +3 -3
  112. package/test/r61-release-contract.test.mjs +1 -1
  113. package/test/r62-release-contract.test.mjs +1 -1
  114. package/test/r63-release-contract.test.mjs +1 -1
  115. package/test/r64-release-contract.test.mjs +1 -1
  116. package/test/r65-authority-runtime-epoch.test.mjs +9 -1
  117. package/test/r65-epoch-native-activation-integration.test.mjs +4 -4
  118. package/test/r65-release-contract.test.mjs +1 -1
  119. package/test/r66-release-contract.test.mjs +2 -1
  120. package/test/r67-cli-integration.test.mjs +41 -0
  121. package/test/r67-diagnostics-cli.test.mjs +60 -0
  122. package/test/r67-diagnostics-verify.test.mjs +49 -0
  123. package/test/r67-diagnostics-zip-oracle.test.mjs +38 -0
  124. package/test/r67-diagnostics.test.mjs +60 -0
  125. package/test/r67-evidence-reconcile.test.mjs +186 -0
  126. package/test/r67-isolated-slot-rollback-restore.test.mjs +63 -0
  127. package/test/r67-live-log-secret-canary.test.mjs +44 -0
  128. package/test/r67-machine-fs-smoke-epoch.test.mjs +22 -0
  129. package/test/r67-native-inspector.test.mjs +131 -0
  130. package/test/r67-native-observation-authority.test.mjs +49 -0
  131. package/test/r67-npm-cross-volume.test.mjs +74 -0
  132. package/test/r67-npm-publish-gate.test.mjs +40 -0
  133. package/test/r67-regression-shards.test.mjs +184 -0
  134. package/test/r67-release-contract.test.mjs +45 -0
  135. package/test/r67-runtime-observation-binding.test.mjs +86 -0
  136. package/test/r67-server-observation-wiring.test.mjs +12 -0
  137. package/test/r67-signed-receipt.test.mjs +66 -0
  138. package/test/r67-skip-rationale.test.mjs +31 -0
  139. package/test/r67-tool-annotations.test.mjs +21 -0
  140. package/test/r67-windows-gate-argv.test.mjs +13 -0
  141. package/test/r69-live-outcome.test.mjs +137 -0
  142. package/test/r70-autonomous-grant-expiry.test.mjs +89 -0
  143. package/test/r70-autonomous-policy-bootstrap.test.mjs +166 -0
  144. package/test/r70-controller-autonomous-root.test.mjs +104 -0
  145. package/test/r70-controller-grant-subset.test.mjs +28 -0
  146. package/test/r70-controller-owner-issue-boundary.test.mjs +80 -0
  147. package/test/r70-controller-policy-snapshot.test.mjs +66 -0
  148. package/test/r70-owner-approval.test.mjs +67 -0
  149. package/test/r71-full-verifier-artifact.test.mjs +28 -0
  150. package/test/r71-isolated-slot-rollback-restore.test.mjs +62 -0
  151. package/test/r71-native-diff-mcp-wire.test.mjs +75 -0
  152. package/test/r71-publish-fence.test.mjs +38 -0
  153. package/test/r71-release-identity.test.mjs +31 -0
  154. package/test/release-version.test.mjs +1 -1
  155. package/test/remote-live-log-r36.test.mjs +10 -0
  156. package/test/remote-live-log-r37.test.mjs +29 -0
  157. package/test/remote-result-journal.test.mjs +12 -0
  158. package/test/remote-session-cli.test.mjs +2 -1
  159. package/test/semantic-multilang.test.mjs +1 -1
  160. package/test/standing-grants.test.mjs +2 -2
  161. package/test/tool-audit.test.mjs +14 -0
  162. package/bin/appcontainer-stage.obj +0 -0
  163. package/bin/bootstrap-advapi32.obj +0 -0
  164. package/bin/bootstrap-exitcode.obj +0 -0
  165. package/bin/bootstrap-kernel32.obj +0 -0
  166. package/bin/child-control-probe.obj +0 -0
  167. package/bin/child-control-stage.obj +0 -0
  168. package/bin/contained-reverse-worker.obj +0 -0
  169. package/bin/contained-transform-worker.obj +0 -0
  170. package/bin/containment-probe.obj +0 -0
  171. package/bin/deadbyte-contain.obj +0 -0
  172. package/bin/deadbyte-desktop-input-r40.obj +0 -0
  173. package/bin/deadbyte-desktop-observer-r40.obj +0 -0
  174. package/bin/deadbyte-desktop-uia-r40.obj +0 -0
  175. package/bin/deadbyte-exec.obj +0 -0
  176. package/bin/deadbyte-hardware-observer-r45.obj +0 -0
  177. package/bin/deadbyte-process-host.obj +0 -0
  178. package/bin/deadbyte-tunnel-host.obj +0 -0
  179. package/conpty-input-observer.obj +0 -0
  180. package/miniconpty.obj +0 -0
  181. package/proof/CONTAINMENT-BUILD.txt +0 -163
  182. package/proof/MCP-SMOKE-STATUS.txt +0 -9
  183. package/proof/NODE-SYNTAX.txt +0 -4
  184. package/proof/PROOF.txt +0 -6
  185. package/proof/R34-TASK8-SUPERVISOR-CHECKPOINT.json +0 -29
  186. package/proof/R34-TASK9-MCP-SURFACE-CHECKPOINT.json +0 -28
  187. package/proof/SECRET-SCAN.txt +0 -4
  188. package/proof/SOURCE-GATES.txt +0 -16
  189. package/proof/STATUS.txt +0 -11
  190. package/proof/TARGET-V0313-CONTAINMENT-PASS.sha256 +0 -1
  191. package/proof/TARGET-V0313-CONTAINMENT-PASS.txt +0 -215
  192. package/proof/TARGET-V040-CONTAINED-IPC-FAIL.sha256 +0 -1
  193. package/proof/TARGET-V040-CONTAINED-IPC-FAIL.txt +0 -299
  194. package/proof/TARGET-V041-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  195. package/proof/TARGET-V041-CONTAINED-CREATEPROCESS-203.txt +0 -311
  196. package/proof/TARGET-V042-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  197. package/proof/TARGET-V042-CONTAINED-CREATEPROCESS-203.txt +0 -313
  198. package/proof/TARGET-V043-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  199. package/proof/TARGET-V043-CONTAINED-CREATEPROCESS-203.txt +0 -308
  200. package/proof/TARGET-V044-CONTAINED-PASS.sha256 +0 -1
  201. package/proof/TARGET-V044-CONTAINED-PASS.txt +0 -432
  202. package/proof/TARGET-V045-DUAL-OPERATION-PASS.sha256 +0 -1
  203. package/proof/TARGET-V045-DUAL-OPERATION-PASS.txt +0 -481
  204. package/proof/TARGET-V046-FIXED-EXECUTABLE-REGISTRY-PASS.sha256 +0 -1
  205. package/proof/TARGET-V046-FIXED-EXECUTABLE-REGISTRY-PASS.txt +0 -610
  206. package/proof/TARGET-V047-RUNTIME-MANIFEST-PASS.sha256 +0 -1
  207. package/proof/TARGET-V047-RUNTIME-MANIFEST-PASS.txt +0 -642
  208. package/proof/TARGET-V050-BATCH-GATE-PASS.sha256 +0 -1
  209. package/proof/TARGET-V050-BATCH-GATE-PASS.txt +0 -713
  210. package/proof/TESTS.txt +0 -686
  211. package/proof/TRUST-EPHEMERAL.txt +0 -4
  212. package/proof/V03-FREEZE.txt +0 -27
  213. package/proof/V041-IPC-HOTFIX.txt +0 -16
  214. package/proof/V042-ENV-HOTFIX.txt +0 -15
  215. package/proof/V043-DRIVE-CWD-HOTFIX.txt +0 -14
  216. package/proof/V044-LOCALAPPDATA-HOTFIX.txt +0 -18
  217. package/proof/V045-OPERATION-REGISTRY.txt +0 -7
  218. package/proof/V046-WORKER-REGISTRY.txt +0 -12
  219. package/proof/V047-WORKER-MANIFEST.txt +0 -18
  220. package/proof/V050-BATCH-TRUST-CLOSURE.txt +0 -21
  221. package/proof/V060-ACTIVE-NETWORK-AUTHORITY.txt +0 -29
  222. package/proof/V070-NODE-SYNTAX.txt +0 -36
  223. package/proof/V070-NODE-TESTS.txt +0 -752
  224. package/proof/V070-PACK-DRY-RUN.txt +0 -126
  225. package/proof/V070-SOURCE-GATE.txt +0 -30
  226. package/proof/V070-STATIC-SCAN.txt +0 -4
  227. package/proof/V070-WINDOWS-GATE-PENDING.txt +0 -25
  228. package/proof/V071-NODE-SYNTAX.txt +0 -1
  229. package/proof/V071-NODE-TESTS.txt +0 -796
  230. package/proof/V071-PACK-DRY-RUN.json +0 -656
  231. package/proof/V071-SOURCE-GATE.txt +0 -16
  232. package/proof/V071-WINDOWS-GATE-PENDING.txt +0 -24
  233. package/proof/V073-NODE-SYNTAX.txt +0 -4
  234. package/proof/V073-SOURCE-GATE.txt +0 -21
  235. package/proof/V073-STATIC-SCAN.txt +0 -10
  236. package/proof/V073-WINDOWS-GATE-PENDING.txt +0 -5
  237. package/proof/VERIFY.txt +0 -7
  238. package/proof/WINDOWS-CONTAINED-STATUS.txt +0 -5
  239. package/proof/WINDOWS-CONTAINMENT-STATUS.txt +0 -3
  240. package/proof/commander-closure-20260927/CONTINUATION.json +0 -43
  241. package/proof/commander-closure-20260927/RESULT.json +0 -30
  242. package/proof/commander-closure-20260927/SEARCH-CONTINUATION.json +0 -30
  243. package/proof/commander-closure-20260927/XLS-REFERENCE-PROBE.json +0 -13
  244. package/proof/commander-closure-20260928/DIFFERENTIAL-CHECKPOINT.json +0 -122
  245. package/proof/r59-full-regression-current.json +0 -13
  246. package/proof/r59-full-regression-current.stderr.log +0 -0
  247. package/proof/r59-full-regression-current.stdout.log +0 -1268
@@ -1,7 +1,10 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { reconcileNpmPublication } from './npm-publication-r65.mjs';
4
- import { mkdtemp, readFile, rm, unlink, mkdir, rename } from 'node:fs/promises';
4
+ import { mkdtemp, readFile, rm, unlink, mkdir } from 'node:fs/promises';
5
+ import {preserveNpmTarball,assertVacantPackDestination} from './npm-preserve-artifact-r67.mjs';
6
+ import {assertR67NpmPublishReady} from './npm-release-readiness-r67.mjs';
7
+ import {assertR71NpmPublishReady} from './npm-release-readiness-r71.mjs';
5
8
  import { existsSync } from 'node:fs';
6
9
  import { resolveStateRoot } from '../src/state-root.mjs';
7
10
  import path from 'node:path';
@@ -86,6 +89,8 @@ async function main() {
86
89
  if (provenance.version !== version) {
87
90
  throw new Error(`PROVENANCE.json version mismatch: package=${version} provenance=${provenance.version}`);
88
91
  }
92
+ if (!isVerifyOnly && version==='0.15.44') assertR67NpmPublishReady(release);
93
+ if (!isVerifyOnly && version==='0.15.45') assertR71NpmPublishReady(release);
89
94
  if (release.parent?.release_id !== provenance.parent_release_id ||
90
95
  release.parent?.manifest_sha256 !== provenance.parent_manifest_sha256 ||
91
96
  release.parent?.generation_manifest_sha256 !== provenance.parent_generation_manifest_sha256) {
@@ -113,6 +118,7 @@ async function main() {
113
118
  if(publicationDir)await mkdir(publicationDir,{recursive:true});
114
119
  if(resuming&&!existsSync(preservedTarball))throw new Error('immutable npm publication claim exists but exact local tarball is missing; manual artifact reconciliation required');
115
120
  if(!resuming&&preservedTarball&&existsSync(preservedTarball))throw new Error('unclaimed preserved npm tarball exists; inspect artifact evidence before another pack');
121
+ if(!resuming)await assertVacantPackDestination({root,filename:`deadbyte-mcp-${version}.tgz`});
116
122
  const packed=resuming?null:parseJson(runNpm(['pack', '--json'], { timeout: 180000 }));
117
123
  const packRecord=resuming?{filename:path.basename(preservedTarball)}:(Array.isArray(packed) ? packed[0] : packed?.[pkg.name]);
118
124
  const filename = packRecord?.filename;
@@ -196,7 +202,11 @@ async function main() {
196
202
  return;
197
203
  }
198
204
 
199
- if(!resuming)await rename(tarball,preservedTarball);
205
+ if(!resuming){
206
+ const preserved=await preserveNpmTarball({source:tarball,destination:preservedTarball,
207
+ expectedIntegrity:packRecord.integrity,expectedShasum:packRecord.shasum});
208
+ console.log('Immutable cross-volume artifact preservation verified: '+JSON.stringify(preserved));
209
+ }
200
210
  const publishTarball=preservedTarball;
201
211
  const localBytes = await readFile(publishTarball);
202
212
  const localIntegrity=`sha512-${createHash('sha512').update(localBytes).digest('base64')}`;
@@ -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,21 @@
1
+ /** Publication fence for the exact R71 successor, not an execution receipt. */
2
+ export function assertR71NpmPublishReady(release){
3
+ if(release?.version!=='0.15.45'||release?.train!=='R71'||
4
+ release?.parent?.release_id!=='v0.15.44-9f500af433df3e77'||
5
+ release?.parent?.manifest_sha256!=='9f500af433df3e7778d4f11acf418526d5889f478114c955c8c72c0077a0636e'||
6
+ release?.parent?.generation_manifest_sha256!=='c35f6ccca58083acd53484a983ef401ee18f28b11185cd02c7b1eb3e29028c71'){
7
+ throw new Error('PUBLISH_BLOCKED R71 release or sealed predecessor identity mismatch');
8
+ }
9
+ const state=release.r71_candidate;
10
+ const required={status:'CANDIDATE_SEALED',full_regression:'PASS',manifest:'PASS',
11
+ windows_gate:'PASS',hot_swap:'PASS',package_acceptance:'PASS',
12
+ local_coding_preview:'PASS_CODING_READ_ONLY_NO_AUTONOMOUS_APPLY',
13
+ public_catalog:'PASS_43_TOOLS',signed_public_mcp:'PASS',performance_l0:'PASS'};
14
+ for(const [field,expected] of Object.entries(required)){
15
+ if(state?.[field]!==expected) throw new Error(`PUBLISH_BLOCKED R71 ${field}=${String(state?.[field]??'MISSING')}; require ${expected}`);
16
+ }
17
+ if(!['PASS_OWNER_ENROLLED','DISABLED_FAIL_CLOSED_NO_OWNER_ENROLLMENT'].includes(state?.owner_independent_project_grant)){
18
+ throw new Error('PUBLISH_BLOCKED R71 owner project grant must be proven or explicitly fail-closed disabled');
19
+ }
20
+ return {status:'R71_METADATA_GATES_MATCH',policy:'PUBLISH_REQUIRES_INDEPENDENT_RELEASE_EVIDENCE'};
21
+ }
@@ -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;