deadbyte-mcp 0.15.44 → 0.15.46

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 (174) hide show
  1. package/MANIFEST.SHA256 +86 -138
  2. package/PROVENANCE.json +35 -18
  3. package/README.txt +22 -21
  4. package/RELEASE.json +369 -334
  5. package/SBOM.cdx.json +2 -2
  6. package/TEST-MATRIX.json +27 -17
  7. package/bridge/package.json +1 -1
  8. package/controller/deadbyte-controller.ps1 +1871 -1769
  9. package/controller/deadbyte-desktop-policy.json +6 -6
  10. package/controller/deadbyte-process-policy.json +4 -4
  11. package/docs/R68-COMPAT-HOST-EXEC-CANDIDATE.md +63 -0
  12. package/docs/R69-LIVE-OUTCOME-R70-POLICY-TRANSFER.md +136 -0
  13. package/docs/R70-CODING-DIGEST-SUPERVISOR-CHECKPOINT-20261013.md +42 -0
  14. package/docs/R70-FINITE-GRANT-OWNER-BOUNDARY-20261013.md +80 -0
  15. package/docs/R70-OWNER-BOOTSTRAP-CHECKPOINT-20261013.md +60 -0
  16. package/docs/R70-REFERENCE-MECHANISMS.json +95 -0
  17. package/docs/R70-TRUST-GUARD-EXPIRY-CHECKPOINT-20261013.md +47 -0
  18. package/package.json +2 -2
  19. package/scripts/benchmark-l0-r71.mjs +76 -0
  20. package/scripts/gate-windows-r71.ps1 +64 -0
  21. package/scripts/gate-windows-r72.ps1 +76 -0
  22. package/scripts/npm-release-r48.mjs +4 -0
  23. package/scripts/npm-release-readiness-r71.mjs +21 -0
  24. package/scripts/npm-release-readiness-r72.mjs +76 -0
  25. package/scripts/verify-r70-full-regression.ps1 +72 -0
  26. package/src/authority-continuity-r65.mjs +28 -8
  27. package/src/autonomous-mcp-tools.mjs +1 -1
  28. package/src/autonomous-output-contracts.mjs +4 -1
  29. package/src/autonomous-policy.mjs +54 -7
  30. package/src/capability-ledger.mjs +1 -1
  31. package/src/capability-resolver.mjs +2 -1
  32. package/src/commander-compat-runtime.mjs +30 -2
  33. package/src/deadbyte-cli.mjs +722 -719
  34. package/src/launcher-isolation.mjs +58 -0
  35. package/src/native-diff-v2.mjs +18 -5
  36. package/src/native-diff.mjs +21 -5
  37. package/src/r70-owner-approval.mjs +78 -0
  38. package/src/remote-authority.mjs +75 -75
  39. package/src/remote-live-log.mjs +48 -14
  40. package/src/remote-mcp-machine-smoke-client.mjs +84 -84
  41. package/src/remote-result-journal.mjs +1 -1
  42. package/src/runtime-update.mjs +232 -24
  43. package/src/staging-input-isolation.mjs +79 -0
  44. package/src/tool-audit.mjs +2 -0
  45. package/src/version.mjs +1 -1
  46. package/test/autonomous-local-supervisor.test.mjs +2 -1
  47. package/test/autonomous-output-contract.test.mjs +17 -1
  48. package/test/autonomous-supervisor-integration.test.mjs +2 -1
  49. package/test/capability-resolver.test.mjs +17 -0
  50. package/test/codex-autonomous-r44.test.mjs +1 -1
  51. package/test/commander-compat-runtime.test.mjs +42 -0
  52. package/test/controller-policy-preflight-r59.test.mjs +1 -0
  53. package/test/deferred-slot-operation-behavior.test.mjs +2 -2
  54. package/test/native-diff-topology-r36.test.mjs +35 -2
  55. package/test/native-diff.test.mjs +83 -3
  56. package/test/r58-cleanup-retention.test.mjs +3 -3
  57. package/test/r58-concurrent-recovery.test.mjs +3 -3
  58. package/test/r58-stale-owner.test.mjs +1 -1
  59. package/test/r59-tool-surface-compat.test.mjs +9 -5
  60. package/test/r60-authority-coherence.test.mjs +10 -2
  61. package/test/r65-authority-runtime-epoch.test.mjs +9 -1
  62. package/test/r67-isolated-slot-rollback-restore.test.mjs +2 -1
  63. package/test/r67-npm-publish-gate.test.mjs +4 -2
  64. package/test/r67-release-contract.test.mjs +8 -7
  65. package/test/r69-live-outcome.test.mjs +137 -0
  66. package/test/r70-autonomous-grant-expiry.test.mjs +89 -0
  67. package/test/r70-autonomous-policy-bootstrap.test.mjs +166 -0
  68. package/test/r70-controller-autonomous-root.test.mjs +104 -0
  69. package/test/r70-controller-grant-subset.test.mjs +28 -0
  70. package/test/r70-controller-owner-issue-boundary.test.mjs +80 -0
  71. package/test/r70-controller-policy-snapshot.test.mjs +66 -0
  72. package/test/r70-owner-approval.test.mjs +67 -0
  73. package/test/r71-full-verifier-artifact.test.mjs +28 -0
  74. package/test/r71-isolated-slot-rollback-restore.test.mjs +62 -0
  75. package/test/r71-native-diff-mcp-wire.test.mjs +75 -0
  76. package/test/r71-publish-fence.test.mjs +38 -0
  77. package/test/r71-release-identity.test.mjs +33 -0
  78. package/test/r72-launcher-isolation.test.mjs +99 -0
  79. package/test/r72-publication-fence.test.mjs +56 -0
  80. package/test/r72-publication-output-integrity.test.mjs +110 -0
  81. package/test/r72-remote-safe-contract.test.mjs +101 -0
  82. package/test/r72-staging-input-isolation.test.mjs +87 -0
  83. package/test/r72-staging-workspace-isolation.test.mjs +114 -0
  84. package/test/remote-result-journal.test.mjs +12 -0
  85. package/test/remote-session-cli.test.mjs +112 -65
  86. package/test/standing-grants.test.mjs +2 -2
  87. package/test/tool-audit.test.mjs +14 -0
  88. package/bin/appcontainer-stage.obj +0 -0
  89. package/bin/bootstrap-advapi32.obj +0 -0
  90. package/bin/bootstrap-exitcode.obj +0 -0
  91. package/bin/bootstrap-kernel32.obj +0 -0
  92. package/bin/child-control-probe.obj +0 -0
  93. package/bin/child-control-stage.obj +0 -0
  94. package/bin/contained-reverse-worker.obj +0 -0
  95. package/bin/contained-transform-worker.obj +0 -0
  96. package/bin/containment-probe.obj +0 -0
  97. package/bin/deadbyte-contain.obj +0 -0
  98. package/bin/deadbyte-desktop-input-r40.obj +0 -0
  99. package/bin/deadbyte-desktop-observer-r40.obj +0 -0
  100. package/bin/deadbyte-desktop-uia-r40.obj +0 -0
  101. package/bin/deadbyte-exec.obj +0 -0
  102. package/bin/deadbyte-hardware-observer-r45.obj +0 -0
  103. package/bin/deadbyte-native-inspect-r67.obj +0 -0
  104. package/bin/deadbyte-process-host.obj +0 -0
  105. package/bin/deadbyte-tunnel-host.obj +0 -0
  106. package/conpty-input-observer.obj +0 -0
  107. package/miniconpty.obj +0 -0
  108. package/proof/CONTAINMENT-BUILD.txt +0 -163
  109. package/proof/MCP-SMOKE-STATUS.txt +0 -9
  110. package/proof/NODE-SYNTAX.txt +0 -4
  111. package/proof/PROOF.txt +0 -6
  112. package/proof/R34-TASK8-SUPERVISOR-CHECKPOINT.json +0 -29
  113. package/proof/R34-TASK9-MCP-SURFACE-CHECKPOINT.json +0 -28
  114. package/proof/SECRET-SCAN.txt +0 -4
  115. package/proof/SOURCE-GATES.txt +0 -16
  116. package/proof/STATUS.txt +0 -11
  117. package/proof/TARGET-V0313-CONTAINMENT-PASS.sha256 +0 -1
  118. package/proof/TARGET-V0313-CONTAINMENT-PASS.txt +0 -215
  119. package/proof/TARGET-V040-CONTAINED-IPC-FAIL.sha256 +0 -1
  120. package/proof/TARGET-V040-CONTAINED-IPC-FAIL.txt +0 -299
  121. package/proof/TARGET-V041-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  122. package/proof/TARGET-V041-CONTAINED-CREATEPROCESS-203.txt +0 -311
  123. package/proof/TARGET-V042-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  124. package/proof/TARGET-V042-CONTAINED-CREATEPROCESS-203.txt +0 -313
  125. package/proof/TARGET-V043-CONTAINED-CREATEPROCESS-203.sha256 +0 -1
  126. package/proof/TARGET-V043-CONTAINED-CREATEPROCESS-203.txt +0 -308
  127. package/proof/TARGET-V044-CONTAINED-PASS.sha256 +0 -1
  128. package/proof/TARGET-V044-CONTAINED-PASS.txt +0 -432
  129. package/proof/TARGET-V045-DUAL-OPERATION-PASS.sha256 +0 -1
  130. package/proof/TARGET-V045-DUAL-OPERATION-PASS.txt +0 -481
  131. package/proof/TARGET-V046-FIXED-EXECUTABLE-REGISTRY-PASS.sha256 +0 -1
  132. package/proof/TARGET-V046-FIXED-EXECUTABLE-REGISTRY-PASS.txt +0 -610
  133. package/proof/TARGET-V047-RUNTIME-MANIFEST-PASS.sha256 +0 -1
  134. package/proof/TARGET-V047-RUNTIME-MANIFEST-PASS.txt +0 -642
  135. package/proof/TARGET-V050-BATCH-GATE-PASS.sha256 +0 -1
  136. package/proof/TARGET-V050-BATCH-GATE-PASS.txt +0 -713
  137. package/proof/TESTS.txt +0 -686
  138. package/proof/TRUST-EPHEMERAL.txt +0 -4
  139. package/proof/V03-FREEZE.txt +0 -27
  140. package/proof/V041-IPC-HOTFIX.txt +0 -16
  141. package/proof/V042-ENV-HOTFIX.txt +0 -15
  142. package/proof/V043-DRIVE-CWD-HOTFIX.txt +0 -14
  143. package/proof/V044-LOCALAPPDATA-HOTFIX.txt +0 -18
  144. package/proof/V045-OPERATION-REGISTRY.txt +0 -7
  145. package/proof/V046-WORKER-REGISTRY.txt +0 -12
  146. package/proof/V047-WORKER-MANIFEST.txt +0 -18
  147. package/proof/V050-BATCH-TRUST-CLOSURE.txt +0 -21
  148. package/proof/V060-ACTIVE-NETWORK-AUTHORITY.txt +0 -29
  149. package/proof/V070-NODE-SYNTAX.txt +0 -36
  150. package/proof/V070-NODE-TESTS.txt +0 -752
  151. package/proof/V070-PACK-DRY-RUN.txt +0 -126
  152. package/proof/V070-SOURCE-GATE.txt +0 -30
  153. package/proof/V070-STATIC-SCAN.txt +0 -4
  154. package/proof/V070-WINDOWS-GATE-PENDING.txt +0 -25
  155. package/proof/V071-NODE-SYNTAX.txt +0 -1
  156. package/proof/V071-NODE-TESTS.txt +0 -796
  157. package/proof/V071-PACK-DRY-RUN.json +0 -656
  158. package/proof/V071-SOURCE-GATE.txt +0 -16
  159. package/proof/V071-WINDOWS-GATE-PENDING.txt +0 -24
  160. package/proof/V073-NODE-SYNTAX.txt +0 -4
  161. package/proof/V073-SOURCE-GATE.txt +0 -21
  162. package/proof/V073-STATIC-SCAN.txt +0 -10
  163. package/proof/V073-WINDOWS-GATE-PENDING.txt +0 -5
  164. package/proof/VERIFY.txt +0 -7
  165. package/proof/WINDOWS-CONTAINED-STATUS.txt +0 -5
  166. package/proof/WINDOWS-CONTAINMENT-STATUS.txt +0 -3
  167. package/proof/commander-closure-20260927/CONTINUATION.json +0 -43
  168. package/proof/commander-closure-20260927/RESULT.json +0 -30
  169. package/proof/commander-closure-20260927/SEARCH-CONTINUATION.json +0 -30
  170. package/proof/commander-closure-20260927/XLS-REFERENCE-PROBE.json +0 -13
  171. package/proof/commander-closure-20260928/DIFFERENTIAL-CHECKPOINT.json +0 -122
  172. package/proof/r59-full-regression-current.json +0 -13
  173. package/proof/r59-full-regression-current.stderr.log +0 -0
  174. package/proof/r59-full-regression-current.stdout.log +0 -1268
