@emilia-protocol/gate 0.10.0 → 0.13.0

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 (419) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +272 -0
  3. package/action-control-manifest.js +3 -268
  4. package/action-escrow-custodian.js +4 -0
  5. package/action-escrow-evidence.js +4 -0
  6. package/action-escrow-package.js +4 -0
  7. package/action-escrow-postgres.js +4 -0
  8. package/action-escrow-state.js +4 -0
  9. package/action-escrow-verifiers.js +4 -0
  10. package/action-escrow.js +4 -0
  11. package/action-packs.js +3 -140
  12. package/adapters/_kit.js +3 -104
  13. package/adapters/aws.js +3 -108
  14. package/adapters/cloudflare.js +3 -54
  15. package/adapters/gcp.js +3 -70
  16. package/adapters/github.js +3 -109
  17. package/adapters/jira.js +3 -55
  18. package/adapters/k8s.js +3 -70
  19. package/adapters/linear.js +3 -55
  20. package/adapters/salesforce.js +3 -55
  21. package/adapters/stripe.js +3 -81
  22. package/adapters/supabase.js +3 -121
  23. package/adapters/terraform.js +3 -59
  24. package/adapters/vercel.js +3 -84
  25. package/aec-execution.js +3 -312
  26. package/breakglass.js +3 -582
  27. package/capability-receipt.js +4 -0
  28. package/cf1-conformance.js +3 -106
  29. package/challenge-store.js +3 -69
  30. package/control-plane.js +3 -340
  31. package/coverage.js +3 -721
  32. package/demo.mjs +1 -1
  33. package/deployment-attestation.js +3 -247
  34. package/dist/action-control-manifest.d.ts +82 -0
  35. package/dist/action-control-manifest.d.ts.map +1 -0
  36. package/dist/action-control-manifest.js +422 -0
  37. package/dist/action-control-manifest.js.map +1 -0
  38. package/dist/action-escrow-custodian.d.ts +74 -0
  39. package/dist/action-escrow-custodian.d.ts.map +1 -0
  40. package/dist/action-escrow-custodian.js +363 -0
  41. package/dist/action-escrow-custodian.js.map +1 -0
  42. package/dist/action-escrow-evidence.d.ts +130 -0
  43. package/dist/action-escrow-evidence.d.ts.map +1 -0
  44. package/dist/action-escrow-evidence.js +1012 -0
  45. package/dist/action-escrow-evidence.js.map +1 -0
  46. package/dist/action-escrow-package.d.ts +10 -0
  47. package/dist/action-escrow-package.d.ts.map +1 -0
  48. package/dist/action-escrow-package.js +1583 -0
  49. package/dist/action-escrow-package.js.map +1 -0
  50. package/dist/action-escrow-postgres.d.ts +62 -0
  51. package/dist/action-escrow-postgres.d.ts.map +1 -0
  52. package/dist/action-escrow-postgres.js +339 -0
  53. package/dist/action-escrow-postgres.js.map +1 -0
  54. package/dist/action-escrow-state.d.ts +141 -0
  55. package/dist/action-escrow-state.d.ts.map +1 -0
  56. package/dist/action-escrow-state.js +413 -0
  57. package/dist/action-escrow-state.js.map +1 -0
  58. package/dist/action-escrow-verifiers.d.ts +65 -0
  59. package/dist/action-escrow-verifiers.d.ts.map +1 -0
  60. package/dist/action-escrow-verifiers.js +421 -0
  61. package/dist/action-escrow-verifiers.js.map +1 -0
  62. package/dist/action-escrow.d.ts +112 -0
  63. package/dist/action-escrow.d.ts.map +1 -0
  64. package/dist/action-escrow.js +2661 -0
  65. package/dist/action-escrow.js.map +1 -0
  66. package/dist/action-packs.d.ts +54 -0
  67. package/dist/action-packs.d.ts.map +1 -0
  68. package/dist/action-packs.js +143 -0
  69. package/dist/action-packs.js.map +1 -0
  70. package/dist/adapters/_kit.d.ts +50 -0
  71. package/dist/adapters/_kit.d.ts.map +1 -0
  72. package/dist/adapters/_kit.js +98 -0
  73. package/dist/adapters/_kit.js.map +1 -0
  74. package/dist/adapters/aws.d.ts +158 -0
  75. package/dist/adapters/aws.d.ts.map +1 -0
  76. package/dist/adapters/aws.js +136 -0
  77. package/dist/adapters/aws.js.map +1 -0
  78. package/dist/adapters/cloudflare.d.ts +116 -0
  79. package/dist/adapters/cloudflare.d.ts.map +1 -0
  80. package/dist/adapters/cloudflare.js +75 -0
  81. package/dist/adapters/cloudflare.js.map +1 -0
  82. package/dist/adapters/gcp.d.ts +139 -0
  83. package/dist/adapters/gcp.d.ts.map +1 -0
  84. package/dist/adapters/gcp.js +69 -0
  85. package/dist/adapters/gcp.js.map +1 -0
  86. package/dist/adapters/github.d.ts +123 -0
  87. package/dist/adapters/github.d.ts.map +1 -0
  88. package/dist/adapters/github.js +105 -0
  89. package/dist/adapters/github.js.map +1 -0
  90. package/dist/adapters/jira.d.ts +109 -0
  91. package/dist/adapters/jira.d.ts.map +1 -0
  92. package/dist/adapters/jira.js +54 -0
  93. package/dist/adapters/jira.js.map +1 -0
  94. package/dist/adapters/k8s.d.ts +139 -0
  95. package/dist/adapters/k8s.d.ts.map +1 -0
  96. package/dist/adapters/k8s.js +69 -0
  97. package/dist/adapters/k8s.js.map +1 -0
  98. package/dist/adapters/linear.d.ts +109 -0
  99. package/dist/adapters/linear.d.ts.map +1 -0
  100. package/dist/adapters/linear.js +54 -0
  101. package/dist/adapters/linear.js.map +1 -0
  102. package/dist/adapters/salesforce.d.ts +109 -0
  103. package/dist/adapters/salesforce.d.ts.map +1 -0
  104. package/dist/adapters/salesforce.js +54 -0
  105. package/dist/adapters/salesforce.js.map +1 -0
  106. package/dist/adapters/stripe.d.ts +116 -0
  107. package/dist/adapters/stripe.d.ts.map +1 -0
  108. package/dist/adapters/stripe.js +77 -0
  109. package/dist/adapters/stripe.js.map +1 -0
  110. package/dist/adapters/supabase.d.ts +127 -0
  111. package/dist/adapters/supabase.d.ts.map +1 -0
  112. package/dist/adapters/supabase.js +112 -0
  113. package/dist/adapters/supabase.js.map +1 -0
  114. package/dist/adapters/terraform.d.ts +109 -0
  115. package/dist/adapters/terraform.d.ts.map +1 -0
  116. package/dist/adapters/terraform.js +58 -0
  117. package/dist/adapters/terraform.js.map +1 -0
  118. package/dist/adapters/vercel.d.ts +114 -0
  119. package/dist/adapters/vercel.d.ts.map +1 -0
  120. package/dist/adapters/vercel.js +81 -0
  121. package/dist/adapters/vercel.js.map +1 -0
  122. package/dist/aec-execution.d.ts +107 -0
  123. package/dist/aec-execution.d.ts.map +1 -0
  124. package/dist/aec-execution.js +334 -0
  125. package/dist/aec-execution.js.map +1 -0
  126. package/dist/breakglass.d.ts +205 -0
  127. package/dist/breakglass.d.ts.map +1 -0
  128. package/dist/breakglass.js +627 -0
  129. package/dist/breakglass.js.map +1 -0
  130. package/dist/capability-receipt.d.ts +601 -0
  131. package/dist/capability-receipt.d.ts.map +1 -0
  132. package/dist/capability-receipt.js +1177 -0
  133. package/dist/capability-receipt.js.map +1 -0
  134. package/dist/cf1-conformance.d.ts +83 -0
  135. package/dist/cf1-conformance.d.ts.map +1 -0
  136. package/dist/cf1-conformance.js +94 -0
  137. package/dist/cf1-conformance.js.map +1 -0
  138. package/dist/challenge-store.d.ts +20 -0
  139. package/dist/challenge-store.d.ts.map +1 -0
  140. package/dist/challenge-store.js +62 -0
  141. package/dist/challenge-store.js.map +1 -0
  142. package/dist/control-plane.d.ts +136 -0
  143. package/dist/control-plane.d.ts.map +1 -0
  144. package/dist/control-plane.js +349 -0
  145. package/dist/control-plane.js.map +1 -0
  146. package/dist/coverage.d.ts +156 -0
  147. package/dist/coverage.d.ts.map +1 -0
  148. package/dist/coverage.js +768 -0
  149. package/dist/coverage.js.map +1 -0
  150. package/dist/deployment-attestation.d.ts +93 -0
  151. package/dist/deployment-attestation.d.ts.map +1 -0
  152. package/dist/deployment-attestation.js +262 -0
  153. package/dist/deployment-attestation.js.map +1 -0
  154. package/dist/eg1-conformance.d.ts +286 -0
  155. package/dist/eg1-conformance.d.ts.map +1 -0
  156. package/dist/eg1-conformance.js +379 -0
  157. package/dist/eg1-conformance.js.map +1 -0
  158. package/dist/enterprise.d.ts +88 -0
  159. package/dist/enterprise.d.ts.map +1 -0
  160. package/dist/enterprise.js +194 -0
  161. package/dist/enterprise.js.map +1 -0
  162. package/dist/evidence-postgres.d.ts +123 -0
  163. package/dist/evidence-postgres.d.ts.map +1 -0
  164. package/dist/evidence-postgres.js +343 -0
  165. package/dist/evidence-postgres.js.map +1 -0
  166. package/dist/evidence.d.ts +113 -0
  167. package/dist/evidence.d.ts.map +1 -0
  168. package/dist/evidence.js +369 -0
  169. package/dist/evidence.js.map +1 -0
  170. package/dist/execution-binding.d.ts +49 -0
  171. package/dist/execution-binding.d.ts.map +1 -0
  172. package/dist/execution-binding.js +243 -0
  173. package/dist/execution-binding.js.map +1 -0
  174. package/dist/formal-runtime-map.d.ts +42 -0
  175. package/dist/formal-runtime-map.d.ts.map +1 -0
  176. package/dist/formal-runtime-map.js +23 -0
  177. package/dist/formal-runtime-map.js.map +1 -0
  178. package/dist/index.d.ts +1002 -0
  179. package/dist/index.d.ts.map +1 -0
  180. package/dist/index.js +1736 -0
  181. package/dist/index.js.map +1 -0
  182. package/dist/key-registry.d.ts +60 -0
  183. package/dist/key-registry.d.ts.map +1 -0
  184. package/dist/key-registry.js +144 -0
  185. package/dist/key-registry.js.map +1 -0
  186. package/dist/mcp.d.ts +53 -0
  187. package/dist/mcp.d.ts.map +1 -0
  188. package/dist/mcp.js +112 -0
  189. package/dist/mcp.js.map +1 -0
  190. package/dist/metering.d.ts +80 -0
  191. package/dist/metering.d.ts.map +1 -0
  192. package/dist/metering.js +227 -0
  193. package/dist/metering.js.map +1 -0
  194. package/dist/metrics.d.ts +68 -0
  195. package/dist/metrics.d.ts.map +1 -0
  196. package/dist/metrics.js +242 -0
  197. package/dist/metrics.js.map +1 -0
  198. package/dist/network-witness.d.ts +167 -0
  199. package/dist/network-witness.d.ts.map +1 -0
  200. package/dist/network-witness.js +520 -0
  201. package/dist/network-witness.js.map +1 -0
  202. package/dist/protocol-state.d.ts +141 -0
  203. package/dist/protocol-state.d.ts.map +1 -0
  204. package/dist/protocol-state.js +106 -0
  205. package/dist/protocol-state.js.map +1 -0
  206. package/dist/receipt-program.d.ts +59 -0
  207. package/dist/receipt-program.d.ts.map +1 -0
  208. package/dist/receipt-program.js +1053 -0
  209. package/dist/receipt-program.js.map +1 -0
  210. package/dist/reliance-kernel.d.ts +66 -0
  211. package/dist/reliance-kernel.d.ts.map +1 -0
  212. package/dist/reliance-kernel.js +103 -0
  213. package/dist/reliance-kernel.js.map +1 -0
  214. package/dist/reliance-packet.d.ts +67 -0
  215. package/dist/reliance-packet.d.ts.map +1 -0
  216. package/dist/reliance-packet.js +176 -0
  217. package/dist/reliance-packet.js.map +1 -0
  218. package/dist/remedy-program-postgres.d.ts +37 -0
  219. package/dist/remedy-program-postgres.d.ts.map +1 -0
  220. package/dist/remedy-program-postgres.js +291 -0
  221. package/dist/remedy-program-postgres.js.map +1 -0
  222. package/dist/remedy-program-receipt.d.ts +97 -0
  223. package/dist/remedy-program-receipt.d.ts.map +1 -0
  224. package/dist/remedy-program-receipt.js +817 -0
  225. package/dist/remedy-program-receipt.js.map +1 -0
  226. package/dist/remedy-program.d.ts +76 -0
  227. package/dist/remedy-program.d.ts.map +1 -0
  228. package/dist/remedy-program.js +1346 -0
  229. package/dist/remedy-program.js.map +1 -0
  230. package/dist/reports/art14.d.ts +101 -0
  231. package/dist/reports/art14.d.ts.map +1 -0
  232. package/dist/reports/art14.js +340 -0
  233. package/dist/reports/art14.js.map +1 -0
  234. package/dist/reports/assurance-package.d.ts +197 -0
  235. package/dist/reports/assurance-package.d.ts.map +1 -0
  236. package/dist/reports/assurance-package.js +313 -0
  237. package/dist/reports/assurance-package.js.map +1 -0
  238. package/dist/reports/auditor-workpaper.d.ts +194 -0
  239. package/dist/reports/auditor-workpaper.d.ts.map +1 -0
  240. package/dist/reports/auditor-workpaper.js +545 -0
  241. package/dist/reports/auditor-workpaper.js.map +1 -0
  242. package/dist/reports/external-verification.d.ts +76 -0
  243. package/dist/reports/external-verification.d.ts.map +1 -0
  244. package/dist/reports/external-verification.js +209 -0
  245. package/dist/reports/external-verification.js.map +1 -0
  246. package/dist/reports/reperform.d.ts +122 -0
  247. package/dist/reports/reperform.d.ts.map +1 -0
  248. package/dist/reports/reperform.js +432 -0
  249. package/dist/reports/reperform.js.map +1 -0
  250. package/dist/reports/underwriter.d.ts +127 -0
  251. package/dist/reports/underwriter.d.ts.map +1 -0
  252. package/dist/reports/underwriter.js +348 -0
  253. package/dist/reports/underwriter.js.map +1 -0
  254. package/dist/retention.d.ts +88 -0
  255. package/dist/retention.d.ts.map +1 -0
  256. package/dist/retention.js +90 -0
  257. package/dist/retention.js.map +1 -0
  258. package/dist/roster.d.ts +113 -0
  259. package/dist/roster.d.ts.map +1 -0
  260. package/dist/roster.js +261 -0
  261. package/dist/roster.js.map +1 -0
  262. package/dist/runtime-monitor.d.ts +132 -0
  263. package/dist/runtime-monitor.d.ts.map +1 -0
  264. package/dist/runtime-monitor.js +197 -0
  265. package/dist/runtime-monitor.js.map +1 -0
  266. package/dist/settlement.d.ts +68 -0
  267. package/dist/settlement.d.ts.map +1 -0
  268. package/dist/settlement.js +306 -0
  269. package/dist/settlement.js.map +1 -0
  270. package/dist/siem.d.ts +261 -0
  271. package/dist/siem.d.ts.map +1 -0
  272. package/dist/siem.js +247 -0
  273. package/dist/siem.js.map +1 -0
  274. package/dist/store-postgres.d.ts +107 -0
  275. package/dist/store-postgres.d.ts.map +1 -0
  276. package/dist/store-postgres.js +152 -0
  277. package/dist/store-postgres.js.map +1 -0
  278. package/dist/store.d.ts +95 -0
  279. package/dist/store.d.ts.map +1 -0
  280. package/dist/store.js +202 -0
  281. package/dist/store.js.map +1 -0
  282. package/dist/strict-json.d.ts +14 -0
  283. package/dist/strict-json.d.ts.map +1 -0
  284. package/dist/strict-json.js +132 -0
  285. package/dist/strict-json.js.map +1 -0
  286. package/dist/trust-program-adapters.d.ts +122 -0
  287. package/dist/trust-program-adapters.d.ts.map +1 -0
  288. package/dist/trust-program-adapters.js +802 -0
  289. package/dist/trust-program-adapters.js.map +1 -0
  290. package/dist/trust-program-postgres.d.ts +41 -0
  291. package/dist/trust-program-postgres.d.ts.map +1 -0
  292. package/dist/trust-program-postgres.js +346 -0
  293. package/dist/trust-program-postgres.js.map +1 -0
  294. package/dist/trust-program-revocation.d.ts +206 -0
  295. package/dist/trust-program-revocation.d.ts.map +1 -0
  296. package/dist/trust-program-revocation.js +600 -0
  297. package/dist/trust-program-revocation.js.map +1 -0
  298. package/dist/trust-program.d.ts +197 -0
  299. package/dist/trust-program.d.ts.map +1 -0
  300. package/dist/trust-program.js +1351 -0
  301. package/dist/trust-program.js.map +1 -0
  302. package/dist/witness-postgres.d.ts +43 -0
  303. package/dist/witness-postgres.d.ts.map +1 -0
  304. package/dist/witness-postgres.js +92 -0
  305. package/dist/witness-postgres.js.map +1 -0
  306. package/dist/zk-range-proof.d.ts +78 -0
  307. package/dist/zk-range-proof.d.ts.map +1 -0
  308. package/dist/zk-range-proof.js +228 -0
  309. package/dist/zk-range-proof.js.map +1 -0
  310. package/eg1-conformance.js +3 -404
  311. package/enterprise.js +3 -180
  312. package/ep-assure.mjs +1 -0
  313. package/evidence-postgres.js +3 -356
  314. package/evidence.js +4 -360
  315. package/execution-binding.js +3 -212
  316. package/formal-runtime-map.js +4 -0
  317. package/index.js +4 -1249
  318. package/key-registry.js +3 -134
  319. package/mcp.js +3 -109
  320. package/metering.js +3 -226
  321. package/metrics.js +3 -231
  322. package/network-witness.js +3 -499
  323. package/package.json +47 -4
  324. package/receipt-program.js +4 -0
  325. package/reliance-kernel.js +3 -112
  326. package/reliance-packet.js +3 -175
  327. package/remedy-program-postgres.js +4 -0
  328. package/remedy-program-receipt.js +4 -0
  329. package/remedy-program.js +4 -0
  330. package/reports/art14.js +0 -0
  331. package/reports/assurance-package.js +2 -312
  332. package/reports/auditor-workpaper.js +3 -537
  333. package/reports/external-verification.js +3 -222
  334. package/reports/reperform.js +3 -424
  335. package/reports/underwriter.js +3 -339
  336. package/retention.js +3 -84
  337. package/roster.js +3 -264
  338. package/runtime-monitor.js +4 -0
  339. package/settlement.js +3 -299
  340. package/siem.js +3 -235
  341. package/src/action-control-manifest.ts +424 -0
  342. package/src/action-escrow-custodian.ts +427 -0
  343. package/src/action-escrow-evidence.ts +1178 -0
  344. package/src/action-escrow-package.ts +1821 -0
  345. package/src/action-escrow-postgres.ts +366 -0
  346. package/src/action-escrow-state.ts +498 -0
  347. package/src/action-escrow-verifiers.ts +484 -0
  348. package/src/action-escrow.ts +3039 -0
  349. package/src/action-packs.ts +170 -0
  350. package/src/adapters/_kit.ts +117 -0
  351. package/src/adapters/aws.ts +142 -0
  352. package/src/adapters/cloudflare.ts +78 -0
  353. package/src/adapters/gcp.ts +71 -0
  354. package/src/adapters/github.ts +110 -0
  355. package/src/adapters/jira.ts +56 -0
  356. package/src/adapters/k8s.ts +71 -0
  357. package/src/adapters/linear.ts +56 -0
  358. package/src/adapters/salesforce.ts +56 -0
  359. package/src/adapters/stripe.ts +82 -0
  360. package/src/adapters/supabase.ts +122 -0
  361. package/src/adapters/terraform.ts +60 -0
  362. package/src/adapters/vercel.ts +85 -0
  363. package/src/aec-execution.ts +354 -0
  364. package/src/breakglass.ts +647 -0
  365. package/src/capability-receipt.ts +1258 -0
  366. package/src/cf1-conformance.ts +120 -0
  367. package/src/challenge-store.ts +70 -0
  368. package/src/control-plane.ts +374 -0
  369. package/src/coverage.ts +832 -0
  370. package/src/deployment-attestation.ts +259 -0
  371. package/src/eg1-conformance.ts +471 -0
  372. package/src/enterprise.ts +195 -0
  373. package/src/evidence-postgres.ts +374 -0
  374. package/src/evidence.ts +367 -0
  375. package/src/execution-binding.ts +236 -0
  376. package/src/formal-runtime-map.ts +24 -0
  377. package/src/index.ts +2122 -0
  378. package/src/key-registry.ts +150 -0
  379. package/src/mcp.ts +120 -0
  380. package/src/metering.ts +237 -0
  381. package/src/metrics.ts +232 -0
  382. package/src/network-witness.ts +585 -0
  383. package/src/protocol-state.ts +143 -0
  384. package/src/protocol-state.typecheck.ts +94 -0
  385. package/src/receipt-program.ts +1105 -0
  386. package/src/reliance-kernel.ts +119 -0
  387. package/src/reliance-packet.ts +206 -0
  388. package/src/remedy-program-postgres.ts +367 -0
  389. package/src/remedy-program-receipt.ts +891 -0
  390. package/src/remedy-program.ts +1388 -0
  391. package/src/reports/art14.ts +361 -0
  392. package/src/reports/assurance-package.ts +330 -0
  393. package/src/reports/auditor-workpaper.ts +558 -0
  394. package/src/reports/external-verification.ts +232 -0
  395. package/src/reports/reperform.ts +441 -0
  396. package/src/reports/underwriter.ts +356 -0
  397. package/src/retention.ts +100 -0
  398. package/src/roster.ts +273 -0
  399. package/src/runtime-monitor.ts +217 -0
  400. package/src/settlement.ts +313 -0
  401. package/src/siem.ts +247 -0
  402. package/src/store-postgres.ts +167 -0
  403. package/src/store.ts +214 -0
  404. package/src/strict-json.ts +115 -0
  405. package/src/trust-program-adapters.ts +847 -0
  406. package/src/trust-program-postgres.ts +429 -0
  407. package/src/trust-program-revocation.ts +751 -0
  408. package/src/trust-program.ts +1460 -0
  409. package/src/witness-postgres.ts +106 -0
  410. package/src/zk-range-proof.ts +250 -0
  411. package/store-postgres.js +3 -161
  412. package/store.js +4 -198
  413. package/strict-json.js +3 -85
  414. package/trust-program-adapters.js +4 -0
  415. package/trust-program-postgres.js +4 -0
  416. package/trust-program-revocation.js +4 -0
  417. package/trust-program.js +4 -0
  418. package/witness-postgres.js +3 -96
  419. package/zk-range-proof.js +4 -0
