deadbyte-mcp 0.15.72 → 0.15.75

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 (144) hide show
  1. package/MANIFEST.SHA256 +143 -35
  2. package/PROVENANCE.json +47 -21
  3. package/README.txt +29 -18
  4. package/RELEASE.json +85 -18
  5. package/SBOM.cdx.json +14 -2
  6. package/TEST-MATRIX.json +50 -2
  7. package/bin/deadbyte-desktop-uia-r199-fixed.exe +0 -0
  8. package/bin/deadbyte-desktop-uia-r199-fixed.obj +0 -0
  9. package/bin/deadbyte-desktop-uia-r199.exe +0 -0
  10. package/bin/deadbyte-desktop-uia-r199.obj +0 -0
  11. package/bin/deadbyte-fs-read-r197-fixed.exe +0 -0
  12. package/bin/deadbyte-fs-read-r198.exe +0 -0
  13. package/bin/deadbyte-fs-read-r198.obj +0 -0
  14. package/bin/deadbyte-owner-token-r193.exe +0 -0
  15. package/bin/deadbyte-root-relative-probe-r197.exe +0 -0
  16. package/bridge/package.json +1 -1
  17. package/controller/deadbyte-process-policy.json +4 -4
  18. package/docs/R184-package-lock.json +2 -8
  19. package/native/deadbyte-desktop-uia-r199.cpp +345 -0
  20. package/native/deadbyte-fs-read-r197.cpp +174 -0
  21. package/native/deadbyte-fs-read-r198.cpp +181 -0
  22. package/native/deadbyte-owner-token-r193.cpp +156 -0
  23. package/native/deadbyte-root-relative-probe-r197.cpp +97 -0
  24. package/package.json +4 -2
  25. package/scripts/build-native-desktop-uia-r199-fixed.ps1 +28 -0
  26. package/scripts/build-native-desktop-uia-r199.ps1 +28 -0
  27. package/scripts/build-native-fs-read-r197-fixed.ps1 +28 -0
  28. package/scripts/build-native-fs-read-r197.ps1 +28 -0
  29. package/scripts/build-native-fs-read-r198.ps1 +28 -0
  30. package/scripts/build-native-root-probe-r197.ps1 +28 -0
  31. package/scripts/gate-windows-r193.ps1 +108 -0
  32. package/scripts/gate-windows-r194.ps1 +112 -0
  33. package/scripts/gate-windows-r195.ps1 +114 -0
  34. package/scripts/gate-windows-r206.ps1 +116 -0
  35. package/scripts/init-desktop-policy-r199.ps1 +85 -0
  36. package/scripts/npm-interactive-r194.mjs +13 -0
  37. package/scripts/npm-publication-r65.mjs +64 -4
  38. package/scripts/npm-release-r48.mjs +75 -11
  39. package/scripts/npm-release-readiness-r193.mjs +80 -0
  40. package/scripts/npm-release-readiness-r194.mjs +80 -0
  41. package/scripts/npm-release-readiness-r195.mjs +72 -0
  42. package/scripts/npm-release-readiness-r206.mjs +76 -0
  43. package/scripts/r188-owner-uac-review.ps1 +91 -0
  44. package/scripts/r188-uac-review-preview.mjs +65 -0
  45. package/scripts/r193-compile-token.ps1 +22 -0
  46. package/scripts/r193-evidence-relocate.ps1 +12 -0
  47. package/scripts/r193-focused-gate.mjs +20 -0
  48. package/scripts/r193-import-r188-scripts.ps1 +14 -0
  49. package/scripts/r193-limited-subject-probe.ps1 +25 -0
  50. package/scripts/r193-migrate-runtime-limited.ps1 +103 -0
  51. package/scripts/r193-owner-keygen.mjs +43 -0
  52. package/scripts/r193-owner-request-live.mjs +49 -0
  53. package/scripts/r193-owner-uac-approve.ps1 +42 -0
  54. package/scripts/r193-owner-uac-broker.mjs +139 -0
  55. package/scripts/r193-owner-uac-enroll-and-approve.ps1 +62 -0
  56. package/scripts/r193-test-limited-token.ps1 +49 -0
  57. package/scripts/r193-toolchain-inventory.ps1 +7 -0
  58. package/scripts/r193-uac-bridge-focused.mjs +21 -0
  59. package/scripts/r205-candidate-selection.mjs +22 -0
  60. package/src/candidate-selection-evidence-r206.mjs +71 -0
  61. package/src/candidate-selection-r205.mjs +96 -0
  62. package/src/desktop-postcondition-r196.mjs +30 -0
  63. package/src/desktop-runtime-r40.mjs +44 -7
  64. package/src/desktop-uia-identity-r199.mjs +51 -0
  65. package/src/desktop-uia-r40.mjs +9 -1
  66. package/src/machine-fs-handle-read-r196.mjs +43 -0
  67. package/src/machine-fs-native-read-r197.mjs +73 -0
  68. package/src/machine-fs-native-read-r198.mjs +76 -0
  69. package/src/machine-fs-read-worker.mjs +5 -25
  70. package/src/machine-fs.mjs +31 -16
  71. package/src/r188-owner-uac.mjs +105 -0
  72. package/src/r188-uac-boundary.mjs +21 -0
  73. package/src/r193-live-owner-subject.mjs +110 -0
  74. package/src/r193-owner-secret-acl.mjs +67 -0
  75. package/src/r193-owner-uac-broker.mjs +85 -0
  76. package/src/r193-uac-r70-bridge.mjs +54 -0
  77. package/src/r195-canonical-owner-observation.mjs +15 -0
  78. package/src/remote-destination-journal-r202.mjs +120 -0
  79. package/src/remote-device-r44.mjs +89 -14
  80. package/src/remote-payload-boundary-r201.mjs +71 -0
  81. package/src/remote-terminal-evidence-r200.mjs +60 -0
  82. package/src/version.mjs +1 -1
  83. package/test/desktop-runtime-r40.test.mjs +111 -0
  84. package/test/desktop-uia-r40.test.mjs +15 -0
  85. package/test/fixtures/r197-junction-swap-worker.mjs +21 -0
  86. package/test/fixtures/r203-journal-writer.mjs +6 -0
  87. package/test/process-policy-refresh.test.mjs +4 -4
  88. package/test/r130-release-security-contract.test.mjs +8 -8
  89. package/test/r132-release-identity.test.mjs +7 -7
  90. package/test/r153-prepublish-identity.test.mjs +1 -1
  91. package/test/r160-release-contract.test.mjs +3 -3
  92. package/test/r165-live-cli-skew.test.mjs +1 -1
  93. package/test/r167-release-contract.test.mjs +11 -11
  94. package/test/r168-release-contract.test.mjs +4 -4
  95. package/test/r172-release-contract.test.mjs +6 -6
  96. package/test/r173-release-contract.test.mjs +16 -16
  97. package/test/r179-release-contract.test.mjs +12 -12
  98. package/test/r188-owner-uac.test.mjs +48 -0
  99. package/test/r188-uac-boundary.test.mjs +42 -0
  100. package/test/r190-release-contract.test.mjs +10 -10
  101. package/test/r191-release-contract.test.mjs +12 -12
  102. package/test/r192-release-identity.test.mjs +10 -10
  103. package/test/r193-limited-migration-contract.test.mjs +26 -0
  104. package/test/r193-live-owner-subject.test.mjs +61 -0
  105. package/test/r193-native-process-observer.test.mjs +36 -0
  106. package/test/r193-native-token.test.mjs +43 -0
  107. package/test/r193-owner-enrollment-entrypoint.test.mjs +38 -0
  108. package/test/r193-owner-secret-acl.test.mjs +23 -0
  109. package/test/r193-owner-uac-broker.test.mjs +82 -0
  110. package/test/r193-owner-uac-entrypoint.test.mjs +36 -0
  111. package/test/r193-release-identity.test.mjs +58 -0
  112. package/test/r193-release-readiness.test.mjs +87 -0
  113. package/test/r193-uac-r70-bridge.test.mjs +88 -0
  114. package/test/r193-windows-gate.test.mjs +30 -0
  115. package/test/r194-npm-auth-recovery.test.mjs +77 -0
  116. package/test/r194-npm-preauth.test.mjs +57 -0
  117. package/test/r194-release-identity.test.mjs +47 -0
  118. package/test/r194-release-readiness.test.mjs +87 -0
  119. package/test/r194-windows-gate.test.mjs +22 -0
  120. package/test/r195-canonical-owner-observation.test.mjs +32 -0
  121. package/test/r195-release-readiness.test.mjs +22 -0
  122. package/test/r196-desktop-postcondition.test.mjs +53 -0
  123. package/test/r196-handle-bound-read.test.mjs +99 -0
  124. package/test/r196-remote-outcome.test.mjs +94 -0
  125. package/test/r197-namespace-race.test.mjs +41 -0
  126. package/test/r197-native-dispatch-race.test.mjs +49 -0
  127. package/test/r197-native-file-read.test.mjs +60 -0
  128. package/test/r197-native-root-open.test.mjs +61 -0
  129. package/test/r198-root-identity.test.mjs +88 -0
  130. package/test/r199-native-uia-worker.test.mjs +28 -0
  131. package/test/r199-uia-identity.test.mjs +43 -0
  132. package/test/r200-remote-reconcile.test.mjs +106 -0
  133. package/test/r201-payload-boundary.test.mjs +78 -0
  134. package/test/r201-payload-fuzz.test.mjs +37 -0
  135. package/test/r201-tool-boundary-fuzz.test.mjs +120 -0
  136. package/test/r202-destination-journal.test.mjs +92 -0
  137. package/test/r203-atomic-journal.test.mjs +86 -0
  138. package/test/r205-candidate-selection-cli.test.mjs +31 -0
  139. package/test/r205-candidate-selection.test.mjs +83 -0
  140. package/test/r206-candidate-evidence.test.mjs +64 -0
  141. package/test/r206-release-contract.test.mjs +42 -0
  142. package/test/r206-release-readiness.test.mjs +23 -0
  143. package/test/r59-tool-surface-compat.test.mjs +1 -1
  144. package/test/r64-machine-fs-large-read.test.mjs +26 -12