@@ -0,0 +1,47 @@
1
+ # R70 owner trust guard + expiring grant checkpoint — 2026-10-13
2
+
3
+ ## Status (candidate only)
4
+ No deploy, npm publish, change to active release, generation switch, owner key enrollment, policy broadening, or new Coding/Autonomous grant. Mutable Windows candidate root:
5
+ `D:\Projects\deadbyte-mcp\development\deadbyte-mcp-0.15.44-r67`
6
+
7
+ Production known-good `v0.15.44-9f500af433df3e77`. Initial active release manifest SHA-256 `9f500af433df3e7778d4f11acf418526d5889f478114c955c8c72c0077a0636e`; generation manifest `c35f6ccca58083acd53484a983ef401ee18f28b11185cd02c7b1eb3e29028c71`.
8
+
9
+ Existing R70 updater approval verifier is NOT equivalent to independent controller owner approval; real trust-anchor enrollment is absent. Existing Coding grant includes broad `local_c`/`local_d`, Autonomous grant remains scoped only to `core`.
10
+
11
+ ## New observed RED->GREEN (verified Windows)
12
+ 1. RED: updater accepts project approval while Coding policy `exec:true` remains enabled, permitting OS-level execution without a filesystem sandbox.
13
+ - Fix `src/runtime-update.mjs`: reject any selected Coding root with `exec:true` in `verifyAutonomousOwnerBootstrap`, while retaining rejection of writable owner-key paths.
14
+ - Focused related Windows policy/controller/updater tests: 59 PASS / 0 FAIL / 0 SKIP; exit code 0, stdout SHA-256 `0f859c250fc9bf31aee6edb89b94a3d0abafc28604ac6287e294c2f515eb90ce`.
15
+ 2. RED: `Arm-Autonomous` accepts arbitrary new project policy and reaches grant creation without owner approval.
16
+ - Controller candidate `controller/deadbyte-controller.ps1` has R70 fail-closed MIGRATION FENCE: exact known-good legacy policy SHA-256 `6274492644c303b38117541cc22a59e88e6ff5fdef7051a5d57ad336f45765f5` with the single `core` root retains existing explicit manual arm route; all successor policy digests and project root selections fail `R70_OWNER_ENROLLMENT_REQUIRED` before any grant writes.
17
+ - `test/r70-controller-owner-issue-boundary.test.mjs`: RED 1 PASS / 1 FAIL, GREEN 2 PASS / 0 FAIL; fake `Ensure-Directory` prevents real grant I/O in the test.
18
+ - Broader Windows regression with 24 test files `r70-*`, `autonomous-*`, `runtime-self-update.test.mjs`: 174 PASS / 0 FAIL / 1 historical SKIP, exit 0, stdout SHA-256 `d0a27d691c5e2268744dc2c97b242581888edf49b64a8f2bd66645cc6a87c9dc`. **This predates the optional-expiry edit below.**
19
+
20
+ ## New expiration RED and unverified candidate edit
21
+ 3. `test/r70-autonomous-grant-expiry.test.mjs`: before change, RED 0 PASS / 2 FAIL: a v2 signed grant with expired `expires_at_utc` was still reported ARMED by controller, and `inspectAutonomousStandingWindow` helper did not exist.
22
+ 4. Candidate edit made AFTER that RED:
23
+ - `src/autonomous-policy.mjs` adds `inspectAutonomousStandingWindow` with canonical UTC, positive lifetime <=1 hour, not-yet-valid/expired/reject cases and calls it before live v2 standing authority validation; grants without `expires_at_utc` retain legacy behavior.
24
+ - `controller/deadbyte-controller.ps1` checks same optional expiry and lifetime before `Get-AuthorityEpochStatus`; legacy without field remains unchanged.
25
+ - **NOT VERIFIED GREEN**. Direct authorized Windows test execution was blocked by the platform safety layer immediately after the edits. Do NOT route via a different executor, claim PASS, freeze, deploy or publish; check this test only if a future normally authorized test execution succeeds. Signed mutation receipts and file hashes alone DO NOT prove runtime test correctness.
26
+ - This optional field has NOT been issued in a real owner-signed grant. Wall-clock rollback resistance and independent controller owner trust are not solved.
27
+
28
+ ## Exact final candidate file hashes (read-only)
29
+ - `src/runtime-update.mjs`: `bcf90f70cfc8316f7d3aac033a772ba8c048061e83e76cacd4a290cc0e307c6c`
30
+ - `src/autonomous-policy.mjs`: `4eb2070a3c25fe5299c42ced065ba652ee0ec95549bb366d46f691e64248f73d`
31
+ - `controller/deadbyte-controller.ps1`: `0f378871888962cc24b0e89873699ecd0de21d0d89fa9147b049765cd21fee1a`
32
+ - `test/r70-autonomous-grant-expiry.test.mjs`: `94a4ca838f4b67a14f1873a5497419e0853306bf60150b5c76024813cc95b85c`
33
+
34
+ ## Byte-identical rollback snapshots
35
+ - `proof/R70-TRUST-EXEC-GUARD-UPDATER-PREIMAGE.mjs.txt` SHA-256 `3328bbbc11a7ee09d8bb4bd88d16626f9160b889511014e82ad480b4fb2e6fd0`
36
+ - `proof/R70-CONTROLLER-OWNER-ISSUE-PREIMAGE.ps1.txt` SHA-256 `f034be2ca85e3380491758cef3efef78121139d2488a5b3407167cbe9bf22b5c`
37
+ - `proof/R70-GRANT-EXPIRY-AUTO-PREIMAGE.mjs.txt` SHA-256 `4df3073b9070617a31068ddf7bdab4bb8b6e669aa843f1f2072650f004f9439e`
38
+ - `proof/R70-GRANT-EXPIRY-CONTROLLER-PREIMAGE.ps1.txt` SHA-256 `1c0b1d8814fcb393fc2658f3586b897688c3df399bf033d5e2c281b70f60e9f4`
39
+ - `proof/R70-TRUST-EXEC-GUARD-TEST-PREIMAGE.mjs.txt` SHA-256 `676eb1a34d50bd4f326064c79ce56c3f3ee333e73a4d949e7f30de3f59820bb8`
40
+
41
+ Restore only with current hash preconditions and signed receipts; never overwrite parallel work. No Git repository metadata in candidate folder.
42
+
43
+ ## Still blocked
44
+ - Real independently held owner signing key and trusted, non-agent-writable owner key enrollment; the public key under stateRoot/trust does not establish this by itself.
45
+ - Positive scoped owner authorization at controller issuance: current R70 fence DENIES new project grants until trustworthy verifier is integrated.
46
+ - Finite grant issuance and authority epoch expiry/revoke test; optional expiry validator source still unverified.
47
+ - Full candidate manifest freeze, full Windows regression, benchmark, immutable hot-swap crash/reconciliation and ChatGPT/MCP remote client round trip.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deadbyte-mcp",
3
- "version": "0.15.44",
3
+ "version": "0.15.46",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Authenticated MCP agentic runtime with signed skills, persistent model backends, identity-bound remote devices, durable job supervision, immutable release slots, and separately revocable machine authority.",
@@ -42,7 +42,7 @@
42
42
  "contained:run": "node src/contained-cli.mjs workspaces/demo input.txt",