@@ -0,0 +1,545 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EMILIA Gate — auditor control-testing workpaper (ITGC / SOX-shaped).
4
+ *
5
+ * The artifact an external auditor's control test consumes: a pinned population
6
+ * of guarded gate decisions over a period, a deterministic (seed-reproducible,
7
+ * RNG-free) attribute sample, per-item attribute observations tied to named
8
+ * evidence-log fields, and an exception list — computed from the gate's
9
+ * tamper-evident evidence log. Pure function: same entries + same options in,
10
+ * identical JSON out (pin `now` for a byte-stable artifact).
11
+ *
12
+ * HONESTY BOUNDARY (carried inside the artifact): this workpaper SUPPORTS the
13
+ * auditor's control test. It never performs, reviews, or concludes the test —
14
+ * the sign-off fields are ALWAYS emitted null and rendered as blanks for the
15
+ * auditor to complete. A refusal (deny decision) is the deny-by-default control
16
+ * operating as designed and is NOT a control exception.
17
+ *
18
+ * Fail closed: missing client/engagement/control reference, an invalid or
19
+ * inverted period, a non-integer sample size, or a missing sample seed is an
20
+ * error, not a guess. Entries that cannot be verified as log records are
21
+ * EXCLUDED from the population and surfaced as integrity_warnings — the
22
+ * workpaper never samples what it cannot account for. Window is half-open
23
+ * [periodStart, periodEnd): an entry stamped exactly at periodEnd belongs to
24
+ * the NEXT period, so adjacent workpapers never double-count.
25
+ */
26
+ import crypto from 'node:crypto';
27
+ export const AUDIT_WORKPAPER_VERSION = 'EP-GATE-AUDIT-WORKPAPER-v1';
28
+ /**
29
+ * Mandatory honesty header. Present verbatim in every workpaper and every
30
+ * rendered view; a document without it is not an EP-GATE-AUDIT-WORKPAPER-v1.
31
+ */
32
+ export const AUDIT_WORKPAPER_HONESTY_NOTICE = 'This workpaper was prepared from the deploying organization\'s tamper-evident '
33
+ + 'evidence log to SUPPORT control testing. It supplies the population, a '
34
+ + 'reproducible sample, and per-item attribute observations; it does not perform '
35
+ + 'the test. The auditor performs and concludes the test and remains responsible '
36
+ + 'for sample evaluation and any conclusion drawn. This is not an audit opinion, '
37
+ + 'and nothing in this document constitutes a conclusion, certification, or '
38
+ + 'attestation by the preparer or by EMILIA Gate.';
39
+ /**
40
+ * Refusal treatment is a structural statement of the format, not commentary:
41
+ * a denial is the control WORKING, so it can never be a control exception.
42
+ */
43
+ export const REFUSAL_TREATMENT = 'A refusal (deny decision) is the deny-by-default control operating as designed: '
44
+ + 'the gate withheld execution. Refusals are therefore NOT control exceptions. '
45
+ + 'Attributes A1-A5 describe properties of a granted authorization and are recorded '
46
+ + 'as not_applicable on refusals; only A6 (the refusal was durably logged in the '
47
+ + 'tamper-evident chain) is tested on a refusal.';
48
+ /**
49
+ * The attribute test plan. Each attribute names the evidence-log field(s) the
50
+ * observation is read from, so the auditor can retrace every pass/fail to the
51
+ * underlying record. Missing or malformed evidence FAILS the attribute — an
52
+ * observation the log cannot support is never presumed to pass.
53
+ */
54
+ export const AUDIT_ATTRIBUTES = [
55
+ {
56
+ id: 'A1',
57
+ name: 'receipt_verified_against_pinned_issuer',
58
+ evidence_field: 'signer',
59
+ test: 'The decision records the pinned issuer key that verified the receipt signature. The gate sets `signer` only after Ed25519 verification against pinned/registry issuer keys; an allow without a recorded signer fails.',
60
+ },
61
+ {
62
+ id: 'A2',
63
+ name: 'credited_assurance_tier_meets_required',
64
+ evidence_field: 'have_tier, required_tier',
65
+ test: 'The cryptographically credited assurance tier meets or exceeds the tier the manifest requires for this action. An unknown or missing tier on either side fails (fail closed).',
66
+ },
67
+ {
68
+ id: 'A3',
69
+ name: 'not_a_replay',
70
+ evidence_field: 'reason, receipt_id',
71
+ test: 'The authorization was granted on a fresh presentation: the decision reason is `allow` and a stable issuer-generated receipt_id (the replay-defense key) is present. Without a receipt_id, replay detection is impossible for this decision.',
72
+ },
73
+ {
74
+ id: 'A4',
75
+ name: 'one_time_consumption_recorded',
76
+ evidence_field: 'consumption_mode',
77
+ test: 'One-time consumption of the receipt was actually recorded (`consume` or `reserve`). Mode `none` means replay defense was explicitly bypassed for this decision and fails.',
78
+ },
79
+ {
80
+ id: 'A5',
81
+ name: 'named_principal_present',
82
+ evidence_field: 'subject',
83
+ test: 'A named principal (the receipt subject) is recorded on the decision, attributing the authorization to a human identity as pinned by the deployer.',
84
+ },
85
+ {
86
+ id: 'A6',
87
+ name: 'decision_logged_tamper_evident',
88
+ evidence_field: 'hash, prev_hash, seq',
89
+ test: 'The decision is a well-formed record of the hash-chained evidence log: 64-hex record hash, non-empty prev_hash, non-negative integer seq.',
90
+ },
91
+ ];
92
+ const TIER_RANK = { software: 0, class_a: 1, quorum: 2 };
93
+ const HEX64 = /^[0-9a-f]{64}$/;
94
+ function sha256hex(s) {
95
+ return crypto.createHash('sha256').update(s, 'utf8').digest('hex');
96
+ }
97
+ function toMs(t) {
98
+ if (t == null)
99
+ return null;
100
+ const ms = typeof t === 'number' ? t : Date.parse(t);
101
+ return Number.isFinite(ms) ? ms : null;
102
+ }
103
+ function nonEmptyString(v) {
104
+ return typeof v === 'string' && v.length > 0;
105
+ }
106
+ /* ------------------------- attribute observations ------------------------ */
107
+ function observeA1(e) {
108
+ return { pass: nonEmptyString(e.signer), observed: nonEmptyString(e.signer) ? e.signer : 'signer absent' };
109
+ }
110
+ function observeA2(e) {
111
+ const have = e.have_tier;
112
+ const req = e.required_tier;
113
+ const pass = nonEmptyString(have) && nonEmptyString(req)
114
+ && TIER_RANK[have] !== undefined && TIER_RANK[req] !== undefined
115
+ && TIER_RANK[have] >= TIER_RANK[req];
116
+ return { pass, observed: `credited=${have ?? 'absent'} required=${req ?? 'absent'}` };
117
+ }
118
+ function observeA3(e) {
119
+ const pass = e.reason === 'allow' && nonEmptyString(e.receipt_id);
120
+ return { pass, observed: `reason=${e.reason ?? 'absent'} receipt_id=${nonEmptyString(e.receipt_id) ? e.receipt_id : 'absent'}` };
121
+ }
122
+ function observeA4(e) {
123
+ const pass = e.consumption_mode === 'consume' || e.consumption_mode === 'reserve';
124
+ return { pass, observed: `consumption_mode=${e.consumption_mode ?? 'absent'}` };
125
+ }
126
+ function observeA5(e) {
127
+ return { pass: nonEmptyString(e.subject), observed: nonEmptyString(e.subject) ? e.subject : 'subject absent' };
128
+ }
129
+ function observeA6(e) {
130
+ const pass = nonEmptyString(e.hash) && HEX64.test(e.hash)
131
+ && nonEmptyString(e.prev_hash)
132
+ && Number.isInteger(e.seq) && e.seq >= 0;
133
+ return {
134
+ pass,
135
+ observed: `hash=${nonEmptyString(e.hash) && HEX64.test(e.hash) ? 'well-formed' : 'malformed'} prev_hash=${nonEmptyString(e.prev_hash) ? 'present' : 'absent'} seq=${Number.isInteger(e.seq) ? e.seq : 'absent'}`,
136
+ };
137
+ }
138
+ const OBSERVERS = { A1: observeA1, A2: observeA2, A3: observeA3, A4: observeA4, A5: observeA5, A6: observeA6 };
139
+ /** Attributes tested even on a refusal (the refusal itself must be accounted for). */
140
+ const REFUSAL_TESTED = new Set(['A6']);
141
+ function testItem(e) {
142
+ const isRefusal = e.allow === false;
143
+ const attributes = AUDIT_ATTRIBUTES.map((a) => {
144
+ if (isRefusal && !REFUSAL_TESTED.has(a.id)) {
145
+ return {
146
+ id: a.id,
147
+ name: a.name,
148
+ evidence_field: a.evidence_field,
149
+ result: 'not_applicable',
150
+ observed: `refusal (reason=${e.reason ?? 'unspecified'}) — control operated as designed; attribute describes a granted authorization`,
151
+ };
152
+ }
153
+ const { pass, observed } = OBSERVERS[a.id](e);
154
+ return { id: a.id, name: a.name, evidence_field: a.evidence_field, result: pass ? 'pass' : 'fail', observed };
155
+ });
156
+ return {
157
+ hash: e.hash,
158
+ seq: Number.isInteger(e.seq) ? e.seq : null,
159
+ at: e.at,
160
+ action: nonEmptyString(e.action) ? e.action : null,
161
+ verdict: isRefusal ? 'refusal' : 'allow',
162
+ reason: nonEmptyString(e.reason) ? e.reason : null,
163
+ attributes,
164
+ };
165
+ }
166
+ /* --------------------------------- build --------------------------------- */
167
+ /**
168
+ * Build the control-testing workpaper over a slice of the evidence log.
169
+ *
170
+ * Population = every well-formed guarded decision entry in the half-open
171
+ * window [periodStart, periodEnd). `population_hash` pins the population
172
+ * itself: sha256 over the lexicographically sorted entry hashes, newline-
173
+ * joined — the auditor can recompute it from the listed items.
174
+ *
175
+ * Sampling is deterministic and RNG-free: for each population entry compute
176
+ * sha256(sampleSeed + entry_hash) as lowercase hex; order ascending (ties
177
+ * broken by entry hash); select the first sampleSize entries. Reproducible by
178
+ * the auditor from the same seed and the same population. sampleSize >= the
179
+ * population size selects the full population ("100% examination").
180
+ *
181
+ * @param {Array<object>} entries evidence.all() (or a durable export of it)
182
+ * @param {object} [o]
183
+ * @param {string} [o.client] audit client / deploying organization (required)
184
+ * @param {string} [o.engagement] engagement reference (required)
185
+ * @param {string} [o.controlRef] control identifier under test (required)
186
+ * @param {string|number} [o.periodStart] inclusive window start (ISO or epoch ms)
187
+ * @param {string|number} [o.periodEnd] EXCLUSIVE window end (ISO or epoch ms)
188
+ * @param {number} [o.sampleSize] positive integer sample size (required)
189
+ * @param {string} [o.sampleSeed] seed pinning the sample selection (required)
190
+ * @param {number|Function} [o.now=Date.now] clock for generated_at (pin for determinism)
191
+ * @returns {object} EP-GATE-AUDIT-WORKPAPER-v1 document
192
+ */
193
+ export function buildAuditWorkpaper(entries = [], { client, engagement, controlRef, periodStart, periodEnd, sampleSize, sampleSeed, now = Date.now, } = {}) {
194
+ if (!Array.isArray(entries))
195
+ throw new Error('audit workpaper: entries must be an array (evidence.all())');
196
+ if (!nonEmptyString(client))
197
+ throw new Error('audit workpaper: client is required');
198
+ if (!nonEmptyString(engagement))
199
+ throw new Error('audit workpaper: engagement is required');
200
+ if (!nonEmptyString(controlRef))
201
+ throw new Error('audit workpaper: controlRef is required');
202
+ const startMs = toMs(periodStart);
203
+ const endMs = toMs(periodEnd);
204
+ if (startMs == null || endMs == null) {
205
+ throw new Error('audit workpaper: periodStart and periodEnd must be ISO timestamps or epoch ms');
206
+ }
207
+ if (endMs <= startMs)
208
+ throw new Error('audit workpaper: empty or inverted period (periodEnd must be after periodStart)');
209
+ if (!Number.isInteger(sampleSize) || sampleSize < 1) {
210
+ throw new Error('audit workpaper: sampleSize must be a positive integer');
211
+ }
212
+ if (!nonEmptyString(sampleSeed)) {
213
+ throw new Error('audit workpaper: sampleSeed is required — the sample must be reproducible by the auditor');
214
+ }
215
+ // Scope + integrity pass. Out-of-window records are out of scope; records we
216
+ // cannot verify as log entries are warned AND excluded — never sampled over.
217
+ const warnings = [];
218
+ const population = []; // guarded decision entries, in supplied (log) order
219
+ let inWindow = 0;
220
+ let outsideWindow = 0;
221
+ let notGuarded = 0;
222
+ let executions = 0;
223
+ entries.forEach((e, index) => {
224
+ const ref = { index, seq: e && typeof e === 'object' && Number.isInteger(e.seq) ? e.seq : null };
225
+ if (!e || typeof e !== 'object' || Array.isArray(e)) {
226
+ warnings.push({ ...ref, problem: 'not_an_object' });
227
+ return;
228
+ }
229
+ // An entry whose timestamp cannot be parsed cannot be placed in ANY period;
230
+ // it is warned, never silently assigned in or out of the window.
231
+ const t = toMs(e.at);
232
+ if (t == null) {
233
+ warnings.push({ ...ref, problem: 'missing_or_unparseable_at' });
234
+ return;
235
+ }
236
+ if (t < startMs || t >= endMs) {
237
+ outsideWindow += 1;
238
+ return;
239
+ }
240
+ if (!nonEmptyString(e.hash)) {
241
+ warnings.push({ ...ref, problem: 'missing_hash' });
242
+ return;
243
+ }
244
+ if (e.kind !== 'decision' && e.kind !== 'execution') {
245
+ warnings.push({ ...ref, problem: 'unknown_kind', kind: e.kind ?? null });
246
+ return;
247
+ }
248
+ inWindow += 1;
249
+ if (e.kind === 'execution') {
250
+ executions += 1;
251
+ return;
252
+ }
253
+ if (typeof e.allow !== 'boolean') {
254
+ warnings.push({ ...ref, problem: 'decision_missing_allow' });
255
+ inWindow -= 1;
256
+ return;
257
+ }
258
+ if (e.reason === 'not_guarded') {
259
+ notGuarded += 1;
260
+ return;
261
+ } // ran OUTSIDE the control — not in the tested population
262
+ population.push(e);
263
+ });
264
+ // Pin the population itself: order-independent hash over the entry hashes.
265
+ const popHashes = population.map((e) => e.hash);
266
+ const populationHash = sha256hex([...popHashes].sort().join('\n'));
267
+ // Deterministic, RNG-free sampling — reproducible from (seed, population).
268
+ const keyed = population
269
+ .map((e) => ({ e, key: sha256hex(sampleSeed + e.hash) }))
270
+ .sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : (a.e.hash < b.e.hash ? -1 : 1)));
271
+ const fullPopulation = sampleSize >= population.length;
272
+ const selected = fullPopulation ? keyed : keyed.slice(0, sampleSize);
273
+ const testedItems = selected.map(({ e }) => testItem(e));
274
+ // Exceptions = failed attributes on sampled items. Refusals cannot produce
275
+ // A1-A5 exceptions by construction (not_applicable) — see REFUSAL_TREATMENT.
276
+ const exceptions = [];
277
+ for (const item of testedItems) {
278
+ for (const a of item.attributes) {
279
+ if (a.result === 'fail') {
280
+ exceptions.push({
281
+ entry_hash: item.hash,
282
+ seq: item.seq,
283
+ at: item.at,
284
+ action: item.action,
285
+ attribute: a.id,
286
+ name: a.name,
287
+ evidence_field: a.evidence_field,
288
+ observed: a.observed,
289
+ });
290
+ }
291
+ }
292
+ }
293
+ // Chain head at export time: the last supplied entry carrying a hash.
294
+ let chainHead = null;
295
+ for (let i = entries.length - 1; i >= 0; i -= 1) {
296
+ const e = entries[i];
297
+ if (e && typeof e === 'object' && nonEmptyString(e.hash)) {
298
+ chainHead = e.hash;
299
+ break;
300
+ }
301
+ }
302
+ const nowMs = typeof now === 'function' ? now() : now;
303
+ return {
304
+ '@version': AUDIT_WORKPAPER_VERSION,
305
+ notice: AUDIT_WORKPAPER_HONESTY_NOTICE,
306
+ client,
307
+ engagement,
308
+ control: {
309
+ ref: controlRef,
310
+ name: 'EMILIA Gate — deny-by-default authorization of consequential machine actions',
311
+ statement: 'Guarded actions execute only with a valid, in-scope, sufficiently-assured, fresh, one-time authorization receipt from a named principal; every decision (allow or refusal) is appended to a hash-chained, tamper-evident evidence log.',
312
+ },
313
+ period: { start: new Date(startMs).toISOString(), end: new Date(endMs).toISOString(), end_exclusive: true },
314
+ generated_at: new Date(nowMs).toISOString(),
315
+ population: {
316
+ size: population.length,
317
+ population_hash: populationHash,
318
+ hash_method: 'sha256 over the lexicographically sorted entry hashes, newline-joined',
319
+ excluded: {
320
+ outside_window: outsideWindow,
321
+ not_guarded_passthroughs: notGuarded,
322
+ executions,
323
+ integrity_warnings: warnings.length,
324
+ },
325
+ items: population.map((e) => ({
326
+ hash: e.hash,
327
+ seq: Number.isInteger(e.seq) ? e.seq : null,
328
+ at: e.at,
329
+ action: nonEmptyString(e.action) ? e.action : null,
330
+ allow: e.allow,
331
+ reason: nonEmptyString(e.reason) ? e.reason : null,
332
+ })),
333
+ },
334
+ sampling: {
335
+ method: 'Deterministic attribute sampling, no RNG: for each population entry compute sha256(seed + entry_hash) as lowercase hex; order ascending (ties broken by entry hash); select the first sample_size entries. Reproducible from the same seed and the same population.',
336
+ seed: sampleSeed,
337
+ requested_size: sampleSize,
338
+ selected_size: selected.length,
339
+ full_population: fullPopulation,
340
+ basis: fullPopulation ? '100% examination' : 'attribute sample',
341
+ selected: selected.map(({ e }) => e.hash),
342
+ },
343
+ attribute_testing: {
344
+ plan: AUDIT_ATTRIBUTES,
345
+ refusal_treatment: REFUSAL_TREATMENT,
346
+ items: testedItems,
347
+ },
348
+ exceptions: {
349
+ total: exceptions.length,
350
+ refusals_are_not_exceptions: REFUSAL_TREATMENT,
351
+ items: exceptions,
352
+ },
353
+ completeness: {
354
+ entries_supplied: entries.length,
355
+ entries_in_window: inWindow,
356
+ population_size: population.length,
357
+ first_population_hash: popHashes[0] ?? null,
358
+ last_population_hash: popHashes[popHashes.length - 1] ?? null,
359
+ chain_head: chainHead,
360
+ },
361
+ integrity_warnings: warnings,
362
+ // The module NEVER concludes. These are the auditor's fields, emitted null
363
+ // by construction and rendered as blanks to fill.
364
+ conclusion: { tested_by: null, reviewed_by: null, conclusion: null },
365
+ };
366
+ }
367
+ /* -------------------------------- markdown ------------------------------- */
368
+ /**
369
+ * Table cells must not break the table; the source strings are log-derived.
370
+ * Backslash is escaped FIRST: escaping only the pipe turns a log-derived
371
+ * `a\|b` into `a\\|b`, where the `\\` renders as a literal backslash and
372
+ * leaves the pipe live as a cell delimiter, letting an action or refusal
373
+ * reason split its cell and shift every column after it.
374
+ */
375
+ function cell(v) {
376
+ return String(v ?? '—')
377
+ .replace(/\\/g, '\\\\')
378
+ .replace(/\|/g, '\\|')
379
+ .replace(/\r?\n/g, ' ');
380
+ }
381
+ const BLANK = '`____________________`';
382
+ function resultMark(r) {
383
+ return r === 'pass' ? 'pass' : r === 'fail' ? 'FAIL' : 'n/a';
384
+ }
385
+ /**
386
+ * Render the workpaper for the audit file. Refuses any document that is not a
387
+ * verbatim EP-GATE-AUDIT-WORKPAPER-v1: wrong @version, an altered or removed
388
+ * honesty notice, or machine-filled sign-off fields (the format defines them
389
+ * as always-null; a filled conclusion did not come from this module and must
390
+ * never render as an apparently machine-supported conclusion).
391
+ */
392
+ export function renderMarkdown(pack) {
393
+ if (!pack || typeof pack !== 'object' || pack['@version'] !== AUDIT_WORKPAPER_VERSION) {
394
+ throw new Error(`audit workpaper: renderMarkdown requires an ${AUDIT_WORKPAPER_VERSION} document`);
395
+ }
396
+ if (pack.notice !== AUDIT_WORKPAPER_HONESTY_NOTICE) {
397
+ throw new Error('audit workpaper: refusing to render a document whose honesty notice was altered or removed');
398
+ }
399
+ const c = pack.conclusion;
400
+ if (!c || typeof c !== 'object' || c.tested_by !== null || c.reviewed_by !== null || c.conclusion !== null) {
401
+ throw new Error('audit workpaper: refusing to render — sign-off fields must be null (the auditor completes them on the rendered workpaper, never in the machine artifact)');
402
+ }
403
+ const L = [];
404
+ L.push('# Control-Testing Workpaper — EMILIA Gate');
405
+ L.push('');
406
+ L.push(`> ${pack.notice}`);
407
+ L.push('');
408
+ L.push(`- **Format:** ${AUDIT_WORKPAPER_VERSION}`);
409
+ L.push(`- **Client:** ${cell(pack.client)}`);
410
+ L.push(`- **Engagement:** ${cell(pack.engagement)}`);
411
+ L.push(`- **Control:** ${cell(pack.control.ref)} — ${cell(pack.control.name)}`);
412
+ L.push(`- **Period:** ${pack.period.start} — ${pack.period.end} (end exclusive)`);
413
+ L.push(`- **Generated:** ${pack.generated_at}`);
414
+ L.push('');
415
+ L.push('## Control under test');
416
+ L.push('');
417
+ L.push(pack.control.statement);
418
+ L.push('');
419
+ L.push('## Population');
420
+ L.push('');
421
+ L.push(`- Guarded decisions in window: **${pack.population.size}**`);
422
+ L.push(`- Population hash: \`${cell(pack.population.population_hash)}\` (${pack.population.hash_method})`);
423
+ L.push(`- Excluded: ${pack.population.excluded.outside_window} outside window, ${pack.population.excluded.not_guarded_passthroughs} not-guarded pass-through(s), ${pack.population.excluded.executions} execution record(s), ${pack.population.excluded.integrity_warnings} integrity warning(s)`);
424
+ if (pack.population.items.length === 0) {
425
+ L.push('');
426
+ L.push('_No guarded decisions in the period. A zero-activity population is a valid (boring) result, not an error._');
427
+ }
428
+ else {
429
+ L.push('');
430
+ L.push('| Seq | At | Action | Verdict | Reason | Entry hash |');
431
+ L.push('| ---: | --- | --- | --- | --- | --- |');
432
+ for (const it of pack.population.items) {
433
+ L.push(`| ${cell(it.seq)} | ${cell(it.at)} | ${cell(it.action)} | ${it.allow ? 'allow' : 'refusal'} | ${cell(it.reason)} | \`${cell(it.hash)}\` |`);
434
+ }
435
+ }
436
+ L.push('');
437
+ L.push('## Sampling');
438
+ L.push('');
439
+ L.push(`- Method: ${pack.sampling.method}`);
440
+ L.push(`- Seed: \`${cell(pack.sampling.seed)}\``);
441
+ L.push(`- Requested: ${pack.sampling.requested_size} · Selected: ${pack.sampling.selected_size} · Basis: **${pack.sampling.basis}**`);
442
+ if (pack.sampling.selected.length) {
443
+ L.push('- Selected entry hashes (selection order):');
444
+ for (const h of pack.sampling.selected)
445
+ L.push(` - \`${cell(h)}\``);
446
+ }
447
+ else {
448
+ L.push('- Selected entry hashes: _none (empty population)_');
449
+ }
450
+ L.push('');
451
+ L.push('## Attribute test plan');
452
+ L.push('');
453
+ L.push('| # | Attribute | Evidence field(s) | Test |');
454
+ L.push('| --- | --- | --- | --- |');
455
+ for (const a of pack.attribute_testing.plan) {
456
+ L.push(`| ${a.id} | ${cell(a.name)} | ${cell(a.evidence_field)} | ${cell(a.test)} |`);
457
+ }
458
+ L.push('');
459
+ L.push(`> ${pack.attribute_testing.refusal_treatment}`);
460
+ L.push('');
461
+ L.push('## Attribute results');
462
+ if (pack.attribute_testing.items.length === 0) {
463
+ L.push('');
464
+ L.push('_No items sampled (empty population)._');
465
+ }
466
+ else {
467
+ L.push('');
468
+ L.push('| Item | At | Action | Verdict | A1 | A2 | A3 | A4 | A5 | A6 |');
469
+ L.push('| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |');
470
+ for (const it of pack.attribute_testing.items) {
471
+ const marks = it.attributes.map((a) => resultMark(a.result));
472
+ L.push(`| \`${cell(it.hash)}\` | ${cell(it.at)} | ${cell(it.action)} | ${it.verdict} | ${marks.join(' | ')} |`);
473
+ }
474
+ L.push('');
475
+ L.push('Observations (per attribute, per item):');
476
+ L.push('');
477
+ for (const it of pack.attribute_testing.items) {
478
+ L.push(`- \`${cell(it.hash)}\` (${it.verdict}${it.reason ? `, reason: ${cell(it.reason)}` : ''})`);
479
+ for (const a of it.attributes) {
480
+ L.push(` - ${a.id} ${cell(a.name)} [${resultMark(a.result)}] — ${cell(a.evidence_field)}: ${cell(a.observed)}`);
481
+ }
482
+ }
483
+ }
484
+ L.push('');
485
+ L.push('## Exceptions');
486
+ L.push('');
487
+ L.push(`> ${pack.exceptions.refusals_are_not_exceptions}`);
488
+ L.push('');
489
+ if (pack.exceptions.total === 0) {
490
+ L.push('No exceptions: no sampled item failed an applicable attribute.');
491
+ }
492
+ else {
493
+ L.push(`${pack.exceptions.total} failed attribute observation(s):`);
494
+ L.push('');
495
+ L.push('| Entry hash | Seq | Attribute | Evidence field(s) | Observed |');
496
+ L.push('| --- | ---: | --- | --- | --- |');
497
+ for (const x of pack.exceptions.items) {
498
+ L.push(`| \`${cell(x.entry_hash)}\` | ${cell(x.seq)} | ${x.attribute} ${cell(x.name)} | ${cell(x.evidence_field)} | ${cell(x.observed)} |`);
499
+ }
500
+ }
501
+ L.push('');
502
+ L.push('## Completeness');
503
+ L.push('');
504
+ L.push(`- Log entries supplied: ${pack.completeness.entries_supplied} · in window: ${pack.completeness.entries_in_window} · population: ${pack.completeness.population_size}`);
505
+ L.push(`- First population hash: ${pack.completeness.first_population_hash ? `\`${cell(pack.completeness.first_population_hash)}\`` : '—'}`);
506
+ L.push(`- Last population hash: ${pack.completeness.last_population_hash ? `\`${cell(pack.completeness.last_population_hash)}\`` : '—'}`);
507
+ L.push(`- Evidence chain head at export: ${pack.completeness.chain_head ? `\`${cell(pack.completeness.chain_head)}\`` : '—'}`);
508
+ L.push('');
509
+ L.push('## Integrity warnings');
510
+ if (pack.integrity_warnings.length === 0) {
511
+ L.push('');
512
+ L.push('None.');
513
+ }
514
+ else {
515
+ L.push('');
516
+ L.push(`${pack.integrity_warnings.length} supplied entr(ies) could not be verified as log records and are EXCLUDED from the population above:`);
517
+ L.push('');
518
+ L.push('| Index | Seq | Problem |');
519
+ L.push('| ---: | ---: | --- |');
520
+ for (const w of pack.integrity_warnings) {
521
+ L.push(`| ${w.index} | ${cell(w.seq)} | ${cell(w.problem)} |`);
522
+ }
523
+ }
524
+ L.push('');
525
+ L.push('## Sign-off (auditor completes)');
526
+ L.push('');
527
+ L.push('_These fields are intentionally blank. The preparer of this workpaper does not perform, review, or conclude the test._');
528
+ L.push('');
529
+ L.push('| Field | Entry |');
530
+ L.push('| --- | --- |');
531
+ L.push(`| Tested by / date | ${BLANK} |`);
532
+ L.push(`| Reviewed by / date | ${BLANK} |`);
533
+ L.push(`| Conclusion | ${BLANK} |`);
534
+ L.push('');
535
+ return L.join('\n');
536
+ }
537
+ export default {
538
+ AUDIT_WORKPAPER_VERSION,
539
+ AUDIT_WORKPAPER_HONESTY_NOTICE,
540
+ AUDIT_ATTRIBUTES,
541
+ REFUSAL_TREATMENT,
542
+ buildAuditWorkpaper,
543
+ renderMarkdown,
544
+ };
545
+ //# sourceMappingURL=auditor-workpaper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditor-workpaper.js","sourceRoot":"","sources":["../../src/reports/auditor-workpaper.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAIjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GACzC,gFAAgF;MAC9E,yEAAyE;MACzE,gFAAgF;MAChF,gFAAgF;MAChF,gFAAgF;MAChF,2EAA2E;MAC3E,gDAAgD,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,kFAAkF;MAChF,8EAA8E;MAC9E,mFAAmF;MACnF,gFAAgF;MAChF,+CAA+C,CAAC;AAEpD;;;;;GAKG;AACH,M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kBAAkB,KAAK,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,eAAe;IACb,uBAAuB;IACvB,8BAA8B;IAC9B,gBAAgB;IAChB,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;CACf,CAAC"}
@@ -0,0 +1,76 @@
1
+ export declare const EXTERNAL_VERIFICATION_STATEMENT_VERSION = "EP-EXTERNAL-VERIFICATION-STATEMENT-v1";
2
+ export declare const EXTERNAL_VERIFICATION_DOMAIN = "EP-EXTERNAL-VERIFICATION-STATEMENT-v1\0";
3
+ /** Digest of the signed statement body, excluding the signature envelope. */
4
+ export declare function externalVerificationDigest(statement: any): string;
5
+ /**
6
+ * Build and sign an external-verifier statement.
7
+ *
8
+ * @param {object} args
9
+ * @param {object} args.verifier {id, name?, organization?}
10
+ * @param {object} args.subject what was checked, e.g. {kind:'evidence_log', head:'sha256:...'}
11
+ * @param {object} args.procedure {id, version?, tool?, command?}
12
+ * @param {object} args.result {status, checks?, artifact_digest?}
13
+ * @param {object} [args.inputs] stable digests/ids the procedure consumed
14
+ * @param {string[]} [args.limitations] honest non-claims
15
+ * @param {string|number} [args.generated_at] ISO or epoch millis
16
+ * @param {crypto.KeyObject} privateKey Ed25519 private key
17
+ */
18
+ export declare function signExternalVerificationStatement(args: any, privateKey: any): Readonly<{
19
+ signature: {
20
+ algorithm: string;
21
+ key_id: string;
22
+ public_key: string;
23
+ statement_digest: string;
24
+ signature_b64u: string;
25
+ };
26
+ '@version': string;
27
+ generated_at: string;
28
+ verifier: {
29
+ organization?: any;
30
+ name?: any;
31
+ id: any;
32
+ };
33
+ subject: any;
34
+ procedure: any;
35
+ inputs: any;
36
+ result: {
37
+ artifact_digest?: any;
38
+ status: string;
39
+ checks: {
40
+ detail?: any;
41
+ id: string;
42
+ ok: boolean;
43
+ }[];
44
+ };
45
+ limitations: any;
46
+ }>;
47
+ /**
48
+ * Verify a signed external-verifier statement against pinned verifier keys.
49
+ *
50
+ * @param {object} statement
51
+ * @param {{pinnedVerifierKeys?:Array<{verifier_id?:string,key_id?:string,public_key:string}>}} [opts]
52
+ */
53
+ export declare function verifyExternalVerificationStatement(statement: any, opts?: {
54
+ pinnedVerifierKeys?: Array<{
55
+ verifier_id?: string;
56
+ key_id?: string;
57
+ public_key: string;
58
+ }>;
59
+ }): {
60
+ verified: boolean;
61
+ accepted: boolean;
62
+ checks: Record<string, boolean>;
63
+ reason?: string;
64
+ statement_digest?: string;
65
+ verifier_id?: string;
66
+ key_id?: string;
67
+ };
68
+ declare const _default: {
69
+ EXTERNAL_VERIFICATION_STATEMENT_VERSION: string;
70
+ EXTERNAL_VERIFICATION_DOMAIN: string;
71
+ externalVerificationDigest: typeof externalVerificationDigest;
72
+ signExternalVerificationStatement: typeof signExternalVerificationStatement;
73
+ verifyExternalVerificationStatement: typeof verifyExternalVerificationStatement;
74
+ };
75
+ export default _default;
76
+ //# sourceMappingURL=external-verification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-verification.d.ts","sourceRoot":"","sources":["../../src/reports/external-verification.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,uCAAuC,0CAA0C,CAAC;AAC/F,eAAO,MAAM,4BAA4B,4CAA4C,CAAC;AA4BtF,6EAA6E;AAC7E,wBAAgB,0BAA0B,CAAC,SAAS,KAAA,UAEnD;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,KAAA,EAAE,UAAU,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CjE;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,SAAS,KAAA,EAAE,IAAI,GAAE;IACnE,kBAAkB,CAAC,EAAE,KAAK,CAAC;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtF,GAAG;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAqFA;;;;;;;;AAED,wBAME"}