@@ -1,6 +1,7 @@
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 { classifyNpmPublishFailure } from './npm-interactive-r194.mjs';
4
5
  import { mkdtemp, readFile, rm, unlink, mkdir } from 'node:fs/promises';
5
6
  import {preserveNpmTarball,assertVacantPackDestination} from './npm-preserve-artifact-r67.mjs';
6
7
  import {assertR67NpmPublishReady} from './npm-release-readiness-r67.mjs';
@@ -12,8 +13,12 @@ import {assertR165NpmPublishReady} from './npm-release-readiness-r165.mjs';
12
13
  import {assertR166NpmPublishReady} from './npm-release-readiness-r166.mjs';
13
14
  import {assertR167NpmPublishReady,assertR167PackedIdentity} from './npm-release-readiness-r167.mjs';
14
15
  import {assertR168NpmPublishReady,assertR168PackedIdentity} from './npm-release-readiness-r168.mjs';
16
+ import {assertR193NpmPublishReady,assertR193PackedIdentity} from './npm-release-readiness-r193.mjs';
17
+ import {assertR194NpmPublishReady,assertR194PackedIdentity} from './npm-release-readiness-r194.mjs';
18
+ import {assertR195NpmPublishReady,assertR195PackedIdentity} from './npm-release-readiness-r195.mjs';
19
+ import {assertR206NpmPublishReady,assertR206PackedIdentity} from './npm-release-readiness-r206.mjs';
15
20
  import {resumePackRecord} from '../src/npm-publication-resume-r168.mjs';
16
- import { existsSync } from 'node:fs';
21
+ import { existsSync,mkdtempSync,readdirSync,readFileSync,rmSync } from 'node:fs';
17
22
  import { resolveStateRoot } from '../src/state-root.mjs';
18
23
  import path from 'node:path';
19
24
  import os from 'node:os';
@@ -46,18 +51,39 @@ function runNpm(args, options = {}) {
46
51
  return run(node, [npmCli, ...args], options);
47
52
  }
48
53
 
54
+ function verifyNpmOwnerPreflight(){
55
+ try{
56
+ const registry=runNpm(['config','get','registry'],{timeout:30000}).trim();
57
+ if(registry!=='https://registry.npmjs.org/')return false;
58
+ const name=runNpm(['whoami','--registry=https://registry.npmjs.org/'],{timeout:30000}).trim();
59
+ if(name!=='deadbytes')return false;
60
+ const owners=runNpm(['owner','ls','deadbyte-mcp','--registry=https://registry.npmjs.org/'],{timeout:30000});
61
+ return owners.split(/\r?\n/).some(line=>/^\s*deadbytes(?:\s|$)/.test(line));
62
+ }catch{return false;}
63
+ }
64
+
49
65
  function runNpmInteractive(args, options = {}) {
50
66
  const { cwd = root, timeout = 300000 } = options;
51
- const r = spawnSync(node, [npmCli, ...args], {
52
- cwd,
53
- timeout,
54
- stdio: 'inherit',
55
- shell: false,
56
- windowsHide: false,
57
- });
58
- if (r.error) throw r.error;
59
- if (r.status !== 0) throw new Error('Interactive npm command failed (exit=' + r.status + ', cwd=' + cwd + ')');
60
- return '';
67
+ const logDir=mkdtempSync(path.join(os.tmpdir(),'deadbyte-r194-npm-diagnostic-'));
68
+ try{
69
+ // Preserve interactive browser/2FA prompts; classify failures from the
70
+ // isolated npm debug log without printing or preserving credential data.
71
+ const r=spawnSync(node,[npmCli,...args,'--logs-dir',logDir],{
72
+ cwd,timeout,stdio:'inherit',shell:false,windowsHide:false
73
+ });
74
+ if(r.error)throw r.error;
75
+ if(r.status!==0){
76
+ const debug=readdirSync(logDir).filter(name=>name.endsWith('-debug-0.log')).slice(-3)
77
+ .map(name=>readFileSync(path.join(logDir,name),'utf8').slice(-16000)).join('\n');
78
+ const reason=classifyNpmPublishFailure({exitCode:r.status,output:debug});
79
+ const error=new Error('Interactive npm publish did not complete; classified '+reason);
80
+ error.code=reason;
81
+ throw error;
82
+ }
83
+ return '';
84
+ }finally{
85
+ rmSync(logDir,{recursive:true,force:true});
86
+ }
61
87
  }
62
88
 