43
43
  "contained:smoke": "node src/contained-smoke.mjs",
44
44
  "mcp:contained:smoke": "node src/mcp-contained-smoke-client.mjs",
45
- "gate:windows": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-windows-r67.ps1",
45
+ "gate:windows": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/gate-windows-r72.ps1",
46
46
  "authority:smoke": "node src/authority-smoke.mjs",
47
47
  "mcp:remote:smoke": "node src/remote-mcp-smoke-client.mjs",
48
48
  "mcp:host:smoke": "node src/mcp-host-smoke-client.mjs",
@@ -0,0 +1,76 @@
1
+ import {randomBytes,createHash} from 'node:crypto';
2
+ import {mkdir,mkdtemp,readFile,rm,writeFile} from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {loadCodingPolicy,codingSessionStatus} from '../src/coding-plane.mjs';
7
+ import {createAuthorityEpochStore} from '../src/authority-continuity-r65.mjs';
8
+ import {registerAutonomousTools} from '../src/autonomous-mcp-tools.mjs';
9
+ import {classifyRemoteOperation} from '../bridge/src/remote-dispatch-r60.mjs';
10
+ import {prepareAuthorityTestTrust} from '../test/r65-authority-test-trust.mjs';
11
+
12
+ const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
13
+ const evidenceDir=path.join(root,'testing','r71-l0-benchmark');
14
+ const samples=100_000;
15
+ const warmup=5_000;
16
+ const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
17
+ const percentile=(sorted,p)=>Number(sorted[Math.min(sorted.length-1,Math.ceil(sorted.length*p)-1)]/1e6).toFixed(6);
18
+
19
+ await mkdir(evidenceDir,{recursive:true});
20
+ const state=await mkdtemp(path.join(evidenceDir,'state-'));
21
+ try{
22
+ const runtime=await prepareAuthorityTestTrust(state);
23
+ const project=path.join(state,'project');
24
+ await mkdir(project);
25
+ const policyPath=path.join(state,'coding-policy.json');
26
+ const grantFile=path.join(runtime,'coding-grant.json');
27
+ await writeFile(policyPath,JSON.stringify({schema:'deadbyte.coding-policy.v1',enabled:true,
28
+ lease_file:grantFile,evidence_dir:path.join(state,'evidence'),
29
+ roots:{project:{path:project,read:true,write:false,exec:false,deny_paths:[]}},commands:{}}));
30
+ const policy=await loadCodingPolicy(policyPath);
31
+ const grant={schema:'deadbyte.coding-grant.v2',policy_sha256:policy.policy_sha256,
32
+ instance_nonce:randomBytes(32).toString('hex'),root_ids:['project'],granted_at_utc:new Date().toISOString()};
33
+ await writeFile(grantFile,JSON.stringify(grant));
34
+ const grantBytes=await readFile(grantFile);
35
+ const store=createAuthorityEpochStore({runtimeDir:runtime,policyBytes:await readFile(policyPath)});
36
+ await store.append({plane:'coding',action:'grant',grantBytes,grantInstanceNonce:grant.instance_nonce,updateId:null});
37
+ const contracts=new Map();
38
+ registerAutonomousTools({registerTool:(name,contract)=>contracts.set(name,contract)},
39
+ {autonomousRuntime:{},nativeDiffRuntime:{}});
40
+ const schema=contracts.get('native_diff_preview')?.inputSchema;
41
+ if(!schema)throw new Error('native_diff_preview schema unavailable');
42
+ const request={root_id:'project',title:'L0 read-only probe',operations:[{kind:'write',path:'scratch.txt',
43
+ content:'x',encoding:'utf8',expected_sha256:'absent'}]};
44
+ const observed=new Float64Array(samples);
45
+ const execute=async()=>{
46
+ const parsed=schema.parse(request);
47
+ if(classifyRemoteOperation({name:'native_diff_preview'},parsed)!=='read_only')throw new Error('dispatch classification drift');
48
+ const authority=await codingSessionStatus(policy);
49
+ if(authority.armed!==true||authority.authority_epoch?.trusted!==true||
50
+ !authority.root_ids.includes(parsed.root_id)||policy.roots[parsed.root_id]?.read!==true)
51
+ throw new Error('signed Coding authority decision failed');
52
+ };
53
+ for(let i=0;i<warmup;i++)await execute();
54
+ const started=process.hrtime.bigint();
55
+ for(let i=0;i<samples;i++){
56
+ const tick=process.hrtime.bigint();
57
+ await execute();
58
+ observed[i]=Number(process.hrtime.bigint()-tick);
59
+ }
60
+ const elapsedMs=Number(process.hrtime.bigint()-started)/1e6;
61
+ observed.sort();
62
+ const result={schema:'deadbyte.r71-l0-benchmark.v1',created_at_utc:new Date().toISOString(),
63
+ scope:'native_diff_preview input validation + remote dispatch classification + real isolated signed Coding grant/epoch decision; excludes IPC, filesystem operation, native execution and ChatGPT',
64
+ clock:'process.hrtime.bigint',warmup,samples,elapsed_ms:elapsedMs,
65
+ p50_ms:Number(percentile(observed,0.50)),p95_ms:Number(percentile(observed,0.95)),
66
+ p99_ms:Number(percentile(observed,0.99)),max_ms:Number((observed.at(-1)/1e6).toFixed(6)),
67
+ threshold_p95_ms:1,pass:observed[Math.ceil(samples*0.95)-1]<1e6,
68
+ coding_policy_sha256:policy.policy_sha256,source_manifest_sha256:sha(await readFile(path.join(root,'MANIFEST.SHA256')))};
69
+ const bytes=Buffer.from(JSON.stringify(result)+'\n');
70
+ const output=path.join(evidenceDir,`result-${Date.now()}-${randomBytes(4).toString('hex')}.json`);
71
+ await writeFile(output,bytes,{flag:'wx'});
72
+ process.stdout.write(JSON.stringify({...result,evidence_path:output,evidence_sha256:sha(bytes)})+'\n');
73
+ if(!result.pass)process.exitCode=1;
74
+ }finally{
75
+ await rm(state,{recursive:true,force:true});
76
+ }
@@ -0,0 +1,64 @@
1
+ param(
2
+ [ValidateSet('preflight','focused','full','manifest','doctor','all')]
3
+ [string]$Stage='preflight'
4
+ )
5
+ $ErrorActionPreference='Stop'
6
+ Set-StrictMode -Version Latest
7
+ $root=Split-Path -Parent $PSScriptRoot
8
+ $state=Join-Path $env:USERPROFILE '.deadbyte-mcp'
9
+ $parent=Join-Path $state 'releases\v0.15.44-9f500af433df3e77'
10
+ $expected='9f500af433df3e7778d4f11acf418526d5889f478114c955c8c72c0077a0636e'
11
+ $generation='c35f6ccca58083acd53484a983ef401ee18f28b11185cd02c7b1eb3e29028c71'
12
+ $releaseId='v0.15.44-9f500af433df3e77'
13
+ function Sha256-File([string]$File){
14
+ $algorithm=[System.Security.Cryptography.SHA256]::Create()
15
+ try{
16
+ $stream=[System.IO.File]::OpenRead($File)
17
+ try{return ([BitConverter]::ToString($algorithm.ComputeHash($stream))).Replace('-','').ToLowerInvariant()}
18
+ finally{$stream.Dispose()}
19
+ }finally{$algorithm.Dispose()}
20
+ }
21
+ if(!(Test-Path -LiteralPath $parent -PathType Container)){throw 'R71 sealed predecessor slot missing'}
22
+ if((Sha256-File (Join-Path $parent 'MANIFEST.SHA256')) -ne $expected){throw 'R71 predecessor manifest mismatch'}
23
+ $pointer=Get-Content -LiteralPath (Join-Path $state 'active-release.json') -Raw | ConvertFrom-Json
24
+ if($pointer.release_id -ne $releaseId -or $pointer.manifest_sha256 -ne $expected -or
25
+ $pointer.generation_manifest_sha256 -ne $generation){throw 'R71 active predecessor pointer mismatch'}
26
+ $pkg=Get-Content -LiteralPath (Join-Path $root 'package.json') -Raw | ConvertFrom-Json
27
+ if($pkg.version -ne '0.15.45'){throw 'R71 package version mismatch'}
28
+ Write-Output 'R71_PREDECESSOR_PREFLIGHT=PASS'
29
+ if($Stage -eq 'preflight'){return}
30
+ function Invoke-Node([string]$Label,[string[]]$Arguments){
31
+ Write-Output "R71_STAGE_START=$Label"
32
+ & node @Arguments
33
+ if($LASTEXITCODE -ne 0){throw "R71 stage $Label exit=$LASTEXITCODE"}
34
+ Write-Output "R71_STAGE_PASS=$Label"
35
+ }
36
+ if($Stage -eq 'focused' -or $Stage -eq 'all'){
37
+ Invoke-Node 'focused' @('--test','test/native-diff.test.mjs','test/native-diff-topology-r36.test.mjs',
38
+ 'test/capability-resolver.test.mjs','test/capability-ledger-r36.test.mjs',
39
+ 'test/r70-owner-approval.test.mjs','test/r70-autonomous-policy-bootstrap.test.mjs',
40
+ 'test/r71-publish-fence.test.mjs','test/r71-release-identity.test.mjs',
41
+ 'test/r71-full-verifier-artifact.test.mjs','test/r71-native-diff-mcp-wire.test.mjs')
42
+ if($Stage -eq 'focused'){return}
43
+ }
44
+ if($Stage -eq 'full' -or $Stage -eq 'all'){
45
+ Write-Output 'R71_STAGE_START=full'
46
+ & powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $root 'scripts\verify-r70-full-regression.ps1')
47
+ if($LASTEXITCODE -ne 0){throw "R71 full regression exit=$LASTEXITCODE"}
48
+ Write-Output 'R71_STAGE_PASS=full'
49
+ if($Stage -eq 'full'){return}
50
+ }
51
+ if($Stage -eq 'manifest' -or $Stage -eq 'all'){
52
+ Invoke-Node 'manifest' @('scripts/release-manifest.mjs','verify')
53
+ if($Stage -eq 'manifest'){return}
54
+ }
55
+ if($Stage -eq 'doctor' -or $Stage -eq 'all'){
56
+ $previous=$env:DEADBYTE_STATE_ROOT
57
+ $isolated='D:\Projects\deadbyte-mcp\testing\0.15.45-r71\doctor-isolated-empty'
58
+ if(Test-Path -LiteralPath (Join-Path $isolated 'active-release.json')){throw 'R71 isolated doctor state has an unexpected pointer'}
59
+ try{
60
+ $env:DEADBYTE_STATE_ROOT=$isolated
61
+ Invoke-Node 'isolated-doctor' @('src/deadbyte-cli.mjs','doctor')
62
+ }finally{$env:DEADBYTE_STATE_ROOT=$previous}
63
+ }
64
+ Write-Output 'R71_WINDOWS_GATE=PASS_PREDEPLOY_CANDIDATE'
@@ -0,0 +1,76 @@
1
+ #requires -Version 5.1
2
+ [CmdletBinding()]
3
+ param([ValidateSet('preflight','focused','full','manifest','doctor','all')][string]$Stage='preflight')
4
+ Set-StrictMode -Version Latest
5
+ $ErrorActionPreference='Stop'
6
+ $repo=Split-Path -Parent $PSScriptRoot
7
+ $state=Join-Path $env:USERPROFILE '.deadbyte-mcp'
8
+ $parentId='v0.15.45-34aa8d1241cfb8bf'
9
+ $parentSha='34aa8d1241cfb8bf0b5ba303bf3c06e0e9e1bf01f64457bca659d6dd4d634fdc'
10
+ $parentGen='ff2b73410062688651abd7bc2dd7b2b8c87810a28e3808bfe1f4352a25b0e6e4'
11
+ function Sha([string]$file){
12
+ $sha=[System.Security.Cryptography.SHA256]::Create()
13
+ try {
14
+ $stream=[System.IO.File]::OpenRead($file)
15
+ try {return ([BitConverter]::ToString($sha.ComputeHash($stream))).Replace('-','').ToLowerInvariant()}
16
+ finally {$stream.Dispose()}
17
+ } finally {$sha.Dispose()}
18
+ }
19
+ function Run-Node([string]$label,[string[]]$nodeArgs) {
20
+ Write-Output "R72_STAGE_START=$label"
21
+ & node @nodeArgs
22
+ if($LASTEXITCODE -ne 0){throw "R72_${label}_FAILED exit=$LASTEXITCODE"}
23
+ Write-Output "R72_STAGE_PASS=$label"
24
+ }
25
+ Push-Location $repo
26
+ try {
27
+ $pkg=Get-Content -LiteralPath 'package.json' -Raw | ConvertFrom-Json
28
+ $release=Get-Content -LiteralPath 'RELEASE.json' -Raw | ConvertFrom-Json
29
+ if($pkg.version -ne '0.15.46' -or $release.version -ne '0.15.46' -or $release.train -ne 'R72'){
30
+ throw 'R72_CANDIDATE_VERSION_DRIFT'
31
+ }
32
+ if($release.parent.release_id -ne $parentId -or $release.parent.manifest_sha256 -ne $parentSha -or
33
+ $release.parent.generation_manifest_sha256 -ne $parentGen){throw 'R72_PARENT_IDENTITY_DRIFT'}
34
+ $parentRoot=Join-Path $state "releases\$parentId"
35
+ if(-not (Test-Path -LiteralPath $parentRoot -PathType Container)){throw 'R72_PARENT_SLOT_MISSING'}
36
+ if((Sha (Join-Path $parentRoot 'MANIFEST.SHA256')) -ne $parentSha){throw 'R72_PARENT_MANIFEST_MISMATCH'}
37
+ $active=Get-Content -LiteralPath (Join-Path $state 'active-release.json') -Raw | ConvertFrom-Json
38
+ if($active.version -ne '0.15.45' -or $active.release_id -ne $parentId -or
39
+ $active.manifest_sha256 -ne $parentSha -or $active.generation_manifest_sha256 -ne $parentGen){
40
+ throw 'R72_PRODUCTION_PREDECESSOR_DRIFT'
41
+ }
42
+ Write-Output 'R72_PREDECESSOR_PREFLIGHT=PASS'
43
+ if($Stage -eq 'preflight'){return}
44
+ if($Stage -in @('focused','all')){
45
+ Run-Node -label 'focused' -nodeArgs @('--test','--test-concurrency=1',
46
+ 'test/r72-remote-safe-contract.test.mjs','test/r72-publication-fence.test.mjs',
47
+ 'test/r60-authority-coherence.test.mjs','test/r58-cleanup-retention.test.mjs',
48
+ 'test/remote-session-cli.test.mjs','test/r70-controller-autonomous-root.test.mjs',
49
+ 'test/r70-controller-owner-issue-boundary.test.mjs','test/r71-release-identity.test.mjs',
50
+ 'test/r71-isolated-slot-rollback-restore.test.mjs','test/r59-tool-surface-compat.test.mjs')
51
+ if($Stage -eq 'focused'){return}
52
+ }
53
+ if($Stage -in @('full','all')){
54
+ & powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo 'scripts\verify-r70-full-regression.ps1')
55
+ if($LASTEXITCODE -ne 0){throw "R72_FULL_REGRESSION_FAILED exit=$LASTEXITCODE"}
56
+ Write-Output 'R72_FULL_REGRESSION_PASS'
57
+ if($Stage -eq 'full'){return}
58
+ }
59
+ if($Stage -in @('manifest','all')){
60
+ Run-Node -label 'manifest' -nodeArgs @('scripts/release-manifest.mjs','verify')
61
+ if($Stage -eq 'manifest'){return}
62
+ }
63
+ if($Stage -in @('doctor','all')){
64
+ $previous=$env:DEADBYTE_STATE_ROOT
65
+ $isolated=Join-Path $env:TEMP ('deadbyte-r72-doctor-'+[guid]::NewGuid().ToString('N'))
66
+ try{
67
+ New-Item -ItemType Directory -Path $isolated -Force | Out-Null
68
+ $env:DEADBYTE_STATE_ROOT=$isolated
69
+ Run-Node -label 'isolated_doctor' -nodeArgs @('src/deadbyte-cli.mjs','doctor')
70
+ }finally{
71
+ $env:DEADBYTE_STATE_ROOT=$previous
72
+ Remove-Item -LiteralPath $isolated -Recurse -Force -ErrorAction SilentlyContinue
73
+ }
74
+ }
75
+ Write-Output 'R72_WINDOWS_CANDIDATE_GATE=PASS_PREPUBLICATION'
76
+ }finally{Pop-Location}
@@ -4,6 +4,8 @@ import { reconcileNpmPublication } from './npm-publication-r65.mjs';
4
4
  import { mkdtemp, readFile, rm, unlink, mkdir } from 'node:fs/promises';