63
89
  function parseJson(text) {
@@ -123,6 +149,23 @@ async function main() {
123
149
  if (!publishOnly) throw new Error('PUBLISH_BLOCKED R168 requires --publish-only; activation is separate');
124
150
  r168Readiness=await assertR168NpmPublishReady(release,{root});
125
151
  }
152
+ let r193Readiness=null;
153
+ if (!isVerifyOnly && version==='0.15.73') {
154
+ if (!publishOnly) throw new Error('PUBLISH_BLOCKED R193 requires --publish-only; owner enrollment, runtime migration, and activation are separate authority boundaries');
155
+ r193Readiness=await assertR193NpmPublishReady(release,{root});
156
+ }
157
+ let r194Readiness=null;
158
+ if (!isVerifyOnly && version==='0.15.74') {
159
+ if (!publishOnly) throw new Error('PUBLISH_BLOCKED R194 requires --publish-only; activation remains separately authorized');
160
+ r194Readiness=await assertR194NpmPublishReady(release,{root});
161
+ }
162
+ let r195Readiness=null;
163
+ let r206Readiness=null;
164
+ if (!isVerifyOnly && version==='0.15.75') {
165
+ if (!publishOnly) throw new Error('PUBLISH_BLOCKED R206 requires --publish-only; owner enrollment and activation remain separate');
166
+ if(release.train==='R206')r206Readiness=await assertR206NpmPublishReady(release,{root});
167
+ else r195Readiness=await assertR195NpmPublishReady(release,{root});
168
+ }
126
169
  if (release.parent?.release_id !== provenance.parent_release_id ||
127
170
  release.parent?.manifest_sha256 !== provenance.parent_manifest_sha256 ||
128
171
  release.parent?.generation_manifest_sha256 !== provenance.parent_generation_manifest_sha256) {
@@ -262,10 +305,31 @@ async function main() {
262
305
  ...r168Readiness,observedSha256:createHash('sha256').update(localBytes).digest('hex'),
263
306
  observedIntegrity:localIntegrity,observedShasum:packRecord.shasum
264
307
  });
308
+ if(r193Readiness)assertR193PackedIdentity({
309
+ ...r193Readiness,observedSha256:createHash('sha256').update(localBytes).digest('hex'),
310
+ observedIntegrity:localIntegrity,observedShasum:packRecord.shasum
311
+ });
312
+ if(r194Readiness)assertR194PackedIdentity({
313
+ ...r194Readiness,observedSha256:createHash('sha256').update(localBytes).digest('hex'),
314
+ observedIntegrity:localIntegrity,observedShasum:packRecord.shasum
315
+ });
316
+ if(r195Readiness)assertR195PackedIdentity({
317
+ ...r195Readiness,observedSha256:createHash('sha256').update(localBytes).digest('hex'),
318
+ observedIntegrity:localIntegrity,observedShasum:packRecord.shasum
319
+ });
320
+ if(r206Readiness)assertR206PackedIdentity({
321
+ ...r206Readiness,observedSha256:createHash('sha256').update(localBytes).digest('hex'),
322
+ observedIntegrity:localIntegrity,observedShasum:packRecord.shasum
323
+ });
265
324
 
266
325
  console.log('[6/7] Publishing artifact to npm registry...');
267
326
  publishAttempted = true;
327
+ const ownerAuth=async subject=>
328
+ subject.version===version&&subject.manifest_sha256===manifestSha256&&
329
+ subject.tarball_sha256===createHash('sha256').update(localBytes).digest('hex')&&
330
+ verifyNpmOwnerPreflight();
268
331
  const reconciliation=await reconcileNpmPublication({recordPath:publicationDir,version,manifestSha256,localBytes,
332
+ authorizePublish:ownerAuth,authorizeAuthRetry:ownerAuth,
269
333
  publish:async()=>runNpmInteractive(['publish',publishTarball,'--access','public','--auth-type=web'],{timeout:300000}),
270
334
  lookup:async()=>{
271
335
  try{
@@ -0,0 +1,80 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {lstat,readFile} from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
5
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
6
+ const hex64=value=>typeof value==='string'&&/^[0-9a-f]{64}$/.test(value);
7
+ const fail=message=>{throw new Error(`PUBLISH_BLOCKED R193 ${message}`);};
8
+ const required=(value,message)=>{if(!value)fail(message);};
9
+
10
+ async function checkedFile(file,expected,{maxBytes=64*1024*1024}={}){
11
+ required(hex64(expected),'evidence digest missing');
12
+ let info;try{info=await lstat(file);}catch{fail('evidence file absent');}
13
+ required(info.isFile()&&!info.isSymbolicLink()&&info.size>0&&info.size<=maxBytes,'evidence file invalid');
14
+ const bytes=await readFile(file);
15
+ required(sha256(bytes)===expected,'evidence digest differs');
16
+ return bytes;
17
+ }
18
+
19
+ function tapSummary(text,label){
20
+ const summaries=[...text.matchAll(/^# tests (\d+)\s*\r?\n# suites (\d+)\s*\r?\n# pass (\d+)\s*\r?\n# fail (\d+)\s*\r?\n# cancelled (\d+)\s*\r?\n# skipped (\d+)/gm)];
21
+ required(summaries.length>0,`${label} TAP summary absent`);
22
+ const last=summaries.at(-1);
23
+ return {tests:Number(last[1]),passes:Number(last[3]),fails:Number(last[4]),cancelled:Number(last[5]),skips:Number(last[6])};
24
+ }
25
+
26
+ export function assertR193PackedIdentity({tarball_sha256,tarball_integrity,tarball_shasum,observedSha256,observedIntegrity,observedShasum}={}){
27
+ required(hex64(tarball_sha256)&&typeof tarball_integrity==='string'&&tarball_integrity.startsWith('sha512-')&&
28
+ typeof tarball_shasum==='string'&&/^[0-9a-f]{40}$/.test(tarball_shasum),'verified tarball identity invalid');
29
+ required(observedSha256===tarball_sha256&&observedIntegrity===tarball_integrity&&observedShasum===tarball_shasum,
30
+ 'repacked tarball differs from verified closure bytes');
31
+ return true;
32
+ }
33
+
34
+ export async function assertR193NpmPublishReady(release,{root,closureRoot=process.env.DEADBYTE_R193_CLOSURE_ROOT}={}){
35
+ required(release?.version==='0.15.73'&&release?.train==='R193'&&
36
+ release?.r193?.scope==='PROTECTED_OWNER_AUTHORIZATION_AND_LIMITED_RUNTIME_MIGRATION','candidate metadata invalid');
37
+ required(release?.r193?.public_tool_delta===0&&release?.r193?.authority_scope_delta===0,'public authority surface widened');
38
+ required(release?.parent?.version==='0.15.72'&&
39
+ release?.parent?.release_id==='v0.15.72-0a5d9436e06e2d9e'&&
40
+ release?.parent?.manifest_sha256==='0a5d9436e06e2d9e7cf9179417465955d8ca5ba88655b13dd019190243c1cc90'&&
41
+ release?.parent?.generation_manifest_sha256==='aec7b998306a3bbbcc59088648e7bc46ca7e203d749d4550b5b5f372032f92b0','lineage mismatch');
42
+ required(root&&path.isAbsolute(root)&&closureRoot&&path.isAbsolute(closureRoot),'closure root absent');
43
+ const expected=path.resolve(root,'..','..','testing','r193-final-closure');
44
+ required(path.resolve(closureRoot).toLowerCase()===expected.toLowerCase(),'closure root outside scoped testing folder');
45
+
46
+ let closure;try{closure=JSON.parse(await readFile(path.join(closureRoot,'closure.json'),'utf8'));}catch{fail('closure unreadable');}
47
+ required(closure?.schema==='deadbyte.r193-release-closure.v1'&&closure.status==='RELEASE_READY'&&
48
+ closure.version==='0.15.73'&&closure.train==='R193','closure status mismatch');
49
+ required(closure.production_release_id===release.parent.release_id&&
50
+ closure.production_manifest_sha256===release.parent.manifest_sha256&&
51
+ closure.production_generation_manifest_sha256===release.parent.generation_manifest_sha256,'production predecessor mismatch');
52
+ required(hex64(closure.manifest_sha256)&&closure.manifest_sha256===sha256(await readFile(path.join(root,'MANIFEST.SHA256'))),'final manifest drift');
53
+ required(closure.compact_tools===43&&closure.full_tools===117,'catalog count mismatch');
54
+ required(closure.owner_enrollment==='NOT_RUN'&&closure.limited_runtime_migration==='NOT_RUN'&&
55
+ closure.production_activation==='NOT_RUN','prepublication closure crossed production authority boundary');
56
+
57
+ const receipt=JSON.parse((await checkedFile(path.join(closureRoot,'protected-install-receipt.json'),closure.protected_receipt_sha256)).toString('utf8'));
58
+ required(receipt?.status==='PASS'&&receipt.package_version==='0.15.73'&&
59
+ receipt.source_manifest_sha256===closure.manifest_sha256&&receipt.protected_manifest_sha256===closure.manifest_sha256,
60
+ 'protected exact-byte receipt mismatch');
61
+ const focused=(await checkedFile(path.join(closureRoot,'windows-focused.stdout.log'),closure.focused_stdout_sha256)).toString('utf8');
62
+ const full=(await checkedFile(path.join(closureRoot,'windows-full.stdout.log'),closure.full_stdout_sha256)).toString('utf8');
63
+ const verify=(await checkedFile(path.join(closureRoot,'npm-verify.stdout.log'),closure.verify_stdout_sha256)).toString('utf8');
64
+ required(focused.includes('R193_STAGE_PASS=focused'),'focused protected gate incomplete');
65
+ const focusedSummary=tapSummary(focused,'focused');
66
+ required(focusedSummary.fails===0&&focusedSummary.cancelled===0&&focusedSummary.passes>=60&&focusedSummary.skips<=2,'focused regression count mismatch');
67
+ required(full.includes('R193_STAGE_PASS=full'),'full protected gate incomplete');
68
+ const summary=tapSummary(full,'full');
69
+ required(summary.tests>=2150&&summary.passes>=2100&&summary.fails===0&&summary.cancelled===0&&summary.skips<=70&&summary.passes+summary.skips===summary.tests,
70
+ 'full regression count mismatch');
71
+ required(verify.includes('VERIFY-ONLY PIPELINE PASS')&&verify.includes('Artifact isolation gate PASS')&&verify.includes('VERIFIED_TARBALL '),
72
+ 'npm exact-artifact verification incomplete');
73
+ const line=verify.split(/\r?\n/).find(value=>value.startsWith('VERIFIED_TARBALL '));
74
+ let artifact;try{artifact=JSON.parse(line.slice('VERIFIED_TARBALL '.length));}catch{fail('tarball evidence malformed');}
75
+ required(artifact.filename==='deadbyte-mcp-0.15.73.tgz'&&artifact.bytes>0&&artifact.sha256===closure.tarball_sha256&&
76
+ artifact.integrity===closure.tarball_integrity&&artifact.shasum===closure.tarball_shasum,'tarball identity mismatch');
77
+ return Object.freeze({status:'R193_RELEASE_READY_EVIDENCE_BOUND',manifest_sha256:closure.manifest_sha256,
78
+ tarball_sha256:artifact.sha256,tarball_integrity:artifact.integrity,tarball_shasum:artifact.shasum,
79
+ tests:summary.tests,passes:summary.passes,skips:summary.skips});
80
+ }
@@ -0,0 +1,80 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {lstat,readFile} from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
5
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
6
+ const hex64=value=>typeof value==='string'&&/^[0-9a-f]{64}$/.test(value);
7
+ const fail=message=>{throw new Error(`PUBLISH_BLOCKED R194 ${message}`);};
8
+ const required=(value,message)=>{if(!value)fail(message);};
9
+
10
+ async function checkedFile(file,expected,{maxBytes=64*1024*1024}={}){
11
+ required(hex64(expected),'evidence digest missing');
12
+ let info;try{info=await lstat(file);}catch{fail('evidence file absent');}
13
+ required(info.isFile()&&!info.isSymbolicLink()&&info.size>0&&info.size<=maxBytes,'evidence file invalid');
14
+ const bytes=await readFile(file);
15
+ required(sha256(bytes)===expected,'evidence digest differs');
16
+ return bytes;
17
+ }
18
+
19
+ function tapSummary(text,label){
20
+ const summaries=[...text.matchAll(/^# tests (\d+)\s*\r?\n# suites (\d+)\s*\r?\n# pass (\d+)\s*\r?\n# fail (\d+)\s*\r?\n# cancelled (\d+)\s*\r?\n# skipped (\d+)/gm)];
21
+ required(summaries.length>0,`${label} TAP summary absent`);
22
+ const last=summaries.at(-1);
23
+ return {tests:Number(last[1]),passes:Number(last[3]),fails:Number(last[4]),cancelled:Number(last[5]),skips:Number(last[6])};
24
+ }
25
+
26
+ export function assertR194PackedIdentity({tarball_sha256,tarball_integrity,tarball_shasum,observedSha256,observedIntegrity,observedShasum}={}){
27
+ required(hex64(tarball_sha256)&&typeof tarball_integrity==='string'&&tarball_integrity.startsWith('sha512-')&&
28
+ typeof tarball_shasum==='string'&&/^[0-9a-f]{40}$/.test(tarball_shasum),'verified tarball identity invalid');
29
+ required(observedSha256===tarball_sha256&&observedIntegrity===tarball_integrity&&observedShasum===tarball_shasum,
30
+ 'repacked tarball differs from verified closure bytes');
31
+ return true;
32
+ }
33
+
34
+ export async function assertR194NpmPublishReady(release,{root,closureRoot=process.env.DEADBYTE_R194_CLOSURE_ROOT}={}){
35
+ required(release?.version==='0.15.74'&&release?.train==='R194'&&
36
+ release?.r194?.scope==='NPM_AUTH_RECOVERY_AND_OWNER_AUTHORIZATION','candidate metadata invalid');
37
+ required(release?.r194?.public_tool_delta===0&&release?.r194?.authority_scope_delta===0,'public authority surface widened');
38
+ required(release?.parent?.version==='0.15.72'&&
39
+ release?.parent?.release_id==='v0.15.72-0a5d9436e06e2d9e'&&
40
+ release?.parent?.manifest_sha256==='0a5d9436e06e2d9e7cf9179417465955d8ca5ba88655b13dd019190243c1cc90'&&
41
+ release?.parent?.generation_manifest_sha256==='aec7b998306a3bbbcc59088648e7bc46ca7e203d749d4550b5b5f372032f92b0','lineage mismatch');
42
+ required(root&&path.isAbsolute(root)&&closureRoot&&path.isAbsolute(closureRoot),'closure root absent');
43
+ const expected=path.resolve(root,'..','..','testing','r194-final-closure');
44
+ required(path.resolve(closureRoot).toLowerCase()===expected.toLowerCase(),'closure root outside scoped testing folder');
45
+
46
+ let closure;try{closure=JSON.parse(await readFile(path.join(closureRoot,'closure.json'),'utf8'));}catch{fail('closure unreadable');}
47
+ required(closure?.schema==='deadbyte.r194-release-closure.v1'&&closure.status==='RELEASE_READY'&&
48
+ closure.version==='0.15.74'&&closure.train==='R194','closure status mismatch');
49
+ required(closure.production_release_id===release.parent.release_id&&
50
+ closure.production_manifest_sha256===release.parent.manifest_sha256&&
51
+ closure.production_generation_manifest_sha256===release.parent.generation_manifest_sha256,'production predecessor mismatch');
52
+ required(hex64(closure.manifest_sha256)&&closure.manifest_sha256===sha256(await readFile(path.join(root,'MANIFEST.SHA256'))),'final manifest drift');
53
+ required(closure.compact_tools===43&&closure.full_tools===117,'catalog count mismatch');
54
+ required(closure.owner_enrollment==='NOT_RUN'&&closure.limited_runtime_migration==='NOT_RUN'&&
55
+ closure.production_activation==='NOT_RUN','prepublication closure crossed production authority boundary');
56
+
57
+ const receipt=JSON.parse((await checkedFile(path.join(closureRoot,'protected-install-receipt.json'),closure.protected_receipt_sha256)).toString('utf8'));
58
+ required(receipt?.status==='PASS'&&receipt.package_version==='0.15.74'&&
59
+ receipt.source_manifest_sha256===closure.manifest_sha256&&receipt.protected_manifest_sha256===closure.manifest_sha256,
60
+ 'protected exact-byte receipt mismatch');
61
+ const focused=(await checkedFile(path.join(closureRoot,'windows-focused.stdout.log'),closure.focused_stdout_sha256)).toString('utf8');
62
+ const full=(await checkedFile(path.join(closureRoot,'windows-full.stdout.log'),closure.full_stdout_sha256)).toString('utf8');
63
+ const verify=(await checkedFile(path.join(closureRoot,'npm-verify.stdout.log'),closure.verify_stdout_sha256)).toString('utf8');
64
+ required(focused.includes('R194_STAGE_PASS=focused'),'focused protected gate incomplete');
65
+ const focusedSummary=tapSummary(focused,'focused');
66
+ required(focusedSummary.fails===0&&focusedSummary.cancelled===0&&focusedSummary.passes>=60&&focusedSummary.skips<=2,'focused regression count mismatch');
67
+ required(full.includes('R194_STAGE_PASS=full'),'full protected gate incomplete');
68
+ const summary=tapSummary(full,'full');
69
+ required(summary.tests>=2150&&summary.passes>=2100&&summary.fails===0&&summary.cancelled===0&&summary.skips<=70&&summary.passes+summary.skips===summary.tests,
70
+ 'full regression count mismatch');
71
+ required(verify.includes('VERIFY-ONLY PIPELINE PASS')&&verify.includes('Artifact isolation gate PASS')&&verify.includes('VERIFIED_TARBALL '),
72
+ 'npm exact-artifact verification incomplete');
73
+ const line=verify.split(/\r?\n/).find(value=>value.startsWith('VERIFIED_TARBALL '));
74
+ let artifact;try{artifact=JSON.parse(line.slice('VERIFIED_TARBALL '.length));}catch{fail('tarball evidence malformed');}
75
+ required(artifact.filename==='deadbyte-mcp-0.15.74.tgz'&&artifact.bytes>0&&artifact.sha256===closure.tarball_sha256&&
76
+ artifact.integrity===closure.tarball_integrity&&artifact.shasum===closure.tarball_shasum,'tarball identity mismatch');
77
+ return Object.freeze({status:'R194_RELEASE_READY_EVIDENCE_BOUND',manifest_sha256:closure.manifest_sha256,
78
+ tarball_sha256:artifact.sha256,tarball_integrity:artifact.integrity,tarball_shasum:artifact.shasum,
79
+ tests:summary.tests,passes:summary.passes,skips:summary.skips});
80
+ }
@@ -0,0 +1,72 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {lstat,readFile} from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
5
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
6
+ const hex64=value=>typeof value==='string'&&/^[0-9a-f]{64}$/.test(value);
7
+ const fail=message=>{throw new Error(`PUBLISH_BLOCKED R195 ${message}`);};
8
+ const required=(value,message)=>{if(!value)fail(message);};
9
+
10
+ async function checkedFile(file,expected,{maxBytes=64*1024*1024}={}){
11
+ required(hex64(expected),'evidence digest missing');
12
+ let info;try{info=await lstat(file);}catch{fail('evidence file absent');}
13
+ required(info.isFile()&&!info.isSymbolicLink()&&info.size>0&&info.size<=maxBytes,'evidence file invalid');
14
+ const bytes=await readFile(file);
15
+ required(sha256(bytes)===expected,'evidence digest differs');
16
+ return bytes;
17
+ }
18
+
19
+ function tapSummary(text,label){
20
+ const summaries=[...text.matchAll(/^# tests (\d+)\s*\r?\n# suites (\d+)\s*\r?\n# pass (\d+)\s*\r?\n# fail (\d+)\s*\r?\n# cancelled (\d+)\s*\r?\n# skipped (\d+)/gm)];
21
+ required(summaries.length>0,`${label} TAP summary absent`);
22
+ const last=summaries.at(-1);
23
+ return {tests:Number(last[1]),passes:Number(last[3]),fails:Number(last[4]),cancelled:Number(last[5]),skips:Number(last[6])};
24
+ }
25
+
26
+ export function assertR195PackedIdentity({tarball_sha256,tarball_integrity,tarball_shasum,observedSha256,observedIntegrity,observedShasum}={}){
27
+ required(hex64(tarball_sha256)&&typeof tarball_integrity==='string'&&tarball_integrity.startsWith('sha512-')&&
28
+ typeof tarball_shasum==='string'&&/^[0-9a-f]{40}$/.test(tarball_shasum),'verified tarball identity invalid');
29
+ required(observedSha256===tarball_sha256&&observedIntegrity===tarball_integrity&&observedShasum===tarball_shasum,
30
+ 'repacked tarball differs from verified closure bytes');
31
+ return true;
32
+ }
33
+
34
+ export async function assertR195NpmPublishReady(release,{root,closureRoot=process.env.DEADBYTE_R195_CLOSURE_ROOT}={}){
35
+ required(release?.version==='0.15.75'&&release?.train==='R195'&&
36
+ release?.r195?.scope==='CANONICAL_PROTECTED_OWNER_OBSERVATION','candidate metadata invalid');
37
+ required(release?.r195?.public_tool_delta===0&&release?.r195?.authority_scope_delta===0,'public authority surface widened');
38
+ required(release?.parent?.version==='0.15.74'&&release?.parent?.release_id==='v0.15.74-e84bf4eed16e9443'&&
39
+ release?.parent?.manifest_sha256==='e84bf4eed16e9443fbd0bf9f0f562e26b01db778647aefcc8b12fd7f48636b47'&&
40
+ release?.parent?.generation_manifest_sha256==='598f896be9ce65e6b0c618e8c8f6eaa2a9d91617a76a146bf3deb385a56d19e7','lineage mismatch');
41
+ required(root&&path.isAbsolute(root)&&closureRoot&&path.isAbsolute(closureRoot),'closure root absent');
42
+ const expected=path.resolve(root,'..','..','testing','r195-final-closure');
43
+ required(path.resolve(closureRoot).toLowerCase()===expected.toLowerCase(),'closure root outside scoped testing folder');
44
+ let closure;try{closure=JSON.parse(await readFile(path.join(closureRoot,'closure.json'),'utf8'));}catch{fail('closure unreadable');}
45
+ required(closure?.schema==='deadbyte.r195-release-closure.v1'&&closure.status==='RELEASE_READY'&&
46
+ closure.version==='0.15.75'&&closure.train==='R195','closure status mismatch');
47
+ required(closure.production_release_id===release.parent.release_id&&closure.production_manifest_sha256===release.parent.manifest_sha256&&
48
+ closure.production_generation_manifest_sha256===release.parent.generation_manifest_sha256,'production predecessor mismatch');
49
+ required(hex64(closure.manifest_sha256)&&closure.manifest_sha256===sha256(await readFile(path.join(root,'MANIFEST.SHA256'))),'final manifest drift');
50
+ required(closure.compact_tools===43&&closure.full_tools===117,'catalog count mismatch');
51
+ required(closure.owner_enrollment==='NOT_RUN'&&closure.production_activation==='NOT_RUN','prepublication closure crossed authority boundary');
52
+ const receipt=JSON.parse((await checkedFile(path.join(closureRoot,'protected-install-receipt.json'),closure.protected_receipt_sha256)).toString('utf8'));
53
+ required(receipt?.status==='PASS'&&receipt.package_version==='0.15.75'&&receipt.source_manifest_sha256===closure.manifest_sha256&&
54
+ receipt.protected_manifest_sha256===closure.manifest_sha256,'protected exact-byte receipt mismatch');
55
+ const focused=(await checkedFile(path.join(closureRoot,'windows-focused.stdout.log'),closure.focused_stdout_sha256)).toString('utf8');
56
+ const full=(await checkedFile(path.join(closureRoot,'windows-full.stdout.log'),closure.full_stdout_sha256)).toString('utf8');
57
+ const verify=(await checkedFile(path.join(closureRoot,'npm-verify.stdout.log'),closure.verify_stdout_sha256)).toString('utf8');
58
+ required(focused.includes('R195_STAGE_PASS=focused'),'focused protected gate incomplete');
59
+ const focusedSummary=tapSummary(focused,'focused');
60
+ required(focusedSummary.fails===0&&focusedSummary.cancelled===0&&focusedSummary.passes>=70&&focusedSummary.skips<=3,'focused regression count mismatch');
61
+ required(full.includes('R195_STAGE_PASS=full'),'full protected gate incomplete');
62
+ const summary=tapSummary(full,'full');
63
+ required(summary.tests>=2200&&summary.passes>=2100&&summary.fails===0&&summary.cancelled===0&&summary.skips<=70&&summary.passes+summary.skips===summary.tests,'full regression count mismatch');
64
+ required(verify.includes('VERIFY-ONLY PIPELINE PASS')&&verify.includes('Artifact isolation gate PASS')&&verify.includes('VERIFIED_TARBALL '),'npm exact-artifact verification incomplete');
65
+ const line=verify.split(/\r?\n/).find(value=>value.startsWith('VERIFIED_TARBALL '));
66
+ let artifact;try{artifact=JSON.parse(line.slice('VERIFIED_TARBALL '.length));}catch{fail('tarball evidence malformed');}
67
+ required(artifact.filename==='deadbyte-mcp-0.15.75.tgz'&&artifact.bytes>0&&artifact.sha256===closure.tarball_sha256&&
68
+ artifact.integrity===closure.tarball_integrity&&artifact.shasum===closure.tarball_shasum,'tarball identity mismatch');
69
+ return Object.freeze({status:'R195_RELEASE_READY_EVIDENCE_BOUND',manifest_sha256:closure.manifest_sha256,
70
+ tarball_sha256:artifact.sha256,tarball_integrity:artifact.integrity,tarball_shasum:artifact.shasum,
71
+ tests:summary.tests,passes:summary.passes,skips:summary.skips});
72
+ }
@@ -0,0 +1,76 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {lstat,readFile} from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
5
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
6
+ const hex64=value=>typeof value==='string'&&/^[0-9a-f]{64}$/.test(value);
7
+ const fail=message=>{throw new Error(`PUBLISH_BLOCKED R206 ${message}`);};
8
+ const required=(value,message)=>{if(!value)fail(message);};
9
+
10
+ async function checkedFile(file,expected,{maxBytes=64*1024*1024}={}){
11
+ required(hex64(expected),'evidence digest missing');
12
+ let info;try{info=await lstat(file);}catch{fail('evidence file absent');}
13
+ required(info.isFile()&&!info.isSymbolicLink()&&info.size>0&&info.size<=maxBytes,'evidence file invalid');
14
+ const bytes=await readFile(file);
15
+ required(sha256(bytes)===expected,'evidence digest differs');
16
+ return bytes;
17
+ }
18
+
19
+ function tapSummary(text,label){
20
+ const summaries=[...text.matchAll(/^# tests (\d+)\s*\r?\n# suites (\d+)\s*\r?\n# pass (\d+)\s*\r?\n# fail (\d+)\s*\r?\n# cancelled (\d+)\s*\r?\n# skipped (\d+)/gm)];
21
+ required(summaries.length>0,`${label} TAP summary absent`);
22
+ const last=summaries.at(-1);
23
+ return {tests:Number(last[1]),passes:Number(last[3]),fails:Number(last[4]),cancelled:Number(last[5]),skips:Number(last[6])};
24
+ }
25
+
26
+ export function assertR206PackedIdentity({tarball_sha256,tarball_integrity,tarball_shasum,observedSha256,observedIntegrity,observedShasum}={}){
27
+ required(hex64(tarball_sha256)&&typeof tarball_integrity==='string'&&tarball_integrity.startsWith('sha512-')&&
28
+ typeof tarball_shasum==='string'&&/^[0-9a-f]{40}$/.test(tarball_shasum),'verified tarball identity invalid');
29
+ required(observedSha256===tarball_sha256&&observedIntegrity===tarball_integrity&&observedShasum===tarball_shasum,
30
+ 'repacked tarball differs from verified closure bytes');
31
+ return true;
32
+ }
33
+
34
+ export async function assertR206NpmPublishReady(release,{root,closureRoot=process.env.DEADBYTE_R206_CLOSURE_ROOT}={}){
35
+ required(release?.version==='0.15.75'&&release?.train==='R206'&&
36
+ release?.r206?.scope==='EVIDENCE_BOUND_CANDIDATE_SELECTION_RELEASE_CLOSURE','candidate metadata invalid');
37
+ required(release?.r206?.public_tool_delta===0&&release?.r206?.authority_scope_delta===0&&
38
+ release?.r206?.selector_release_authority===false,'public authority surface widened');
39
+ required(release?.source_predecessor?.train==='R205'&&
40
+ release?.source_predecessor?.manifest_sha256==='166eebde18d53a9ec46f738383c289733f9cd37918b3572b7515d1ab9b122c92',
41
+ 'source predecessor mismatch');
42
+ required(release?.parent?.version==='0.15.74'&&release?.parent?.release_id==='v0.15.74-e84bf4eed16e9443'&&
43
+ release?.parent?.manifest_sha256==='e84bf4eed16e9443fbd0bf9f0f562e26b01db778647aefcc8b12fd7f48636b47'&&
44
+ release?.parent?.generation_manifest_sha256==='598f896be9ce65e6b0c618e8c8f6eaa2a9d91617a76a146bf3deb385a56d19e7','lineage mismatch');
45
+ required(root&&path.isAbsolute(root)&&closureRoot&&path.isAbsolute(closureRoot),'closure root absent');
46
+ const expected=path.resolve(root,'..','..','testing','r206-final-closure');
47
+ required(path.resolve(closureRoot).toLowerCase()===expected.toLowerCase(),'closure root outside scoped testing folder');
48
+ let closure;try{closure=JSON.parse(await readFile(path.join(closureRoot,'closure.json'),'utf8'));}catch{fail('closure unreadable');}
49
+ required(closure?.schema==='deadbyte.r206-release-closure.v1'&&closure.status==='RELEASE_READY'&&
50
+ closure.version==='0.15.75'&&closure.train==='R206','closure status mismatch');
51
+ required(closure.production_release_id===release.parent.release_id&&closure.production_manifest_sha256===release.parent.manifest_sha256&&
52
+ closure.production_generation_manifest_sha256===release.parent.generation_manifest_sha256,'production predecessor mismatch');
53
+ required(hex64(closure.manifest_sha256)&&closure.manifest_sha256===sha256(await readFile(path.join(root,'MANIFEST.SHA256'))),'final manifest drift');
54
+ required(closure.compact_tools===43&&closure.full_tools===117,'catalog count mismatch');
55
+ required(closure.owner_enrollment==='NOT_RUN'&&closure.production_activation==='NOT_RUN','prepublication closure crossed authority boundary');
56
+ const receipt=JSON.parse((await checkedFile(path.join(closureRoot,'protected-install-receipt.json'),closure.protected_receipt_sha256)).toString('utf8'));
57
+ required(receipt?.status==='PASS'&&receipt.package_version==='0.15.75'&&receipt.source_manifest_sha256===closure.manifest_sha256&&
58
+ receipt.protected_manifest_sha256===closure.manifest_sha256,'protected exact-byte receipt mismatch');
59
+ const focused=(await checkedFile(path.join(closureRoot,'windows-focused.stdout.log'),closure.focused_stdout_sha256)).toString('utf8');
60
+ const full=(await checkedFile(path.join(closureRoot,'windows-full.stdout.log'),closure.full_stdout_sha256)).toString('utf8');
61
+ const verify=(await checkedFile(path.join(closureRoot,'npm-verify.stdout.log'),closure.verify_stdout_sha256)).toString('utf8');
62
+ required(focused.includes('R206_STAGE_PASS=focused'),'focused protected gate incomplete');
63
+ const focusedSummary=tapSummary(focused,'focused');
64
+ required(focusedSummary.fails===0&&focusedSummary.cancelled===0&&focusedSummary.passes>=70&&focusedSummary.skips<=3,'focused regression count mismatch');
65
+ required(full.includes('R206_STAGE_PASS=full'),'full protected gate incomplete');
66
+ const summary=tapSummary(full,'full');
67
+ required(summary.tests>=2200&&summary.passes>=2100&&summary.fails===0&&summary.cancelled===0&&summary.skips<=70&&summary.passes+summary.skips===summary.tests,'full regression count mismatch');
68
+ required(verify.includes('VERIFY-ONLY PIPELINE PASS')&&verify.includes('Artifact isolation gate PASS')&&verify.includes('VERIFIED_TARBALL '),'npm exact-artifact verification incomplete');
69
+ const line=verify.split(/\r?\n/).find(value=>value.startsWith('VERIFIED_TARBALL '));
70
+ let artifact;try{artifact=JSON.parse(line.slice('VERIFIED_TARBALL '.length));}catch{fail('tarball evidence malformed');}
71
+ required(artifact.filename==='deadbyte-mcp-0.15.75.tgz'&&artifact.bytes>0&&artifact.sha256===closure.tarball_sha256&&
72
+ artifact.integrity===closure.tarball_integrity&&artifact.shasum===closure.tarball_shasum,'tarball identity mismatch');
73
+ return Object.freeze({status:'R206_RELEASE_READY_EVIDENCE_BOUND',manifest_sha256:closure.manifest_sha256,
74
+ tarball_sha256:artifact.sha256,tarball_integrity:artifact.integrity,tarball_shasum:artifact.shasum,
75
+ tests:summary.tests,passes:summary.passes,skips:summary.skips});
76
+ }
@@ -0,0 +1,91 @@
1
+ #requires -Version 5.1
2
+ #requires -RunAsAdministrator
3
+ # R188: owner-operated elevated REVIEW receipt only. Never issues an agent grant.
4
+ # Invoke by hand from a trusted interactive desktop; not through an agent or MCP.
5
+ [CmdletBinding()]
6
+ param([Parameter(Mandatory=$true)][string]$RequestPath)
7
+ $ErrorActionPreference='Stop'
8
+ Set-StrictMode -Version Latest
9
+ $root=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
10
+ $program=[IO.Path]::GetFullPath($env:ProgramFiles).TrimEnd('\')+'\'
11
+ if(-not ($root.TrimEnd('\')+'\').StartsWith($program,[StringComparison]::OrdinalIgnoreCase)){
12
+ throw 'R188 must run from an installed Program Files release, not a writable development directory'
13
+ }
14
+ $settings=Get-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
15
+ if([int]$settings.EnableLUA -ne 1 -or [int]$settings.PromptOnSecureDesktop -ne 1 -or
16
+ [int]$settings.ConsentPromptBehaviorAdmin -eq 0){
17
+ throw 'R188 UAC secure desktop and nonautomatic admin consent must be enabled'
18
+ }
19
+ if(-not [Environment]::UserInteractive){throw 'R188 requires a local interactive owner session'}
20
+ $node='C:\Program Files\nodejs\node.exe'
21
+ if(-not (Test-Path -LiteralPath $node -PathType Leaf)){throw 'R188 trusted Node executable missing'}
22
+ $request=[IO.Path]::GetFullPath($RequestPath)
23
+ $preflight=Join-Path $root 'scripts\r188-uac-review-preview.mjs'
24
+ $raw=(& $node $preflight $request 2>&1 | Out-String)
25
+ if($LASTEXITCODE -ne 0){throw ('R188 preflight blocked: '+$raw.Substring(0,[Math]::Min(300,$raw.Length)))}
26
+ $preview=$raw|ConvertFrom-Json
27
+ if([string]$preview.status -cne 'R188_PROTECTED_REVIEW_PREVIEW_ONLY' -or
28
+ [bool]$preview.authority_granted -or [bool]$preview.owner_approved -or
29
+ [bool]$preview.live_epoch_verified -or [bool]$preview.live_policies_verified){
30
+ throw 'R188 preview unexpectedly claims grant/authorization'
31
+ }
32
+ $phrase=[string]$preview.review_phrase
33
+ if($phrase -cnotmatch '^APPROVE-[A-F0-9]{12}$'){throw 'R188 owner review phrase invalid'}
34
+ Write-Host ''
35
+ Write-Host 'DEADBYTE R188 / OWNER UAC REVIEW' -ForegroundColor Yellow
36
+ Write-Host 'This is a read-only scope REVIEW. It will NOT arm Autonomous.'
37
+ Write-Host ('Request SHA-256: '+[string]$preview.request_sha256)
38
+ Write-Host ('Project: '+[string]$preview.project_root)
39
+ Write-Host ('Action: '+[string]$preview.operation)
40
+ Write-Host ('Duration cap seconds: '+[string]$preview.max_seconds)
41
+ Write-Host ('Expires UTC: '+[string]$preview.expires_at_utc)
42
+ Write-Host ('Release manifest SHA-256: '+[string]$preview.installed_manifest_sha256)
43
+ Write-Host 'Coding policy and live machine epoch still require an independent trusted runtime read.'
44
+ Write-Host 'Do not approve requests you did not initiate and inspect yourself.'
45
+ $entered=Read-Host ('If you recognize this exact request, type '+$phrase+' (anything else rejects)')
46
+ if($entered -cne $phrase){throw 'R188 owner rejected request'}
47
+ $target='C:\Program Files\DEADBYTE-R188-OwnerReview'
48
+ if(-not (Test-Path -LiteralPath $target -PathType Container)){
49
+ $admins=New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')
50
+ $system=New-Object Security.Principal.SecurityIdentifier('S-1-5-18')
51
+ $users=New-Object Security.Principal.SecurityIdentifier('S-1-5-32-545')
52
+ New-Item -ItemType Directory -Path $target -ErrorAction Stop | Out-Null
53
+ $acl=New-Object Security.AccessControl.DirectorySecurity
54
+ $acl.SetAccessRuleProtection($true,$false)
55
+ $acl.SetOwner($admins)
56
+ $inherit=[Security.AccessControl.InheritanceFlags]'ContainerInherit, ObjectInherit'
57
+ $none=[Security.AccessControl.PropagationFlags]::None
58
+ $allow=[Security.AccessControl.AccessControlType]::Allow
59
+ $acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule($admins,'FullControl',$inherit,$none,$allow)))
60
+ $acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule($system,'FullControl',$inherit,$none,$allow)))
61
+ $acl.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule($users,'ReadAndExecute',$inherit,$none,$allow)))
62
+ Set-Acl -LiteralPath $target -AclObject $acl
63
+ }
64
+ $receipt=[ordered]@{
65
+ schema='deadbyte.r188-uac-owner-review.v1'
66
+ status='REVIEWED_NO_GRANT'
67
+ request_sha256=[string]$preview.request_sha256
68
+ release_manifest_sha256=[string]$preview.installed_manifest_sha256
69
+ reviewed_scope=[string]$preview.operation
70
+ project_root=[string]$preview.project_root
71
+ duration_cap_seconds=[int]$preview.max_seconds
72
+ reviewed_at_utc=[DateTime]::UtcNow.ToString('o')
73
+ live_epoch_verified=$false
74
+ live_policies_verified=$false
75
+ owner_reviewed=$true
76
+ authority_granted=$false
77
+ grant_issued=$false
78
+ }
79
+ $name=([string]$preview.request_sha256)+'.review.json'
80
+ $dest=Join-Path $target $name
81
+ $text=$receipt|ConvertTo-Json -Compress
82
+ $utf8=New-Object Text.UTF8Encoding($false)
83
+ $stream=[IO.File]::Open($dest,[IO.FileMode]::CreateNew,[IO.FileAccess]::Write,[IO.FileShare]::None)
84
+ try{
85
+ $bytes=$utf8.GetBytes($text+[Environment]::NewLine)
86
+ $stream.Write($bytes,0,$bytes.Length)
87
+ $stream.Flush($true)
88
+ }finally{$stream.Dispose()}
89
+ Write-Host 'R188_OWNER_REVIEWED_NO_GRANT' -ForegroundColor Yellow
90
+ Write-Host ('Receipt: '+$dest)
91
+ Write-Host 'No PEM, Windows Hello, Autonomous grant, npm publish, or production activation performed.'
@@ -0,0 +1,65 @@
1
+ // Protected owner's manual UAC review: verify a request without granting.
2
+ // Requested policy / epoch hashes are UNTRUSTED previews until a protected
3
+ // runtime reader binds them; never interpret this as an authorization token.
4
+ import {readFile,lstat} from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import {fileURLToPath} from 'node:url';
7
+ import {inspectTrustedInstallation} from '../src/privileged-install-trust-r89.mjs';
8
+ import {parseManifest,verifyManifestTreeExact} from '../src/release-slot.mjs';
9
+ import {verifyR188OwnerUacRequest} from '../src/r188-owner-uac.mjs';
10
+ const thisFile=fileURLToPath(import.meta.url);
11
+ const root=path.resolve(path.dirname(thisFile),'..');
12
+ const args=process.argv.slice(2);
13
+ function block(reason){throw Error('R188_UAC_REVIEW_BLOCKED '+reason);}
14
+ async function bounded(file,max){
15
+ const st=await lstat(file);
16
+ if(!st.isFile()||st.isSymbolicLink()||st.size<1||st.size>max)block('UNSAFE_FILE');
17
+ return readFile(file);
18
+ }
19
+ async function main(){
20
+ if(process.platform!=='win32'||process.arch!=='x64')block('WINDOWS_X64_REQUIRED');
21
+ if(args.length!==1||!path.win32.isAbsolute(args[0]))block('ABSOLUTE_REQUEST_REQUIRED');
22
+ const os=await inspectTrustedInstallation([
23
+ process.execPath,thisFile,
24
+ path.join(root,'MANIFEST.SHA256'),
25
+ path.join(root,'src','r188-owner-uac.mjs'),
26
+ path.join(root,'src','canonical-json.mjs'),
27
+ path.join(root,'src','privileged-install-trust-r89.mjs')
28
+ ]);
29
+ if(!os.trusted)block('R89_PROTECTED_INSTALLATION_REQUIRED');
30
+ const manifestBytes=await bounded(path.join(root,'MANIFEST.SHA256'),512*1024);
31
+ const manifest=parseManifest(manifestBytes.toString('utf8'));
32
+ await verifyManifestTreeExact(root,manifest);
33
+ const request=JSON.parse((await bounded(args[0],64*1024)).toString('utf8'));
34
+ const subject=request.subject;
35
+ if(!subject||typeof subject!=='object')block('SUBJECT_MISSING');
36
+ const expected={
37
+ machineEpoch:subject.machine_epoch,
38
+ releaseManifestSha256:subject.release_manifest_sha256,
39
+ codingPolicySha256:subject.coding_policy_sha256,
40
+ autonomousPolicySha256:subject.autonomous_policy_sha256,
41
+ rootId:subject.root_id,projectRoot:subject.project_root,
42
+ maxSeconds:subject.max_seconds
43
+ };
44
+ // Strict self-consistency proof, NOT yet verification of the live epoch/policy.
45
+ const verified=verifyR188OwnerUacRequest({request,expected,now:new Date()});
46
+ const {createHash}=await import('node:crypto');
47
+ const actualManifest=createHash('sha256').update(manifestBytes).digest('hex');
48
+ if(subject.release_manifest_sha256!==actualManifest)block('INSTALLED_RELEASE_NOT_REVIEWED_RELEASE');
49
+ process.stdout.write(JSON.stringify({
50
+ status:'R188_PROTECTED_REVIEW_PREVIEW_ONLY',
51
+ request_sha256:verified.request_sha256,
52
+ review_phrase:verified.review_phrase,
53
+ root_id:subject.root_id,project_root:subject.project_root,
54
+ max_seconds:subject.max_seconds,operation:subject.operation,
55
+ expires_at_utc:subject.expires_at_utc,
56
+ requested_machine_epoch:subject.machine_epoch,
57
+ requested_coding_policy_sha256:subject.coding_policy_sha256,
58
+ requested_autonomous_policy_sha256:subject.autonomous_policy_sha256,
59
+ installed_manifest_sha256:actualManifest,
60
+ os_acl_trusted:true,
61
+ live_epoch_verified:false,live_policies_verified:false,
62
+ authority_granted:false,owner_approved:false
63
+ })+'\n');
64
+ }
65
+ main().catch(e=>{console.error(String(e?.message||e).slice(0,320));process.exitCode=2;});
@@ -0,0 +1,22 @@
1
+ $ErrorActionPreference='Stop'
2
+ $root=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
3
+ $source=Join-Path $root 'native\deadbyte-owner-token-r193.cpp'
4
+ $dest=Join-Path $root 'bin\deadbyte-owner-token-r193.exe'
5
+ $sourceDigest='99d1ec196e3e3242a9d44a6445d60abd1b3fbbd53dc9be126d4cc5bb91074099'
6
+ if ((Get-FileHash $source).Hash.ToLowerInvariant() -cne $sourceDigest) { throw 'R193_SOURCE_DRIFT' }
7
+ $gpp='C:\Users\DEADBYTE\scoop\apps\w64devkit\current\bin\g++.exe'
8
+ if(-not(Test-Path $gpp -PathType Leaf)){throw 'R193_TOOLCHAIN_MISSING'}
9
+ if(Test-Path $dest){throw 'R193_BINARY_EXISTS - do not overwrite without explicit inspection'}
10
+ & $gpp -std=c++17 -O2 -Wall -Wextra -Werror -static -s -o $dest $source -ladvapi32
11
+ if($LASTEXITCODE -ne 0){throw "R193_COMPILER_FAILED exit=$LASTEXITCODE"}
12
+ $raw=@(& $dest --report)
13
+ if($LASTEXITCODE -ne 0){throw "R193_REPORT_FAILED exit=$LASTEXITCODE"}
14
+ $report=($raw -join [Environment]::NewLine)|ConvertFrom-Json
15
+ if($report.schema -cne 'deadbyte.r193-native-token.v1' -or $report.authority_granted -or $report.owner_approved -or $report.parent_independence_verified){throw 'R193_INVALID_TOKEN_REPORT'}
16
+ $strictRaw=@(& $dest --require-standard)
17
+ $strictExit=$LASTEXITCODE
18
+ $strict=($strictRaw -join [Environment]::NewLine) | ConvertFrom-Json
19
+ if($report.status -cne $strict.status){throw 'R193_SUBJECT_STATUS_CHANGED'}
20
+ if($report.status -eq 'BLOCKED' -and $strictExit -ne 3){throw 'R193_FAIL_CLOSED_EXPECTED_EXIT3'}
21
+ if($report.status -eq 'STANDARD_TOKEN_OBSERVED' -and $strictExit -ne 0){throw 'R193_STANDARD_EXPECTED_EXIT0'}
22
+ [pscustomobject]@{schema='deadbyte.r193-native-token-acceptance.v1';status='PASS';source_sha256=$sourceDigest;binary_sha256=(Get-FileHash $dest).Hash.ToLowerInvariant();binary_bytes=(Get-Item $dest).Length;native_report=$report;strict_exit=$strictExit;no_grant=$true}|ConvertTo-Json -Depth 7 -Compress