5
5
  import {preserveNpmTarball,assertVacantPackDestination} from './npm-preserve-artifact-r67.mjs';
6
6
  import {assertR67NpmPublishReady} from './npm-release-readiness-r67.mjs';
7
+ import {assertR71NpmPublishReady} from './npm-release-readiness-r71.mjs';
8
+ import {assertR72NpmPublishReady} from './npm-release-readiness-r72.mjs';
7
9
  import { existsSync } from 'node:fs';
8
10
  import { resolveStateRoot } from '../src/state-root.mjs';
9
11
  import path from 'node:path';
@@ -89,6 +91,8 @@ async function main() {
89
91
  throw new Error(`PROVENANCE.json version mismatch: package=${version} provenance=${provenance.version}`);
90
92
  }
91
93
  if (!isVerifyOnly && version==='0.15.44') assertR67NpmPublishReady(release);
94
+ if (!isVerifyOnly && version==='0.15.45') assertR71NpmPublishReady(release);
95
+ if (!isVerifyOnly && version==='0.15.46') await assertR72NpmPublishReady(release,{root});
92
96
  if (release.parent?.release_id !== provenance.parent_release_id ||
93
97
  release.parent?.manifest_sha256 !== provenance.parent_manifest_sha256 ||
94
98
  release.parent?.generation_manifest_sha256 !== provenance.parent_generation_manifest_sha256) {
@@ -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,76 @@
1
+ /** R72 publication fence: exact v0.15.45 parent, final manifest and external gate evidence.
2
+ * This deliberately does NOT generate, sign or upgrade release evidence. */
3
+ import {createHash} from 'node:crypto';
4
+ import {readFile,lstat} from 'node:fs/promises';
5
+ import path from 'node:path';
6
+
7
+ const HEX64=/^[0-9a-f]{64}$/;
8
+ const expectedParent=Object.freeze({
9
+ version:'0.15.45',
10
+ release_id:'v0.15.45-34aa8d1241cfb8bf',
11
+ manifest_sha256:'34aa8d1241cfb8bf0b5ba303bf3c06e0e9e1bf01f64457bca659d6dd4d634fdc',
12
+ generation_manifest_sha256:'ff2b73410062688651abd7bc2dd7b2b8c87810a28e3808bfe1f4352a25b0e6e4'
13
+ });
14
+ const evidenceGates=['full_regression','windows_lifecycle','package_acceptance','independent_judge'];
15
+ const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
16
+ function reject(reason){throw new Error(`PUBLISH_BLOCKED R72 ${reason}`);}
17
+ function exactParent(subject){return expectedParent.version===subject?.version&&
18
+ expectedParent.release_id===subject?.release_id&&
19
+ expectedParent.manifest_sha256===subject?.manifest_sha256&&
20
+ expectedParent.generation_manifest_sha256===subject?.generation_manifest_sha256;}
21
+
22
+ export async function assertR72NpmPublishReady(release,{root}={}){
23
+ if(release?.version!=='0.15.46'||release?.train!=='R72'||
24
+ release?.name!=='deadbyte-mcp'||!exactParent(release?.parent)||
25
+ !exactParent(release?.runtime_predecessor))reject('release identity or predecessor mismatch');
26
+ const status=release.r72_hotfix;
27
+ for(const [name,value] of Object.entries({
28
+ status:'CANDIDATE_SEALED',windows_regression:'PASS',package_acceptance:'PASS',
29
+ manifest:'PASS',remote_lifecycle:'PASS',security_gate:'PASS',independent_judge:'PASS'
30
+ }))if(status?.[name]!==value)reject(`${name}=${String(status?.[name]??'MISSING')}; require ${value}`);
31
+ if(!root||!path.isAbsolute(root))reject('candidate root missing');
32
+ const manifest=await readFile(path.join(root,'MANIFEST.SHA256')).catch(()=>reject('candidate manifest unavailable'));
33
+ const manifestSha256=sha(manifest);
34
+ const evidenceRoot=path.join(root,'testing','r72-release-evidence');
35
+ // Evidence and transcript storage must not be junctions/symlinks to another tree.
36
+ for(const dir of [evidenceRoot,path.join(evidenceRoot,'outputs')]){
37
+ const info=await lstat(dir).catch(()=>reject('evidence/output directory missing'));
38
+ if(!info.isDirectory()||info.isSymbolicLink())reject('evidence/output directory is not a real directory');
39
+ }
40
+ let ready;
41
+ try{ready=JSON.parse(await readFile(path.join(evidenceRoot,'ready.json'),'utf8'));}
42
+ catch{reject('independent release evidence index missing/invalid');}
43
+ if(ready?.schema!=='deadbyte.r72-release-evidence-index.v1'||ready?.version!=='0.15.46'||
44
+ ready?.manifest_sha256!==manifestSha256||!exactParent(ready?.parent))reject('evidence index subject mismatch');
45
+ for(const gate of evidenceGates){
46
+ const hash=ready?.gate_sha256?.[gate];
47
+ if(!HEX64.test(String(hash??'')))reject(`${gate} receipt identity missing`);
48
+ let bytes,receipt;
49
+ try{bytes=await readFile(path.join(evidenceRoot,`${gate}.json`));receipt=JSON.parse(bytes.toString('utf8'));}
50
+ catch{reject(`${gate} receipt missing/invalid`);}
51
+ if(sha(bytes)!==hash||receipt?.schema!=='deadbyte.r72-gate-result.v1'||
52
+ receipt?.gate!==gate||receipt?.version!=='0.15.46'||
53
+ receipt?.manifest_sha256!==manifestSha256||
54
+ receipt?.status!=='PASS'||receipt?.exit_code!==0)reject(`${gate} receipt tamper or failed gate`);
55
+ if(!HEX64.test(String(receipt.output_sha256??'')))reject(`${gate} missing bound command output`);
56
+ // Exact, gate-specific transcript path: a self-declared digest alone is not evidence.
57
+ const relativeOutput=`outputs/${gate}.log`;
58
+ if(receipt.output_file!==relativeOutput)reject(`${gate} output path identity mismatch`);
59
+ const outputPath=path.join(evidenceRoot,'outputs',`${gate}.log`);
60
+ const outputInfo=await lstat(outputPath).catch(()=>reject(`${gate} output missing/unavailable`));
61
+ if(!outputInfo.isFile()||outputInfo.isSymbolicLink())reject(`${gate} output must be a regular non-symlink file`);
62
+ if(outputInfo.size<1||outputInfo.size>64*1024*1024)reject(`${gate} output size invalid`);
63
+ const output=await readFile(outputPath).catch(()=>reject(`${gate} output unavailable`));
64
+ if(sha(output)!==receipt.output_sha256)reject(`${gate} output hash mismatch`);
65
+ if(gate==='full_regression'&&(!Number.isSafeInteger(receipt.pass_count)||receipt.pass_count<1||receipt.fail_count!==0))
66
+ reject('full regression count contract invalid');
67
+ if(gate==='windows_lifecycle'&&(
68
+ receipt.safe_default_arm_count!==0||receipt.operator_owner_consent_enforced!==true||
69
+ receipt.stale_owner_recovery_verified!==true||receipt.signed_epoch_fail_closed!==true))
70
+ reject('Windows lifecycle or R70 owner authority verification missing');
71
+ if(gate==='independent_judge'&&receipt.independent_verification!=='PASS')
72
+ reject('independent judge verdict unavailable');
73
+ }
74
+ return Object.freeze({status:'R72_RELEASE_READY_EVIDENCE_BOUND',version:'0.15.46',
75
+ manifest_sha256:manifestSha256,evidence_count:evidenceGates.length});
76
+ }
@@ -0,0 +1,72 @@
1
+ #requires -Version 5.1
2
+ # R70 verifier artifact: runs the candidate test suite without altering release manifests.
3
+ param([switch]$SelfTest)
4
+ Set-StrictMode -Version Latest
5
+ $ErrorActionPreference = 'Continue'
6
+ Set-Location -LiteralPath (Split-Path -Parent $PSScriptRoot)
7
+ $timer = [System.Diagnostics.Stopwatch]::StartNew()
8
+ if ($SelfTest) {
9
+ $lines = @('tests 1', 'pass 0', 'fail 1', 'skipped 0', 'hash mismatch: SYNTHETIC_TEST')
10
+ $exitCode = 1
11
+ } else {
12
+ $lines = @(& npm.cmd test 2>&1 | ForEach-Object { [string]$_ })
13
+ $exitCode = [int]$LASTEXITCODE
14
+ }
15
+ $timer.Stop()
16
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
17
+ $stdoutBytes = $utf8.GetBytes(($lines -join "`n"))
18
+ $sha = [System.Security.Cryptography.SHA256]::Create()
19
+ try {
20
+ $hash = ([BitConverter]::ToString($sha.ComputeHash($stdoutBytes))).Replace('-', '').ToLowerInvariant()
21
+ } finally {
22
+ $sha.Dispose()
23
+ }
24
+ Write-Output 'R70_FULL_TEST_SCHEMA=deadbyte.verifier-output.r70.v1'
25
+ Write-Output ('R70_FULL_TEST_EXIT_CODE=' + $exitCode)
26
+ Write-Output ('R70_FULL_TEST_ELAPSED_MS=' + [math]::Round($timer.Elapsed.TotalMilliseconds))
27
+ Write-Output ('R70_FULL_TEST_STDOUT_SHA256=' + $hash)
28
+ Write-Output ('R70_FULL_TEST_LINE_COUNT=' + $lines.Count)
29
+ $selected = @($lines | Where-Object {
30
+ $_ -match '(?i)(?:^|\s)(?:tests|pass|fail|skipped|cancelled|duration_ms)\s+[0-9.]+' -or
31
+ $_ -match '^✖' -or
32
+ $_ -match '^ (Error|AssertionError|SyntaxError):' -or
33
+ $_ -match 'hash mismatch:' -or
34
+ $_ -match '^# (tests|pass|fail|skipped) '
35
+ })
36
+ $summary = @($selected | Select-Object -Last 140 | ForEach-Object {
37
+ if ($_.Length -gt 512) { $_.Substring(0, 512) } else { $_ }
38
+ })
39
+ $artifactDir = Join-Path (Get-Location).Path 'testing\r70-verifier'
40
+ if (-not (Test-Path -LiteralPath $artifactDir -PathType Container)) {
41
+ New-Item -ItemType Directory -Path $artifactDir -Force | Out-Null
42
+ }
43
+ $artifact = Join-Path $artifactDir ('result-{0}-{1}.json' -f (Get-Date -Format 'yyyyMMdd-HHmmss'), [Guid]::NewGuid().ToString('N'))
44
+ $stdoutPath = [System.IO.Path]::ChangeExtension($artifact, '.stdout.txt')
45
+ $stdoutStream = New-Object System.IO.FileStream($stdoutPath, [System.IO.FileMode]::CreateNew, [System.IO.FileAccess]::Write, [System.IO.FileShare]::None)
46
+ try { $stdoutStream.Write($stdoutBytes, 0, $stdoutBytes.Length); $stdoutStream.Flush($true) } finally { $stdoutStream.Dispose() }
47
+ $record = [ordered]@{
48
+ schema = 'deadbyte.r70-full-regression-result.v1'
49
+ mode = if ($SelfTest) { 'synthetic-selftest' } else { 'candidate-full-regression' }
50
+ created_at_utc = [DateTime]::UtcNow.ToString('o')
51
+ exit_code = $exitCode
52
+ elapsed_ms = [math]::Round($timer.Elapsed.TotalMilliseconds)
53
+ stdout_sha256 = $hash
54
+ stdout_path = $stdoutPath
55
+ total_line_count = $lines.Count
56
+ summary = $summary
57
+ }
58
+ $json = ($record | ConvertTo-Json -Depth 5 -Compress) + "`n"
59
+ $bytes = $utf8.GetBytes($json)
60
+ $stream = New-Object System.IO.FileStream($artifact, [System.IO.FileMode]::CreateNew, [System.IO.FileAccess]::Write, [System.IO.FileShare]::None)
61
+ try { $stream.Write($bytes, 0, $bytes.Length); $stream.Flush($true) } finally { $stream.Dispose() }
62
+ $artifactHashAlgorithm = [System.Security.Cryptography.SHA256]::Create()
63
+ try {
64
+ $artifactStream = [System.IO.File]::OpenRead($artifact)
65
+ try { $artifactSha = ([BitConverter]::ToString($artifactHashAlgorithm.ComputeHash($artifactStream))).Replace('-', '').ToLowerInvariant() }
66
+ finally { $artifactStream.Dispose() }
67
+ } finally { $artifactHashAlgorithm.Dispose() }
68
+ Write-Output ('R70_FULL_TEST_ARTIFACT=' + $artifact)
69
+ Write-Output ('R70_FULL_TEST_ARTIFACT_SHA256=' + $artifactSha)
70
+ foreach ($line in $summary) { Write-Output $line }
71
+ if ($SelfTest) { exit 0 }
72
+ exit $exitCode
@@ -207,6 +207,10 @@ const DURABLE_EPOCH_ACTIONS=new Set(['grant','transaction_revoke','user_revoke',
207
207
  const DURABLE_EPOCH_SCHEMA='deadbyte.authority-epoch-event.r65.v1';
208
208
  const DURABLE_HEAD_SCHEMA='deadbyte.authority-epoch-head.r65.v1';
209
209
  const DURABLE_EPOCH_DOMAIN=Buffer.from('DEADBYTE-AUTHORITY-DURABLE-EPOCH-R65-V1\0','utf8');
210
+ // Cache parsed public keys by the exact bytes read from disk, never by path.
211
+ // A changed trust file is re-read and yields a different entry immediately.
212
+ const DURABLE_PUBLIC_KEY_CACHE_LIMIT=8;
213
+ const durablePublicKeys=new Map();
210
214
  const RESTORE_BINDING_FIELDS=Object.freeze(['prior_grant_sha256','prior_grant_instance_nonce','predecessor_policy_envelope_sha256','successor_policy_envelope_sha256','candidate_manifest_sha256','continuity_subject_sha256']);
211
215
  function normalizeRestoreBinding(value,{required=false}={}){
212
216
  if(value===undefined||value===null){if(required)throw new Error('authority epoch transaction restore binding required');return null;}
@@ -218,9 +222,19 @@ function normalizeRestoreBinding(value,{required=false}={}){
218
222
 
219
223
  async function durableEpochKeys(runtimeDir,{privateRequired=false}={}){
220
224
  const trust=path.join(path.dirname(path.resolve(runtimeDir)),'trust');
221
- const publicKey=createPublicKey(await readFile(path.join(trust,'ed25519-public.pem')));
222
- if(publicKey.asymmetricKeyType!=='ed25519')throw new Error('authority epoch trust public key invalid');
223
- const keyId=hashBytes(Buffer.from(publicKey.export({format:'der',type:'spki'})));
225
+ const publicBytes=await readFile(path.join(trust,'ed25519-public.pem'));
226
+ const publicSha=hashBytes(publicBytes);
227
+ let cached=durablePublicKeys.get(publicSha);
228
+ if(!cached){
229
+ const publicKey=createPublicKey(publicBytes);
230
+ if(publicKey.asymmetricKeyType!=='ed25519')throw new Error('authority epoch trust public key invalid');
231
+ const keyId=hashBytes(Buffer.from(publicKey.export({format:'der',type:'spki'})));
232
+ cached={publicKey,keyId};
233
+ if(durablePublicKeys.size>=DURABLE_PUBLIC_KEY_CACHE_LIMIT)
234
+ durablePublicKeys.delete(durablePublicKeys.keys().next().value);
235
+ durablePublicKeys.set(publicSha,cached);
236
+ }
237
+ const {publicKey,keyId}=cached;
224
238
  if(!privateRequired)return {publicKey,keyId};
225
239
  const privateKey=createPrivateKey(await readFile(path.join(trust,'ed25519-private.pem')));
226
240
  if(privateKey.asymmetricKeyType!=='ed25519'||
@@ -315,7 +329,14 @@ async function readDurableHead(runtimeDir,plane){
315
329
  if(head.action!=='transaction_restore'&&headRestoreBinding!==null)throw new Error('authority epoch unexpected restore binding');
316
330
  const expectedName=durableEventName(head.seq,head.event_sha256);
317
331
  if(head.event_file!==expectedName)throw new Error('authority epoch head event name mismatch');
318
- const eventNames=await readdir(path.join(dir,'events'));
332
+ // These are independent observations of one immutable event identity.
333
+ // Read them concurrently, then validate the complete set before trusting
334
+ // the head. The head remains freshly read on every authority decision.
335
+ const [eventNames,eventRead,keys]=await Promise.all([
336
+ readdir(path.join(dir,'events')),
337
+ readFile(path.join(dir,'events',head.event_file)).then(bytes=>({bytes}),()=>({bytes:null})),
338
+ durableEpochKeys(runtimeDir)
339
+ ]);
319
340
  if(eventNames.length>10000)throw new Error('authority epoch event budget exceeded');
320
341
  for(const name of eventNames){
321
342
  const match=/^(\d{16})-([0-9a-f]{64})\.json$/.exec(name);
@@ -324,13 +345,12 @@ async function readDurableHead(runtimeDir,plane){
324
345
  if(!Number.isSafeInteger(seq)||seq>head.seq||(seq===head.seq&&name!==head.event_file))
325
346
  throw new Error('authority epoch head replay or incomplete write');
326
347
  }
327
- let eventBytes;
328
- try{eventBytes=await readFile(path.join(dir,'events',head.event_file));}
329
- catch{throw new Error('authority epoch event missing');}
348
+ const eventBytes=eventRead.bytes;
349
+ if(!eventBytes)throw new Error('authority epoch event missing');
330
350
  if(hashBytes(eventBytes)!==head.event_sha256)throw new Error('authority epoch event hash mismatch');
331
351
  let event;
332
352
  try{event=JSON.parse(decodeUtf8Strict(eventBytes));}catch{throw new Error('authority epoch event invalid');}
333
- const {publicKey,keyId}=await durableEpochKeys(runtimeDir);
353
+ const {publicKey,keyId}=keys;
334
354
  if(!verifyDurableEvent(event,publicKey,keyId))throw new Error('authority epoch event signature invalid');
335
355
  for(const key of ['schema','plane','seq','action','update_id','grant_sha256','grant_instance_nonce','previous_event_sha256']){
336
356
  const expected=key==='schema'?DURABLE_EPOCH_SCHEMA:head[key];
@@ -48,7 +48,7 @@ export function registerAutonomousTools(server,{ autonomousRuntime, nativeDiffRu
48
48
  catch(error){ return fail(autonomousSessionStatusOutputSchema,error); } });
49
49
 
50
50
  server.registerTool('native_diff_preview',{
51
- description:'Create a signed content-addressed DEADBYTE Native Diff v1 after validating exact file SHA-256 preconditions. No Git metadata is used.',
51
+ description:'Validate exact file SHA-256 preconditions. With Coding read authority alone, return a read-only preview_only result that cannot be applied; a signed applicable diff additionally requires Autonomous authority. No Git metadata is used.',
52
52
  inputSchema:z.strictObject({ root_id:id, title:z.string().max(160).default(''), operations:z.array(nativeOperation).min(1).max(32) }),
53
53
  outputSchema:nativeDiffPreviewOutputSchema
54
54
  },async({root_id,title,operations})=>{ try { return result(nativeDiffPreviewOutputSchema,
@@ -83,10 +83,13 @@ export const autonomousSessionStatusOutputSchema = statusContract({
83
83
  });
84
84
 
85
85
  export const nativeDiffPreviewOutputSchema = statusContract({
86
- statuses:['ready','failed'], success:['ready'], required:['diff_id','root_id','operation_count','payload_bytes','paths','operations'],
86
+ statuses:['ready','preview_only','failed'], success:['ready','preview_only'], required:['root_id','operation_count','payload_bytes','paths','operations'],
87
87
  shape:{ schema:z.enum(['deadbyte.native-diff.v1','deadbyte.native-diff.v2']).optional(), diff_id:hex64.optional(), root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
88
88
  payload_bytes:z.number().int().min(0).optional(), paths:z.array(z.string()).max(64).optional(),
89
89
  operations:z.array(jsonObject).max(32).optional() }
90
+ }).superRefine((value,ctx)=>{
91
+ if(value.status==='ready'&&value.diff_id===undefined) ctx.addIssue({code:'custom',path:['diff_id'],message:'signed ready diff requires diff_id'});
92
+ if(value.status==='preview_only'&&value.diff_id!==undefined) ctx.addIssue({code:'custom',path:['diff_id'],message:'coding-only preview must not have an applicable diff_id'});
90
93
  });
91
94
  export const nativeDiffApplyOutputSchema = statusContract({
92
95
  statuses:['committed','existing','failed'], success:['committed','existing'],