@hiroshi.inoue/agent-spectrum-kernel 0.0.0-stage → 1.0.1

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 (1559) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja.md +158 -0
  3. package/README.md +18 -2
  4. package/bin/ask.mjs +9 -0
  5. package/dist/AGENTS.md +266 -0
  6. package/dist/CHANGELOG.md +110 -0
  7. package/dist/CUSTOM_INSTRUCTIONS.md +72 -0
  8. package/dist/LICENSE +21 -0
  9. package/dist/README.md +19 -0
  10. package/dist/adapters/claude-code/README.md +185 -0
  11. package/dist/adapters/claude-code/github-actions/README.md +45 -0
  12. package/dist/adapters/claude-code/github-actions/claude-review-on-mention.yml +151 -0
  13. package/dist/adapters/claude-code/plugin/.claude-plugin/plugin.json +15 -0
  14. package/dist/adapters/claude-code/plugin/README.md +48 -0
  15. package/dist/adapters/claude-code/plugin/bin/ai-skills-metrics-record +18 -0
  16. package/dist/adapters/claude-code/plugin/contracts/claim-evidence-status-contract.md +60 -0
  17. package/dist/adapters/claude-code/plugin/contracts/execution-envelope-contract.md +105 -0
  18. package/dist/adapters/claude-code/plugin/contracts/lifecycle-traceability-contract.md +169 -0
  19. package/dist/adapters/claude-code/plugin/contracts/review-signal-gate-map.json +128 -0
  20. package/dist/adapters/claude-code/plugin/hooks/hooks.json +25 -0
  21. package/dist/adapters/claude-code/plugin/schemas/claim-evidence-status.schema.json +85 -0
  22. package/dist/adapters/claude-code/plugin/schemas/codex-risk-action.schema.json +58 -0
  23. package/dist/adapters/claude-code/plugin/schemas/codex-risk-approval-request.schema.json +204 -0
  24. package/dist/adapters/claude-code/plugin/schemas/execution-envelope.schema.json +127 -0
  25. package/dist/adapters/claude-code/plugin/schemas/metrics-event.schema.json +395 -0
  26. package/dist/adapters/claude-code/plugin/scripts/claim-evidence-status.mjs +162 -0
  27. package/dist/adapters/claude-code/plugin/skills/adoption-report/SKILL.md +19 -0
  28. package/dist/adapters/claude-code/plugin/skills/evidence-ledger/SKILL.md +96 -0
  29. package/dist/adapters/claude-code/plugin/skills/handoff/SKILL.md +36 -0
  30. package/dist/adapters/claude-code/plugin/skills/implement/SKILL.md +41 -0
  31. package/dist/adapters/claude-code/plugin/skills/implementation-context-check/SKILL.md +21 -0
  32. package/dist/adapters/claude-code/plugin/skills/investigate/SKILL.md +40 -0
  33. package/dist/adapters/claude-code/plugin/skills/ledger-refresh/SKILL.md +22 -0
  34. package/dist/adapters/claude-code/plugin/skills/review-pr/SKILL.md +54 -0
  35. package/dist/adapters/claude-code/plugin/skills/verify/SKILL.md +44 -0
  36. package/dist/adapters/claude-code/plugin/templates/handoff.md +30 -0
  37. package/dist/adapters/claude-code/plugin/templates/implement.md +35 -0
  38. package/dist/adapters/claude-code/plugin/templates/investigate.md +34 -0
  39. package/dist/adapters/claude-code/plugin/templates/review-pr.md +48 -0
  40. package/dist/adapters/claude-code/plugin/templates/verify.md +38 -0
  41. package/dist/adapters/claude-code/project/.claude/commands/skill-handoff.md +27 -0
  42. package/dist/adapters/claude-code/project/.claude/commands/skill-implement.md +32 -0
  43. package/dist/adapters/claude-code/project/.claude/commands/skill-investigate.md +29 -0
  44. package/dist/adapters/claude-code/project/.claude/commands/skill-ledger-refresh.md +22 -0
  45. package/dist/adapters/claude-code/project/.claude/commands/skill-report.md +17 -0
  46. package/dist/adapters/claude-code/project/.claude/commands/skill-review.md +43 -0
  47. package/dist/adapters/claude-code/project/.claude/commands/skill-verify.md +37 -0
  48. package/dist/adapters/claude-code/project/.claude/hooks/hooks.json +52 -0
  49. package/dist/adapters/claude-code/project/.claude/skills/README.md +11 -0
  50. package/dist/adapters/codex/README.md +128 -0
  51. package/dist/adapters/codex/commands/codex-exec.md +69 -0
  52. package/dist/adapters/codex/project/.agents/skills/README.md +36 -0
  53. package/dist/adapters/codex/prompts/skill-handoff.md +23 -0
  54. package/dist/adapters/codex/prompts/skill-implement.md +28 -0
  55. package/dist/adapters/codex/prompts/skill-investigate.md +27 -0
  56. package/dist/adapters/codex/prompts/skill-review.md +44 -0
  57. package/dist/adapters/codex/prompts/skill-verify.md +28 -0
  58. package/dist/benchmarks/README.md +125 -0
  59. package/dist/benchmarks/adaptive-portfolio.config.json +439 -0
  60. package/dist/benchmarks/admission-decision-overlay.md +72 -0
  61. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/common/operation-and-observation.md +35 -0
  62. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/TASK.md +15 -0
  63. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/acceptance.md +29 -0
  64. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/business-decisions.md +21 -0
  65. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/contract.md +37 -0
  66. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/delivery-provider.md +7 -0
  67. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/fixture-format.md +13 -0
  68. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/fixtures/example.json +237 -0
  69. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/goal-pr.txt +5 -0
  70. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/nonfunctional.md +3 -0
  71. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/prompt.txt +5 -0
  72. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/roles.md +24 -0
  73. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch02-report-operations/workflows.md +35 -0
  74. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/TASK.md +15 -0
  75. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/acceptance.md +30 -0
  76. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/business-decisions.md +23 -0
  77. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/contract.md +45 -0
  78. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/fixture-format.md +15 -0
  79. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/fixtures/campaign-stores.json +284 -0
  80. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/fixtures/example.json +299 -0
  81. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/goal-pr.txt +5 -0
  82. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/nonfunctional.md +3 -0
  83. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/prompt.txt +5 -0
  84. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/roles.md +28 -0
  85. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch03-price-rollout/workflows.md +35 -0
  86. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/TASK.md +15 -0
  87. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/acceptance.md +30 -0
  88. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/business-decisions.md +23 -0
  89. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/contract.md +39 -0
  90. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/fixture-format.md +11 -0
  91. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/fixtures/dossier-delivery.json +325 -0
  92. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/fixtures/example.json +289 -0
  93. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/goal-pr.txt +5 -0
  94. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/nonfunctional.md +3 -0
  95. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/prompt.txt +5 -0
  96. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/roles.md +27 -0
  97. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch04-document-access/workflows.md +35 -0
  98. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/TASK.md +15 -0
  99. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/acceptance.md +30 -0
  100. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/business-decisions.md +27 -0
  101. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/contract.md +39 -0
  102. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/fixture-format.md +11 -0
  103. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/fixtures/example.json +276 -0
  104. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/goal-pr.txt +5 -0
  105. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/nonfunctional.md +3 -0
  106. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/prompt.txt +5 -0
  107. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/roles.md +27 -0
  108. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch05-sales-reconciliation/workflows.md +35 -0
  109. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/TASK.md +15 -0
  110. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/acceptance.md +30 -0
  111. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/business-decisions.md +23 -0
  112. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/compiler-provider.md +9 -0
  113. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/contract.md +39 -0
  114. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/fixture-format.md +11 -0
  115. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/fixtures/example.json +292 -0
  116. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/goal-pr.txt +5 -0
  117. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/nonfunctional.md +3 -0
  118. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/prompt.txt +5 -0
  119. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/roles.md +25 -0
  120. package/dist/benchmarks/challenge-candidates/business-five-v3-decisions/public/tasks/ch06-build-operations/workflows.md +35 -0
  121. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/evaluation-protocol.md +58 -0
  122. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/LICENSE +21 -0
  123. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/PROVENANCE.md +9 -0
  124. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/README-ja.md +29 -0
  125. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/README.md +47 -0
  126. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/adr/001-local-storage.md +6 -0
  127. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/adr/007-shared-boundary.md +9 -0
  128. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/adr/009-retention-draft.md +4 -0
  129. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/architecture.md +29 -0
  130. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/contracts.md +14 -0
  131. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/library-policy.md +16 -0
  132. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/open-decisions.md +10 -0
  133. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/release.md +32 -0
  134. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/brief/spec-index.md +17 -0
  135. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/docs/design.md +1624 -0
  136. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/docs/requirements.md +1194 -0
  137. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/eslint.config.mjs +23 -0
  138. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/ci-summary.json +11 -0
  139. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/operational-observations.md +11 -0
  140. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/approval-history.csv +6 -0
  141. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/batches.csv +21 -0
  142. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/bookings.csv +6 -0
  143. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/clearance.csv +6 -0
  144. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/desk-ledger.csv +13 -0
  145. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/service-agreement.md +11 -0
  146. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/pilot-desk/signoffs.csv +12 -0
  147. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/evidence/previous-readiness-note.md +7 -0
  148. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/package.json +26 -0
  149. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/package.json +21 -0
  150. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/action-log.test.ts +32 -0
  151. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/artifact-store.test.ts +64 -0
  152. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/command-catalog.test.ts +89 -0
  153. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/config-store.test.ts +28 -0
  154. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/core-info.test.ts +13 -0
  155. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/cycle-meta.test.ts +491 -0
  156. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/field-report.test.ts +107 -0
  157. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/fix-flow.test.ts +289 -0
  158. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/flow-manifest.test.ts +126 -0
  159. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/flow-run.test.ts +44 -0
  160. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/knowledge-capture.test.ts +288 -0
  161. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/meta-status.test.ts +109 -0
  162. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/p0-readiness.test.ts +192 -0
  163. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/project-context.test.ts +172 -0
  164. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/project-init.test.ts +82 -0
  165. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/prompt-renderer.test.ts +87 -0
  166. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/prompt-template.test.ts +55 -0
  167. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/response-import.test.ts +40 -0
  168. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/response-normalize.test.ts +59 -0
  169. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/review-resolution.test.ts +187 -0
  170. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/review-work-metrics.test.ts +173 -0
  171. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/runtime-ports.test.ts +118 -0
  172. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/__tests__/skill-evidence.test.ts +101 -0
  173. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/actions/action-log.ts +48 -0
  174. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/application/project-context.ts +291 -0
  175. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/application/project-init.ts +224 -0
  176. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/artifacts/artifact-store.ts +2 -0
  177. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/artifacts/open-artifact.ts +21 -0
  178. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/config/config-store.ts +73 -0
  179. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/cycles/state.ts +799 -0
  180. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/domain/artifacts.ts +20 -0
  181. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/domain/diff-classification.ts +65 -0
  182. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/flows/manifest.ts +1648 -0
  183. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/flows/run.ts +77 -0
  184. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/index.ts +48 -0
  185. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/infrastructure/fs/artifact-store.ts +60 -0
  186. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/infrastructure/fs/runtime.ts +22 -0
  187. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/infrastructure/fs/workspace-store.ts +107 -0
  188. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/infrastructure/memory/runtime.ts +185 -0
  189. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/knowledge/capture.ts +666 -0
  190. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/meta/command-catalog.ts +909 -0
  191. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/meta/readiness.ts +519 -0
  192. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/meta/status.ts +58 -0
  193. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/metrics/review-work.ts +317 -0
  194. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/ports/artifact-store.ts +16 -0
  195. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/ports/runtime.ts +56 -0
  196. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/project/context.ts +46 -0
  197. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/project/init.ts +20 -0
  198. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/prompts/render.ts +369 -0
  199. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/prompts/templates.ts +153 -0
  200. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/reports/field-report.ts +230 -0
  201. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/responses/import.ts +127 -0
  202. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/responses/normalize.ts +389 -0
  203. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/reviews/action-plan-understanding.ts +136 -0
  204. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/reviews/comment-resolution.ts +605 -0
  205. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/reviews/fix-flow.ts +863 -0
  206. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/serialization/json.ts +18 -0
  207. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/serialization/paths.ts +27 -0
  208. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/serialization/yaml.ts +20 -0
  209. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/skill/evidence.ts +207 -0
  210. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/src/types.ts +634 -0
  211. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/core/tsconfig.json +10 -0
  212. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/README.md +18 -0
  213. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/package.json +13 -0
  214. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/public/app.js +357 -0
  215. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/public/index.html +35 -0
  216. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/public/styles.css +172 -0
  217. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/API.md +41 -0
  218. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/access.mjs +17 -0
  219. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/app.mjs +320 -0
  220. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/artifacts.mjs +81 -0
  221. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/core-bridge.mjs +48 -0
  222. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/errors.mjs +9 -0
  223. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/fixtures.mjs +75 -0
  224. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/index.mjs +14 -0
  225. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/jobs.mjs +93 -0
  226. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/journal.mjs +46 -0
  227. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/provider.mjs +59 -0
  228. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/reviews.mjs +80 -0
  229. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/server/store.mjs +105 -0
  230. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/test/helpers/review-fixture.mjs +9 -0
  231. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/test/persistence.test.mjs +60 -0
  232. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/portal/test/portal.test.mjs +364 -0
  233. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/package.json +21 -0
  234. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/__tests__/github.test.ts +335 -0
  235. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/__tests__/local-git.test.ts +98 -0
  236. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/__tests__/provider-boundary.test.ts +18 -0
  237. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/github.ts +643 -0
  238. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/index.ts +54 -0
  239. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/src/local-git.ts +520 -0
  240. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/providers/tsconfig.json +15 -0
  241. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/l10n/bundle.l10n.ja.json +868 -0
  242. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/l10n/bundle.l10n.json +868 -0
  243. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/package.json +474 -0
  244. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/package.nls.ja.json +38 -0
  245. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/package.nls.json +38 -0
  246. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/resources/reviewops-activitybar.svg +12 -0
  247. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/resources/reviewops-command-dark.svg +12 -0
  248. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/resources/reviewops-command-light.svg +12 -0
  249. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/resources/reviewops_guard_icon_128.png +0 -0
  250. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/artifact-browser.ts +380 -0
  251. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/artifact-loader.ts +460 -0
  252. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/command-center-renderer.ts +1341 -0
  253. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/command-center-results.ts +183 -0
  254. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/command-center.ts +819 -0
  255. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/extension-runtime.ts +2670 -0
  256. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/extension.ts +1 -0
  257. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/localization.ts +19 -0
  258. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/publish-draft-artifacts.ts +58 -0
  259. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/review-targets.ts +178 -0
  260. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/review-work-artifacts.ts +200 -0
  261. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/run-id.ts +3 -0
  262. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/scoped-cycle-prompt.ts +119 -0
  263. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/tree-views.ts +243 -0
  264. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/src/webview-renderers.ts +184 -0
  265. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/packages/vscode-extension/tsconfig.json +18 -0
  266. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/pnpm-lock.yaml +1708 -0
  267. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/pnpm-workspace.yaml +2 -0
  268. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/scripts/check-policy.mjs +14 -0
  269. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/scripts/generate-vsix.command +226 -0
  270. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/scripts/pilot-board.mjs +20 -0
  271. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/scripts/policy-checker.mjs +145 -0
  272. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/scripts/smoke-vsix.command +129 -0
  273. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/task.md +11 -0
  274. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tests/policy/ai-network-guard.test.ts +9 -0
  275. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tests/vscode-extension-activation.test.ts +474 -0
  276. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tests/vscode-extension-artifacts.test.ts +2087 -0
  277. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tests/vscode-extension-package.test.ts +336 -0
  278. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tests/vsix-smoke-command.test.ts +32 -0
  279. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/tsconfig.base.json +15 -0
  280. package/dist/benchmarks/challenge-candidates/review-ceiling-v1/workspace/vitest.config.ts +11 -0
  281. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/README.md +66 -0
  282. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/brief/data-contract.md +51 -0
  283. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/brief/rubric.json +756 -0
  284. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/brief/scenarios.json +333 -0
  285. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/brief/spec.md +35 -0
  286. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/assessment-valid.json +53 -0
  287. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/assessment-wrong-evidence.json +53 -0
  288. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/backup-dangling.json +565 -0
  289. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/career-valid.json +51 -0
  290. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/plan-over-limit.json +61 -0
  291. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/plan-valid.json +61 -0
  292. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/plan-wrong-request.json +61 -0
  293. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/fixtures/seed.json +565 -0
  294. package/dist/benchmarks/challenge-candidates/ui-reconstruction-v1/workspace/task.md +29 -0
  295. package/dist/benchmarks/contracts/rule-batch/2.0.0/bundle.json +270 -0
  296. package/dist/benchmarks/contracts/rule-batch/2.0.0/examples/mutants.mjs +129 -0
  297. package/dist/benchmarks/contracts/rule-batch/2.0.0/examples/reference.mjs +150 -0
  298. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/cases.mjs +261 -0
  299. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/contract.test.mjs +5 -0
  300. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-baseline/src/errors.mjs +17 -0
  301. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-baseline/src/index.mjs +3 -0
  302. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-baseline/src/rule-service.mjs +27 -0
  303. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-baseline/src/rule-store.mjs +38 -0
  304. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-baseline/src/validation.mjs +20 -0
  305. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-case-ids.json +458 -0
  306. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-results.mjs +37 -0
  307. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy-verifier.v1.2.mjs +115 -0
  308. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/legacy.test.mjs +4 -0
  309. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r1.test.mjs +10 -0
  310. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r10.test.mjs +10 -0
  311. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r2.test.mjs +10 -0
  312. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r3.test.mjs +10 -0
  313. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r4.test.mjs +10 -0
  314. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r5.test.mjs +10 -0
  315. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r6.test.mjs +10 -0
  316. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r7.test.mjs +10 -0
  317. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r8.test.mjs +10 -0
  318. package/dist/benchmarks/contracts/rule-batch/2.0.0/fixed/r9.test.mjs +10 -0
  319. package/dist/benchmarks/contracts/rule-batch/2.0.0/history.json +27 -0
  320. package/dist/benchmarks/contracts/rule-batch/2.0.0/requirements.json +547 -0
  321. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/docs/rule-batch.schema.json +27 -0
  322. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/docs/rule-batches.md +140 -0
  323. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/package.json +7 -0
  324. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/src/errors.mjs +17 -0
  325. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/src/index.mjs +3 -0
  326. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/src/rule-service.mjs +27 -0
  327. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/src/rule-store.mjs +38 -0
  328. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/src/validation.mjs +20 -0
  329. package/dist/benchmarks/contracts/rule-batch/2.0.0/seed/test/rule-service.test.mjs +34 -0
  330. package/dist/benchmarks/contracts/rule-batch/2.0.0/spec.md +140 -0
  331. package/dist/benchmarks/contracts/rule-batch/2.0.0/task.md +35 -0
  332. package/dist/benchmarks/contracts/rule-batch/2.0.0/verification-contract.md +56 -0
  333. package/dist/benchmarks/contracts/rule-batch/2.0.0/verification.json +100 -0
  334. package/dist/benchmarks/evaluation-tasks.json +1645 -0
  335. package/dist/benchmarks/evaluator-boundary.md +107 -0
  336. package/dist/benchmarks/portfolio-admission-policy.json +1171 -0
  337. package/dist/benchmarks/portfolio-catalog.json +837 -0
  338. package/dist/benchmarks/portfolio-design-admission-manifest.json +170 -0
  339. package/dist/benchmarks/portfolio-design-admission-records/hi-authorization-exception.json +99 -0
  340. package/dist/benchmarks/portfolio-design-admission-records/hi-external-action-approval.json +105 -0
  341. package/dist/benchmarks/portfolio-design-admission-records/hi-financial-state-integrity.json +105 -0
  342. package/dist/benchmarks/portfolio-design-admission-records/hi-versioned-migration-safety.json +108 -0
  343. package/dist/benchmarks/portfolio-design-admission-records/mn-build-option-update.json +108 -0
  344. package/dist/benchmarks/portfolio-design-admission-records/mn-client-compatibility-fix.json +108 -0
  345. package/dist/benchmarks/portfolio-design-admission-records/mn-doc-config-correction.json +108 -0
  346. package/dist/benchmarks/portfolio-design-admission-records/mn-focused-regression-test.json +108 -0
  347. package/dist/benchmarks/portfolio-design-admission-records/mn-frontend-default-fix.json +108 -0
  348. package/dist/benchmarks/portfolio-design-admission-records/mn-schema-field-alignment.json +108 -0
  349. package/dist/benchmarks/portfolio-design-admission-records/mp-accessibility-interaction-review.json +103 -0
  350. package/dist/benchmarks/portfolio-design-admission-records/mp-ci-evidence-gap.json +103 -0
  351. package/dist/benchmarks/portfolio-design-admission-records/mp-data-migration-handoff.json +108 -0
  352. package/dist/benchmarks/portfolio-design-admission-records/mp-frontend-state-review.json +103 -0
  353. package/dist/benchmarks/portfolio-design-admission-records/mp-iac-rollback-design.json +106 -0
  354. package/dist/benchmarks/portfolio-design-admission-records/mp-performance-investigation.json +106 -0
  355. package/dist/benchmarks/portfolio-design-admission-records/pf-api-pagination-behavior.json +108 -0
  356. package/dist/benchmarks/portfolio-design-admission-records/pf-ci-cache-flake.json +106 -0
  357. package/dist/benchmarks/portfolio-design-admission-records/pf-data-schema-evolution.json +105 -0
  358. package/dist/benchmarks/portfolio-design-admission-records/pf-frontend-async-state.json +108 -0
  359. package/dist/benchmarks/portfolio-design-admission-records/pf-library-compat-upgrade.json +105 -0
  360. package/dist/benchmarks/portfolio-design-admission-records/pf-observability-redaction.json +99 -0
  361. package/dist/benchmarks/portfolio-design-admission-records/pf-performance-regression.json +108 -0
  362. package/dist/benchmarks/portfolio-design-admission-records/pf-review-error-contract.json +103 -0
  363. package/dist/benchmarks/portfolio-design-independent-review.json +1666 -0
  364. package/dist/benchmarks/portfolio-design-review-package.json +249 -0
  365. package/dist/benchmarks/portfolio-design-reviewed-state.json +152 -0
  366. package/dist/benchmarks/portfolio-high-impact-sensitivity-policy.json +40 -0
  367. package/dist/benchmarks/portfolio-lineage-policy.json +213 -0
  368. package/dist/benchmarks/portfolio-policy-manifest.json +32 -0
  369. package/dist/benchmarks/portfolio-scoring-policy.json +589 -0
  370. package/dist/benchmarks/portfolio-similarity.json +2222 -0
  371. package/dist/benchmarks/prompt-v2-preregistration.json +411 -0
  372. package/dist/benchmarks/protocol-adaptive.md +487 -0
  373. package/dist/benchmarks/protocol-b2.md +113 -0
  374. package/dist/benchmarks/protocol-prompt-v2.md +108 -0
  375. package/dist/benchmarks/protocol.md +122 -0
  376. package/dist/benchmarks/report-template.md +61 -0
  377. package/dist/benchmarks/schemas/adaptive-selection-input.schema.json +82 -0
  378. package/dist/benchmarks/schemas/adaptive-selection-state.schema.json +45 -0
  379. package/dist/benchmarks/schemas/adaptive-selection.schema.json +137 -0
  380. package/dist/benchmarks/schemas/agent-output.schema.json +66 -0
  381. package/dist/benchmarks/schemas/core-evaluator-result-envelope.schema.json +708 -0
  382. package/dist/benchmarks/schemas/core-native-compatibility-provenance.schema.json +130 -0
  383. package/dist/benchmarks/schemas/core-normalized-portfolio-result.schema.json +945 -0
  384. package/dist/benchmarks/schemas/core-normalized-portfolio-run.schema.json +676 -0
  385. package/dist/benchmarks/schemas/core-original-workspace-authority.schema.json +315 -0
  386. package/dist/benchmarks/schemas/core-portfolio-command-evidence.schema.json +548 -0
  387. package/dist/benchmarks/schemas/core-portfolio-engineering-result.schema.json +1187 -0
  388. package/dist/benchmarks/schemas/core-portfolio-terminal-workspace-authority.schema.json +395 -0
  389. package/dist/benchmarks/schemas/core-repository-diff-artifact.schema.json +253 -0
  390. package/dist/benchmarks/schemas/evaluation-input-failure-artifact.schema.json +36 -0
  391. package/dist/benchmarks/schemas/evaluator-authority-manifest.schema.json +63 -0
  392. package/dist/benchmarks/schemas/evaluator-check-artifact.schema.json +35 -0
  393. package/dist/benchmarks/schemas/evaluator-reference.schema.json +129 -0
  394. package/dist/benchmarks/schemas/evaluator-result-envelope.schema.json +261 -0
  395. package/dist/benchmarks/schemas/execution-plan.schema.json +121 -0
  396. package/dist/benchmarks/schemas/materialization-manifest.schema.json +187 -0
  397. package/dist/benchmarks/schemas/normalized-portfolio-result.schema.json +379 -0
  398. package/dist/benchmarks/schemas/normalized-portfolio-root.schema.json +49 -0
  399. package/dist/benchmarks/schemas/normalized-portfolio-run.schema.json +289 -0
  400. package/dist/benchmarks/schemas/original-workspace-authority.schema.json +99 -0
  401. package/dist/benchmarks/schemas/portfolio-adapter-identity.schema.json +148 -0
  402. package/dist/benchmarks/schemas/portfolio-admission-decision.schema.json +140 -0
  403. package/dist/benchmarks/schemas/portfolio-admission-policy.schema.json +347 -0
  404. package/dist/benchmarks/schemas/portfolio-admission-review-authority.schema.json +60 -0
  405. package/dist/benchmarks/schemas/portfolio-aggregate-result-v2.schema.json +1107 -0
  406. package/dist/benchmarks/schemas/portfolio-aggregate-result.schema.json +140 -0
  407. package/dist/benchmarks/schemas/portfolio-attempt-commit.schema.json +30 -0
  408. package/dist/benchmarks/schemas/portfolio-attempt-request.schema.json +134 -0
  409. package/dist/benchmarks/schemas/portfolio-attempt-result.schema.json +256 -0
  410. package/dist/benchmarks/schemas/portfolio-case-state.schema.json +38 -0
  411. package/dist/benchmarks/schemas/portfolio-catalog.schema.json +122 -0
  412. package/dist/benchmarks/schemas/portfolio-claim.schema.json +72 -0
  413. package/dist/benchmarks/schemas/portfolio-classification-record.schema.json +46 -0
  414. package/dist/benchmarks/schemas/portfolio-command-evidence.schema.json +122 -0
  415. package/dist/benchmarks/schemas/portfolio-config.schema.json +138 -0
  416. package/dist/benchmarks/schemas/portfolio-consumer-report.schema.json +289 -0
  417. package/dist/benchmarks/schemas/portfolio-design-admission-manifest.schema.json +76 -0
  418. package/dist/benchmarks/schemas/portfolio-design-admission-record.schema.json +205 -0
  419. package/dist/benchmarks/schemas/portfolio-design-independent-review.schema.json +264 -0
  420. package/dist/benchmarks/schemas/portfolio-design-review-package.schema.json +96 -0
  421. package/dist/benchmarks/schemas/portfolio-design-reviewed-state.schema.json +99 -0
  422. package/dist/benchmarks/schemas/portfolio-directional-outcome-report.schema.json +164 -0
  423. package/dist/benchmarks/schemas/portfolio-engineering-result-set.schema.json +222 -0
  424. package/dist/benchmarks/schemas/portfolio-engineering-result-source-manifest.schema.json +93 -0
  425. package/dist/benchmarks/schemas/portfolio-engineering-result.schema.json +515 -0
  426. package/dist/benchmarks/schemas/portfolio-evolution-binding.schema.json +71 -0
  427. package/dist/benchmarks/schemas/portfolio-final-admission-record.schema.json +125 -0
  428. package/dist/benchmarks/schemas/portfolio-high-impact-sensitivity-policy.schema.json +44 -0
  429. package/dist/benchmarks/schemas/portfolio-high-impact-sensitivity-registration.schema.json +136 -0
  430. package/dist/benchmarks/schemas/portfolio-high-impact-sensitivity-report.schema.json +384 -0
  431. package/dist/benchmarks/schemas/portfolio-legacy-calibration-migration.schema.json +308 -0
  432. package/dist/benchmarks/schemas/portfolio-lineage-policy.schema.json +180 -0
  433. package/dist/benchmarks/schemas/portfolio-lineage-record.schema.json +52 -0
  434. package/dist/benchmarks/schemas/portfolio-mechanism-scorecard.schema.json +197 -0
  435. package/dist/benchmarks/schemas/portfolio-output-contract.schema.json +52 -0
  436. package/dist/benchmarks/schemas/portfolio-paired-comparison-report.schema.json +346 -0
  437. package/dist/benchmarks/schemas/portfolio-policy-manifest.schema.json +85 -0
  438. package/dist/benchmarks/schemas/portfolio-repetition-report.schema.json +204 -0
  439. package/dist/benchmarks/schemas/portfolio-requirement-record.schema.json +72 -0
  440. package/dist/benchmarks/schemas/portfolio-run-identity.schema.json +58 -0
  441. package/dist/benchmarks/schemas/portfolio-runtime-config.schema.json +147 -0
  442. package/dist/benchmarks/schemas/portfolio-scoring-policy.schema.json +497 -0
  443. package/dist/benchmarks/schemas/portfolio-similarity.schema.json +64 -0
  444. package/dist/benchmarks/schemas/portfolio-terminal-workspace-authority.schema.json +134 -0
  445. package/dist/benchmarks/schemas/portfolio-verification-command-contract.schema.json +69 -0
  446. package/dist/benchmarks/schemas/primary-evaluator-result-envelope.schema.json +708 -0
  447. package/dist/benchmarks/schemas/primary-k2-evaluator-result-envelope.schema.json +708 -0
  448. package/dist/benchmarks/schemas/primary-k2-normalized-portfolio-result.schema.json +945 -0
  449. package/dist/benchmarks/schemas/primary-k2-normalized-portfolio-run.schema.json +676 -0
  450. package/dist/benchmarks/schemas/primary-k2-original-workspace-authority.schema.json +315 -0
  451. package/dist/benchmarks/schemas/primary-k2-portfolio-command-evidence.schema.json +554 -0
  452. package/dist/benchmarks/schemas/primary-k2-portfolio-engineering-result.schema.json +1187 -0
  453. package/dist/benchmarks/schemas/primary-k2-portfolio-terminal-workspace-authority.schema.json +395 -0
  454. package/dist/benchmarks/schemas/primary-k2-repository-diff-artifact.schema.json +253 -0
  455. package/dist/benchmarks/schemas/primary-k2-saved-v10-evaluator-result-envelope.schema.json +3604 -0
  456. package/dist/benchmarks/schemas/primary-k2-saved-v10-normalized-portfolio-result.schema.json +3804 -0
  457. package/dist/benchmarks/schemas/primary-k2-saved-v10-portfolio-command-evidence.schema.json +3531 -0
  458. package/dist/benchmarks/schemas/primary-k2-saved-v10-portfolio-engineering-result.schema.json +4126 -0
  459. package/dist/benchmarks/schemas/primary-k2-saved-v2-portfolio-command-evidence.schema.json +548 -0
  460. package/dist/benchmarks/schemas/primary-k2-saved-v3-portfolio-command-evidence.schema.json +548 -0
  461. package/dist/benchmarks/schemas/primary-k2-saved-v4-portfolio-command-evidence.schema.json +548 -0
  462. package/dist/benchmarks/schemas/primary-k2-saved-v5-portfolio-command-evidence.schema.json +558 -0
  463. package/dist/benchmarks/schemas/primary-k2-saved-v6-portfolio-command-evidence.schema.json +668 -0
  464. package/dist/benchmarks/schemas/primary-k2-saved-v7-evaluator-result-envelope.schema.json +708 -0
  465. package/dist/benchmarks/schemas/primary-k2-saved-v7-portfolio-command-evidence.schema.json +676 -0
  466. package/dist/benchmarks/schemas/primary-k2-saved-v8-evaluator-result-envelope.schema.json +760 -0
  467. package/dist/benchmarks/schemas/primary-k2-saved-v8-normalized-portfolio-result.schema.json +960 -0
  468. package/dist/benchmarks/schemas/primary-k2-saved-v8-portfolio-command-evidence.schema.json +687 -0
  469. package/dist/benchmarks/schemas/primary-k2-saved-v8-portfolio-engineering-result.schema.json +1282 -0
  470. package/dist/benchmarks/schemas/primary-k2-saved-v9-evaluator-result-envelope.schema.json +760 -0
  471. package/dist/benchmarks/schemas/primary-k2-saved-v9-normalized-portfolio-result.schema.json +960 -0
  472. package/dist/benchmarks/schemas/primary-k2-saved-v9-portfolio-command-evidence.schema.json +687 -0
  473. package/dist/benchmarks/schemas/primary-k2-saved-v9-portfolio-engineering-result.schema.json +1282 -0
  474. package/dist/benchmarks/schemas/primary-normalized-portfolio-result.schema.json +945 -0
  475. package/dist/benchmarks/schemas/primary-normalized-portfolio-run.schema.json +676 -0
  476. package/dist/benchmarks/schemas/primary-original-workspace-authority.schema.json +315 -0
  477. package/dist/benchmarks/schemas/primary-portfolio-command-evidence.schema.json +554 -0
  478. package/dist/benchmarks/schemas/primary-portfolio-engineering-result.schema.json +1187 -0
  479. package/dist/benchmarks/schemas/primary-portfolio-terminal-workspace-authority.schema.json +395 -0
  480. package/dist/benchmarks/schemas/primary-public-capability-selection-v2.schema.json +31 -0
  481. package/dist/benchmarks/schemas/primary-repository-diff-artifact.schema.json +253 -0
  482. package/dist/benchmarks/schemas/primary-runtime-v10-binding.schema.json +2843 -0
  483. package/dist/benchmarks/schemas/primary-saved-v10-evaluator-result-envelope.schema.json +3604 -0
  484. package/dist/benchmarks/schemas/primary-saved-v10-normalized-portfolio-result.schema.json +3804 -0
  485. package/dist/benchmarks/schemas/primary-saved-v10-portfolio-command-evidence.schema.json +3531 -0
  486. package/dist/benchmarks/schemas/primary-saved-v10-portfolio-engineering-result.schema.json +4126 -0
  487. package/dist/benchmarks/schemas/primary-saved-v2-portfolio-command-evidence.schema.json +548 -0
  488. package/dist/benchmarks/schemas/primary-saved-v3-portfolio-command-evidence.schema.json +548 -0
  489. package/dist/benchmarks/schemas/primary-saved-v4-portfolio-command-evidence.schema.json +548 -0
  490. package/dist/benchmarks/schemas/primary-saved-v5-portfolio-command-evidence.schema.json +558 -0
  491. package/dist/benchmarks/schemas/primary-saved-v6-portfolio-command-evidence.schema.json +668 -0
  492. package/dist/benchmarks/schemas/primary-saved-v7-evaluator-result-envelope.schema.json +708 -0
  493. package/dist/benchmarks/schemas/primary-saved-v7-portfolio-command-evidence.schema.json +676 -0
  494. package/dist/benchmarks/schemas/primary-saved-v8-evaluator-result-envelope.schema.json +760 -0
  495. package/dist/benchmarks/schemas/primary-saved-v8-normalized-portfolio-result.schema.json +960 -0
  496. package/dist/benchmarks/schemas/primary-saved-v8-portfolio-command-evidence.schema.json +687 -0
  497. package/dist/benchmarks/schemas/primary-saved-v8-portfolio-engineering-result.schema.json +1282 -0
  498. package/dist/benchmarks/schemas/primary-saved-v9-evaluator-result-envelope.schema.json +760 -0
  499. package/dist/benchmarks/schemas/primary-saved-v9-normalized-portfolio-result.schema.json +960 -0
  500. package/dist/benchmarks/schemas/primary-saved-v9-portfolio-command-evidence.schema.json +687 -0
  501. package/dist/benchmarks/schemas/primary-saved-v9-portfolio-engineering-result.schema.json +1282 -0
  502. package/dist/benchmarks/schemas/private-evaluation-record.schema.json +311 -0
  503. package/dist/benchmarks/schemas/private-evaluator-bundle.schema.json +224 -0
  504. package/dist/benchmarks/schemas/private-evaluator-fragment.schema.json +140 -0
  505. package/dist/benchmarks/schemas/private-evaluator-independence-statement.schema.json +168 -0
  506. package/dist/benchmarks/schemas/prompt-v2-comparison-report.schema.json +94 -0
  507. package/dist/benchmarks/schemas/prompt-v2-execution-plan.schema.json +115 -0
  508. package/dist/benchmarks/schemas/prompt-v2-materialization-manifest.schema.json +58 -0
  509. package/dist/benchmarks/schemas/prompt-v2-normalized-result.schema.json +109 -0
  510. package/dist/benchmarks/schemas/prompt-v2-preregistration.schema.json +266 -0
  511. package/dist/benchmarks/schemas/prompt-v2-resume-state.schema.json +60 -0
  512. package/dist/benchmarks/schemas/repository-diff-artifact.schema.json +78 -0
  513. package/dist/benchmarks/schemas/result.schema.json +292 -0
  514. package/dist/benchmarks/schemas/runtime-observation-carrier.schema.json +480 -0
  515. package/dist/benchmarks/schemas/scoring-input-freeze-manifest.schema.json +77 -0
  516. package/dist/benchmarks/task-revisions/ch01-inventory-reservation-logistics/rubric.json +41 -0
  517. package/dist/benchmarks/task-revisions/ch02-report-operations/input-manifest.json +141 -0
  518. package/dist/benchmarks/task-revisions/ch02-report-operations/rubric.json +40 -0
  519. package/dist/benchmarks/task-revisions/ch03-price-rollout/input-manifest.json +141 -0
  520. package/dist/benchmarks/task-revisions/ch03-price-rollout/rubric.json +49 -0
  521. package/dist/benchmarks/task-revisions/ch04-document-access/input-manifest.json +141 -0
  522. package/dist/benchmarks/task-revisions/ch04-document-access/rubric.json +49 -0
  523. package/dist/benchmarks/task-revisions/ch05-sales-reconciliation/input-manifest.json +131 -0
  524. package/dist/benchmarks/task-revisions/ch05-sales-reconciliation/rubric.json +49 -0
  525. package/dist/benchmarks/task-revisions/ch06-build-operations/input-manifest.json +141 -0
  526. package/dist/benchmarks/task-revisions/ch06-build-operations/rubric.json +49 -0
  527. package/dist/benchmarks/task-revisions/ch08-growth-workspace/input-manifest.json +78 -0
  528. package/dist/benchmarks/task-revisions/ch08-growth-workspace/rubric.json +49 -0
  529. package/dist/benchmarks/task-revisions/hi-authorization-exception/input-manifest.json +72 -0
  530. package/dist/benchmarks/task-revisions/hi-authorization-exception/rubric.json +52 -0
  531. package/dist/benchmarks/task-revisions/hi-authorization-exception/task.md +17 -0
  532. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/base/authorization.mjs +6 -0
  533. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/data/access-cases.json +251 -0
  534. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/docs/ownership-contract.md +11 -0
  535. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/package.json +13 -0
  536. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/pr.diff +12 -0
  537. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/review.schema.json +175 -0
  538. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/scripts/trace-access.mjs +14 -0
  539. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/scripts/validate-review.mjs +12 -0
  540. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/src/authorization.mjs +6 -0
  541. package/dist/benchmarks/task-revisions/hi-authorization-exception/workspace/test/access-subset.test.mjs +1 -0
  542. package/dist/benchmarks/task-revisions/hi-external-action-approval/input-manifest.json +87 -0
  543. package/dist/benchmarks/task-revisions/hi-external-action-approval/rubric.json +44 -0
  544. package/dist/benchmarks/task-revisions/hi-external-action-approval/task.md +7 -0
  545. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/data/approval-receipts.json +162 -0
  546. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/data/operation-cases.json +257 -0
  547. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/data/review-attestations.json +257 -0
  548. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/data/state.json +1 -0
  549. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/docs/action-contract.md +15 -0
  550. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/operation-plan.json +5 -0
  551. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/package.json +13 -0
  552. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/plan.schema.json +127 -0
  553. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/scripts/controller.mjs +45 -0
  554. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/scripts/dry-run.mjs +1 -0
  555. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/scripts/validate-plan.mjs +1 -0
  556. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/scripts/validate-shape.mjs +16 -0
  557. package/dist/benchmarks/task-revisions/hi-external-action-approval/workspace/test/approval.test.mjs +55 -0
  558. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/input-manifest.json +52 -0
  559. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/rubric.json +45 -0
  560. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/task.md +17 -0
  561. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/data/incident.json +19 -0
  562. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/data/initial-state.json +9 -0
  563. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/docs/ledger-contract.md +9 -0
  564. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/package.json +11 -0
  565. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/src/ledger.mjs +11 -0
  566. package/dist/benchmarks/task-revisions/hi-financial-state-integrity/workspace/test/ledger.test.mjs +15 -0
  567. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/input-manifest.json +87 -0
  568. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/rubric.json +45 -0
  569. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/task.md +7 -0
  570. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/data/mixed-state.json +17 -0
  571. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/data/rollback-cases.json +84 -0
  572. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/data/schema-phases.json +54 -0
  573. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/data/timeline.json +52 -0
  574. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/docs/migration-contract.md +17 -0
  575. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/migration-plan.json +10 -0
  576. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/package.json +13 -0
  577. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/plan.schema.json +110 -0
  578. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/scripts/compatibility.mjs +51 -0
  579. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/scripts/dry-run.mjs +1 -0
  580. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/scripts/validate-plan.mjs +1 -0
  581. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/scripts/validate-shape.mjs +16 -0
  582. package/dist/benchmarks/task-revisions/hi-versioned-migration-safety/workspace/test/mixed-version.test.mjs +61 -0
  583. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/input-manifest.json +85 -0
  584. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/rubric.json +34 -0
  585. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/task.md +5 -0
  586. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/data/incident.json +8 -0
  587. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/data/initial-state.json +21 -0
  588. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/data/service-save.json +160 -0
  589. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/docs/bank-interchange.md +37 -0
  590. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/docs/close-instructions.md +27 -0
  591. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/docs/ledger-contract.md +21 -0
  592. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/package.json +11 -0
  593. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/src/archive.mjs +46 -0
  594. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/src/clearing.mjs +47 -0
  595. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/src/ledger.mjs +36 -0
  596. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/src/money.mjs +11 -0
  597. package/dist/benchmarks/task-revisions/implementation-clearing-cutover/workspace/test/ledger.test.mjs +50 -0
  598. package/dist/benchmarks/task-revisions/implementation-timeline-restore/input-manifest.json +52 -0
  599. package/dist/benchmarks/task-revisions/implementation-timeline-restore/rubric.json +44 -0
  600. package/dist/benchmarks/task-revisions/implementation-timeline-restore/task.md +5 -0
  601. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/docs/archive-operations.md +13 -0
  602. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/docs/interchange.md +16 -0
  603. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/docs/statement-interface.md +9 -0
  604. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/package.json +8 -0
  605. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/src/event-lookup.mjs +39 -0
  606. package/dist/benchmarks/task-revisions/implementation-timeline-restore/workspace/test/client.test.mjs +38 -0
  607. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/input-manifest.json +94 -0
  608. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/rubric.json +84 -0
  609. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/task.md +5 -0
  610. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/docs/dispatch.md +25 -0
  611. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/docs/installed-clients.md +35 -0
  612. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/docs/returned-sheets.md +15 -0
  613. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/package.json +8 -0
  614. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/console.mjs +2 -0
  615. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/database.mjs +52 -0
  616. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/desk.mjs +24 -0
  617. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/kiosk.mjs +47 -0
  618. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/operator.mjs +17 -0
  619. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/release/printer.mjs +63 -0
  620. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/src/delivery.mjs +28 -0
  621. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/src/reconcile.mjs +16 -0
  622. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/src/workspace.mjs +44 -0
  623. package/dist/benchmarks/task-revisions/implementation-workspace-upgrade/workspace/test/desk.test.mjs +34 -0
  624. package/dist/benchmarks/task-revisions/mn-build-option-update/input-manifest.json +52 -0
  625. package/dist/benchmarks/task-revisions/mn-build-option-update/rubric.json +38 -0
  626. package/dist/benchmarks/task-revisions/mn-build-option-update/task.md +5 -0
  627. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/build.config.json +14 -0
  628. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/ci/release-build.log +7 -0
  629. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/docs/build-options.md +12 -0
  630. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/package.json +9 -0
  631. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/scripts/validate-build-config.mjs +11 -0
  632. package/dist/benchmarks/task-revisions/mn-build-option-update/workspace/test/build-config.test.mjs +15 -0
  633. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/input-manifest.json +48 -0
  634. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/rubric.json +29 -0
  635. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/task.md +5 -0
  636. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/workspace/docs/client-support.md +12 -0
  637. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/workspace/docs/preferences.md +5 -0
  638. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/workspace/package.json +6 -0
  639. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/workspace/src/preferences.mjs +3 -0
  640. package/dist/benchmarks/task-revisions/mn-client-compatibility-fix/workspace/test/preferences.test.mjs +20 -0
  641. package/dist/benchmarks/task-revisions/mn-doc-config-correction/input-manifest.json +42 -0
  642. package/dist/benchmarks/task-revisions/mn-doc-config-correction/rubric.json +37 -0
  643. package/dist/benchmarks/task-revisions/mn-doc-config-correction/task.md +3 -0
  644. package/dist/benchmarks/task-revisions/mn-doc-config-correction/workspace/config/retry-policy.json +6 -0
  645. package/dist/benchmarks/task-revisions/mn-doc-config-correction/workspace/docs/worker-retries.md +12 -0
  646. package/dist/benchmarks/task-revisions/mn-doc-config-correction/workspace/package.json +8 -0
  647. package/dist/benchmarks/task-revisions/mn-doc-config-correction/workspace/test/worker-retries.test.mjs +16 -0
  648. package/dist/benchmarks/task-revisions/mn-focused-regression-test/input-manifest.json +42 -0
  649. package/dist/benchmarks/task-revisions/mn-focused-regression-test/rubric.json +37 -0
  650. package/dist/benchmarks/task-revisions/mn-focused-regression-test/task.md +5 -0
  651. package/dist/benchmarks/task-revisions/mn-focused-regression-test/workspace/package.json +9 -0
  652. package/dist/benchmarks/task-revisions/mn-focused-regression-test/workspace/spec/session-key.md +7 -0
  653. package/dist/benchmarks/task-revisions/mn-focused-regression-test/workspace/src/session-key.mjs +12 -0
  654. package/dist/benchmarks/task-revisions/mn-focused-regression-test/workspace/test/session-key.test.mjs +11 -0
  655. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/input-manifest.json +48 -0
  656. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/rubric.json +45 -0
  657. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/task.md +5 -0
  658. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/workspace/package.json +7 -0
  659. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/workspace/spec/default-state.md +14 -0
  660. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/workspace/src/display-controls.mjs +6 -0
  661. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/workspace/src/display-preferences.mjs +18 -0
  662. package/dist/benchmarks/task-revisions/mn-frontend-default-fix/workspace/test/display-preferences.test.mjs +54 -0
  663. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/input-manifest.json +58 -0
  664. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/rubric.json +45 -0
  665. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/task.md +5 -0
  666. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/package.json +7 -0
  667. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/schemas/member.schema.json +12 -0
  668. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/spec/member-contract.md +13 -0
  669. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/spec/schema-alignment-plan.md +5 -0
  670. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/src/member-export.mjs +3 -0
  671. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/src/member-import.mjs +23 -0
  672. package/dist/benchmarks/task-revisions/mn-schema-field-alignment/workspace/test/member-record.test.mjs +36 -0
  673. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/input-manifest.json +82 -0
  674. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/rubric.json +52 -0
  675. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/task.md +7 -0
  676. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/docs/interaction-notes.md +11 -0
  677. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/notice-editor.html +31 -0
  678. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/package-lock.json +15 -0
  679. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/package.json +14 -0
  680. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/pr.diff +83 -0
  681. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/review.schema.json +57 -0
  682. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/scripts/validate-review.mjs +40 -0
  683. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/src/format-toolbar.html +10 -0
  684. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/src/format-toolbar.mjs +42 -0
  685. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/test/helpers/toolbar-fixture.mjs +19 -0
  686. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/test/integration/format-toolbar.test.mjs +16 -0
  687. package/dist/benchmarks/task-revisions/mp-accessibility-interaction-review/workspace/test/unit/format-toolbar.test.mjs +23 -0
  688. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/input-manifest.json +87 -0
  689. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/rubric.json +52 -0
  690. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/task.md +5 -0
  691. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/.github/workflows/pull-request.yml +23 -0
  692. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/ci/pull-request-314.log +22 -0
  693. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/docs/verification.md +9 -0
  694. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/package-lock.json +13 -0
  695. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/package.json +14 -0
  696. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/pr.diff +49 -0
  697. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/review.schema.json +61 -0
  698. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/scripts/upload-diagnostics.mjs +4 -0
  699. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/scripts/validate-review.mjs +40 -0
  700. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/src/checkout.mjs +6 -0
  701. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/src/quote-order.mjs +13 -0
  702. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/test/checkout/quote-order-contract.test.mjs +12 -0
  703. package/dist/benchmarks/task-revisions/mp-ci-evidence-gap/workspace/test/unit/quote-order.test.mjs +23 -0
  704. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/input-manifest.json +97 -0
  705. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/rubric.json +44 -0
  706. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/task.md +7 -0
  707. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/docs/migration-plan.md +21 -0
  708. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/docs/rollback-runbook.md +3 -0
  709. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/evidence/checkpoint-journal.ndjson +10 -0
  710. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/evidence/comparisons.ndjson +6 -0
  711. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/evidence/compatibility.json +25 -0
  712. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/evidence/outbox.ndjson +4 -0
  713. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/handoff.schema.json +216 -0
  714. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/operations/commands.json +71 -0
  715. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/operations/pages.json +134 -0
  716. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/operations/work-orders.json +39 -0
  717. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/package-lock.json +13 -0
  718. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/package.json +11 -0
  719. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/scripts/validate-handoff.mjs +63 -0
  720. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/state/grants.ndjson +5 -0
  721. package/dist/benchmarks/task-revisions/mp-data-migration-handoff/workspace/state/routing.json +22 -0
  722. package/dist/benchmarks/task-revisions/mp-frontend-state-review/input-manifest.json +77 -0
  723. package/dist/benchmarks/task-revisions/mp-frontend-state-review/rubric.json +44 -0
  724. package/dist/benchmarks/task-revisions/mp-frontend-state-review/task.md +5 -0
  725. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/docs/state-contract.md +14 -0
  726. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/package-lock.json +15 -0
  727. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/package.json +14 -0
  728. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/pr.diff +116 -0
  729. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/review.schema.json +57 -0
  730. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/scripts/validate-review.mjs +40 -0
  731. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/src/inbox-state.mjs +47 -0
  732. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/src/inbox-view.mjs +19 -0
  733. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/test/helpers/inbox-fixture.mjs +8 -0
  734. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/test/integration/inbox-view.test.mjs +32 -0
  735. package/dist/benchmarks/task-revisions/mp-frontend-state-review/workspace/test/unit/inbox-state.test.mjs +20 -0
  736. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/input-manifest.json +87 -0
  737. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/rubric.json +52 -0
  738. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/task.md +7 -0
  739. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/change-plan.schema.json +186 -0
  740. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/docs/change-request.md +9 -0
  741. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/docs/knowledge-policy.md +6 -0
  742. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/docs/rollback-policy.md +8 -0
  743. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/infra/alias.tf +11 -0
  744. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/infra/iam.tf +12 -0
  745. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/operations/commands.json +46 -0
  746. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/package-lock.json +15 -0
  747. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/package.json +12 -0
  748. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/plans/candidate-plan.json +15 -0
  749. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/plans/pre-apply-records.json +117 -0
  750. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/scripts/validate-change-plan.mjs +138 -0
  751. package/dist/benchmarks/task-revisions/mp-iac-rollback-design/workspace/state/current-state.json +23 -0
  752. package/dist/benchmarks/task-revisions/mp-performance-investigation/input-manifest.json +97 -0
  753. package/dist/benchmarks/task-revisions/mp-performance-investigation/rubric.json +44 -0
  754. package/dist/benchmarks/task-revisions/mp-performance-investigation/task.md +7 -0
  755. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/docs/investigation-contract.md +14 -0
  756. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/investigation.schema.json +92 -0
  757. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/observability/cache-samples.csv +7 -0
  758. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/observability/release-events.json +14 -0
  759. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/observability/request-windows.csv +4 -0
  760. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/observability/runtime-profile.json +25 -0
  761. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/package-lock.json +15 -0
  762. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/package.json +15 -0
  763. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/scripts/replay-summary.mjs +12 -0
  764. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/scripts/validate-investigation.mjs +84 -0
  765. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/src/cache-key.mjs +6 -0
  766. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/src/summary-replay.mjs +42 -0
  767. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/src/summary-service.mjs +9 -0
  768. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/test/integration/summary-replay.test.mjs +11 -0
  769. package/dist/benchmarks/task-revisions/mp-performance-investigation/workspace/test/unit/cache-key.test.mjs +9 -0
  770. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/input-manifest.json +53 -0
  771. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/rubric.json +44 -0
  772. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/task.md +7 -0
  773. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/package.json +6 -0
  774. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/spec/pagination-contract.md +9 -0
  775. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/src/api-pages.mjs +16 -0
  776. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/src/catalog-consumer.mjs +5 -0
  777. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/src/pagination.mjs +19 -0
  778. package/dist/benchmarks/task-revisions/pf-api-pagination-behavior/workspace/test/pagination.test.mjs +76 -0
  779. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/input-manifest.json +77 -0
  780. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/rubric.json +44 -0
  781. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/task.md +11 -0
  782. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/ci/build-config.json +11 -0
  783. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/ci/build-history.log +6 -0
  784. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/ci/scenarios.json +38 -0
  785. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/docs/investigation-contract.md +19 -0
  786. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/investigation.schema.json +503 -0
  787. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/package.json +14 -0
  788. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/scripts/reproduce-cache.mjs +5 -0
  789. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/scripts/validate-report.mjs +31 -0
  790. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/src/cache-model.mjs +9 -0
  791. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/test/cache-observation.test.mjs +33 -0
  792. package/dist/benchmarks/task-revisions/pf-ci-cache-flake/workspace/test/report-structure.test.mjs +2 -0
  793. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/input-manifest.json +68 -0
  794. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/rubric.json +45 -0
  795. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/task.md +11 -0
  796. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/data/legacy-customers.json +17 -0
  797. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/migrations/v1-v2.plan.json +11 -0
  798. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/package.json +12 -0
  799. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/schemas/customer-v1.schema.json +27 -0
  800. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/schemas/customer-v2.schema.json +25 -0
  801. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/spec/evolution-contract.md +8 -0
  802. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/src/readers.mjs +3 -0
  803. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/src/schema-contract.mjs +7 -0
  804. package/dist/benchmarks/task-revisions/pf-data-schema-evolution/workspace/test/schema-evolution.test.mjs +15 -0
  805. package/dist/benchmarks/task-revisions/pf-frontend-async-state/input-manifest.json +47 -0
  806. package/dist/benchmarks/task-revisions/pf-frontend-async-state/rubric.json +37 -0
  807. package/dist/benchmarks/task-revisions/pf-frontend-async-state/task.md +7 -0
  808. package/dist/benchmarks/task-revisions/pf-frontend-async-state/workspace/package.json +1 -0
  809. package/dist/benchmarks/task-revisions/pf-frontend-async-state/workspace/spec/search-state-contract.md +6 -0
  810. package/dist/benchmarks/task-revisions/pf-frontend-async-state/workspace/src/search-controller.mjs +5 -0
  811. package/dist/benchmarks/task-revisions/pf-frontend-async-state/workspace/src/search-view.mjs +3 -0
  812. package/dist/benchmarks/task-revisions/pf-frontend-async-state/workspace/test/search-state.test.mjs +14 -0
  813. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/input-manifest.json +90 -0
  814. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/rubric.json +42 -0
  815. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/task.md +9 -0
  816. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/config/migration-settings.json +5 -0
  817. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/data/compatibility-matrix.json +44 -0
  818. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/docs/migration-contract.md +13 -0
  819. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/package.json +13 -0
  820. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/scripts/check-rollback.mjs +5 -0
  821. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/scripts/validate-migration.mjs +2 -0
  822. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/src/archive-compat.mjs +2 -0
  823. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/src/download-export.mjs +5 -0
  824. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/src/scheduled-export.mjs +5 -0
  825. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/test/application-callers.test.mjs +19 -0
  826. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/test/archive-compat.test.mjs +13 -0
  827. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/vendor/archive-v1.mjs +3 -0
  828. package/dist/benchmarks/task-revisions/pf-library-compat-upgrade/workspace/vendor/archive-v2.mjs +3 -0
  829. package/dist/benchmarks/task-revisions/pf-observability-redaction/input-manifest.json +88 -0
  830. package/dist/benchmarks/task-revisions/pf-observability-redaction/rubric.json +45 -0
  831. package/dist/benchmarks/task-revisions/pf-observability-redaction/task.md +11 -0
  832. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/base/projection-policy.json +14 -0
  833. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/config/field-contract.json +24 -0
  834. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/config/projection-policy.json +18 -0
  835. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/config/proposed-policy.json +18 -0
  836. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/data/events.json +80 -0
  837. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/docs/projection-contract.md +11 -0
  838. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/package.json +13 -0
  839. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/pr.diff +19 -0
  840. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/review.schema.json +120 -0
  841. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/scripts/trace-policy.mjs +1 -0
  842. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/scripts/validate-review.mjs +12 -0
  843. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/src/project-event.mjs +7 -0
  844. package/dist/benchmarks/task-revisions/pf-observability-redaction/workspace/test/project-event.test.mjs +3 -0
  845. package/dist/benchmarks/task-revisions/pf-performance-regression/input-manifest.json +62 -0
  846. package/dist/benchmarks/task-revisions/pf-performance-regression/rubric.json +45 -0
  847. package/dist/benchmarks/task-revisions/pf-performance-regression/task.md +11 -0
  848. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/data/measurement-config.json +21 -0
  849. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/docs/lookup-contract.md +11 -0
  850. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/package.json +12 -0
  851. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/reference/scan-lookup.mjs +7 -0
  852. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/scripts/generate-data.mjs +5 -0
  853. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/scripts/measure-lookup.mjs +103 -0
  854. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/src/event-lookup.mjs +7 -0
  855. package/dist/benchmarks/task-revisions/pf-performance-regression/workspace/test/event-lookup.test.mjs +17 -0
  856. package/dist/benchmarks/task-revisions/pf-review-error-contract/input-manifest.json +87 -0
  857. package/dist/benchmarks/task-revisions/pf-review-error-contract/rubric.json +44 -0
  858. package/dist/benchmarks/task-revisions/pf-review-error-contract/task.md +11 -0
  859. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/base/response-adapter.mjs +10 -0
  860. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/comparisons/option-a.diff +10 -0
  861. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/comparisons/option-b.diff +11 -0
  862. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/data/cases.json +65 -0
  863. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/docs/error-contract.md +10 -0
  864. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/package.json +10 -0
  865. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/pr.diff +13 -0
  866. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/review.schema.json +407 -0
  867. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/scripts/trace-cases.mjs +7 -0
  868. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/scripts/validate-review.mjs +12 -0
  869. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/src/client-policy.mjs +8 -0
  870. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/src/response-adapter.mjs +10 -0
  871. package/dist/benchmarks/task-revisions/pf-review-error-contract/workspace/test/api-error.test.mjs +6 -0
  872. package/dist/benchmarks/task-revisions/rc01-shared-review-platform/input-manifest.json +808 -0
  873. package/dist/benchmarks/task-revisions/rc01-shared-review-platform/rubric.json +40 -0
  874. package/dist/bin/ask.mjs +9 -0
  875. package/dist/docs/README.md +81 -0
  876. package/dist/docs/adapter-capability-matrix.md +75 -0
  877. package/dist/docs/adapter-conformance-contract.md +81 -0
  878. package/dist/docs/adapter-cross-conformance-report.md +43 -0
  879. package/dist/docs/adapter-deployment-governance.md +110 -0
  880. package/dist/docs/adapter-runtime-boundary-contract.md +211 -0
  881. package/dist/docs/adapter-runtime-migration.md +130 -0
  882. package/dist/docs/adoption-apply.md +97 -0
  883. package/dist/docs/adoption-setup.md +150 -0
  884. package/dist/docs/adr/0001-verification-evidence-trust-boundary.md +100 -0
  885. package/dist/docs/adr/0002-epic-admission-work-package-plan-authority.md +76 -0
  886. package/dist/docs/adr/0003-asset-registry-authority-boundary.md +120 -0
  887. package/dist/docs/adr/0004-portfolio-activation-authority-boundary.md +290 -0
  888. package/dist/docs/adr/0005-evolution-authority-boundary.md +195 -0
  889. package/dist/docs/adr/0006-claim-evidence-status-boundary.md +57 -0
  890. package/dist/docs/adr/0007-runner-owned-execution-envelope-record.md +28 -0
  891. package/dist/docs/adr/0008-monotonic-verification-proof-path.md +122 -0
  892. package/dist/docs/adr/0009-baseline-semantic-review-authority.md +74 -0
  893. package/dist/docs/adr/0010-one-task-effectiveness-authority-boundary.md +143 -0
  894. package/dist/docs/adr/0011-prompt-v2-result-blind-canary-authority.md +155 -0
  895. package/dist/docs/adr/0025-discarded-evaluation-result-use.md +31 -0
  896. package/dist/docs/agent-session-state-contract.md +67 -0
  897. package/dist/docs/ai/adoption-report-template.md +179 -0
  898. package/dist/docs/ai/architecture-decision-memory.md +83 -0
  899. package/dist/docs/ai/documentation-knowledge-ledger.md +85 -0
  900. package/dist/docs/ai/domain-rule-ledger.md +115 -0
  901. package/dist/docs/ai/engineering-capability-ledger.md +90 -0
  902. package/dist/docs/ai/engineering-pattern-ledger.md +81 -0
  903. package/dist/docs/ai/implementation-context.md +158 -0
  904. package/dist/docs/ai/improvement-ledger.md +212 -0
  905. package/dist/docs/ai/metrics/README.md +9 -0
  906. package/dist/docs/ai/metrics/fixtures/stakeholder-readiness-events.jsonl +3 -0
  907. package/dist/docs/ai/observability-config.yml +54 -0
  908. package/dist/docs/ai/reports/README.md +5 -0
  909. package/dist/docs/ai/reports/examples/ai-promotion-readiness-sample.md +43 -0
  910. package/dist/docs/ai/reports/examples/business-unit-client-value-readiness-sample.md +37 -0
  911. package/dist/docs/ai/reports/examples/development-manager-readiness-sample.md +41 -0
  912. package/dist/docs/ai/reports/examples/senior-engineer-readiness-sample.md +42 -0
  913. package/dist/docs/ai/review-context.md +127 -0
  914. package/dist/docs/ai/review-rule-ledger.md +78 -0
  915. package/dist/docs/ai/skill-adoption-metrics.md +251 -0
  916. package/dist/docs/ai/stakeholder-readiness-report-template.md +139 -0
  917. package/dist/docs/ai/verification-pattern-ledger.md +83 -0
  918. package/dist/docs/ask-autonomous-development.md +237 -0
  919. package/dist/docs/ask-core-bundle-implementation.md +155 -0
  920. package/dist/docs/asset-registry-contract.md +392 -0
  921. package/dist/docs/bounded-target-snapshot.md +90 -0
  922. package/dist/docs/claim-evidence-status-contract.md +60 -0
  923. package/dist/docs/claude-github-review-setup.md +65 -0
  924. package/dist/docs/codex-metrics-collector.md +149 -0
  925. package/dist/docs/cross-runtime-environment-loop.md +345 -0
  926. package/dist/docs/customization-guide.md +175 -0
  927. package/dist/docs/debt-lifecycle-contract.md +134 -0
  928. package/dist/docs/demos/personal-loop-saved-demo-ja.md +38 -0
  929. package/dist/docs/epic-admission-work-package-plan-contract.md +239 -0
  930. package/dist/docs/evaluation-task-catalog.md +107 -0
  931. package/dist/docs/evolution-loop-contract.md +395 -0
  932. package/dist/docs/evolution-loop-sample-prompt-candidate.md +15 -0
  933. package/dist/docs/execution-envelope-contract.md +105 -0
  934. package/dist/docs/finding-intake.md +165 -0
  935. package/dist/docs/first-workflow-mac-codex-ja.md +132 -0
  936. package/dist/docs/fixtures/adapter-cross-conformance.json +272 -0
  937. package/dist/docs/fixtures/adapter-runtime-bundle.json +867 -0
  938. package/dist/docs/fixtures/adapter-runtime-evidence.json +111 -0
  939. package/dist/docs/fixtures/adapter-runtime-profiles.json +2055 -0
  940. package/dist/docs/fixtures/asset-registry/reference.json +89 -0
  941. package/dist/docs/fixtures/asset-registry/store/objects/sha256/06/cacaea5b7b84bb2a9f6a6e849f1e561967637cfc0c28bd60675b665f090a54.json +1 -0
  942. package/dist/docs/fixtures/asset-registry/store/objects/sha256/0a/1bf5ec027954e2def2bf6591655365258e4ed6c3e58a151ea242b961591dcc.json +1 -0
  943. package/dist/docs/fixtures/asset-registry/store/objects/sha256/12/4a398892b63295e43b894776bea049625e3847010acd2dce61880a207cf1da.json +1 -0
  944. package/dist/docs/fixtures/asset-registry/store/objects/sha256/33/d26707d82e68099085b91f60b26b6bea6ea17af802a493dd70ee4629dfc72b.json +1 -0
  945. package/dist/docs/fixtures/asset-registry/store/objects/sha256/34/a511af596bc1317941241135f053153d9862ff7552a243c0231fc079c4edba.json +1 -0
  946. package/dist/docs/fixtures/asset-registry/store/objects/sha256/39/f30afcc78d50c1ff2cf85d4c18d546b47811c370146193535af08cc030cc65.json +1 -0
  947. package/dist/docs/fixtures/asset-registry/store/objects/sha256/43/e18c25bca6279ab7b333b5e4ce3bfdc8ada01023bfe47d0889d61e71872c56.json +1 -0
  948. package/dist/docs/fixtures/asset-registry/store/objects/sha256/5b/50712f43feecf82d532178310cf2e0fe2fe709e0d951eb797a3876ff0cf92d.json +1 -0
  949. package/dist/docs/fixtures/asset-registry/store/objects/sha256/5c/c2ab9ca47824d2d13438f7f4460b71db1a6f939cfce1b0f84291e3e5935be5.json +1 -0
  950. package/dist/docs/fixtures/asset-registry/store/objects/sha256/62/1237eed65b92d996a11b259d7ef8854357c9fd1e7170071d59c4f50f4e7b3e.json +1 -0
  951. package/dist/docs/fixtures/asset-registry/store/objects/sha256/9b/fd6af3c3768f8760fb1fe8b8ab98e6d4753d4802e38f7604b446dc7b14a95a.json +1 -0
  952. package/dist/docs/fixtures/asset-registry/store/objects/sha256/be/c5d5f8f9ee2f8fdab1902f73888b251eb9e62e55bef3529542ab0deb8a48e2.json +1 -0
  953. package/dist/docs/fixtures/asset-registry/store/objects/sha256/c6/19c6c426da2f6fac9185c2426908ea83ff1598e5e9af7add61f509678a5853.json +1 -0
  954. package/dist/docs/fixtures/asset-registry/store/objects/sha256/d6/e6ac3acac3ee396987fd0333b6193c809156c88eb343b43c9e0b0c72fbe1c5.json +1 -0
  955. package/dist/docs/fixtures/asset-registry/store/objects/sha256/d9/6f3131c5d6556d2fa74665befef66c0d279dd1177dc6d41f232f2844eafba6.json +1 -0
  956. package/dist/docs/fixtures/asset-registry/store/objects/sha256/f4/6abf273daaaf13cc96c10e54d2de72ba8cd269a58d1ea047331c38ba13dc18.json +1 -0
  957. package/dist/docs/fixtures/claude-fixed-entry-route-baseline.json +36 -0
  958. package/dist/docs/fixtures/claude-pre-fixed-commands/skill-handoff.md +32 -0
  959. package/dist/docs/fixtures/claude-pre-fixed-commands/skill-implement.md +30 -0
  960. package/dist/docs/fixtures/claude-pre-fixed-commands/skill-investigate.md +25 -0
  961. package/dist/docs/fixtures/claude-pre-fixed-commands/skill-review.md +54 -0
  962. package/dist/docs/fixtures/claude-pre-fixed-commands/skill-verify.md +36 -0
  963. package/dist/docs/fixtures/codex-compact-route-baseline.json +42 -0
  964. package/dist/docs/fixtures/codex-pre-compact-prompts/skill-handoff.md +43 -0
  965. package/dist/docs/fixtures/codex-pre-compact-prompts/skill-implement.md +55 -0
  966. package/dist/docs/fixtures/codex-pre-compact-prompts/skill-investigate.md +55 -0
  967. package/dist/docs/fixtures/codex-pre-compact-prompts/skill-review.md +68 -0
  968. package/dist/docs/fixtures/codex-pre-compact-prompts/skill-verify.md +55 -0
  969. package/dist/docs/fixtures/epic-admission-policy.json +50 -0
  970. package/dist/docs/fixtures/epic-admission-work-package-plan-cases.json +766 -0
  971. package/dist/docs/fixtures/evolution-loop/reference.json +551 -0
  972. package/dist/docs/fixtures/first-workflow-315/bypass-input-ja.md +2 -0
  973. package/dist/docs/fixtures/first-workflow-315/implementation-input-ja.md +15 -0
  974. package/dist/docs/fixtures/issue-275-slice-1-epic-admission-decision.json +86 -0
  975. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan-r1.json +1053 -0
  976. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan-r2.json +1078 -0
  977. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan-validation-context-r1.json +81 -0
  978. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan-validation-context-r2.json +117 -0
  979. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan-validation-context.json +117 -0
  980. package/dist/docs/fixtures/issue-275-slice-1-work-package-plan.json +1126 -0
  981. package/dist/docs/fixtures/kernel-principles-source-5f36081.md +266 -0
  982. package/dist/docs/fixtures/lifecycle-artifact-chains.json +108 -0
  983. package/dist/docs/fixtures/lifecycle-traceability-chains.json +356 -0
  984. package/dist/docs/fixtures/portfolio-manager/reference.json +70 -0
  985. package/dist/docs/fixtures/pragmatic-evaluation/notes-template.json +39 -0
  986. package/dist/docs/fixtures/prompt-v2-preregistration/binding.json +170 -0
  987. package/dist/docs/fixtures/prompt-v2-preregistration/reference.json +397 -0
  988. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/claude_code/skill-handoff.md +32 -0
  989. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/claude_code/skill-implement.md +38 -0
  990. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/claude_code/skill-investigate.md +35 -0
  991. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/claude_code/skill-review.md +49 -0
  992. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/claude_code/skill-verify.md +43 -0
  993. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/codex/skill-handoff.md +29 -0
  994. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/codex/skill-implement.md +34 -0
  995. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/codex/skill-investigate.md +33 -0
  996. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/codex/skill-review.md +50 -0
  997. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/codex/skill-verify.md +34 -0
  998. package/dist/docs/fixtures/prompt-v2-preregistration/rendered/reference.json +94 -0
  999. package/dist/docs/fixtures/release-evidence-gate/current-main-756c72-claim-matrix.json +74 -0
  1000. package/dist/docs/fixtures/release-evidence-gate/current-main-756c72-evidence.json +30 -0
  1001. package/dist/docs/fixtures/release-evidence-gate/current-main-d4ad39-claim-matrix.json +389 -0
  1002. package/dist/docs/fixtures/release-evidence-gate/current-main-d4ad39-evidence.json +1024 -0
  1003. package/dist/docs/fixtures/release-evidence-gate/current-main-d4ad39-independent-review.md +95 -0
  1004. package/dist/docs/fixtures/release-evidence-gate/current-main-d4ad39-observations.json +87 -0
  1005. package/dist/docs/fixtures/release-evidence-gate/mac-install-recovery-candidate.json +232 -0
  1006. package/dist/docs/fixtures/release-evidence-gate/mac-install-recovery-review.md +112 -0
  1007. package/dist/docs/fixtures/review-route-cases.json +830 -0
  1008. package/dist/docs/fixtures/skill-effectiveness-outcome-cases.json +549 -0
  1009. package/dist/docs/fixtures/sufficient-change-scope/stage-1.md +51 -0
  1010. package/dist/docs/fixtures/sufficient-change-scope/stage-2.md +30 -0
  1011. package/dist/docs/fixtures/ui-ux-design/README.md +36 -0
  1012. package/dist/docs/fixtures/ui-ux-design/fixture-state.mjs +140 -0
  1013. package/dist/docs/fixtures/ui-ux-design/fixture-state.test.mjs +171 -0
  1014. package/dist/docs/fixtures/ui-ux-design/fixture.mjs +154 -0
  1015. package/dist/docs/fixtures/verification-proof-formal-baseline.md +14 -0
  1016. package/dist/docs/fixtures/verification-proof-policy-cases.json +906 -0
  1017. package/dist/docs/glossary-ja.md +433 -0
  1018. package/dist/docs/instruction-improvement-continuity.md +237 -0
  1019. package/dist/docs/instruction-improvement-delivery.md +130 -0
  1020. package/dist/docs/instruction-improvement-learning-context.md +118 -0
  1021. package/dist/docs/instruction-improvement-readiness.md +116 -0
  1022. package/dist/docs/instruction-loop-failed-preparation.md +45 -0
  1023. package/dist/docs/instruction-loop-fixed-reference-scoring.md +57 -0
  1024. package/dist/docs/instruction-loop-host-authoring.md +83 -0
  1025. package/dist/docs/instruction-loop-reference-evidence.md +185 -0
  1026. package/dist/docs/instruction-loop-retained-authoring.md +115 -0
  1027. package/dist/docs/instruction-loop-source-application.md +110 -0
  1028. package/dist/docs/instruction-loop-source-validation.md +65 -0
  1029. package/dist/docs/instruction-loop-standard-execution.md +101 -0
  1030. package/dist/docs/kernel-principles-candidate-v2.md +124 -0
  1031. package/dist/docs/kernel-principles-comparison.md +135 -0
  1032. package/dist/docs/kernel-principles-v2-adoption.md +118 -0
  1033. package/dist/docs/kernel-standalone-design-proposal.md +198 -0
  1034. package/dist/docs/kernel-standalone-instruction-draft.md +206 -0
  1035. package/dist/docs/lifecycle-artifact-contract.md +274 -0
  1036. package/dist/docs/lifecycle-traceability-contract.md +169 -0
  1037. package/dist/docs/local-codex-admission.md +177 -0
  1038. package/dist/docs/local-codex-connection.md +60 -0
  1039. package/dist/docs/local-codex-read-policy.md +210 -0
  1040. package/dist/docs/local-codex-single-sandbox-design.md +73 -0
  1041. package/dist/docs/local-eval-distribution.md +222 -0
  1042. package/dist/docs/local-full-static-preparation.md +137 -0
  1043. package/dist/docs/local-three-arm-comparison.md +142 -0
  1044. package/dist/docs/local-three-arm-qualification.md +89 -0
  1045. package/dist/docs/mac-ask-full-reference-supplement.json +249 -0
  1046. package/dist/docs/mac-ask-full-static-inventory.json +1488 -0
  1047. package/dist/docs/mac-kernel-value-screening.md +253 -0
  1048. package/dist/docs/measured-review-adoption.md +88 -0
  1049. package/dist/docs/metrics-event-contract.md +252 -0
  1050. package/dist/docs/npm-distribution-ja.md +135 -0
  1051. package/dist/docs/npm-distribution.md +299 -0
  1052. package/dist/docs/npm-loop-spec-example.mjs +34 -0
  1053. package/dist/docs/observability-runtime-contract.md +164 -0
  1054. package/dist/docs/operation-automation-contract.md +89 -0
  1055. package/dist/docs/personal-evolution-bridge.md +33 -0
  1056. package/dist/docs/personal-evolution-cli.md +238 -0
  1057. package/dist/docs/personal-evolution-codex-generation.md +166 -0
  1058. package/dist/docs/personal-evolution-driver.md +15 -0
  1059. package/dist/docs/personal-evolution-generation-connector.md +139 -0
  1060. package/dist/docs/personal-evolution-generation-status.md +86 -0
  1061. package/dist/docs/personal-evolution-generation.md +31 -0
  1062. package/dist/docs/personal-evolution-primary-loop.md +241 -0
  1063. package/dist/docs/personal-evolution-primary-pair-contract.md +72 -0
  1064. package/dist/docs/personal-evolution-saved-results.md +31 -0
  1065. package/dist/docs/personal-evolution-source-reviewer.md +84 -0
  1066. package/dist/docs/personal-evolution-unattended.md +169 -0
  1067. package/dist/docs/personal-loop-quickstart-ja.md +79 -0
  1068. package/dist/docs/personal-v1-release-preparation-ja.md +41 -0
  1069. package/dist/docs/portfolio-manager-contract.md +596 -0
  1070. package/dist/docs/practical-challenge-evaluation.md +273 -0
  1071. package/dist/docs/practical-evaluation-recovery.md +487 -0
  1072. package/dist/docs/practical-grade-supplement.md +193 -0
  1073. package/dist/docs/practical-partial-grading.md +121 -0
  1074. package/dist/docs/practical-quality-observations.md +69 -0
  1075. package/dist/docs/practical-retained-grade-report.md +106 -0
  1076. package/dist/docs/pragmatic-evaluation.md +149 -0
  1077. package/dist/docs/primary-24-practical-review.md +281 -0
  1078. package/dist/docs/primary-24-practical-revision.md +256 -0
  1079. package/dist/docs/primary-24-private-v2.md +28 -0
  1080. package/dist/docs/primary-24-task-assembly.md +276 -0
  1081. package/dist/docs/primary-24-unsafe-action-v8.md +28 -0
  1082. package/dist/docs/primary-evaluation-correctness-v7.md +188 -0
  1083. package/dist/docs/primary-principles-v2-connection.md +88 -0
  1084. package/dist/docs/project-overlay-template.md +152 -0
  1085. package/dist/docs/prompt-recipes-ja.md +955 -0
  1086. package/dist/docs/prompt-v2-execution-handoff.md +81 -0
  1087. package/dist/docs/quality-rubric.md +145 -0
  1088. package/dist/docs/quickstart-ja.md +388 -0
  1089. package/dist/docs/quickstart-mac-codex-ja.md +160 -0
  1090. package/dist/docs/references.md +18 -0
  1091. package/dist/docs/release-evidence-gate-contract.md +198 -0
  1092. package/dist/docs/release-package-2026-10.md +129 -0
  1093. package/dist/docs/review-finding-contract.md +54 -0
  1094. package/dist/docs/review-rule-lifecycle.md +205 -0
  1095. package/dist/docs/routing-model.md +274 -0
  1096. package/dist/docs/rule-batch-prospective-comparison.md +88 -0
  1097. package/dist/docs/skill-effectiveness-evaluation-contract.md +146 -0
  1098. package/dist/docs/skill-matrix.md +190 -0
  1099. package/dist/docs/stack-implementation-overlay-contract.md +122 -0
  1100. package/dist/docs/sufficient-change-scope-evaluation.md +120 -0
  1101. package/dist/docs/supervised-instruction-loop.md +464 -0
  1102. package/dist/docs/unattended-user-comparison-contract.md +90 -0
  1103. package/dist/docs/usage-ja.md +501 -0
  1104. package/dist/docs/user-comparison-contract.md +75 -0
  1105. package/dist/docs/user-repository-comparison-mac-codex-ja.md +571 -0
  1106. package/dist/docs/validation-report.md +756 -0
  1107. package/dist/docs/verification-evidence-contract.md +175 -0
  1108. package/dist/docs/verification-proof-policy-contract.md +177 -0
  1109. package/dist/docs/verification-reuse-completion-contract.md +129 -0
  1110. package/dist/docs/verification-reuse-measurement.md +130 -0
  1111. package/dist/docs/workflow-examples.md +539 -0
  1112. package/dist/examples/01-small-change.md +32 -0
  1113. package/dist/examples/02-new-feature.md +53 -0
  1114. package/dist/examples/03-bug-fix.md +39 -0
  1115. package/dist/examples/04-design-grill.md +40 -0
  1116. package/dist/examples/05-pr-review.md +43 -0
  1117. package/dist/examples/06-handoff-to-agent.md +49 -0
  1118. package/dist/examples/07-mr-readme.md +32 -0
  1119. package/dist/examples/08-code-health-review.md +50 -0
  1120. package/dist/examples/09-improvement-ledger-update.md +90 -0
  1121. package/dist/examples/10-safe-refactor.md +76 -0
  1122. package/dist/examples/11-prevention-rule-feedback.md +104 -0
  1123. package/dist/examples/12-claude-adapter-adoption.md +36 -0
  1124. package/dist/manifest.json +804 -0
  1125. package/dist/npm-runtime-inventory.json +7774 -0
  1126. package/dist/package.json +38 -0
  1127. package/dist/products/ask-core-bundle/AGENTS.md +195 -0
  1128. package/dist/products/ask-core-bundle/capabilities.json +65 -0
  1129. package/dist/products/ask-core-bundle/manifest.json +2738 -0
  1130. package/dist/schemas/adapter-runtime-event.schema.json +169 -0
  1131. package/dist/schemas/adapter-runtime-evidence.schema.json +60 -0
  1132. package/dist/schemas/adapter-runtime-profile.schema.json +281 -0
  1133. package/dist/schemas/adoption-apply-result.schema.json +215 -0
  1134. package/dist/schemas/adoption-plan.schema.json +366 -0
  1135. package/dist/schemas/adoption-report.schema.json +252 -0
  1136. package/dist/schemas/architecture-decision-memory-entry.schema.json +56 -0
  1137. package/dist/schemas/asset-content.schema.json +107 -0
  1138. package/dist/schemas/asset-lifecycle-authority-context.schema.json +69 -0
  1139. package/dist/schemas/asset-record.schema.json +362 -0
  1140. package/dist/schemas/asset-registry-snapshot.schema.json +59 -0
  1141. package/dist/schemas/claim-evidence-status.schema.json +85 -0
  1142. package/dist/schemas/codex-risk-action.schema.json +58 -0
  1143. package/dist/schemas/codex-risk-approval-request.schema.json +204 -0
  1144. package/dist/schemas/codex-risk-approval.schema.json +15 -0
  1145. package/dist/schemas/codex-runner-result.schema.json +41 -0
  1146. package/dist/schemas/compact-profile-control-map.json +154 -0
  1147. package/dist/schemas/context-rollover.schema.json +726 -0
  1148. package/dist/schemas/documentation-knowledge-ledger-entry.schema.json +49 -0
  1149. package/dist/schemas/domain-rule-ledger-entry.schema.json +93 -0
  1150. package/dist/schemas/effectiveness-decision-vocabulary.schema.json +24 -0
  1151. package/dist/schemas/engineering-capability-ledger-entry.schema.json +50 -0
  1152. package/dist/schemas/engineering-pattern-ledger-entry.schema.json +48 -0
  1153. package/dist/schemas/epic-admission-decision.schema.json +196 -0
  1154. package/dist/schemas/epic-admission-policy.schema.json +153 -0
  1155. package/dist/schemas/evolution-action-proposal.schema.json +183 -0
  1156. package/dist/schemas/evolution-application-receipt.schema.json +263 -0
  1157. package/dist/schemas/evolution-candidate.schema.json +269 -0
  1158. package/dist/schemas/evolution-experiment.schema.json +368 -0
  1159. package/dist/schemas/evolution-human-decision.schema.json +79 -0
  1160. package/dist/schemas/evolution-recommendation.schema.json +211 -0
  1161. package/dist/schemas/execution-envelope-record.schema.json +127 -0
  1162. package/dist/schemas/execution-envelope.schema.json +127 -0
  1163. package/dist/schemas/fixed-entry-profile-registry.json +44 -0
  1164. package/dist/schemas/improvement-ledger-entry.schema.json +98 -0
  1165. package/dist/schemas/instruction-asset-package.schema.json +343 -0
  1166. package/dist/schemas/metrics-event.schema.json +395 -0
  1167. package/dist/schemas/normalized-event-schema-registry.json +13 -0
  1168. package/dist/schemas/portfolio-authority-context.schema.json +151 -0
  1169. package/dist/schemas/portfolio-lock.schema.json +99 -0
  1170. package/dist/schemas/portfolio-manifest.schema.json +414 -0
  1171. package/dist/schemas/portfolio-selection-context.schema.json +101 -0
  1172. package/dist/schemas/portfolio-selection.schema.json +266 -0
  1173. package/dist/schemas/release-assessment.schema.json +64 -0
  1174. package/dist/schemas/release-claim-matrix.schema.json +89 -0
  1175. package/dist/schemas/release-evidence-catalog.schema.json +154 -0
  1176. package/dist/schemas/repository-snapshot.schema.json +244 -0
  1177. package/dist/schemas/review-finding.schema.json +110 -0
  1178. package/dist/schemas/review-rule-ledger-entry.schema.json +52 -0
  1179. package/dist/schemas/review-signal-gate-map.json +128 -0
  1180. package/dist/schemas/rollover-evaluation.schema.json +397 -0
  1181. package/dist/schemas/session-checkpoint.schema.json +206 -0
  1182. package/dist/schemas/skill-effectiveness-outcome.schema.json +490 -0
  1183. package/dist/schemas/verification-completion-policy.schema.json +79 -0
  1184. package/dist/schemas/verification-evidence-transfer.schema.json +67 -0
  1185. package/dist/schemas/verification-evidence.schema.json +352 -0
  1186. package/dist/schemas/verification-pattern-ledger-entry.schema.json +52 -0
  1187. package/dist/schemas/verification-proof-policy.schema.json +326 -0
  1188. package/dist/schemas/verification-reuse-measurement.schema.json +370 -0
  1189. package/dist/schemas/verification-reuse-plan.schema.json +239 -0
  1190. package/dist/schemas/verification-scoped-reuse.schema.json +484 -0
  1191. package/dist/schemas/work-package-plan-validation-context.schema.json +244 -0
  1192. package/dist/schemas/work-package-plan.schema.json +495 -0
  1193. package/dist/scripts/adapter-cross-conformance.mjs +431 -0
  1194. package/dist/scripts/adapter-runtime-bundle.mjs +452 -0
  1195. package/dist/scripts/adapter-runtime-event.mjs +233 -0
  1196. package/dist/scripts/adapter-runtime-inventory.mjs +69 -0
  1197. package/dist/scripts/adapter-runtime-smoke.mjs +372 -0
  1198. package/dist/scripts/ai-ledger-refresh.mjs +387 -0
  1199. package/dist/scripts/ai-metrics-record.mjs +1318 -0
  1200. package/dist/scripts/ai-metrics-summarize.mjs +1085 -0
  1201. package/dist/scripts/ask-benchmark-admission-decision.mjs +675 -0
  1202. package/dist/scripts/ask-benchmark-atomic-publication.mjs +85 -0
  1203. package/dist/scripts/ask-benchmark-calibration-source.mjs +49 -0
  1204. package/dist/scripts/ask-benchmark-command-evidence.mjs +1048 -0
  1205. package/dist/scripts/ask-benchmark-design-admission.mjs +524 -0
  1206. package/dist/scripts/ask-benchmark-design-review.mjs +387 -0
  1207. package/dist/scripts/ask-benchmark-duplicate-key-json.mjs +133 -0
  1208. package/dist/scripts/ask-benchmark-evaluator-boundary.mjs +3869 -0
  1209. package/dist/scripts/ask-benchmark-execution.mjs +2442 -0
  1210. package/dist/scripts/ask-benchmark-materialize.mjs +582 -0
  1211. package/dist/scripts/ask-benchmark-mn-build-option-update.mjs +506 -0
  1212. package/dist/scripts/ask-benchmark-mn-client-probe-v2.mjs +185 -0
  1213. package/dist/scripts/ask-benchmark-mn-focused-probe-v2.mjs +318 -0
  1214. package/dist/scripts/ask-benchmark-mn-focused-regression-test.mjs +168 -0
  1215. package/dist/scripts/ask-benchmark-mp-ci-evidence-gap.mjs +167 -0
  1216. package/dist/scripts/ask-benchmark-normalized-results.mjs +884 -0
  1217. package/dist/scripts/ask-benchmark-pf-performance-probe.mjs +342 -0
  1218. package/dist/scripts/ask-benchmark-pf-performance-source.mjs +248 -0
  1219. package/dist/scripts/ask-benchmark-plan.mjs +284 -0
  1220. package/dist/scripts/ask-benchmark-portfolio-aggregate-result-v2.mjs +929 -0
  1221. package/dist/scripts/ask-benchmark-portfolio-aggregate-result.mjs +354 -0
  1222. package/dist/scripts/ask-benchmark-portfolio-catalog.mjs +378 -0
  1223. package/dist/scripts/ask-benchmark-portfolio-consumer-report.mjs +193 -0
  1224. package/dist/scripts/ask-benchmark-portfolio-directional-outcome-report.mjs +274 -0
  1225. package/dist/scripts/ask-benchmark-portfolio-evolution-evidence.mjs +169 -0
  1226. package/dist/scripts/ask-benchmark-portfolio-high-impact-sensitivity.mjs +209 -0
  1227. package/dist/scripts/ask-benchmark-portfolio-legacy-calibration-migration.mjs +383 -0
  1228. package/dist/scripts/ask-benchmark-portfolio-mechanism-scorecard.mjs +382 -0
  1229. package/dist/scripts/ask-benchmark-portfolio-paired-comparison-report.mjs +460 -0
  1230. package/dist/scripts/ask-benchmark-portfolio-policy.mjs +1809 -0
  1231. package/dist/scripts/ask-benchmark-portfolio-repetition-report.mjs +314 -0
  1232. package/dist/scripts/ask-benchmark-portfolio-result-set.mjs +664 -0
  1233. package/dist/scripts/ask-benchmark-portfolio-score.mjs +541 -0
  1234. package/dist/scripts/ask-benchmark-private-evaluator-runner.mjs +615 -0
  1235. package/dist/scripts/ask-benchmark-prompt-successor-bridge.mjs +234 -0
  1236. package/dist/scripts/ask-benchmark-prompt-successor-check.mjs +68 -0
  1237. package/dist/scripts/ask-benchmark-prompt-successor-collection.mjs +113 -0
  1238. package/dist/scripts/ask-benchmark-prompt-successor-control.mjs +115 -0
  1239. package/dist/scripts/ask-benchmark-prompt-successor-delivery.mjs +270 -0
  1240. package/dist/scripts/ask-benchmark-prompt-successor-measured-authority.mjs +249 -0
  1241. package/dist/scripts/ask-benchmark-prompt-successor-measured-execution.mjs +733 -0
  1242. package/dist/scripts/ask-benchmark-prompt-successor-native.mjs +137 -0
  1243. package/dist/scripts/ask-benchmark-prompt-successor-provenance.mjs +191 -0
  1244. package/dist/scripts/ask-benchmark-prompt-successor-report.mjs +256 -0
  1245. package/dist/scripts/ask-benchmark-prompt-successor-repository.mjs +107 -0
  1246. package/dist/scripts/ask-benchmark-prompt-successor-scoring-inputs.mjs +218 -0
  1247. package/dist/scripts/ask-benchmark-prompt-successor-usage.mjs +174 -0
  1248. package/dist/scripts/ask-benchmark-prompt-successor.mjs +263 -0
  1249. package/dist/scripts/ask-benchmark-prompt-v2.mjs +1332 -0
  1250. package/dist/scripts/ask-benchmark-runtime-observation.mjs +235 -0
  1251. package/dist/scripts/ask-benchmark-schema.mjs +29 -0
  1252. package/dist/scripts/ask-benchmark-scoring-contract.mjs +802 -0
  1253. package/dist/scripts/ask-benchmark-selection.mjs +387 -0
  1254. package/dist/scripts/ask-benchmark-source-session.mjs +70 -0
  1255. package/dist/scripts/ask-benchmark-stable-file.mjs +89 -0
  1256. package/dist/scripts/ask-benchmark-terminal-candidate.mjs +432 -0
  1257. package/dist/scripts/ask-benchmark-terminal-workspace.mjs +427 -0
  1258. package/dist/scripts/ask-comparison-conditions.mjs +8 -0
  1259. package/dist/scripts/ask-core-bundle-product.mjs +93 -0
  1260. package/dist/scripts/ask-core-capabilities.mjs +40 -0
  1261. package/dist/scripts/ask-core-capture-producer.mjs +298 -0
  1262. package/dist/scripts/ask-core-codex-native-contract.mjs +61 -0
  1263. package/dist/scripts/ask-core-connected-normalizer.mjs +173 -0
  1264. package/dist/scripts/ask-core-controller-attribution.mjs +74 -0
  1265. package/dist/scripts/ask-core-controller-records.mjs +49 -0
  1266. package/dist/scripts/ask-core-grading-authority.mjs +161 -0
  1267. package/dist/scripts/ask-core-native-authority.mjs +42 -0
  1268. package/dist/scripts/ask-core-native-compatibility-provenance.mjs +77 -0
  1269. package/dist/scripts/ask-core-native-connection.mjs +76 -0
  1270. package/dist/scripts/ask-core-native-files.mjs +16 -0
  1271. package/dist/scripts/ask-core-native-preparation.mjs +61 -0
  1272. package/dist/scripts/ask-core-native-receiver.mjs +91 -0
  1273. package/dist/scripts/ask-core-producer-scope.mjs +38 -0
  1274. package/dist/scripts/ask-core-runner-contract.mjs +65 -0
  1275. package/dist/scripts/ask-core-scored-replay.mjs +12 -0
  1276. package/dist/scripts/ask-core-task-admission.mjs +53 -0
  1277. package/dist/scripts/ask-doctor.mjs +1037 -0
  1278. package/dist/scripts/ask-local-codex-boundaries.mjs +141 -0
  1279. package/dist/scripts/ask-local-codex-time-budget.mjs +119 -0
  1280. package/dist/scripts/ask-local-codex-time-policy.mjs +4 -0
  1281. package/dist/scripts/ask-local-codex-timing.mjs +46 -0
  1282. package/dist/scripts/ask-local-codex.mjs +653 -0
  1283. package/dist/scripts/ask-local-eval.mjs +101 -0
  1284. package/dist/scripts/ask-package-cli.mjs +64 -0
  1285. package/dist/scripts/ask-package-environment.mjs +10 -0
  1286. package/dist/scripts/ask-package-loop-prepare.mjs +87 -0
  1287. package/dist/scripts/ask-package-workspace.mjs +55 -0
  1288. package/dist/scripts/ask-personal-evolution-alignment.mjs +126 -0
  1289. package/dist/scripts/ask-personal-evolution-codex-generation.mjs +224 -0
  1290. package/dist/scripts/ask-personal-evolution-driver.mjs +139 -0
  1291. package/dist/scripts/ask-personal-evolution-generation-connector.mjs +316 -0
  1292. package/dist/scripts/ask-personal-evolution-generation.mjs +122 -0
  1293. package/dist/scripts/ask-personal-evolution-observation.mjs +71 -0
  1294. package/dist/scripts/ask-personal-evolution-primary-pair.mjs +474 -0
  1295. package/dist/scripts/ask-personal-evolution-saved-results.mjs +112 -0
  1296. package/dist/scripts/ask-personal-evolution-source-reviewer.mjs +139 -0
  1297. package/dist/scripts/ask-personal-evolution-unattended.mjs +206 -0
  1298. package/dist/scripts/ask-personal-evolution.mjs +142 -0
  1299. package/dist/scripts/ask-personal-prompt-adoption-materialization.mjs +126 -0
  1300. package/dist/scripts/ask-personal-prompt-materialization.mjs +104 -0
  1301. package/dist/scripts/ask-personal-prompt-repetition-binding.mjs +16 -0
  1302. package/dist/scripts/ask-personal-prompt-repetition-evaluation.mjs +163 -0
  1303. package/dist/scripts/ask-personal-prompt-repetition-statistics.mjs +53 -0
  1304. package/dist/scripts/ask-personal-prompt-target-lock.mjs +34 -0
  1305. package/dist/scripts/ask-pragmatic-evaluation-report.mjs +120 -0
  1306. package/dist/scripts/ask-preparation-git-diagnostic.mjs +14 -0
  1307. package/dist/scripts/ask-primary-client-focused-controller.mjs +119 -0
  1308. package/dist/scripts/ask-primary-discovery-grammar-v9.mjs +105 -0
  1309. package/dist/scripts/ask-primary-engineering-safety.mjs +147 -0
  1310. package/dist/scripts/ask-primary-evaluation-batch.mjs +318 -0
  1311. package/dist/scripts/ask-primary-evaluation-grading.mjs +451 -0
  1312. package/dist/scripts/ask-primary-evaluation-private-grading.mjs +270 -0
  1313. package/dist/scripts/ask-primary-evaluation-producer.mjs +549 -0
  1314. package/dist/scripts/ask-primary-evaluation-profile.mjs +29 -0
  1315. package/dist/scripts/ask-primary-evaluation-scope.mjs +531 -0
  1316. package/dist/scripts/ask-primary-evaluation-start.mjs +34 -0
  1317. package/dist/scripts/ask-primary-execution-input.mjs +299 -0
  1318. package/dist/scripts/ask-primary-fixture-recipe.mjs +102 -0
  1319. package/dist/scripts/ask-primary-fixture-registry.mjs +3 -0
  1320. package/dist/scripts/ask-primary-metadata-task-contract.mjs +31 -0
  1321. package/dist/scripts/ask-primary-native-probe-lifetime.mjs +233 -0
  1322. package/dist/scripts/ask-primary-public-catalog-registry.mjs +13 -0
  1323. package/dist/scripts/ask-primary-runtime-collection-support.mjs +5 -0
  1324. package/dist/scripts/ask-primary-runtime-lineage.mjs +420 -0
  1325. package/dist/scripts/ask-primary-runtime-v10.mjs +59 -0
  1326. package/dist/scripts/ask-primary-scoring-version.mjs +269 -0
  1327. package/dist/scripts/ask-primary-unsafe-action-contract.mjs +86 -0
  1328. package/dist/scripts/ask-review-target-requirement.mjs +118 -0
  1329. package/dist/scripts/ask-rule-batch-bundle.mjs +191 -0
  1330. package/dist/scripts/ask-sensors.mjs +978 -0
  1331. package/dist/scripts/ask-setup-apply-state.mjs +359 -0
  1332. package/dist/scripts/ask-setup-apply.mjs +257 -0
  1333. package/dist/scripts/ask-setup-diagnostics.mjs +45 -0
  1334. package/dist/scripts/ask-setup-doctor-inputs.mjs +78 -0
  1335. package/dist/scripts/ask-setup-git.mjs +130 -0
  1336. package/dist/scripts/ask-setup-inputs.mjs +181 -0
  1337. package/dist/scripts/ask-setup.mjs +762 -0
  1338. package/dist/scripts/ask-shared.mjs +627 -0
  1339. package/dist/scripts/ask-synthetic-json-pilot.mjs +561 -0
  1340. package/dist/scripts/ask-user-comparison-logs.mjs +74 -0
  1341. package/dist/scripts/ask-user-comparison-prepare.mjs +846 -0
  1342. package/dist/scripts/ask-user-comparison-state.mjs +329 -0
  1343. package/dist/scripts/ask-user-comparison-test-reporter.mjs +22 -0
  1344. package/dist/scripts/ask-user-comparison.mjs +1087 -0
  1345. package/dist/scripts/asset-registry.mjs +1002 -0
  1346. package/dist/scripts/claim-evidence-status.mjs +162 -0
  1347. package/dist/scripts/claude-fixed-entry-profile.mjs +218 -0
  1348. package/dist/scripts/claude-native-runtime.mjs +108 -0
  1349. package/dist/scripts/claude-plugin-fixed-entries.mjs +53 -0
  1350. package/dist/scripts/codex-exec-runner.mjs +1479 -0
  1351. package/dist/scripts/codex-metrics-collector.mjs +188 -0
  1352. package/dist/scripts/codex-risk-approval.mjs +477 -0
  1353. package/dist/scripts/codex-risk-workspace.mjs +585 -0
  1354. package/dist/scripts/codex-runtime-profile.mjs +153 -0
  1355. package/dist/scripts/content-addressed-store.mjs +379 -0
  1356. package/dist/scripts/environment-evaluation.mjs +69 -0
  1357. package/dist/scripts/environment-evolution-binding.mjs +66 -0
  1358. package/dist/scripts/environment-saved-results.mjs +122 -0
  1359. package/dist/scripts/environment-target-owner.mjs +103 -0
  1360. package/dist/scripts/environment-target.mjs +260 -0
  1361. package/dist/scripts/epic-admission-work-package-plan.mjs +2009 -0
  1362. package/dist/scripts/evaluation-task-catalog.mjs +268 -0
  1363. package/dist/scripts/evaluation-task-inputs.mjs +166 -0
  1364. package/dist/scripts/evaluation-task-scoring.mjs +237 -0
  1365. package/dist/scripts/evolution-loop.mjs +1773 -0
  1366. package/dist/scripts/execution-envelope.mjs +293 -0
  1367. package/dist/scripts/finding-intake.mjs +114 -0
  1368. package/dist/scripts/fixed-entry-profile.mjs +239 -0
  1369. package/dist/scripts/fixtures/ask-core-receiver-child.mjs +35 -0
  1370. package/dist/scripts/fixtures/instruction-loop/fake-codex.py +6 -0
  1371. package/dist/scripts/generate-ask-core-bundle.mjs +41 -0
  1372. package/dist/scripts/generate-ask-core-grading-schemas.mjs +9 -0
  1373. package/dist/scripts/generate-ask-primary-grading-schemas.mjs +226 -0
  1374. package/dist/scripts/install-ask-core-bundle.mjs +117 -0
  1375. package/dist/scripts/install-claude-adapter.mjs +1444 -0
  1376. package/dist/scripts/install-codex-adapter.mjs +1578 -0
  1377. package/dist/scripts/install-kernel.mjs +408 -0
  1378. package/dist/scripts/installer-lifecycle.mjs +698 -0
  1379. package/dist/scripts/instruction-asset-package.mjs +252 -0
  1380. package/dist/scripts/instruction-composition.mjs +62 -0
  1381. package/dist/scripts/instruction-environment-authoring.mjs +265 -0
  1382. package/dist/scripts/instruction-environment-cli.mjs +129 -0
  1383. package/dist/scripts/instruction-environment-compiler.mjs +92 -0
  1384. package/dist/scripts/instruction-environment.mjs +148 -0
  1385. package/dist/scripts/instruction-evaluation-recovery.mjs +86 -0
  1386. package/dist/scripts/instruction-loop-artifact.mjs +6 -0
  1387. package/dist/scripts/instruction-loop-assets.mjs +67 -0
  1388. package/dist/scripts/instruction-loop-case-selection.mjs +31 -0
  1389. package/dist/scripts/instruction-loop-command-runtime.mjs +108 -0
  1390. package/dist/scripts/instruction-loop-component-candidate.mjs +116 -0
  1391. package/dist/scripts/instruction-loop-component-continuation.mjs +61 -0
  1392. package/dist/scripts/instruction-loop-component-runtime.mjs +151 -0
  1393. package/dist/scripts/instruction-loop-environment-approval.mjs +51 -0
  1394. package/dist/scripts/instruction-loop-failed-preparation.mjs +243 -0
  1395. package/dist/scripts/instruction-loop-feedback.mjs +226 -0
  1396. package/dist/scripts/instruction-loop-fixed-scoring.mjs +39 -0
  1397. package/dist/scripts/instruction-loop-fixed-scoring.py +98 -0
  1398. package/dist/scripts/instruction-loop-full-candidate.mjs +351 -0
  1399. package/dist/scripts/instruction-loop-host-authoring.mjs +66 -0
  1400. package/dist/scripts/instruction-loop-host-scoring.mjs +110 -0
  1401. package/dist/scripts/instruction-loop-measured-adoption.mjs +106 -0
  1402. package/dist/scripts/instruction-loop-native-configuration.mjs +150 -0
  1403. package/dist/scripts/instruction-loop-native-host.mjs +229 -0
  1404. package/dist/scripts/instruction-loop-native-prepare.py +107 -0
  1405. package/dist/scripts/instruction-loop-native-public-inputs.mjs +52 -0
  1406. package/dist/scripts/instruction-loop-native-worker.mjs +10 -0
  1407. package/dist/scripts/instruction-loop-normal-owner-worker.mjs +97 -0
  1408. package/dist/scripts/instruction-loop-operation.mjs +108 -0
  1409. package/dist/scripts/instruction-loop-practical-runtime.mjs +188 -0
  1410. package/dist/scripts/instruction-loop-provider-policy.mjs +23 -0
  1411. package/dist/scripts/instruction-loop-reference-evidence.mjs +95 -0
  1412. package/dist/scripts/instruction-loop-reference-preparation.mjs +138 -0
  1413. package/dist/scripts/instruction-loop-reference-report.mjs +84 -0
  1414. package/dist/scripts/instruction-loop-reference-scoring-runtime.mjs +48 -0
  1415. package/dist/scripts/instruction-loop-result-disposition.mjs +26 -0
  1416. package/dist/scripts/instruction-loop-retained-authoring.mjs +125 -0
  1417. package/dist/scripts/instruction-loop-runtime.mjs +8 -0
  1418. package/dist/scripts/instruction-loop-source-application.mjs +106 -0
  1419. package/dist/scripts/instruction-loop-source-binding.mjs +37 -0
  1420. package/dist/scripts/instruction-projection-paths.mjs +16 -0
  1421. package/dist/scripts/instruction-run-journal.mjs +45 -0
  1422. package/dist/scripts/instruction-source-version.mjs +104 -0
  1423. package/dist/scripts/json-schema-validation.mjs +419 -0
  1424. package/dist/scripts/kernel-principles-candidate-v2.mjs +71 -0
  1425. package/dist/scripts/kernel-principles-v2-catalog24.mjs +86 -0
  1426. package/dist/scripts/kernel-principles-v2.mjs +122 -0
  1427. package/dist/scripts/kernel-principles.mjs +81 -0
  1428. package/dist/scripts/local-codex-probe-worker.mjs +143 -0
  1429. package/dist/scripts/observability-paths.mjs +31 -0
  1430. package/dist/scripts/portfolio-manager.mjs +1870 -0
  1431. package/dist/scripts/practical-challenge-evaluation.mjs +194 -0
  1432. package/dist/scripts/practical-challenge-worker.mjs +126 -0
  1433. package/dist/scripts/practical-codex-adapter.mjs +107 -0
  1434. package/dist/scripts/practical-evaluation-assessor.mjs +92 -0
  1435. package/dist/scripts/practical-evaluation-cli.mjs +134 -0
  1436. package/dist/scripts/practical-evaluation-runner.mjs +261 -0
  1437. package/dist/scripts/practical-evaluation-worker.mjs +193 -0
  1438. package/dist/scripts/practical-grade-report-revision.mjs +12 -0
  1439. package/dist/scripts/practical-grade-source-binding.mjs +53 -0
  1440. package/dist/scripts/practical-grade-supplement.mjs +457 -0
  1441. package/dist/scripts/practical-host-reporting-policy.mjs +85 -0
  1442. package/dist/scripts/practical-initialization-clearance.mjs +143 -0
  1443. package/dist/scripts/practical-initialization-recovery-cli.mjs +44 -0
  1444. package/dist/scripts/practical-isolated-grade-continuation-cli.mjs +19 -0
  1445. package/dist/scripts/practical-isolated-grade-continuation.mjs +179 -0
  1446. package/dist/scripts/practical-primary-grading.mjs +130 -0
  1447. package/dist/scripts/practical-quality-observation.mjs +61 -0
  1448. package/dist/scripts/practical-reporting-grader.mjs +160 -0
  1449. package/dist/scripts/practical-reporting-policy.mjs +126 -0
  1450. package/dist/scripts/practical-retained-grade-report-cli.mjs +19 -0
  1451. package/dist/scripts/practical-retained-grade-report.mjs +80 -0
  1452. package/dist/scripts/practical-saved-command-observation.mjs +159 -0
  1453. package/dist/scripts/practical-session-usage.mjs +73 -0
  1454. package/dist/scripts/prepare-historical-full-test-root.mjs +155 -0
  1455. package/dist/scripts/prompt-v2-historical-renderer.mjs +61 -0
  1456. package/dist/scripts/prompt-v2-preregistration-samples.mjs +1410 -0
  1457. package/dist/scripts/release-evidence-gate.mjs +421 -0
  1458. package/dist/scripts/retained-instruction-comparison.mjs +154 -0
  1459. package/dist/scripts/retained-instruction-layout.mjs +103 -0
  1460. package/dist/scripts/review-route-contract.mjs +135 -0
  1461. package/dist/scripts/review-rule-lifecycle.mjs +171 -0
  1462. package/dist/scripts/saved-instruction-pair-evidence.mjs +37 -0
  1463. package/dist/scripts/skill-assets.mjs +48 -0
  1464. package/dist/scripts/skill-effectiveness-outcome.mjs +501 -0
  1465. package/dist/scripts/skill-usage-evidence.mjs +80 -0
  1466. package/dist/scripts/supervised-instruction-loop-cli.mjs +180 -0
  1467. package/dist/scripts/supervised-instruction-loop.mjs +392 -0
  1468. package/dist/scripts/verification-decision-core.mjs +248 -0
  1469. package/dist/scripts/verification-evidence.mjs +754 -0
  1470. package/dist/scripts/verification-host-provider.mjs +61 -0
  1471. package/dist/scripts/verification-proof-policy.mjs +318 -0
  1472. package/dist/scripts/verification-reuse-completion.mjs +338 -0
  1473. package/dist/scripts/verification-review-dispatch.mjs +144 -0
  1474. package/dist/scripts/verification-scoped-reuse.mjs +993 -0
  1475. package/dist/skills/adr-review/SKILL.md +108 -0
  1476. package/dist/skills/angular-implementation-architecture/SKILL.md +187 -0
  1477. package/dist/skills/application-boundary-architecture/SKILL.md +412 -0
  1478. package/dist/skills/architecture-decision-memory/SKILL.md +102 -0
  1479. package/dist/skills/code-visualization/SKILL.md +24 -0
  1480. package/dist/skills/code-visualization/references/examples/pr497.json +328 -0
  1481. package/dist/skills/code-visualization/references/examples/skill-assets.json +257 -0
  1482. package/dist/skills/code-visualization/references/guide-input.md +48 -0
  1483. package/dist/skills/code-visualization/references/render-guide.mjs +238 -0
  1484. package/dist/skills/code-visualization/references/scene-model.mjs +96 -0
  1485. package/dist/skills/code-visualization/references/visual-player.js +346 -0
  1486. package/dist/skills/code-visualization/references/visual-surface.css +15 -0
  1487. package/dist/skills/controlled-implementation/SKILL.md +195 -0
  1488. package/dist/skills/documentation-knowledge-compiler/SKILL.md +100 -0
  1489. package/dist/skills/domain-rule-ledger/SKILL.md +109 -0
  1490. package/dist/skills/doubt-driven-development/SKILL.md +101 -0
  1491. package/dist/skills/engineering-capability-evaluation/SKILL.md +103 -0
  1492. package/dist/skills/engineering-pattern-ledger/SKILL.md +110 -0
  1493. package/dist/skills/evidence-ledger/SKILL.md +96 -0
  1494. package/dist/skills/grill-design/SKILL.md +92 -0
  1495. package/dist/skills/grill-with-docs/SKILL.md +89 -0
  1496. package/dist/skills/handoff-generation/SKILL.md +99 -0
  1497. package/dist/skills/implementation-context-generation/SKILL.md +185 -0
  1498. package/dist/skills/improvement-ledger/SKILL.md +206 -0
  1499. package/dist/skills/mr-readme-generation/SKILL.md +201 -0
  1500. package/dist/skills/next-best-change-finder/SKILL.md +112 -0
  1501. package/dist/skills/operating-mode-router/SKILL.md +141 -0
  1502. package/dist/skills/planning-with-files/SKILL.md +81 -0
  1503. package/dist/skills/project-adoption-pack-generation/SKILL.md +113 -0
  1504. package/dist/skills/refactor-implementation/SKILL.md +142 -0
  1505. package/dist/skills/release-readiness-gate/SKILL.md +161 -0
  1506. package/dist/skills/repository-orientation/SKILL.md +94 -0
  1507. package/dist/skills/requirement-grill/SKILL.md +137 -0
  1508. package/dist/skills/review-adversarial-risk/SKILL.md +117 -0
  1509. package/dist/skills/review-ai-quality/SKILL.md +127 -0
  1510. package/dist/skills/review-architecture-impact/SKILL.md +144 -0
  1511. package/dist/skills/review-automated-gate/SKILL.md +84 -0
  1512. package/dist/skills/review-code-health/SKILL.md +140 -0
  1513. package/dist/skills/review-context-generation/SKILL.md +175 -0
  1514. package/dist/skills/review-domain-impact/SKILL.md +182 -0
  1515. package/dist/skills/review-final-merge-gate/SKILL.md +120 -0
  1516. package/dist/skills/review-finding-compiler/SKILL.md +96 -0
  1517. package/dist/skills/review-output-quality/SKILL.md +167 -0
  1518. package/dist/skills/review-router/SKILL.md +161 -0
  1519. package/dist/skills/review-to-rule-compiler/SKILL.md +91 -0
  1520. package/dist/skills/risk-gate/SKILL.md +94 -0
  1521. package/dist/skills/scope-control/SKILL.md +97 -0
  1522. package/dist/skills/skill-adoption-metrics/SKILL.md +210 -0
  1523. package/dist/skills/skill-effectiveness-evaluation/SKILL.md +248 -0
  1524. package/dist/skills/skill-effectiveness-evaluation/references/practical-evaluation.md +204 -0
  1525. package/dist/skills/skill-router/SKILL.md +205 -0
  1526. package/dist/skills/spec-driven-development/SKILL.md +136 -0
  1527. package/dist/skills/spec-driven-development/references/context-retrieval.md +40 -0
  1528. package/dist/skills/spec-driven-development/references/decision-led-test-strategy.md +46 -0
  1529. package/dist/skills/spec-driven-development/references/examples/domain-context.md +20 -0
  1530. package/dist/skills/spec-driven-development/references/examples/javascript/reservation.cases.mjs +26 -0
  1531. package/dist/skills/spec-driven-development/references/examples/javascript/reservation.mjs +11 -0
  1532. package/dist/skills/spec-driven-development/references/examples/javascript/reservation.test.mjs +65 -0
  1533. package/dist/skills/spec-driven-development/references/examples/javascript/scenario-observer.mjs +47 -0
  1534. package/dist/skills/spec-driven-development/references/examples/javascript/scenario-player.html +109 -0
  1535. package/dist/skills/spec-driven-development/references/examples/javascript/scenario-review.mjs +166 -0
  1536. package/dist/skills/spec-driven-development/references/examples/python/reservation.py +10 -0
  1537. package/dist/skills/spec-driven-development/references/examples/python/test_reservation.py +40 -0
  1538. package/dist/skills/spec-driven-development/references/examples/quote-reissue/confirmed-quote.mjs +16 -0
  1539. package/dist/skills/spec-driven-development/references/examples/quote-reissue/confirmed-quote.test.mjs +19 -0
  1540. package/dist/skills/spec-driven-development/references/examples/quote-reissue/decision-record.md +25 -0
  1541. package/dist/skills/spec-driven-development/references/examples/quote-reissue/quote-reissue.mjs +28 -0
  1542. package/dist/skills/spec-driven-development/references/examples/quote-reissue/quote-reissue.test.mjs +69 -0
  1543. package/dist/skills/spec-driven-development/references/executable-spec-workflow.md +52 -0
  1544. package/dist/skills/spec-driven-development/references/project-templates.md +92 -0
  1545. package/dist/skills/spec-driven-development/references/quote-reissue-decision.md +35 -0
  1546. package/dist/skills/spec-driven-development/references/scenario-visual-review.md +92 -0
  1547. package/dist/skills/spec-driven-development/references/spec-index.md +51 -0
  1548. package/dist/skills/spec-driven-development/references/spec-writing-conventions.md +52 -0
  1549. package/dist/skills/spec-driven-development/references/verification-selection.md +44 -0
  1550. package/dist/skills/test-first-verification/SKILL.md +170 -0
  1551. package/dist/skills/ui-ux-design/SKILL.md +98 -0
  1552. package/dist/skills/ui-ux-design/references/anti-patterns.md +51 -0
  1553. package/dist/skills/ui-ux-design/references/decision-patterns.md +213 -0
  1554. package/dist/skills/ui-ux-design/references/principles.md +55 -0
  1555. package/dist/skills/ui-ux-design/references/ui-capability-contract.md +70 -0
  1556. package/dist/skills/ui-ux-design/references/working-state.md +52 -0
  1557. package/dist/skills/verification-pattern-ledger/SKILL.md +96 -0
  1558. package/dist/skills/work-package-compiler/SKILL.md +129 -0
  1559. package/package.json +36 -4
@@ -0,0 +1,3869 @@
1
+ import { primaryEvaluatorExecutionControl } from './ask-primary-evaluation-scope.mjs';
2
+ import {primaryClientFocusedProbeProfile,preparePrimaryClientFocusedProbe,preparePrimaryClientFocusedProbeForTest} from './ask-primary-client-focused-controller.mjs';
3
+ import * as unsafeActionContract from './ask-primary-unsafe-action-contract.mjs';
4
+ import { PF_PERFORMANCE_PROBE_VERSION, pfPerformancePrivateProbeRoute, runQualifiedPfPerformancePrivateProbe, runQualifiedPfPerformancePrivateProbeAsync, inspectPfPerformancePrivateAudit } from './ask-benchmark-pf-performance-probe.mjs';
5
+ import { createHash } from "node:crypto";
6
+ import { materializeVerifiedRuntimeObservationEvidence, verifyRuntimeObservationEvidenceAuthority, verifySealedRuntimeObservationEvidence } from './ask-benchmark-runtime-observation.mjs';
7
+ import { execFileSync, spawnSync } from "node:child_process";
8
+ import {
9
+ chmodSync,
10
+ closeSync,
11
+ cpSync,
12
+ existsSync,
13
+ fstatSync,
14
+ fsyncSync,
15
+ lstatSync,
16
+ mkdtempSync,
17
+ mkdirSync,
18
+ openSync,
19
+ readFileSync,
20
+ readSync,
21
+ readdirSync,
22
+ rmSync,
23
+ realpathSync,
24
+ writeFileSync,
25
+ writeSync,
26
+ } from "node:fs";
27
+ import { constants as fsConstants } from "node:fs";
28
+ import { basename, dirname, extname, posix, relative, resolve, sep, win32 } from "node:path";
29
+ import { tmpdir } from "node:os";
30
+ import { assertBenchmarkSchemaInstance } from "./ask-benchmark-schema.mjs";
31
+ import { withCoreGradingAuthority, assertCoreGradingVerified } from "./ask-core-grading-authority.mjs";
32
+ import { readStableJsonFile } from "./ask-benchmark-duplicate-key-json.mjs";
33
+ import { readStableFile } from "./ask-benchmark-stable-file.mjs";
34
+ import { PRIMARY_PROCESSING_AUTHORITY_PATHS } from './ask-primary-scoring-version.mjs';
35
+ import { computePortfolioCatalogDigest } from "./ask-benchmark-portfolio-catalog.mjs";
36
+ import { canonicalDigest, stableCanonicalJson } from "./ask-benchmark-materialize.mjs";
37
+ import { verifyNormalizedPortfolioResults } from "./ask-benchmark-normalized-results.mjs";
38
+ import { materializeVerifiedTerminalCandidate } from "./ask-benchmark-terminal-candidate.mjs";
39
+ import { compareTerminalWorkspacePaths, deriveTerminalCandidateInventory, terminalWorkspaceInventoryDigest } from "./ask-benchmark-terminal-workspace.mjs";
40
+ import { validatePortfolioPolicyArtifacts } from "./ask-benchmark-portfolio-policy.mjs";
41
+ import { computeVerificationCommandContractDigest } from "./ask-benchmark-command-evidence.mjs";
42
+ import { CALIBRATION_INPUT_MANIFEST_PATH, CALIBRATION_INPUT_MANIFEST_SHA256, CALIBRATION_SOURCE_BINDINGS, calibrationSourceIdForFixture } from "./ask-benchmark-calibration-source.mjs";
43
+ import {
44
+ computeFinalAdmissionRecordDigest,
45
+ resolveRequirementAdmissionBindingDigest,
46
+ computeOutputContractDigest,
47
+ computePolicyManifestDigest,
48
+ computeRequirementRecordDigest,
49
+ computeRequirementSetDigest,
50
+ computeScoringInputFreezeManifestDigest,
51
+ computeScoringPolicyDigest,
52
+ BINARY_SCOPE_VERIFICATION_PROFILE_NAME,
53
+ REQUIREMENT_SCOPE_VERIFICATION_PROFILE_NAME,
54
+ deriveRequirementScopeVerificationOutcome,
55
+ deriveEffectiveVerificationEvidenceReferences,
56
+ deriveEffectiveVerificationEvidenceState,
57
+ FINAL_ADMISSION_RECORD_SCHEMA_PATH,
58
+ SCORING_INPUT_FREEZE_MANIFEST_SCHEMA_PATH,
59
+ validateResultProfile,
60
+ validateFrozenFinalAdmissionRecordContract,
61
+ validateEvaluatorAuthorityBindings,
62
+ validateRequirementRecordContract,
63
+ validateRequirementResultObservations,
64
+ validateScoringContractSchemaParity,
65
+ } from "./ask-benchmark-scoring-contract.mjs";
66
+
67
+ const AUTHORITY_SPAWN_SYNC = spawnSync;
68
+ const AUTHORITY_JSON_STRINGIFY = JSON.stringify;
69
+ const AUTHORITY_NODE_EXECUTABLE = process.execPath;
70
+ const ORIGINAL_EXECUTION_AUTHORITIES = new WeakMap();
71
+ const PRODUCTION_EXECUTION_AUTHORITIES = new WeakMap();
72
+ const VERIFIED_FINAL_OUTPUT_EVIDENCE_PATH = "verified-agent-final.json";
73
+ const MAX_VERIFIED_FINAL_OUTPUT_BYTES = 1024 * 1024;
74
+
75
+ export const EVALUATOR_REFERENCE_SCHEMA_PATH = "benchmarks/schemas/evaluator-reference.schema.json";
76
+ export const PRIVATE_EVALUATOR_BUNDLE_SCHEMA_PATH = "benchmarks/schemas/private-evaluator-bundle.schema.json";
77
+ export const PRIVATE_EVALUATOR_INDEPENDENCE_SCHEMA_PATH = "benchmarks/schemas/private-evaluator-independence-statement.schema.json";
78
+ export const PRIVATE_EVALUATOR_FRAGMENT_SCHEMA_PATH = "benchmarks/schemas/private-evaluator-fragment.schema.json";
79
+ export const PRIVATE_EVALUATION_RECORD_SCHEMA_PATH = "benchmarks/schemas/private-evaluation-record.schema.json";
80
+ export const REPOSITORY_DIFF_ARTIFACT_SCHEMA_PATH = "benchmarks/schemas/repository-diff-artifact.schema.json";
81
+ export const ORIGINAL_WORKSPACE_AUTHORITY_SCHEMA_PATH = "benchmarks/schemas/original-workspace-authority.schema.json";
82
+ export const EVALUATION_INPUT_FAILURE_ARTIFACT_SCHEMA_PATH = "benchmarks/schemas/evaluation-input-failure-artifact.schema.json";
83
+ export const EVALUATOR_CHECK_ARTIFACT_SCHEMA_PATH = "benchmarks/schemas/evaluator-check-artifact.schema.json";
84
+ export const EVALUATOR_RESULT_SCHEMA_PATH = "benchmarks/schemas/evaluator-result-envelope.schema.json";
85
+ export const EVALUATOR_DEPENDENCY_ENTRY_PATHS = Object.freeze([
86
+ "scripts/ask-benchmark-scoring-contract.mjs",
87
+ "scripts/ask-benchmark-materialize.mjs",
88
+ "scripts/ask-benchmark-normalized-results.mjs",
89
+ "scripts/ask-benchmark-evaluator-boundary.mjs",
90
+ "scripts/ask-benchmark-private-evaluator-runner.mjs",
91
+ ]);
92
+ export const EVALUATOR_EAGER_AUTHORITY_READS = Object.freeze([
93
+ Object.freeze({ path: "products/ask-core-bundle/capabilities.json", reader: "scripts/ask-core-capabilities.mjs" }),
94
+ Object.freeze({ path: "schemas/review-signal-gate-map.json", reader: "scripts/ask-core-capabilities.mjs" }),
95
+ Object.freeze({ path: "schemas/claim-evidence-status.schema.json", reader: "scripts/claim-evidence-status.mjs" }),
96
+ Object.freeze({ path: "schemas/compact-profile-control-map.json", reader: "scripts/fixed-entry-profile.mjs" }),
97
+ Object.freeze({ path: "schemas/fixed-entry-profile-registry.json", reader: "scripts/fixed-entry-profile.mjs" }),
98
+ Object.freeze({ path: "schemas/verification-proof-policy.schema.json", reader: "scripts/verification-proof-policy.mjs" }),
99
+ Object.freeze({ path: "benchmarks/portfolio-catalog.json", reader: "scripts/ask-primary-public-catalog-registry.mjs" }),
100
+ ]);
101
+ export const EVALUATOR_AUTHORITY_PATHS = Object.freeze([
102
+ "benchmarks/schemas/evaluator-authority-manifest.schema.json",
103
+ "benchmarks/schemas/evaluator-reference.schema.json",
104
+ "benchmarks/schemas/evaluator-result-envelope.schema.json",
105
+ "benchmarks/schemas/evaluator-check-artifact.schema.json",
106
+ "benchmarks/schemas/evaluation-input-failure-artifact.schema.json",
107
+ "benchmarks/schemas/portfolio-final-admission-record.schema.json",
108
+ "benchmarks/schemas/portfolio-requirement-record.schema.json",
109
+ "benchmarks/schemas/portfolio-output-contract.schema.json",
110
+ "benchmarks/schemas/private-evaluator-bundle.schema.json",
111
+ "benchmarks/schemas/private-evaluator-fragment.schema.json",
112
+ "benchmarks/schemas/private-evaluator-independence-statement.schema.json",
113
+ "benchmarks/schemas/private-evaluation-record.schema.json",
114
+ "benchmarks/schemas/repository-diff-artifact.schema.json",
115
+ "benchmarks/schemas/scoring-input-freeze-manifest.schema.json",
116
+ "benchmarks/schemas/normalized-portfolio-result.schema.json",
117
+ "benchmarks/schemas/original-workspace-authority.schema.json",
118
+ ...EVALUATOR_EAGER_AUTHORITY_READS.map(({ path }) => path),
119
+ ]);
120
+ export const EVALUATOR_FIXTURE_AUTHORITY_PATHS = Object.freeze([
121
+ "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/evaluator-authority-manifest.json",
122
+ "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/input-manifest.json",
123
+ "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/evidence-map.json",
124
+ "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/verification-command-contract.json",
125
+ "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/requirement-record.json",
126
+ ]);
127
+ export const EVALUATOR_RUNTIME_AUTHORITY_PATHS = Object.freeze([
128
+ "benchmarks/schemas/normalized-portfolio-result.schema.json",
129
+ ]);
130
+ export const EVALUATOR_REPOSITORY_DESCRIPTOR_PATH = "repository-authority.json";
131
+ export const EVALUATOR_AUTHORITY_MANIFEST_PATH = "benchmarks/fixtures/checkpoint-b2/mn-build-option-update/evaluator-authority-manifest.json";
132
+ export const EVALUATOR_AUTHORITY_MANIFEST_SCHEMA_PATH = "benchmarks/schemas/evaluator-authority-manifest.schema.json";
133
+ export const SEALED_REGULAR_FILE_MODE = 0o444;
134
+ export const SEALED_EXECUTABLE_FILE_MODE = 0o555;
135
+ export const SEALED_DIRECTORY_MODE = 0o555;
136
+ export const SEALED_EXECUTABLE_PATHS = Object.freeze([]);
137
+ const PRIVATE_EVALUATOR_VIRTUAL_ROOT = "private";
138
+ const PRIVATE_EVALUATOR_VIRTUAL_PATH = `${PRIVATE_EVALUATOR_VIRTUAL_ROOT}/hidden-evaluator.mjs`;
139
+ const ORIGINAL_WORKSPACE_AUTHORITY_PATH = "original-workspace-authority.json";
140
+ const SEALED_REPOSITORY_DIFF_ARTIFACT_PATH = "repository-diff-artifact.json";
141
+ const EVALUATOR_PRIVATE_ENTRY_PATHS = Object.freeze([
142
+ "scripts/ask-benchmark-scoring-contract.mjs",
143
+ "scripts/ask-benchmark-materialize.mjs",
144
+ "scripts/ask-benchmark-normalized-results.mjs",
145
+ "scripts/ask-benchmark-evaluator-boundary.mjs",
146
+ ]);
147
+ const CATALOG_SCHEMA_PATH = "benchmarks/schemas/portfolio-catalog.schema.json";
148
+ const POLICY_MANIFEST_SCHEMA_PATH = "benchmarks/schemas/portfolio-policy-manifest.schema.json";
149
+ const SCORING_POLICY_SCHEMA_PATH = "benchmarks/schemas/portfolio-scoring-policy.schema.json";
150
+ const ADMISSION_POLICY_SCHEMA_PATH = "benchmarks/schemas/portfolio-admission-policy.schema.json";
151
+ const ADMISSION_POLICY_PATH = "benchmarks/portfolio-admission-policy.json";
152
+ const REQUIREMENT_RECORD_SCHEMA_PATH = "benchmarks/schemas/portfolio-requirement-record.schema.json";
153
+ const OUTPUT_CONTRACT_SCHEMA_PATH = "benchmarks/schemas/portfolio-output-contract.schema.json";
154
+
155
+ const MAX_PUBLIC_ARTIFACT_BYTES = 1024 * 1024;
156
+ const MAX_PRIVATE_EVALUATOR_EXECUTION_BUDGET_MS = 900_000;
157
+ const MAX_JSON_ARTIFACT_BYTES = 1024 * 1024;
158
+ const MAX_BOUNDARY_FILE_BYTES = 256 * 1024 * 1024;
159
+ const MAX_BOUNDARY_FILES = 100_000;
160
+ const MAX_BOUNDARY_TOTAL_BYTES = 2 * 1024 * 1024 * 1024;
161
+ const DIGEST_CHUNK_BYTES = 64 * 1024;
162
+ const BOUNDARY_MARKERS = [
163
+ ["materializedPath", "materialized root", "materialization-manifest.json"],
164
+ ["selectionState", "selection-state root", "selection-state.json"],
165
+ ["runDir", "execution run root", "run-identity.json"],
166
+ ["normalizedResultsPath", "normalized-results root", "normalized-results-root.json"],
167
+ ];
168
+ const PUBLIC_FORBIDDEN_FIELDS = new Set([
169
+ "credential",
170
+ "credentials",
171
+ "customer_data",
172
+ "expected_decision",
173
+ "expected_finding",
174
+ "expected_finding_details",
175
+ "expected_patch",
176
+ "hidden_answer",
177
+ "hidden_test_source",
178
+ "hidden_tests",
179
+ "matcher",
180
+ "matcher_expression",
181
+ "oracle",
182
+ "oracle_text",
183
+ "personal_data",
184
+ "private_evaluator_path",
185
+ "private_storage_uri",
186
+ "raw_evaluator_prompt",
187
+ "reference_answer",
188
+ "rubric",
189
+ "secret",
190
+ "secrets",
191
+ ]);
192
+
193
+ function createScanBudget(label) {
194
+ return { label, files: 0, bytes: 0 };
195
+ }
196
+
197
+ function accountForFile(status, budget, label) {
198
+ if (status.size > MAX_BOUNDARY_FILE_BYTES) throw new Error(`${label} exceeds the per-file boundary inspection limit`);
199
+ budget.files += 1;
200
+ budget.bytes += status.size;
201
+ if (budget.files > MAX_BOUNDARY_FILES) throw new Error(`${budget.label} exceeds the boundary inspection file-count limit`);
202
+ if (budget.bytes > MAX_BOUNDARY_TOTAL_BYTES) throw new Error(`${budget.label} exceeds the boundary inspection byte limit`);
203
+ }
204
+
205
+ function streamingFileDigest(path, label, budget = createScanBudget(label)) {
206
+ assertRegularFile(path, label);
207
+ const initialStatus = lstatSync(path);
208
+ accountForFile(initialStatus, budget, label);
209
+ const hash = createHash("sha256");
210
+ const chunk = Buffer.allocUnsafe(DIGEST_CHUNK_BYTES);
211
+ let descriptor;
212
+ let bytes = 0;
213
+ try {
214
+ descriptor = openSync(path, "r");
215
+ const openedStatus = fstatSync(descriptor);
216
+ if (!openedStatus.isFile() || openedStatus.dev !== initialStatus.dev || openedStatus.ino !== initialStatus.ino || openedStatus.size !== initialStatus.size) {
217
+ throw new Error(`${label} changed during boundary inspection`);
218
+ }
219
+ for (;;) {
220
+ const count = readSync(descriptor, chunk, 0, chunk.length, null);
221
+ if (count === 0) break;
222
+ hash.update(chunk.subarray(0, count));
223
+ bytes += count;
224
+ }
225
+ const finalStatus = fstatSync(descriptor);
226
+ if (finalStatus.size !== openedStatus.size || finalStatus.mtimeMs !== openedStatus.mtimeMs || finalStatus.ctimeMs !== openedStatus.ctimeMs) {
227
+ throw new Error(`${label} changed during boundary inspection`);
228
+ }
229
+ } finally {
230
+ if (descriptor !== undefined) closeSync(descriptor);
231
+ }
232
+ if (bytes !== initialStatus.size) throw new Error(`${label} changed during boundary inspection`);
233
+ return { bytes, digest: `sha256:${hash.digest("hex")}` };
234
+ }
235
+
236
+ function isInside(root, path) {
237
+ const resolvedRoot = resolve(root);
238
+ const resolvedPath = resolve(path);
239
+ return resolvedPath === resolvedRoot || resolvedPath.startsWith(`${resolvedRoot}${sep}`);
240
+ }
241
+
242
+ function canonicalFilesystemPath(path) {
243
+ const absolute = resolve(path);
244
+ if (existsSync(absolute)) return realpathSync(absolute);
245
+ const suffix = [];
246
+ let current = absolute;
247
+ while (!existsSync(current)) {
248
+ const parent = resolve(current, "..");
249
+ if (parent === current) return absolute;
250
+ suffix.unshift(relative(parent, current));
251
+ current = parent;
252
+ }
253
+ return resolve(realpathSync(current), ...suffix);
254
+ }
255
+
256
+ function pathsOverlap(left, right) {
257
+ const canonicalLeft = canonicalFilesystemPath(left);
258
+ const canonicalRight = canonicalFilesystemPath(right);
259
+ return isInside(canonicalLeft, canonicalRight) || isInside(canonicalRight, canonicalLeft);
260
+ }
261
+
262
+ function assertRegularFile(path, label) {
263
+ if (!path || !existsSync(path)) throw new Error(`${label} is missing`);
264
+ const status = lstatSync(path);
265
+ if (status.isSymbolicLink()) throw new Error(`${label} must not be a symlink`);
266
+ if (!status.isFile()) throw new Error(`${label} must be a regular file`);
267
+ }
268
+
269
+ function assertRealDirectory(path, label) {
270
+ if (!path || !existsSync(path)) throw new Error(`${label} is missing`);
271
+ const status = lstatSync(path);
272
+ if (status.isSymbolicLink()) throw new Error(`${label} must not be a symlink`);
273
+ if (!status.isDirectory()) throw new Error(`${label} must be a directory`);
274
+ return realpathSync(path);
275
+ }
276
+
277
+ function assertPortableRelativePath(value, label) {
278
+ const segments = typeof value === "string" ? value.split("/") : [];
279
+ if (
280
+ typeof value !== "string"
281
+ || value.length === 0
282
+ || value.length > 240
283
+ || value.includes("\\")
284
+ || value.includes(":")
285
+ || value.includes("\0")
286
+ || posix.isAbsolute(value)
287
+ || win32.isAbsolute(value)
288
+ || /^(?:\\\\[?.]\\|[A-Za-z]:[\\/])/u.test(value)
289
+ || segments.some((segment) => segment === "" || segment === "." || segment === "..")
290
+ || posix.normalize(value) !== value
291
+ ) {
292
+ throw new Error(`${label} must be a portable normalized relative path without escape segments`);
293
+ }
294
+ return value;
295
+ }
296
+
297
+ function assertPathInsideRootWithoutSymlinks(root, path, label) {
298
+ const canonicalRoot = realpathSync(root);
299
+ const relativePath = relative(root, path).split(sep).join("/");
300
+ assertPortableRelativePath(relativePath, label);
301
+ let current = root;
302
+ for (const segment of relativePath.split("/")) {
303
+ current = resolve(current, segment);
304
+ if (!existsSync(current)) throw new Error(`${label} is missing`);
305
+ if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} traverses a symlink`);
306
+ }
307
+ if (!isInside(canonicalRoot, realpathSync(path))) throw new Error(`${label} escapes the private evaluator root`);
308
+ return relativePath;
309
+ }
310
+
311
+ function readJsonArtifact(path, label, { publicArtifact = false } = {}) {
312
+ const byteLimit = publicArtifact ? MAX_PUBLIC_ARTIFACT_BYTES : MAX_JSON_ARTIFACT_BYTES;
313
+ return readStableJsonFile(realpathSync(path), label, byteLimit, { allowEmpty: false });
314
+ }
315
+
316
+ function assertNoDuplicateJsonObjectKeys(source, label) {
317
+ let offset = 0;
318
+ const whitespace = /\s/u;
319
+
320
+ function skipWhitespace() {
321
+ while (whitespace.test(source[offset] ?? "")) offset += 1;
322
+ }
323
+
324
+ function parseString() {
325
+ const start = offset;
326
+ if (source[offset] !== '"') throw new Error(`${label} has an invalid JSON string`);
327
+ offset += 1;
328
+ while (offset < source.length) {
329
+ if (source[offset] === "\\") {
330
+ offset += 2;
331
+ continue;
332
+ }
333
+ if (source[offset] === '"') {
334
+ offset += 1;
335
+ return JSON.parse(source.slice(start, offset));
336
+ }
337
+ offset += 1;
338
+ }
339
+ throw new Error(`${label} has an unterminated JSON string`);
340
+ }
341
+
342
+ function parseValue() {
343
+ skipWhitespace();
344
+ if (source[offset] === "{") return parseObject();
345
+ if (source[offset] === "[") return parseArray();
346
+ if (source[offset] === '"') {
347
+ parseString();
348
+ return;
349
+ }
350
+ while (offset < source.length && !/[\s,\]}]/u.test(source[offset])) offset += 1;
351
+ }
352
+
353
+ function parseObject() {
354
+ offset += 1;
355
+ const keys = new Set();
356
+ skipWhitespace();
357
+ if (source[offset] === "}") {
358
+ offset += 1;
359
+ return;
360
+ }
361
+ while (offset < source.length) {
362
+ skipWhitespace();
363
+ const key = parseString();
364
+ if (keys.has(key)) throw new Error(`${label} contains a duplicate JSON object key: ${key}`);
365
+ keys.add(key);
366
+ skipWhitespace();
367
+ if (source[offset] !== ":") throw new Error(`${label} has invalid JSON object syntax`);
368
+ offset += 1;
369
+ parseValue();
370
+ skipWhitespace();
371
+ if (source[offset] === "}") {
372
+ offset += 1;
373
+ return;
374
+ }
375
+ if (source[offset] !== ",") throw new Error(`${label} has invalid JSON object syntax`);
376
+ offset += 1;
377
+ }
378
+ }
379
+
380
+ function parseArray() {
381
+ offset += 1;
382
+ skipWhitespace();
383
+ if (source[offset] === "]") {
384
+ offset += 1;
385
+ return;
386
+ }
387
+ while (offset < source.length) {
388
+ parseValue();
389
+ skipWhitespace();
390
+ if (source[offset] === "]") {
391
+ offset += 1;
392
+ return;
393
+ }
394
+ if (source[offset] !== ",") throw new Error(`${label} has invalid JSON array syntax`);
395
+ offset += 1;
396
+ }
397
+ }
398
+
399
+ parseValue();
400
+ skipWhitespace();
401
+ if (offset !== source.length) throw new Error(`${label} contains trailing JSON content`);
402
+ }
403
+
404
+ function rawByteDigest(bytes) {
405
+ return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
406
+ }
407
+
408
+ export function evaluatorAuthorityPathsForFixture(fixtureId) {
409
+ if (typeof fixtureId !== "string" || !/^[a-z0-9][a-z0-9-]*$/u.test(fixtureId)) throw new Error("evaluator authority fixture ID is invalid");
410
+ const fixtureRoot = `benchmarks/fixtures/checkpoint-b2/${fixtureId}`;
411
+ const bindingPaths = [
412
+ calibrationSourceIdForFixture(fixtureId) ? CALIBRATION_INPUT_MANIFEST_PATH : `${fixtureRoot}/input-manifest.json`,
413
+ `${fixtureRoot}/evidence-map.json`,
414
+ `${fixtureRoot}/verification-command-contract.json`,
415
+ `${fixtureRoot}/requirement-record.json`,
416
+ ];
417
+ const manifestPath = `${fixtureRoot}/evaluator-authority-manifest.json`;
418
+ return { fixtureId, fixtureRoot, bindingPaths, manifestPath, fixturePaths: [manifestPath, ...bindingPaths] };
419
+ }
420
+
421
+ function fixtureIdFromEvaluatorAuthorityManifestPath(path) {
422
+ const match = typeof path === "string" ? path.match(/^benchmarks\/fixtures\/checkpoint-b2\/([a-z0-9][a-z0-9-]*)\/evaluator-authority-manifest\.json$/u) : null;
423
+ if (!match || evaluatorAuthorityPathsForFixture(match[1]).manifestPath !== path) throw new Error("evaluator authority manifest path is invalid");
424
+ return match[1];
425
+ }
426
+
427
+ function resolveEvaluatorAuthorityLayout({ buffers, fixtureId = null } = {}) {
428
+ if (!(buffers instanceof Map)) throw new Error("evaluator authority requires a verified byte map");
429
+ const inputPaths = [...buffers.keys()].filter((path) => path.endsWith("/input-manifest.json"));
430
+ if (inputPaths.length !== 1) throw new Error("evaluator authority input manifest inventory is ambiguous");
431
+ const input = jsonValueFromVerifiedBytes(buffers.get(inputPaths[0]), `evaluator authority ${inputPaths[0]}`);
432
+ const manifestFixtureIds = Object.keys(input.fixtures ?? {});
433
+ const resolvedFixtureId = fixtureId ?? (manifestFixtureIds.length === 1 ? manifestFixtureIds[0] : null);
434
+ const layout = evaluatorAuthorityPathsForFixture(resolvedFixtureId);
435
+ if (layout.bindingPaths.some((path) => !buffers.has(path))) throw new Error("evaluator authority binding path inventory has an omission");
436
+ const calibrationSourceId = calibrationSourceIdForFixture(resolvedFixtureId);
437
+ if (calibrationSourceId) {
438
+ if (buffers.size !== layout.bindingPaths.length) throw new Error("evaluator authority calibration binding path inventory has an addition");
439
+ if (rawByteDigest(buffers.get(CALIBRATION_INPUT_MANIFEST_PATH)) !== `sha256:${CALIBRATION_INPUT_MANIFEST_SHA256}`) throw new Error("evaluator authority calibration input manifest digest changed");
440
+ const expectedSourceIds = CALIBRATION_SOURCE_BINDINGS.map(([, sourceId]) => sourceId).sort();
441
+ if (stableCanonicalJson(manifestFixtureIds.sort()) !== stableCanonicalJson(expectedSourceIds)) throw new Error("evaluator authority calibration input manifest entries changed");
442
+ }
443
+ return { ...layout, input };
444
+ }
445
+
446
+ function jsonValueFromVerifiedBytes(bytes, label) {
447
+ if (!Buffer.isBuffer(bytes) || bytes.length === 0) throw new Error(`${label} verified bytes are missing`);
448
+ const source = bytes.toString("utf8");
449
+ assertNoDuplicateJsonObjectKeys(source, label);
450
+ try {
451
+ return JSON.parse(source);
452
+ } catch {
453
+ throw new Error(`${label} is invalid JSON`);
454
+ }
455
+ }
456
+
457
+ export function computeEvaluatorAuthorityManifestDigest(manifest) {
458
+ const { manifest_digest: _digest, ...base } = manifest;
459
+ return canonicalDigest(base);
460
+ }
461
+
462
+ export function deriveEvaluatorAuthorityManifest({ buffers, evaluatorRevision, fixtureId = null } = {}) {
463
+ if (!(buffers instanceof Map)) throw new Error("evaluator authority manifest requires a verified byte map");
464
+ if (!/^[a-f0-9]{40}$/u.test(evaluatorRevision ?? "")) throw new Error("evaluator authority manifest revision is invalid");
465
+ const layout = resolveEvaluatorAuthorityLayout({ buffers, fixtureId });
466
+ const values = new Map(layout.bindingPaths.map((path) => [path, jsonValueFromVerifiedBytes(buffers.get(path), `evaluator authority ${path}`)]));
467
+ const [inputPath, evidencePath, commandPath, requirementPath] = layout.bindingPaths;
468
+ const input = layout.input;
469
+ const evidence = values.get(evidencePath);
470
+ const command = values.get(commandPath);
471
+ const requirement = values.get(requirementPath);
472
+ const fixtureEntry = input.fixtures?.[calibrationSourceIdForFixture(layout.fixtureId) ?? layout.fixtureId];
473
+ if (!fixtureEntry) throw new Error("evaluator authority input manifest is missing the fixture entry");
474
+ if (evidence.fixture_id !== layout.fixtureId || command.fixture_id !== layout.fixtureId || requirement.fixture_id !== layout.fixtureId) throw new Error("evaluator authority fixture identity is inconsistent");
475
+ if (command.contract_digest !== computeVerificationCommandContractDigest(command)) throw new Error("evaluator authority verification command contract digest is invalid");
476
+ if (requirement.requirement_record_digest !== computeRequirementRecordDigest(requirement) || requirement.requirement_set_digest !== computeRequirementSetDigest(requirement)) throw new Error("evaluator authority requirement record digest is invalid");
477
+ const requirementMapClosure = requirement.requirements.map(({ requirement_id, evidence_map_ids }) => ({ requirement_id, evidence_map_ids }));
478
+ const fileInventory = [
479
+ {
480
+ path: inputPath,
481
+ bytes: buffers.get(inputPath).length,
482
+ raw_sha256: rawByteDigest(buffers.get(inputPath)),
483
+ semantic_digest: canonicalDigest(fixtureEntry),
484
+ authority_role: "fixture_input",
485
+ fixture_input_identity: rawByteDigest(buffers.get(inputPath)),
486
+ semantic_fixture_entry_digest: canonicalDigest(fixtureEntry),
487
+ },
488
+ {
489
+ path: evidencePath,
490
+ bytes: buffers.get(evidencePath).length,
491
+ raw_sha256: rawByteDigest(buffers.get(evidencePath)),
492
+ semantic_digest: canonicalDigest(evidence),
493
+ authority_role: "evidence_map",
494
+ evidence_map_set_digest: canonicalDigest(evidence.maps),
495
+ requirement_ids: requirementMapClosure.map(({ requirement_id }) => requirement_id),
496
+ evidence_map_ids: evidence.maps.map(({ evidence_map_id }) => evidence_map_id),
497
+ requirement_map_closure_digest: canonicalDigest(requirementMapClosure),
498
+ },
499
+ {
500
+ path: commandPath,
501
+ bytes: buffers.get(commandPath).length,
502
+ raw_sha256: rawByteDigest(buffers.get(commandPath)),
503
+ semantic_digest: command.contract_digest,
504
+ authority_role: "verification_command_contract",
505
+ contract_digest: command.contract_digest,
506
+ command_inventory_digest: canonicalDigest(command.commands),
507
+ },
508
+ {
509
+ path: requirementPath,
510
+ bytes: buffers.get(requirementPath).length,
511
+ raw_sha256: rawByteDigest(buffers.get(requirementPath)),
512
+ semantic_digest: requirement.requirement_record_digest,
513
+ authority_role: "requirement_record",
514
+ requirement_record_digest: requirement.requirement_record_digest,
515
+ requirement_set_digest: requirement.requirement_set_digest,
516
+ },
517
+ ];
518
+ const base = {
519
+ schema_version: "1.0.0",
520
+ schema_path: EVALUATOR_AUTHORITY_MANIFEST_SCHEMA_PATH,
521
+ program: "adaptive_ask_evaluator_authority_manifest",
522
+ fixture_id: layout.fixtureId,
523
+ evaluator_revision: evaluatorRevision,
524
+ file_inventory: fileInventory,
525
+ };
526
+ return { ...base, manifest_digest: canonicalDigest(base) };
527
+ }
528
+
529
+ export function validateEvaluatorAuthorityManifest({ manifest, buffers, evaluatorRevision, root = null, label = "evaluator authority manifest" } = {}) {
530
+ if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) throw new Error(`${label} is missing`);
531
+ if (manifest.manifest_digest !== computeEvaluatorAuthorityManifestDigest(manifest)) throw new Error(`${label} digest closure is invalid`);
532
+ if (root) assertBenchmarkSchemaInstance(manifest, { schemaPath: resolve(root, EVALUATOR_AUTHORITY_MANIFEST_SCHEMA_PATH), label });
533
+ const expected = deriveEvaluatorAuthorityManifest({ buffers, evaluatorRevision, fixtureId: manifest.fixture_id });
534
+ if (stableCanonicalJson(manifest) !== stableCanonicalJson(expected)) throw new Error(`${label} does not match the immutable fixture authority bytes`);
535
+ return structuredClone(manifest);
536
+ }
537
+
538
+ function assertExternalEvaluatorAuthorityAnchor(anchor, label) {
539
+ if (!anchor || typeof anchor !== "object" || Array.isArray(anchor)) throw new Error(`${label} external evaluator authority anchor is required`);
540
+ if (!/^[a-f0-9]{40}$/u.test(anchor.evaluator_revision ?? "")) throw new Error(`${label} external evaluator authority revision is invalid`);
541
+ const reference = anchor.evaluator_reference;
542
+ if (!reference || typeof reference !== "object" || Array.isArray(reference)) throw new Error(`${label} external evaluator public reference is missing`);
543
+ const layout = evaluatorAuthorityPathsForFixture(reference.fixture_id);
544
+ if (anchor.evaluator_authority_manifest_path !== layout.manifestPath) throw new Error(`${label} external evaluator authority manifest path drift`);
545
+ if (!Number.isInteger(anchor.evaluator_authority_manifest_bytes) || anchor.evaluator_authority_manifest_bytes < 1) throw new Error(`${label} external evaluator authority manifest byte count is invalid`);
546
+ for (const [field, value] of [
547
+ ["raw-byte digest", anchor.evaluator_authority_manifest_raw_sha256],
548
+ ["semantic digest", anchor.evaluator_authority_manifest_digest],
549
+ ]) if (!/^sha256:[a-f0-9]{64}$/u.test(value ?? "")) throw new Error(`${label} external evaluator authority manifest ${field} is invalid`);
550
+ if (!Array.isArray(anchor.file_inventory)) throw new Error(`${label} external evaluator authority file inventory is missing`);
551
+ const paths = anchor.file_inventory.map((entry) => entry?.path);
552
+ if (new Set(paths).size !== paths.length) throw new Error(`${label} external evaluator authority file inventory contains duplicates`);
553
+ if (stableCanonicalJson(paths) !== stableCanonicalJson(layout.bindingPaths)) throw new Error(`${label} external evaluator authority file inventory has an omission, addition, or ordering drift`);
554
+ for (const entry of anchor.file_inventory) {
555
+ if (!Number.isInteger(entry.bytes) || entry.bytes < 1 || !/^sha256:[a-f0-9]{64}$/u.test(entry.raw_sha256 ?? "")) throw new Error(`${label} external evaluator authority file identity is invalid at ${entry.path}`);
556
+ }
557
+ if (reference.public_metadata_digest !== computeEvaluatorReferenceDigest(reference)) throw new Error(`${label} external evaluator public reference digest closure is invalid`);
558
+ if (reference.evaluator_revision !== anchor.evaluator_revision || reference.evaluator_authority_manifest_path !== anchor.evaluator_authority_manifest_path || reference.evaluator_authority_manifest_raw_sha256 !== anchor.evaluator_authority_manifest_raw_sha256 || reference.evaluator_authority_manifest_digest !== anchor.evaluator_authority_manifest_digest) throw new Error(`${label} external evaluator public reference authority closure is invalid`);
559
+ if (!/^evaluator-[a-f0-9]{64}$/u.test(reference.evaluator_bundle_id ?? "") || !/^sha256:[a-f0-9]{64}$/u.test(reference.evaluator_bundle_digest ?? "")) throw new Error(`${label} external evaluator public reference bundle identity is invalid`);
560
+ if (!reference.evaluator_source_identity || reference.evaluator_source_identity.base_git_revision !== anchor.evaluator_revision) throw new Error(`${label} external evaluator public reference source identity is invalid`);
561
+ return structuredClone(anchor);
562
+ }
563
+
564
+ function buildVerifiedEvaluatorAuthorityAnchor({ evaluatorRevision, evaluatorReference, manifestReference, manifestSource, buffers, root, label }) {
565
+ const layout = evaluatorAuthorityPathsForFixture(evaluatorReference?.fixture_id);
566
+ if (!manifestReference || manifestReference.path !== layout.manifestPath) throw new Error(`${label} evaluator authority manifest freeze reference path drift`);
567
+ if (!manifestSource || !(buffers instanceof Map)) throw new Error(`${label} evaluator authority verified bytes are missing`);
568
+ if (manifestSource.rawByteDigest !== manifestReference.raw_byte_digest) throw new Error(`${label} evaluator authority manifest raw bytes do not match the freeze authority`);
569
+ if (manifestSource.value.manifest_digest !== manifestReference.semantic_digest) throw new Error(`${label} evaluator authority manifest semantic digest does not match the freeze authority`);
570
+ validateEvaluatorAuthorityManifest({ manifest: manifestSource.value, buffers, evaluatorRevision, root, label: `${label} evaluator authority manifest` });
571
+ const fileInventory = manifestSource.value.file_inventory.map(({ path, bytes, raw_sha256 }) => ({ path, bytes, raw_sha256 }));
572
+ return assertExternalEvaluatorAuthorityAnchor({
573
+ evaluator_revision: evaluatorRevision,
574
+ evaluator_authority_manifest_path: manifestReference.path,
575
+ evaluator_authority_manifest_bytes: manifestSource.bytes.length,
576
+ evaluator_authority_manifest_raw_sha256: manifestReference.raw_byte_digest,
577
+ evaluator_authority_manifest_digest: manifestReference.semantic_digest,
578
+ file_inventory: fileInventory,
579
+ evaluator_reference: structuredClone(evaluatorReference),
580
+ }, label);
581
+ }
582
+
583
+ function externalAuthorityIdentityForPath(anchor, path) {
584
+ if (path === anchor.evaluator_authority_manifest_path) return {
585
+ bytes: anchor.evaluator_authority_manifest_bytes,
586
+ raw_sha256: anchor.evaluator_authority_manifest_raw_sha256,
587
+ };
588
+ return anchor.file_inventory.find((entry) => entry.path === path) ?? null;
589
+ }
590
+
591
+ function fixtureAuthorityPathsFromAnchor(anchor, label) {
592
+ const validated = assertExternalEvaluatorAuthorityAnchor(anchor, label);
593
+ return [validated.evaluator_authority_manifest_path, ...validated.file_inventory.map(({ path }) => path)];
594
+ }
595
+
596
+ export function verifySealedEvaluatorExternalAuthority({ descriptor, buffers, externalAuthorityAnchor, label = "sealed evaluator external authority" } = {}) {
597
+ const anchor = assertExternalEvaluatorAuthorityAnchor(externalAuthorityAnchor, label);
598
+ if (!descriptor || !(buffers instanceof Map)) throw new Error(`${label} sealed descriptor or verified byte map is missing`);
599
+ if (descriptor.evaluator_revision !== anchor.evaluator_revision) throw new Error(`${label} evaluator revision does not match the external freeze authority`);
600
+ if (descriptor.evaluator_authority_manifest_path !== anchor.evaluator_authority_manifest_path) throw new Error(`${label} evaluator authority manifest path does not match the external freeze authority`);
601
+ if (descriptor.evaluator_authority_manifest_raw_sha256 !== anchor.evaluator_authority_manifest_raw_sha256) throw new Error(`${label} evaluator authority manifest raw-byte digest does not match the external freeze authority`);
602
+ if (descriptor.evaluator_authority_manifest_digest !== anchor.evaluator_authority_manifest_digest) throw new Error(`${label} evaluator authority manifest semantic digest does not match the external freeze authority`);
603
+ const manifestBytes = buffers.get(anchor.evaluator_authority_manifest_path);
604
+ if (!Buffer.isBuffer(manifestBytes) || manifestBytes.length !== anchor.evaluator_authority_manifest_bytes || rawByteDigest(manifestBytes) !== anchor.evaluator_authority_manifest_raw_sha256) throw new Error(`${label} sealed evaluator authority manifest bytes do not match the external freeze authority`);
605
+ const manifest = jsonValueFromVerifiedBytes(manifestBytes, `${label} sealed evaluator authority manifest`);
606
+ if (manifest.evaluator_revision !== anchor.evaluator_revision || manifest.manifest_digest !== anchor.evaluator_authority_manifest_digest) throw new Error(`${label} sealed evaluator authority manifest identity does not match the external freeze authority`);
607
+ const manifestInventory = manifest.file_inventory.map(({ path, bytes, raw_sha256 }) => ({ path, bytes, raw_sha256 }));
608
+ if (stableCanonicalJson(manifestInventory) !== stableCanonicalJson(anchor.file_inventory)) throw new Error(`${label} sealed evaluator authority manifest inventory does not match the external freeze authority`);
609
+ const descriptorFixtures = new Map((descriptor.fixture_authority ?? []).map((entry) => [entry.path, entry]));
610
+ for (const entry of anchor.file_inventory) {
611
+ const bytes = buffers.get(entry.path);
612
+ if (!Buffer.isBuffer(bytes) || bytes.length !== entry.bytes || rawByteDigest(bytes) !== entry.raw_sha256) throw new Error(`${label} sealed fixture bytes do not match the external freeze authority at ${entry.path}`);
613
+ const descriptorEntry = descriptorFixtures.get(entry.path);
614
+ if (!descriptorEntry || descriptorEntry.bytes !== entry.bytes || descriptorEntry.sha256 !== entry.raw_sha256) throw new Error(`${label} sealed descriptor fixture identity does not match the external freeze authority at ${entry.path}`);
615
+ }
616
+ const descriptorBytes = buffers.get(EVALUATOR_REPOSITORY_DESCRIPTOR_PATH);
617
+ if (!Buffer.isBuffer(descriptorBytes)) throw new Error(`${label} sealed descriptor bytes are missing`);
618
+ return {
619
+ evaluator_revision: anchor.evaluator_revision,
620
+ source_graph_digest: descriptor.source_graph_digest,
621
+ repository_descriptor_sha256: rawByteDigest(descriptorBytes),
622
+ evaluator_authority_manifest_path: anchor.evaluator_authority_manifest_path,
623
+ evaluator_authority_manifest_raw_sha256: anchor.evaluator_authority_manifest_raw_sha256,
624
+ evaluator_authority_manifest_digest: anchor.evaluator_authority_manifest_digest,
625
+ evaluator_authority_files: structuredClone(anchor.file_inventory),
626
+ };
627
+ }
628
+
629
+ function checkedInBytes(root, relativePath) {
630
+ try {
631
+ const repositoryTop = realpathSync(execFileSync("git", ["-C", root, "rev-parse", "--show-toplevel"], { encoding: "utf8", maxBuffer: 1024 * 1024 }).trim());
632
+ if (repositoryTop !== root) return null;
633
+ return execFileSync("git", ["-C", root, "show", `HEAD:${relativePath}`], { encoding: null, maxBuffer: 2 * 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] });
634
+ } catch {
635
+ return null;
636
+ }
637
+ }
638
+
639
+ function checkedInBytesAtRevision(root, revision, relativePath) {
640
+ const key = `${root}\0${revision}\0${relativePath}`;
641
+ const cached = CHECKED_IN_REVISION_BYTES.get(key);
642
+ if (cached) return cached;
643
+ try {
644
+ const bytes = execFileSync("git", ["-C", root, "show", `${revision}:${relativePath}`], {
645
+ encoding: null,
646
+ maxBuffer: 4 * 1024 * 1024,
647
+ stdio: ["ignore", "pipe", "ignore"],
648
+ });
649
+ CHECKED_IN_REVISION_BYTES.set(key, bytes);
650
+ return bytes;
651
+ } catch {
652
+ return null;
653
+ }
654
+ }
655
+
656
+ const CHECKED_IN_REVISION_BYTES = new Map();
657
+
658
+ function lexModule(source, label) {
659
+ const tokens = [];
660
+ let offset = 0;
661
+ let line = 1;
662
+ let column = 1;
663
+ const advance = () => {
664
+ const character = source[offset++];
665
+ if (character === "\n") { line += 1; column = 1; } else column += 1;
666
+ return character;
667
+ };
668
+ const consumeQuoted = (quote) => {
669
+ const start = { line, column };
670
+ let raw = quote;
671
+ advance();
672
+ while (offset < source.length) {
673
+ const character = advance();
674
+ raw += character;
675
+ if (character === "\\") {
676
+ if (offset >= source.length) throw new Error(`${label} contains an unterminated string`);
677
+ raw += advance();
678
+ } else if (character === quote) {
679
+ try {
680
+ const value = raw.slice(1, -1).replace(/\\\\(.)/gsu, "$1");
681
+ tokens.push({ type: "string", value, ...start });
682
+ return;
683
+ } catch { throw new Error(`${label} contains an invalid string literal`); }
684
+ } else if (character === "\n" || character === "\r") throw new Error(`${label} contains an unterminated string`);
685
+ }
686
+ throw new Error(`${label} contains an unterminated string`);
687
+ };
688
+ const consumeTemplate = () => {
689
+ advance();
690
+ while (offset < source.length) {
691
+ if (source[offset] === "\\") {
692
+ advance();
693
+ if (offset >= source.length) throw new Error(`${label} contains an unterminated template literal`);
694
+ advance();
695
+ } else if (source[offset] === "`") {
696
+ advance();
697
+ return;
698
+ } else if (source[offset] === "$" && source[offset + 1] === "{") {
699
+ advance();
700
+ advance();
701
+ consumeCode(true);
702
+ } else {
703
+ advance();
704
+ }
705
+ }
706
+ throw new Error(`${label} contains an unterminated template literal`);
707
+ };
708
+ const consumeCode = (stopAtTemplateExpressionEnd = false) => {
709
+ let nestedBraces = 0;
710
+ while (offset < source.length) {
711
+ const character = source[offset];
712
+ if (stopAtTemplateExpressionEnd && character === "}" && nestedBraces === 0) { advance(); return; }
713
+ if (offset === 0 && character === "#" && source[offset + 1] === "!") { while (offset < source.length && advance() !== "\n") {} continue; }
714
+ if (/\s/u.test(character)) { advance(); continue; }
715
+ if (character === "/" && source[offset + 1] === "/") { while (offset < source.length && advance() !== "\n") {} continue; }
716
+ if (character === "/" && source[offset + 1] === "*") {
717
+ advance(); advance();
718
+ while (offset < source.length && !(source[offset] === "*" && source[offset + 1] === "/")) advance();
719
+ if (offset >= source.length) throw new Error(`${label} contains an unterminated comment`);
720
+ advance(); advance(); continue;
721
+ }
722
+ const previousToken = tokens.at(-1);
723
+ const previous = previousToken?.value;
724
+ const beforePrevious = tokens.at(-2);
725
+ const arrowPrefix = previousToken?.type === "punctuation" && previous === ">" && beforePrevious?.type === "punctuation" && beforePrevious.value === "=";
726
+ const logicalPrefix = previousToken?.type === "punctuation" && ["|", "&"].includes(previous);
727
+ const regexPrefix = arrowPrefix || logicalPrefix || previous === undefined || ["(", "[", "{", "=", ":", ",", ";", "!", "?", "return", "=>"].includes(previous);
728
+ if (character === "/" && regexPrefix) {
729
+ advance();
730
+ let inCharacterClass = false;
731
+ while (offset < source.length) {
732
+ const value = advance();
733
+ if (value === "\\" && offset < source.length) advance();
734
+ else if (value === "[") inCharacterClass = true;
735
+ else if (value === "]") inCharacterClass = false;
736
+ else if (value === "/" && !inCharacterClass) break;
737
+ else if (value === "\n" || value === "\r") throw new Error(`${label} contains an unterminated regular expression`);
738
+ }
739
+ if (source[offset - 1] !== "/") throw new Error(`${label} contains an unterminated regular expression`);
740
+ while (offset < source.length && /[A-Za-z]/u.test(source[offset])) advance();
741
+ continue;
742
+ }
743
+ if (character === '"' || character === "'") { consumeQuoted(character); continue; }
744
+ if (character === "`") { consumeTemplate(); continue; }
745
+ const start = { line, column };
746
+ if (/[A-Za-z_$]/u.test(character)) {
747
+ let value = "";
748
+ while (offset < source.length && /[A-Za-z0-9_$]/u.test(source[offset])) value += advance();
749
+ tokens.push({ type: "identifier", value, ...start }); continue;
750
+ }
751
+ if (character === "{") nestedBraces += 1;
752
+ if (character === "}") nestedBraces -= 1;
753
+ tokens.push({ type: "punctuation", value: advance(), ...start });
754
+ }
755
+ if (stopAtTemplateExpressionEnd) throw new Error(`${label} contains an unterminated template expression`);
756
+ };
757
+ consumeCode();
758
+ return tokens;
759
+ }
760
+
761
+ function assertNoUnsupportedLocalLoad(tokens, index, label) {
762
+ const token = tokens[index];
763
+ const next = tokens[index + 1];
764
+ if (["createRequire", "require", "eval", "Function"].includes(token.value) && next?.value === "(") throw new Error(`${label} contains unsupported local module loading via ${token.value}`);
765
+ if (token.value === "import" && next?.value === "." && tokens[index + 2]?.value === "meta" && tokens[index + 3]?.value === "." && tokens[index + 4]?.value === "resolve") throw new Error(`${label} contains unsupported local module loading via import.meta.resolve`);
766
+ }
767
+
768
+ function dependencySpecifierTarget(root, fromPath, specifier, label) {
769
+ if (!specifier.startsWith(".")) return null;
770
+ if (specifier.includes("\\") || specifier.includes(":") || specifier.includes("\0") || posix.isAbsolute(specifier) || win32.isAbsolute(specifier) || specifier.split("/").some((segment) => segment === ".." || segment === "")) throw new Error(`${label} specifier is not portable`);
771
+ const fromDirectory = resolve(root, fromPath, "..");
772
+ const candidate = resolve(fromDirectory, specifier);
773
+ if (!isInside(root, candidate)) throw new Error(`${label} escapes the repository root`);
774
+ const candidates = [candidate, `${candidate}.mjs`, `${candidate}.js`, `${candidate}.json`];
775
+ const target = candidates.find((path) => existsSync(path));
776
+ if (!target) throw new Error(`${label} target is missing: ${specifier}`);
777
+ const relativeTarget = relative(root, target).split(sep).join("/");
778
+ assertPortableRelativePath(relativeTarget, `${label} target`);
779
+ assertPathInsideRootWithoutSymlinks(root, target, `${label} target`);
780
+ return relativeTarget;
781
+ }
782
+
783
+ function parseLocalModuleEdges(root, path, source) {
784
+ const tokens = lexModule(source, `evaluator dependency ${path}`);
785
+ const edges = [];
786
+ const add = (kind, token) => {
787
+ const target = dependencySpecifierTarget(root, path, token.value, `${kind} from ${path}`);
788
+ if (!target) return;
789
+ const edge = { from: path, to: target, kind, specifier: token.value, source_location: { line: token.line, column: token.column } };
790
+ edge.edge_digest = canonicalDigest(edge);
791
+ edges.push(edge);
792
+ };
793
+ const addPrivateRuntimeEdge = (token) => {
794
+ const edge = {
795
+ from: path,
796
+ to: "private/hidden-evaluator.mjs",
797
+ kind: "runtime_private_import",
798
+ specifier: token,
799
+ syntax_identity: `runtime_private_import:${path}:${token}`,
800
+ };
801
+ edge.edge_digest = canonicalDigest(edge);
802
+ edges.push(edge);
803
+ };
804
+ for (let index = 0; index < tokens.length; index += 1) {
805
+ const token = tokens[index];
806
+ assertNoUnsupportedLocalLoad(tokens, index, `evaluator dependency ${path}`);
807
+ if (token.value === "import") {
808
+ const next = tokens[index + 1];
809
+ if (next?.value === "(") {
810
+ const literal = tokens[index + 2];
811
+ if (literal?.type !== "string") {
812
+ if (path === "scripts/ask-benchmark-private-evaluator-runner.mjs") {
813
+ addPrivateRuntimeEdge("--hidden-evaluator");
814
+ continue;
815
+ }
816
+ throw new Error(`evaluator dependency ${path} contains an unsupported computed dynamic import`);
817
+ }
818
+ let depth = 1;
819
+ let cursor = index + 3;
820
+ for (; cursor < tokens.length && depth > 0; cursor += 1) {
821
+ if (tokens[cursor].value === "(") depth += 1;
822
+ if (tokens[cursor].value === ")") depth -= 1;
823
+ }
824
+ if (depth !== 0) throw new Error(`evaluator dependency ${path} contains an unterminated dynamic import`);
825
+ add("dynamic_import", literal);
826
+ } else if (next?.type === "string") add("static_import", next);
827
+ else {
828
+ for (let cursor = index + 1; cursor < tokens.length && tokens[cursor].value !== ";"; cursor += 1) {
829
+ if (tokens[cursor].value === "from") {
830
+ const literal = tokens[cursor + 1];
831
+ if (literal?.type !== "string") throw new Error(`evaluator dependency ${path} has an invalid static import`);
832
+ add("static_import", literal);
833
+ break;
834
+ }
835
+ if (tokens[cursor].value === "import" || tokens[cursor].value === "export") break;
836
+ }
837
+ }
838
+ } else if (token.value === "export" && ["{", "*"].includes(tokens[index + 1]?.value)) {
839
+ for (let cursor = index + 1; cursor < tokens.length && tokens[cursor].value !== ";"; cursor += 1) {
840
+ if (tokens[cursor].value === "from") {
841
+ const literal = tokens[cursor + 1];
842
+ if (literal?.type !== "string") throw new Error(`evaluator dependency ${path} has an invalid export-from`);
843
+ add("export_from", literal);
844
+ break;
845
+ }
846
+ if (tokens[cursor].value === "import" || tokens[cursor].value === "export") break;
847
+ }
848
+ }
849
+ }
850
+ return edges;
851
+ }
852
+
853
+ function dependencyFileType(path, authorityPaths = EVALUATOR_AUTHORITY_PATHS) {
854
+ if (authorityPaths.includes(path)) return "authority_data";
855
+ if (extname(path).toLowerCase() === ".json") return "json";
856
+ return "module";
857
+ }
858
+
859
+ export function deriveEvaluatorDependencyGraph({
860
+ root,
861
+ baseRevision,
862
+ entryPaths = EVALUATOR_DEPENDENCY_ENTRY_PATHS,
863
+ authorityPaths = EVALUATOR_AUTHORITY_PATHS,
864
+ privateEntryPaths = entryPaths === EVALUATOR_DEPENDENCY_ENTRY_PATHS ? EVALUATOR_PRIVATE_ENTRY_PATHS : [],
865
+ } = {}) {
866
+ const primaryParameters=primaryEvaluatorDependencyGraphParameters({root,baseRevision,
867
+ defaultParameters:entryPaths===EVALUATOR_DEPENDENCY_ENTRY_PATHS&&authorityPaths===EVALUATOR_AUTHORITY_PATHS&&privateEntryPaths===EVALUATOR_PRIVATE_ENTRY_PATHS,
868
+ defaults:{entryPaths:EVALUATOR_DEPENDENCY_ENTRY_PATHS,authorityPaths:EVALUATOR_AUTHORITY_PATHS,privateEntryPaths:EVALUATOR_PRIVATE_ENTRY_PATHS}});
869
+ if(primaryParameters){entryPaths=primaryParameters.entryPaths;authorityPaths=primaryParameters.authorityPaths;privateEntryPaths=primaryParameters.privateEntryPaths;}
870
+ const canonicalRoot = assertRealDirectory(root, "evaluator dependency graph repository root");
871
+ if (!baseRevision || !/^[a-f0-9]{40}$/u.test(baseRevision)) throw new Error("evaluator dependency graph base Git revision is invalid");
872
+ const entries = [...entryPaths].map((path) => assertPortableRelativePath(path, "evaluator dependency graph entry path")).sort();
873
+ if (new Set(entries).size !== entries.length) throw new Error("evaluator dependency graph entry paths contain duplicates");
874
+ const authorities = [...authorityPaths].map((path) => assertPortableRelativePath(path, "evaluator dependency graph authority path")).sort();
875
+ if (new Set(authorities).size !== authorities.length) throw new Error("evaluator dependency graph authority paths contain duplicates");
876
+ const nodePaths = new Set();
877
+ const edges = new Map();
878
+ const visit = (path) => {
879
+ if (nodePaths.has(path)) return;
880
+ nodePaths.add(path);
881
+ const absolute = resolveAuthorityArtifactPath(canonicalRoot, path, `evaluator dependency ${path}`);
882
+ const bytes = readFileSync(absolute);
883
+ const fileType = dependencyFileType(path, authorities);
884
+ const committed = checkedInBytesAtRevision(canonicalRoot, baseRevision, path);
885
+ if (!committed) throw new Error(`evaluator dependency base Git revision is unavailable at ${path}`);
886
+ if (committed.length !== bytes.length || rawByteDigest(committed) !== rawByteDigest(bytes)) throw new Error(`evaluator dependency bytes do not match the base Git revision at ${path}`);
887
+ if (fileType !== "json") {
888
+ for (const edge of parseLocalModuleEdges(canonicalRoot, path, bytes.toString("utf8"))) {
889
+ const edgeKey = stableCanonicalJson(edge);
890
+ edges.set(edgeKey, edge);
891
+ if (edge.kind !== "runtime_private_import") visit(edge.to);
892
+ }
893
+ }
894
+ };
895
+ for (const entry of entries) visit(entry);
896
+ for (const authorityPath of authorities) {
897
+ const eagerAuthorityRead = EVALUATOR_EAGER_AUTHORITY_READS.find(({ path }) => path === authorityPath);
898
+ // Historical entry closures do not acquire data obligations from readers
899
+ // that were never reachable in that evaluator's module graph.
900
+ if (eagerAuthorityRead && !nodePaths.has(eagerAuthorityRead.reader)) continue;
901
+ visit(authorityPath);
902
+ const owner = eagerAuthorityRead?.reader
903
+ ?? (authorityPath.includes("scoring-input") || authorityPath.includes("portfolio-" )
904
+ ? "scripts/ask-benchmark-scoring-contract.mjs"
905
+ : "scripts/ask-benchmark-evaluator-boundary.mjs");
906
+ const edge = { from: owner, to: authorityPath, kind: "authority_read", specifier: authorityPath, syntax_identity: ["authority_read", owner, authorityPath].join(":") };
907
+ edge.edge_digest = canonicalDigest(edge);
908
+ edges.set(stableCanonicalJson(edge), edge);
909
+ }
910
+ const privateEntries = [...privateEntryPaths].map((path) => assertPortableRelativePath(path, "private evaluator entry path")).sort();
911
+ if (new Set(privateEntries).size !== privateEntries.length) throw new Error("private evaluator entry paths contain duplicates");
912
+ if (privateEntries.length > 0) {
913
+ const privateRuntimeEdge = {
914
+ from: "scripts/ask-benchmark-private-evaluator-runner.mjs",
915
+ to: PRIVATE_EVALUATOR_VIRTUAL_PATH,
916
+ kind: "runtime_private_import",
917
+ specifier: "--verified-authority-payload",
918
+ syntax_identity: "runtime_private_import:scripts/ask-benchmark-private-evaluator-runner.mjs:verified-authority-payload",
919
+ };
920
+ privateRuntimeEdge.edge_digest = canonicalDigest(privateRuntimeEdge);
921
+ edges.set(stableCanonicalJson(privateRuntimeEdge), privateRuntimeEdge);
922
+ }
923
+ for (const path of privateEntries) {
924
+ if (!nodePaths.has(path)) throw new Error(`private evaluator entry is outside the dependency graph: ${path}`);
925
+ const edge = {
926
+ from: PRIVATE_EVALUATOR_VIRTUAL_PATH,
927
+ to: path,
928
+ kind: "private_entry_import",
929
+ specifier: path,
930
+ syntax_identity: ["private_entry_import", PRIVATE_EVALUATOR_VIRTUAL_PATH, path].join(":"),
931
+ };
932
+ edge.edge_digest = canonicalDigest(edge);
933
+ edges.set(stableCanonicalJson(edge), edge);
934
+ }
935
+ const casePaths = new Map();
936
+ for (const path of nodePaths) {
937
+ const folded = path.toLocaleLowerCase("en-US");
938
+ if (casePaths.has(folded) && casePaths.get(folded) !== path) throw new Error(`evaluator dependency graph contains a case collision: ${casePaths.get(folded)} / ${path}`);
939
+ casePaths.set(folded, path);
940
+ }
941
+ const nodeInventory = [...nodePaths].sort().map((path) => {
942
+ const bytes = readFileSync(resolve(canonicalRoot, path));
943
+ const committed = checkedInBytesAtRevision(canonicalRoot, baseRevision, path);
944
+ return {
945
+ path,
946
+ bytes: bytes.length,
947
+ sha256: rawByteDigest(bytes),
948
+ file_type: dependencyFileType(path, authorities),
949
+ base_git_revision_bytes: committed.length,
950
+ base_git_revision_sha256: rawByteDigest(committed),
951
+ };
952
+ });
953
+ const edgeInventory = [...edges.values()].sort((left, right) => stableCanonicalJson(left).localeCompare(stableCanonicalJson(right)));
954
+ const graph = { entry_paths: entries, node_inventory: nodeInventory, edge_inventory: edgeInventory };
955
+ return { ...graph, graph_digest: canonicalDigest(graph) };
956
+ }
957
+
958
+ export function validateEvaluatorSourceIdentity({ identity, root, expectedRevision = null, expectedGeneratorSourceDigest = null, label = "evaluator source identity" }) {
959
+ if (!identity || typeof identity !== "object" || !Array.isArray(identity.source_files) || identity.source_files.length === 0 || !identity.dependency_graph) throw new Error(`${label} is missing or empty`);
960
+ if (expectedRevision && identity.base_git_revision !== expectedRevision) throw new Error(`${label} base Git revision drift`);
961
+ if (expectedGeneratorSourceDigest && identity.generator_source_digest !== expectedGeneratorSourceDigest) throw new Error(`${label} generator source digest drift`);
962
+ const sourceFiles = identity.source_files.map((entry) => ({ path: assertPortableRelativePath(entry.path, `${label} source path`), bytes: entry.bytes, sha256: entry.sha256 }));
963
+ const sorted = [...sourceFiles].sort((left, right) => left.path.localeCompare(right.path));
964
+ if (stableCanonicalJson(sourceFiles) !== stableCanonicalJson(sorted)) throw new Error(`${label} source inventory is not deterministically ordered`);
965
+ if (new Set(sourceFiles.map(({ path }) => path)).size !== sourceFiles.length) throw new Error(`${label} source inventory contains duplicate paths`);
966
+ if (identity.source_tree_digest !== canonicalDigest(sourceFiles)) throw new Error(`${label} source-tree digest closure is invalid`);
967
+ for (const entry of sourceFiles) {
968
+ const path = resolveAuthorityArtifactPath(realpathSync(root), entry.path, `${label} source`);
969
+ const actual = streamingFileDigest(path, `${label} source ${entry.path}`);
970
+ if (actual.bytes !== entry.bytes || actual.digest !== entry.sha256) throw new Error(`${label} source bytes drift at ${entry.path}`);
971
+ const committed = checkedInBytesAtRevision(realpathSync(root), identity.base_git_revision, entry.path);
972
+ if (!committed) throw new Error(`${label} base Git revision or source path is unavailable at ${entry.path}`);
973
+ if (committed.length !== entry.bytes || rawByteDigest(committed) !== entry.sha256) throw new Error(`${label} source bytes do not match the immutable base Git revision at ${entry.path}`);
974
+ }
975
+ const graph = deriveEvaluatorDependencyGraph({ root, baseRevision: identity.base_git_revision });
976
+ if (stableCanonicalJson(identity.dependency_graph) !== stableCanonicalJson(graph)) throw new Error(`${label} dependency graph closure is invalid`);
977
+ const graphSourceFiles = graph.node_inventory.map(({ path, bytes, sha256 }) => ({ path, bytes, sha256 }));
978
+ if (stableCanonicalJson(sourceFiles) !== stableCanonicalJson(graphSourceFiles)) throw new Error(`${label} source inventory does not match the dependency graph`);
979
+ return structuredClone(identity);
980
+ }
981
+
982
+ function resolveAuthorityArtifactPath(authorityRoot, relativePath, label) {
983
+ assertPortableRelativePath(relativePath, `${label} path`);
984
+ const absolutePath = resolve(authorityRoot, relativePath);
985
+ if (!isInside(authorityRoot, absolutePath)) throw new Error(`${label} path escapes the authority root`);
986
+ let current = authorityRoot;
987
+ for (const segment of relativePath.split("/")) {
988
+ current = resolve(current, segment);
989
+ if (!existsSync(current)) throw new Error(`${label} is missing`);
990
+ if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} path must not traverse a symlink`);
991
+ }
992
+ if (!lstatSync(absolutePath).isFile()) throw new Error(`${label} must be a regular file`);
993
+ if (!isInside(authorityRoot, realpathSync(absolutePath))) throw new Error(`${label} path escapes the authority root`);
994
+ return absolutePath;
995
+ }
996
+
997
+ function authorityRelativePathForSupplied(authorityRoot, suppliedPath, label) {
998
+ if (!suppliedPath) throw new Error(`${label} path is required for scoring input authority closure`);
999
+ const relativePath = relative(authorityRoot, resolve(suppliedPath)).split(sep).join("/");
1000
+ assertPortableRelativePath(relativePath, `${label} path`);
1001
+ const authoritativePath = resolveAuthorityArtifactPath(authorityRoot, relativePath, label);
1002
+ if (resolve(suppliedPath) !== authoritativePath) throw new Error(`${label} supplied path does not match its authority path`);
1003
+ return { authoritativePath, relativePath };
1004
+ }
1005
+
1006
+ function readAnchoredFreezeManifest({ root, freezeManifestPath, freezeManifestSourceDigest }) {
1007
+ const authorityRoot = assertRealDirectory(root, "scoring input authority root");
1008
+ const { authoritativePath, relativePath } = authorityRelativePathForSupplied(authorityRoot, freezeManifestPath, "scoring input freeze manifest");
1009
+ const source = readJsonArtifact(authoritativePath, "scoring input freeze manifest", { publicArtifact: true });
1010
+ const sourceDigest = rawByteDigest(source.bytes);
1011
+ const committed = checkedInBytes(authorityRoot, relativePath);
1012
+ const matchesCheckedInBytes = committed !== null && Buffer.compare(source.bytes, committed) === 0;
1013
+ if (!matchesCheckedInBytes) {
1014
+ if (!/^sha256:[a-f0-9]{64}$/u.test(freezeManifestSourceDigest ?? "")) {
1015
+ throw new Error("scoring input freeze manifest requires checked-in bytes or an explicitly approved immutable source digest");
1016
+ }
1017
+ if (freezeManifestSourceDigest !== sourceDigest) throw new Error("scoring input freeze manifest raw-byte digest does not match the approved immutable source digest");
1018
+ }
1019
+ assertBenchmarkSchemaInstance(source.value, { schemaPath: resolve(root, SCORING_INPUT_FREEZE_MANIFEST_SCHEMA_PATH), label: "scoring input freeze manifest" });
1020
+ assertPublicArtifactTree(source.value, "scoring input freeze manifest");
1021
+ if (source.value.manifest_digest !== computeScoringInputFreezeManifestDigest(source.value)) throw new Error("scoring input freeze manifest digest closure is invalid");
1022
+ return { authorityRoot, manifest: source.value, manifestPath: authoritativePath, manifestRelativePath: relativePath, sourceDigest, source };
1023
+ }
1024
+
1025
+ function readFrozenJsonArtifact({ authorityRoot, root, reference, suppliedPath, schemaPath, label, publicArtifact = false }) {
1026
+ const authoritativePath = resolveAuthorityArtifactPath(authorityRoot, reference.path, label);
1027
+ if (!suppliedPath || resolve(suppliedPath) !== authoritativePath) throw new Error(`${label} supplied path does not match the freeze manifest authority path`);
1028
+ const source = readJsonArtifact(authoritativePath, label, { publicArtifact });
1029
+ if (rawByteDigest(source.bytes) !== reference.raw_byte_digest) throw new Error(`${label} raw-byte digest does not match the scoring input freeze manifest`);
1030
+ assertBenchmarkSchemaInstance(source.value, { schemaPath: resolve(root, schemaPath), label });
1031
+ if (publicArtifact) assertPublicArtifactTree(source.value, label);
1032
+ return { ...source, absolutePath: authoritativePath };
1033
+ }
1034
+
1035
+ export function readEvaluatorAuthorityAnchorFromFreeze({
1036
+ root,
1037
+ freezeManifestPath,
1038
+ freezeManifestSourceDigest = null,
1039
+ referencePath = null,
1040
+ label = "external evaluator freeze authority",
1041
+ } = {}) {
1042
+ const freeze = readAnchoredFreezeManifest({ root, freezeManifestPath, freezeManifestSourceDigest });
1043
+ const { authorityRoot, manifest: freezeManifest } = freeze;
1044
+ if (!freezeManifest.evaluator_authority_manifest) throw new Error(`${label} evaluator authority manifest reference is missing`);
1045
+ if (!freezeManifest.evaluator_public_reference) throw new Error(`${label} evaluator public reference is missing`);
1046
+ const evaluatorReferenceSource = readFrozenJsonArtifact({
1047
+ authorityRoot,
1048
+ root,
1049
+ reference: freezeManifest.evaluator_public_reference,
1050
+ suppliedPath: referencePath ?? resolve(authorityRoot, freezeManifest.evaluator_public_reference.path),
1051
+ schemaPath: EVALUATOR_REFERENCE_SCHEMA_PATH,
1052
+ label: `${label} evaluator public reference`,
1053
+ publicArtifact: true,
1054
+ });
1055
+ if (evaluatorReferenceSource.value.public_metadata_digest !== computeEvaluatorReferenceDigest(evaluatorReferenceSource.value) || freezeManifest.evaluator_public_reference.semantic_digest !== evaluatorReferenceSource.value.public_metadata_digest) throw new Error(`${label} evaluator public reference semantic closure is invalid`);
1056
+ const manifestReference = freezeManifest.evaluator_authority_manifest;
1057
+ const manifestSource = readFrozenJsonArtifact({
1058
+ authorityRoot,
1059
+ root,
1060
+ reference: manifestReference,
1061
+ suppliedPath: resolve(authorityRoot, manifestReference.path),
1062
+ schemaPath: EVALUATOR_AUTHORITY_MANIFEST_SCHEMA_PATH,
1063
+ label: `${label} evaluator authority manifest`,
1064
+ publicArtifact: true,
1065
+ });
1066
+ const buffers = new Map(manifestSource.value.file_inventory.map(({ path }) => {
1067
+ const absolute = resolveAuthorityArtifactPath(authorityRoot, path, `${label} evaluator authority binding ${path}`);
1068
+ return [path, Buffer.from(readStableFile(absolute, `${label} evaluator authority binding ${path}`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false }).bytes)];
1069
+ }));
1070
+ const anchor = buildVerifiedEvaluatorAuthorityAnchor({
1071
+ evaluatorRevision: evaluatorReferenceSource.value.evaluator_revision,
1072
+ evaluatorReference: evaluatorReferenceSource.value,
1073
+ manifestReference,
1074
+ manifestSource,
1075
+ buffers,
1076
+ root,
1077
+ label,
1078
+ });
1079
+ for (const [field, expected] of [
1080
+ ["evaluator_authority_manifest_path", anchor.evaluator_authority_manifest_path],
1081
+ ["evaluator_authority_manifest_raw_sha256", anchor.evaluator_authority_manifest_raw_sha256],
1082
+ ["evaluator_authority_manifest_digest", anchor.evaluator_authority_manifest_digest],
1083
+ ]) if (evaluatorReferenceSource.value[field] !== expected) throw new Error(`${label} evaluator public reference ${field} does not match the external freeze authority`);
1084
+ return anchor;
1085
+ }
1086
+
1087
+ function looksLikePrivatePathOrUri(value) {
1088
+ return posix.isAbsolute(value)
1089
+ || win32.isAbsolute(value)
1090
+ || /^(?:\\\\[?.]\\|[A-Za-z]:[\\/])/u.test(value)
1091
+ || value.includes("\\")
1092
+ || /^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(value);
1093
+ }
1094
+
1095
+ function assertPublicArtifactTree(value, label, path = "$", depth = 0) {
1096
+ if (depth > 12) throw new Error(`${label} exceeds the public structure depth limit`);
1097
+ if (typeof value === "string") {
1098
+ if (value.length > 256) throw new Error(`${label} contains oversized raw text at ${path}`);
1099
+ if (looksLikePrivatePathOrUri(value)) throw new Error(`${label} contains a private path or storage URI at ${path}`);
1100
+ return;
1101
+ }
1102
+ if (Array.isArray(value)) {
1103
+ for (let index = 0; index < value.length; index += 1) assertPublicArtifactTree(value[index], label, `${path}[${index}]`, depth + 1);
1104
+ return;
1105
+ }
1106
+ if (!value || typeof value !== "object") return;
1107
+ for (const [key, child] of Object.entries(value)) {
1108
+ if (PUBLIC_FORBIDDEN_FIELDS.has(key.toLowerCase())) throw new Error(`${label} contains prohibited answer-bearing or private field ${key}`);
1109
+ assertPublicArtifactTree(child, label, `${path}.${key}`, depth + 1);
1110
+ }
1111
+ }
1112
+
1113
+ function directoryFileInventory(root, label) {
1114
+ const files = new Map();
1115
+ function walk(directory) {
1116
+ for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
1117
+ const absolute = resolve(directory, entry.name);
1118
+ const path = relative(root, absolute).split(sep).join("/");
1119
+ if (entry.isSymbolicLink()) throw new Error(`${label} contains a symlink`);
1120
+ if (entry.isDirectory()) walk(absolute);
1121
+ else if (entry.isFile()) files.set(path, absolute);
1122
+ else throw new Error(`${label} contains a non-regular entry`);
1123
+ if (files.size > MAX_BOUNDARY_FILES) throw new Error(`${label} exceeds the boundary inspection file-count limit`);
1124
+ }
1125
+ }
1126
+ walk(root);
1127
+ return files;
1128
+ }
1129
+
1130
+ export function readStableWorkspaceInventory(root, label = "workspace authority") {
1131
+ const canonicalRoot = assertRealDirectory(root, `${label} root`);
1132
+ const rootBefore = lstatSync(canonicalRoot);
1133
+ const entries = [];
1134
+ const buffers = new Map();
1135
+ const inodePaths = new Map();
1136
+ const casePaths = new Map();
1137
+ const visit = (directory) => {
1138
+ const parentBefore = lstatSync(directory);
1139
+ if (!parentBefore.isDirectory() || parentBefore.isSymbolicLink()) throw new Error(`${label} contains an invalid directory`);
1140
+ const children = readdirSync(directory).sort((left, right) => left.localeCompare(right));
1141
+ for (const name of children) {
1142
+ const absolute = resolve(directory, name);
1143
+ const path = relative(canonicalRoot, absolute).split(sep).join("/");
1144
+ assertPortableRelativePath(path, `${label} path`);
1145
+ const folded = path.toLocaleLowerCase("en-US");
1146
+ if (casePaths.has(folded) && casePaths.get(folded) !== path) throw new Error(`${label} contains a case collision: ${casePaths.get(folded)} / ${path}`);
1147
+ casePaths.set(folded, path);
1148
+ const status = lstatSync(absolute);
1149
+ if (status.isSymbolicLink() || status.isFIFO() || status.isSocket() || status.isBlockDevice() || status.isCharacterDevice()) throw new Error(`${label} contains a prohibited filesystem entry: ${path}`);
1150
+ const mode = status.mode & 0o777;
1151
+ if (status.isDirectory()) {
1152
+ entries.push({ path, file_type: "directory", mode, dev: status.dev, ino: status.ino, nlink: status.nlink, mtimeMs: status.mtimeMs, ctimeMs: status.ctimeMs, bytes: null, sha256: null });
1153
+ visit(absolute);
1154
+ } else if (status.isFile()) {
1155
+ if (status.nlink > 1) throw new Error(`${label} contains an implicit hard-link authority: ${path}`);
1156
+ const stable = readStableFile(absolute, `${label} file ${path}`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: true });
1157
+ const final = lstatSync(absolute);
1158
+ if (final.dev !== status.dev || final.ino !== status.ino || final.mode !== status.mode || final.nlink !== status.nlink || final.mtimeMs !== status.mtimeMs || final.ctimeMs !== status.ctimeMs) throw new Error(`${label} file identity changed during inventory: ${path}`);
1159
+ buffers.set(path, Buffer.from(stable.bytes));
1160
+ entries.push({ path, file_type: "file", mode, dev: status.dev, ino: status.ino, nlink: status.nlink, mtimeMs: status.mtimeMs, ctimeMs: status.ctimeMs, bytes: stable.bytes.length, sha256: stable.rawByteDigest });
1161
+ const inodeKey = `${status.dev}:${status.ino}`;
1162
+ if (inodePaths.has(inodeKey)) throw new Error(`${label} contains hard-linked paths: ${inodePaths.get(inodeKey)} / ${path}`);
1163
+ inodePaths.set(inodeKey, path);
1164
+ } else throw new Error(`${label} contains a non-regular entry: ${path}`);
1165
+ if (entries.length > MAX_BOUNDARY_FILES) throw new Error(`${label} exceeds the boundary inspection file-count limit`);
1166
+ }
1167
+ const parentAfter = lstatSync(directory);
1168
+ if (parentAfter.dev !== parentBefore.dev || parentAfter.ino !== parentBefore.ino || parentAfter.mtimeMs !== parentBefore.mtimeMs || parentAfter.ctimeMs !== parentBefore.ctimeMs) throw new Error(`${label} parent directory changed during inventory`);
1169
+ };
1170
+ visit(canonicalRoot);
1171
+ const rootAfter = lstatSync(canonicalRoot);
1172
+ if (rootAfter.dev !== rootBefore.dev || rootAfter.ino !== rootBefore.ino || rootAfter.nlink !== rootBefore.nlink || rootAfter.mtimeMs !== rootBefore.mtimeMs || rootAfter.ctimeMs !== rootBefore.ctimeMs) throw new Error(`${label} root identity changed during inventory`);
1173
+ entries.sort((left, right) => left.path.localeCompare(right.path));
1174
+ const portableEntries = entries.map(({ path, file_type, mode, bytes, sha256 }) => ({ path, file_type, mode, bytes, sha256 }));
1175
+ const runtimeEntries = entries.map(({ path, file_type, mode, dev, ino, nlink, mtimeMs, ctimeMs, bytes, sha256 }) => ({ path, file_type, mode, dev, ino, nlink, mtimeMs, ctimeMs, bytes, sha256 }));
1176
+ return {
1177
+ root: canonicalRoot,
1178
+ entries,
1179
+ portableEntries,
1180
+ runtimeEntries,
1181
+ buffers,
1182
+ digest: canonicalDigest(portableEntries),
1183
+ runtimeDigest: canonicalDigest(runtimeEntries),
1184
+ rootIdentity: {
1185
+ dev: rootBefore.dev,
1186
+ ino: rootBefore.ino,
1187
+ nlink: rootBefore.nlink,
1188
+ mode: rootBefore.mode,
1189
+ mtimeMs: rootBefore.mtimeMs,
1190
+ ctimeMs: rootBefore.ctimeMs,
1191
+ },
1192
+ };
1193
+ }
1194
+
1195
+ function filesystemIdentity(status) {
1196
+ return {
1197
+ dev: status.dev,
1198
+ ino: status.ino,
1199
+ nlink: status.nlink,
1200
+ mode: status.mode,
1201
+ size: status.size,
1202
+ mtimeMs: status.mtimeMs,
1203
+ ctimeMs: status.ctimeMs,
1204
+ };
1205
+ }
1206
+
1207
+ function sameFilesystemIdentity(left, right) {
1208
+ return stableCanonicalJson(left) === stableCanonicalJson(right);
1209
+ }
1210
+
1211
+ function assertFreshPath(path, label) {
1212
+ try {
1213
+ lstatSync(path);
1214
+ throw new Error(`${label} already exists`);
1215
+ } catch (error) {
1216
+ if (error?.code !== "ENOENT") throw error;
1217
+ }
1218
+ }
1219
+
1220
+ function assertRealParentDirectory(path, label) {
1221
+ const parent = dirname(path);
1222
+ assertRealDirectory(parent, `${label} parent`);
1223
+ return parent;
1224
+ }
1225
+
1226
+ function sealedFileMode(path, executablePaths = SEALED_EXECUTABLE_PATHS) {
1227
+ return executablePaths.includes(path) ? SEALED_EXECUTABLE_FILE_MODE : SEALED_REGULAR_FILE_MODE;
1228
+ }
1229
+
1230
+ function expectedSealedPortableEntries(inventory, executablePaths, label) {
1231
+ const allowed = [...executablePaths].map((path) => assertPortableRelativePath(path, `${label} executable path`)).sort();
1232
+ if (new Set(allowed).size !== allowed.length) throw new Error(`${label} executable allowlist contains duplicates`);
1233
+ const filePaths = new Set(inventory.entries.filter(({ file_type }) => file_type === "file").map(({ path }) => path));
1234
+ for (const path of allowed) if (!filePaths.has(path)) throw new Error(`${label} executable allowlist contains a non-file path: ${path}`);
1235
+ return inventory.entries.map(({ path, file_type, bytes, sha256 }) => ({
1236
+ path,
1237
+ file_type,
1238
+ mode: file_type === "directory" ? SEALED_DIRECTORY_MODE : sealedFileMode(path, allowed),
1239
+ bytes,
1240
+ sha256,
1241
+ })).sort((left, right) => left.path.localeCompare(right.path));
1242
+ }
1243
+
1244
+ export function assertSealedSnapshotModes(inventory, { executablePaths = SEALED_EXECUTABLE_PATHS, label = "sealed snapshot" } = {}) {
1245
+ const allowed = new Set(executablePaths);
1246
+ if ((inventory.rootIdentity.mode & 0o777) !== SEALED_DIRECTORY_MODE) throw new Error(`${label} root directory mode is not sealed`);
1247
+ for (const entry of inventory.portableEntries) {
1248
+ if ((entry.mode & 0o222) !== 0) throw new Error(`${label} retains a write bit at ${entry.path}`);
1249
+ if (entry.file_type === "directory") {
1250
+ if (entry.mode !== SEALED_DIRECTORY_MODE) throw new Error(`${label} directory mode is not sealed at ${entry.path}`);
1251
+ continue;
1252
+ }
1253
+ const expected = allowed.has(entry.path) ? SEALED_EXECUTABLE_FILE_MODE : SEALED_REGULAR_FILE_MODE;
1254
+ if (entry.mode !== expected) throw new Error(`${label} file mode is not sealed at ${entry.path}`);
1255
+ if (!allowed.has(entry.path) && (entry.mode & 0o111) !== 0) throw new Error(`${label} contains an unexpected executable bit at ${entry.path}`);
1256
+ }
1257
+ return true;
1258
+ }
1259
+
1260
+ export function materializeSealedFile({ bytes, destination, label = "sealed file", mode = SEALED_REGULAR_FILE_MODE, allowEmpty = false } = {}) {
1261
+ if (!Buffer.isBuffer(bytes) || (!allowEmpty && bytes.length === 0)) throw new Error(`${label} requires ${allowEmpty ? "verified" : "non-empty verified"} bytes`);
1262
+ if (![SEALED_REGULAR_FILE_MODE, SEALED_EXECUTABLE_FILE_MODE].includes(mode)) throw new Error(`${label} mode is outside the closed sealed-file policy`);
1263
+ assertFreshPath(destination, label);
1264
+ const parent = assertRealParentDirectory(destination, label);
1265
+ let descriptor;
1266
+ try {
1267
+ descriptor = openSync(destination, fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL, 0o600);
1268
+ let offset = 0;
1269
+ while (offset < bytes.length) offset += writeSync(descriptor, bytes, offset, bytes.length - offset);
1270
+ fsyncSync(descriptor);
1271
+ } finally {
1272
+ if (descriptor !== undefined) closeSync(descriptor);
1273
+ }
1274
+ chmodSync(destination, mode & 0o777);
1275
+ try {
1276
+ const parentDescriptor = openSync(parent, fsConstants.O_RDONLY);
1277
+ try { fsyncSync(parentDescriptor); } finally { closeSync(parentDescriptor); }
1278
+ } catch {
1279
+ // Some filesystems do not allow fsync on directory descriptors. The file fsync above remains mandatory.
1280
+ }
1281
+ const verified = readStableFile(destination, label, MAX_BOUNDARY_FILE_BYTES, { allowEmpty });
1282
+ if (Buffer.compare(verified.bytes, bytes) !== 0) throw new Error(`${label} sealed bytes do not match the verified source`);
1283
+ if ((verified.evidence.finalPath.mode & 0o777) !== mode) throw new Error(`${label} sealed mode does not match the requested mode`);
1284
+ return {
1285
+ path: verified.path,
1286
+ bytes: verified.bytes.length,
1287
+ sha256: verified.rawByteDigest,
1288
+ identity: filesystemIdentity(verified.evidence.finalPath),
1289
+ };
1290
+ }
1291
+
1292
+ function comparePortableInventories(expected, actual, label) {
1293
+ if (stableCanonicalJson(expected.portableEntries) !== stableCanonicalJson(actual.portableEntries)) throw new Error(`${label} portable inventory does not match the verified source`);
1294
+ }
1295
+
1296
+ export function materializeSealedWorkspaceSnapshot({ inventory, destination, label = "sealed workspace snapshot", executablePaths = SEALED_EXECUTABLE_PATHS } = {}) {
1297
+ if (!inventory || !Array.isArray(inventory.entries) || !(inventory.buffers instanceof Map)) throw new Error(`${label} requires a verified workspace inventory`);
1298
+ const expectedPortableEntries = expectedSealedPortableEntries(inventory, executablePaths, label);
1299
+ assertFreshPath(destination, label);
1300
+ const parent = dirname(destination);
1301
+ assertRealDirectory(parent, `${label} parent`);
1302
+ mkdirSync(destination, 0o700);
1303
+ for (const entry of inventory.entries.filter(({ file_type }) => file_type === "directory").sort((left, right) => left.path.localeCompare(right.path))) {
1304
+ const directory = resolve(destination, entry.path);
1305
+ assertFreshPath(directory, `${label} directory ${entry.path}`);
1306
+ mkdirSync(directory, 0o700);
1307
+ }
1308
+ for (const entry of inventory.entries.filter(({ file_type }) => file_type === "file").sort((left, right) => left.path.localeCompare(right.path))) {
1309
+ const file = resolve(destination, entry.path);
1310
+ const content = inventory.buffers.get(entry.path);
1311
+ if (!content) throw new Error(`${label} verified bytes are missing for ${entry.path}`);
1312
+ materializeSealedFile({ bytes: content, destination: file, label: `${label} file ${entry.path}`, mode: sealedFileMode(entry.path, executablePaths), allowEmpty: true });
1313
+ }
1314
+ for (const entry of inventory.entries.filter(({ file_type }) => file_type === "directory").sort((left, right) => right.path.split("/").length - left.path.split("/").length || right.path.localeCompare(left.path))) chmodSync(resolve(destination, entry.path), SEALED_DIRECTORY_MODE);
1315
+ chmodSync(destination, SEALED_DIRECTORY_MODE);
1316
+ const sealedInventory = readStableWorkspaceInventory(destination, label);
1317
+ comparePortableInventories({ portableEntries: expectedPortableEntries }, sealedInventory, label);
1318
+ assertSealedSnapshotModes(sealedInventory, { executablePaths, label });
1319
+ return sealedInventory;
1320
+ }
1321
+
1322
+ function descriptorFileRecord(path, read, executablePaths = SEALED_EXECUTABLE_PATHS) {
1323
+ return {
1324
+ path,
1325
+ file_type: "file",
1326
+ mode: sealedFileMode(path, executablePaths),
1327
+ bytes: read.bytes.length,
1328
+ sha256: read.rawByteDigest,
1329
+ };
1330
+ }
1331
+
1332
+ function descriptorDirectoryEntries(filePaths) {
1333
+ const directories = new Map();
1334
+ for (const path of filePaths) {
1335
+ const segments = path.split("/");
1336
+ for (let index = 1; index < segments.length; index += 1) {
1337
+ const directory = segments.slice(0, index).join("/");
1338
+ directories.set(directory, {
1339
+ path: directory,
1340
+ file_type: "directory",
1341
+ mode: SEALED_DIRECTORY_MODE,
1342
+ bytes: null,
1343
+ sha256: null,
1344
+ });
1345
+ }
1346
+ }
1347
+ return [...directories.values()];
1348
+ }
1349
+
1350
+ function assertDescriptorInventoryClosed({ inventory, descriptorPath, label }) {
1351
+ const actual = inventory.portableEntries.filter(({ path }) => path !== descriptorPath);
1352
+ if (stableCanonicalJson(actual) !== stableCanonicalJson(inventory.expectedPortableEntries)) throw new Error(`${label} portable inventory drifted from the sealed descriptor authority`);
1353
+ const extra = inventory.portableEntries.filter(({ path }) => path !== descriptorPath && !inventory.expectedPathSet.has(path));
1354
+ if (extra.length > 0) throw new Error(`${label} contains an unmanaged authority path: ${extra[0].path}`);
1355
+ }
1356
+
1357
+ function assertSortedUniquePaths(entries, label) {
1358
+ if (!Array.isArray(entries)) throw new Error(`${label} must be an array`);
1359
+ const paths = entries.map(({ path }) => assertPortableRelativePath(path, `${label} path`));
1360
+ if (new Set(paths).size !== paths.length) throw new Error(`${label} contains duplicate paths`);
1361
+ if (stableCanonicalJson(paths) !== stableCanonicalJson([...paths].sort())) throw new Error(`${label} is not deterministically ordered`);
1362
+ return paths;
1363
+ }
1364
+
1365
+ function assertDescriptorModePolicy(descriptor, label) {
1366
+ const expected = {
1367
+ regular_file_mode: SEALED_REGULAR_FILE_MODE,
1368
+ executable_file_mode: SEALED_EXECUTABLE_FILE_MODE,
1369
+ directory_mode: SEALED_DIRECTORY_MODE,
1370
+ executable_paths: [...SEALED_EXECUTABLE_PATHS],
1371
+ };
1372
+ if (stableCanonicalJson(descriptor.sealed_mode_policy) !== stableCanonicalJson(expected)) throw new Error(`${label} sealed mode policy is invalid`);
1373
+ if (descriptor.execution_authority_transport !== "in_memory_byte_map_v1") throw new Error(`${label} execution authority transport is invalid`);
1374
+ }
1375
+
1376
+ export function validateSealedRepositoryAuthorityBytes({
1377
+ descriptor,
1378
+ buffers,
1379
+ actualInventory = null,
1380
+ expectedSourceGraphDigest = null,
1381
+ expectedEvaluatorRevision = null,
1382
+ rootForSchema = null,
1383
+ label = "sealed repository authority",
1384
+ } = {}) {
1385
+ if (!descriptor || typeof descriptor !== "object" || Array.isArray(descriptor)) throw new Error(`${label} descriptor is missing`);
1386
+ const { authority_digest: authorityDigest, ...descriptorBase } = descriptor;
1387
+ if (authorityDigest !== canonicalDigest(descriptorBase)) throw new Error(`${label} descriptor digest closure is invalid`);
1388
+ if (descriptor.schema_version !== "1.0.0" || descriptor.program !== "adaptive_ask_sealed_repository_authority") throw new Error(`${label} descriptor contract is invalid`);
1389
+ if (expectedEvaluatorRevision && descriptor.evaluator_revision !== expectedEvaluatorRevision) throw new Error(`${label} evaluator revision does not match immutable authority`);
1390
+ assertDescriptorModePolicy(descriptor, label);
1391
+
1392
+ const graph = descriptor.source_graph;
1393
+ if (!graph || typeof graph !== "object" || Array.isArray(graph)) throw new Error(`${label} source graph is missing`);
1394
+ const { graph_digest: graphDigest, ...graphBase } = graph;
1395
+ if (graphDigest !== canonicalDigest(graphBase) || descriptor.source_graph_digest !== graphDigest) throw new Error(`${label} source graph digest closure is invalid`);
1396
+ if (expectedSourceGraphDigest && graphDigest !== expectedSourceGraphDigest) throw new Error(`${label} source graph does not match immutable evaluator authority`);
1397
+ const graphPaths = assertSortedUniquePaths(graph.node_inventory, `${label} source graph node inventory`);
1398
+ const graphPathSet = new Set(graphPaths);
1399
+ const graphByPath = new Map(graph.node_inventory.map((entry) => [entry.path, entry]));
1400
+ const sortedEdges = [...(graph.edge_inventory ?? [])].sort((left, right) => stableCanonicalJson(left).localeCompare(stableCanonicalJson(right)));
1401
+ if (stableCanonicalJson(graph.edge_inventory) !== stableCanonicalJson(sortedEdges)) throw new Error(`${label} source graph edge inventory is not deterministically ordered`);
1402
+ for (const edge of graph.edge_inventory ?? []) {
1403
+ const { edge_digest: edgeDigest, ...edgeBase } = edge;
1404
+ if (edgeDigest !== canonicalDigest(edgeBase)) throw new Error(`${label} source graph edge digest is invalid`);
1405
+ const ordinary = ["static_import", "export_from", "dynamic_import", "authority_read"].includes(edge.kind) && graphPathSet.has(edge.from) && graphPathSet.has(edge.to);
1406
+ const privateRuntime = edge.kind === "runtime_private_import" && graphPathSet.has(edge.from) && edge.to === PRIVATE_EVALUATOR_VIRTUAL_PATH;
1407
+ const privateEntry = edge.kind === "private_entry_import" && edge.from === PRIVATE_EVALUATOR_VIRTUAL_PATH && graphPathSet.has(edge.to);
1408
+ if (!ordinary && !privateRuntime && !privateEntry) throw new Error(`${label} source graph edge escapes the closed module graph`);
1409
+ }
1410
+ for (const path of EVALUATOR_PRIVATE_ENTRY_PATHS) {
1411
+ if (!(graph.edge_inventory ?? []).some((edge) => edge.kind === "private_entry_import" && edge.from === PRIVATE_EVALUATOR_VIRTUAL_PATH && edge.to === path)) throw new Error(`${label} source graph is missing private entry edge ${path}`);
1412
+ }
1413
+
1414
+ const descriptorInventory = descriptor.inventory;
1415
+ const inventoryPaths = assertSortedUniquePaths(descriptorInventory, `${label} descriptor inventory`);
1416
+ const fileEntries = descriptorInventory.filter(({ file_type }) => file_type === "file");
1417
+ const directoryEntries = descriptorInventory.filter(({ file_type }) => file_type === "directory");
1418
+ if (fileEntries.length + directoryEntries.length !== descriptorInventory.length) throw new Error(`${label} descriptor inventory contains an invalid file type`);
1419
+ const fileByPath = new Map(fileEntries.map((entry) => [entry.path, entry]));
1420
+ const fixturePaths = (descriptor.fixture_authority ?? []).map(({ path }) => path);
1421
+ if (!(buffers instanceof Map)) throw new Error(`${label} requires a descriptor-stable verified byte map`);
1422
+ const manifestPath = assertPortableRelativePath(descriptor.evaluator_authority_manifest_path, `${label} evaluator authority manifest path`);
1423
+ const manifestBytes = buffers.get(manifestPath);
1424
+ const manifest = jsonValueFromVerifiedBytes(manifestBytes, `${label} evaluator authority manifest`);
1425
+ const expectedFixturePaths = evaluatorAuthorityPathsForFixture(manifest.fixture_id).fixturePaths;
1426
+ if (stableCanonicalJson(fixturePaths) !== stableCanonicalJson(expectedFixturePaths)) throw new Error(`${label} fixture authority path inventory is not closed`);
1427
+ if (descriptor.fixture_authority_digest !== canonicalDigest(descriptor.fixture_authority)) throw new Error(`${label} fixture authority digest closure is invalid`);
1428
+ if (stableCanonicalJson(descriptor.runtime_authority_paths) !== stableCanonicalJson(EVALUATOR_RUNTIME_AUTHORITY_PATHS)) throw new Error(`${label} runtime authority path inventory is not closed`);
1429
+ const expectedFilePaths = [...new Set([...graphPaths, ...fixturePaths, ...EVALUATOR_RUNTIME_AUTHORITY_PATHS])].sort();
1430
+ if (stableCanonicalJson(fileEntries.map(({ path }) => path)) !== stableCanonicalJson(expectedFilePaths)) throw new Error(`${label} graph, fixture, and file inventories are not exactly cross-bound`);
1431
+ const expectedDirectories = descriptorDirectoryEntries(expectedFilePaths).sort((left, right) => left.path.localeCompare(right.path));
1432
+ if (stableCanonicalJson(directoryEntries) !== stableCanonicalJson(expectedDirectories)) throw new Error(`${label} directory inventory is not exactly closed over authority files`);
1433
+ for (const entry of descriptorInventory) {
1434
+ if ((entry.mode & 0o222) !== 0) throw new Error(`${label} descriptor retains a write bit at ${entry.path}`);
1435
+ if (entry.file_type === "directory" && entry.mode !== SEALED_DIRECTORY_MODE) throw new Error(`${label} descriptor directory mode is invalid at ${entry.path}`);
1436
+ if (entry.file_type === "file") {
1437
+ const expectedMode = sealedFileMode(entry.path);
1438
+ if (entry.mode !== expectedMode) throw new Error(`${label} descriptor file mode is invalid at ${entry.path}`);
1439
+ if (!SEALED_EXECUTABLE_PATHS.includes(entry.path) && (entry.mode & 0o111) !== 0) throw new Error(`${label} descriptor contains an unexpected executable bit at ${entry.path}`);
1440
+ }
1441
+ }
1442
+ for (const node of graph.node_inventory) {
1443
+ const inventoryEntry = fileByPath.get(node.path);
1444
+ if (!inventoryEntry || inventoryEntry.file_type !== "file" || inventoryEntry.bytes !== node.bytes || inventoryEntry.sha256 !== node.sha256) throw new Error(`${label} source graph node is not cross-bound to executable bytes at ${node.path}`);
1445
+ // Explicit saved-processing graphs select their pinned schema pair. Recognizing these
1446
+ // existing authority-data types does not add paths to default/v1 graphs.
1447
+ const expectedType = dependencyFileType(node.path, [...EVALUATOR_AUTHORITY_PATHS, ...PRIMARY_PROCESSING_AUTHORITY_PATHS]);
1448
+ if (node.file_type !== expectedType) throw new Error(`${label} source graph file type is invalid at ${node.path}`);
1449
+ }
1450
+ for (const fixture of descriptor.fixture_authority) {
1451
+ const inventoryEntry = fileByPath.get(fixture.path);
1452
+ if (!inventoryEntry || stableCanonicalJson(fixture) !== stableCanonicalJson(inventoryEntry)) throw new Error(`${label} fixture authority is not cross-bound to sealed bytes at ${fixture.path}`);
1453
+ }
1454
+
1455
+ const expectedBufferPaths = [...expectedFilePaths, EVALUATOR_REPOSITORY_DESCRIPTOR_PATH].sort();
1456
+ if (stableCanonicalJson([...buffers.keys()].sort()) !== stableCanonicalJson(expectedBufferPaths)) throw new Error(`${label} verified byte map is not closed`);
1457
+ for (const entry of fileEntries) {
1458
+ const bytes = buffers.get(entry.path);
1459
+ if (!Buffer.isBuffer(bytes) || bytes.length !== entry.bytes || rawByteDigest(bytes) !== entry.sha256) throw new Error(`${label} verified bytes do not match the descriptor inventory at ${entry.path}`);
1460
+ }
1461
+ const descriptorBytes = buffers.get(EVALUATOR_REPOSITORY_DESCRIPTOR_PATH);
1462
+ if (!Buffer.isBuffer(descriptorBytes)) throw new Error(`${label} descriptor bytes are absent from the verified byte map`);
1463
+ const parsedDescriptor = jsonValueFromVerifiedBytes(descriptorBytes, `${label} descriptor bytes`);
1464
+ if (stableCanonicalJson(parsedDescriptor) !== stableCanonicalJson(descriptor)) throw new Error(`${label} parsed descriptor does not match the verified descriptor bytes`);
1465
+
1466
+ if (descriptor.evaluator_authority_manifest_raw_sha256 !== rawByteDigest(manifestBytes)) throw new Error(`${label} evaluator authority manifest raw binding is invalid`);
1467
+ if (descriptor.evaluator_authority_manifest_digest !== manifest.manifest_digest) throw new Error(`${label} evaluator authority manifest semantic binding is invalid`);
1468
+ validateEvaluatorAuthorityManifest({ manifest, buffers, evaluatorRevision: descriptor.evaluator_revision, root: rootForSchema, label: `${label} evaluator authority manifest` });
1469
+
1470
+ if (actualInventory) {
1471
+ const actualWithoutDescriptor = actualInventory.filter(({ path }) => path !== EVALUATOR_REPOSITORY_DESCRIPTOR_PATH);
1472
+ if (stableCanonicalJson(actualWithoutDescriptor) !== stableCanonicalJson(descriptorInventory)) throw new Error(`${label} actual inventory does not match the descriptor inventory`);
1473
+ const actualDescriptor = actualInventory.find(({ path }) => path === EVALUATOR_REPOSITORY_DESCRIPTOR_PATH);
1474
+ if (!actualDescriptor || actualDescriptor.file_type !== "file" || actualDescriptor.mode !== SEALED_REGULAR_FILE_MODE || actualDescriptor.bytes !== descriptorBytes.length || actualDescriptor.sha256 !== rawByteDigest(descriptorBytes)) throw new Error(`${label} descriptor file identity is invalid`);
1475
+ }
1476
+ return { descriptor: structuredClone(descriptor), graphByPath, fileByPath, manifest };
1477
+ }
1478
+
1479
+ function buildRepositoryAuthoritySource({ root, evaluatorRevision, externalAuthorityAnchor, label }) {
1480
+ const repositoryRoot = assertRealDirectory(root, `${label} source root`);
1481
+ const anchor = assertExternalEvaluatorAuthorityAnchor(externalAuthorityAnchor, label);
1482
+ if (anchor.evaluator_revision !== evaluatorRevision) throw new Error(`${label} evaluator revision does not match the external freeze authority`);
1483
+ const rootBefore = filesystemIdentity(lstatSync(repositoryRoot));
1484
+ const graph = deriveEvaluatorDependencyGraph({ root: repositoryRoot, baseRevision: evaluatorRevision });
1485
+ const graphPaths = graph.node_inventory.map(({ path }) => path);
1486
+ const fixturePaths = fixtureAuthorityPathsFromAnchor(anchor, label);
1487
+ const runtimePaths = [...EVALUATOR_RUNTIME_AUTHORITY_PATHS];
1488
+ const allPaths = [...new Set([...graphPaths, ...fixturePaths, ...runtimePaths])].sort();
1489
+ const pathSet = new Set(allPaths);
1490
+ const buffers = new Map();
1491
+ const records = new Map();
1492
+ for (const path of allPaths) {
1493
+ assertPortableRelativePath(path, `${label} source path`);
1494
+ const absolute = resolveAuthorityArtifactPath(repositoryRoot, path, `${label} source ${path}`);
1495
+ const read = readStableFile(absolute, `${label} source ${path}`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
1496
+ const graphNode = graph.node_inventory.find((node) => node.path === path);
1497
+ const fixtureAuthority = fixturePaths.includes(path);
1498
+ const committed = graphNode || fixtureAuthority ? checkedInBytesAtRevision(repositoryRoot, evaluatorRevision, path) : null;
1499
+ if ((graphNode || fixtureAuthority) && !committed) throw new Error(`${label} source authority path is absent from the immutable evaluator revision at ${path}`);
1500
+ if (graphNode && Buffer.compare(committed, read.bytes) !== 0) {
1501
+ throw new Error(`${label} source authority does not match the immutable evaluator revision at ${path}`);
1502
+ }
1503
+ if (fixtureAuthority && Buffer.compare(committed, read.bytes) !== 0) {
1504
+ const externalIdentity = externalAuthorityIdentityForPath(anchor, path);
1505
+ if (!externalIdentity || externalIdentity.bytes !== read.bytes.length || externalIdentity.raw_sha256 !== read.rawByteDigest) throw new Error(`${label} fixture authority does not match the immutable evaluator revision or external freeze authority at ${path}`);
1506
+ }
1507
+ if (graphNode && (graphNode.bytes !== read.bytes.length || graphNode.sha256 !== read.rawByteDigest)) throw new Error(`${label} dependency graph source identity drifted at ${path}`);
1508
+ buffers.set(path, Buffer.from(read.bytes));
1509
+ records.set(path, descriptorFileRecord(path, read));
1510
+ }
1511
+ if (pathSet.size !== buffers.size) throw new Error(`${label} source authority inventory contains duplicate paths`);
1512
+ const evaluatorAuthorityManifest = jsonValueFromVerifiedBytes(buffers.get(anchor.evaluator_authority_manifest_path), `${label} evaluator authority manifest`);
1513
+ validateEvaluatorAuthorityManifest({ manifest: evaluatorAuthorityManifest, buffers, evaluatorRevision, root: repositoryRoot, label: `${label} evaluator authority manifest` });
1514
+ const fileEntries = [...records.values()].sort((left, right) => left.path.localeCompare(right.path));
1515
+ const expectedPortableEntries = [...descriptorDirectoryEntries(allPaths), ...fileEntries].sort((left, right) => left.path.localeCompare(right.path));
1516
+ const fixtureEntries = fixturePaths.map((path) => records.get(path));
1517
+ const fixtureAuthorityDigest = canonicalDigest(fixtureEntries);
1518
+ const sourceRuntimeEntries = allPaths.map((path) => {
1519
+ const absolute = resolve(repositoryRoot, path);
1520
+ const status = lstatSync(absolute);
1521
+ return { path, file_type: "file", mode: status.mode & 0o777, dev: status.dev, ino: status.ino, nlink: status.nlink, mtimeMs: status.mtimeMs, ctimeMs: status.ctimeMs, bytes: status.size, sha256: records.get(path).sha256 };
1522
+ });
1523
+ const descriptorBase = {
1524
+ schema_version: "1.0.0",
1525
+ schema_path: "sealed-repository-authority-contract-v1",
1526
+ program: "adaptive_ask_sealed_repository_authority",
1527
+ evaluator_revision: evaluatorRevision,
1528
+ source_graph_digest: graph.graph_digest,
1529
+ source_graph: graph,
1530
+ fixture_authority_digest: fixtureAuthorityDigest,
1531
+ fixture_authority: fixtureEntries,
1532
+ evaluator_authority_manifest_path: anchor.evaluator_authority_manifest_path,
1533
+ evaluator_authority_manifest_raw_sha256: rawByteDigest(buffers.get(anchor.evaluator_authority_manifest_path)),
1534
+ evaluator_authority_manifest_digest: evaluatorAuthorityManifest.manifest_digest,
1535
+ runtime_authority_paths: runtimePaths,
1536
+ sealed_mode_policy: {
1537
+ regular_file_mode: SEALED_REGULAR_FILE_MODE,
1538
+ executable_file_mode: SEALED_EXECUTABLE_FILE_MODE,
1539
+ directory_mode: SEALED_DIRECTORY_MODE,
1540
+ executable_paths: [...SEALED_EXECUTABLE_PATHS],
1541
+ },
1542
+ execution_authority_transport: "in_memory_byte_map_v1",
1543
+ inventory: expectedPortableEntries,
1544
+ };
1545
+ const descriptor = { ...descriptorBase, authority_digest: canonicalDigest(descriptorBase) };
1546
+ const descriptorBytes = Buffer.from(`${JSON.stringify(descriptor, null, 2)}\n`);
1547
+ const externalVerificationBuffers = new Map(buffers);
1548
+ externalVerificationBuffers.set(EVALUATOR_REPOSITORY_DESCRIPTOR_PATH, descriptorBytes);
1549
+ verifySealedEvaluatorExternalAuthority({ descriptor, buffers: externalVerificationBuffers, externalAuthorityAnchor: anchor, label });
1550
+ const rootAfter = filesystemIdentity(lstatSync(repositoryRoot));
1551
+ if (!sameFilesystemIdentity(rootBefore, rootAfter)) throw new Error(`${label} source root identity changed while sealing repository authority`);
1552
+ const sourceInventory = {
1553
+ root: repositoryRoot,
1554
+ entries: expectedPortableEntries.map((entry) => ({ ...entry, dev: 0, ino: 1, nlink: 1, mtimeMs: 0, ctimeMs: 0 })),
1555
+ portableEntries: expectedPortableEntries,
1556
+ runtimeEntries: sourceRuntimeEntries,
1557
+ buffers,
1558
+ digest: canonicalDigest(expectedPortableEntries),
1559
+ runtimeDigest: canonicalDigest(sourceRuntimeEntries),
1560
+ rootIdentity: rootBefore,
1561
+ expectedPortableEntries,
1562
+ expectedPathSet: new Set(expectedPortableEntries.map(({ path }) => path)),
1563
+ };
1564
+ return { graph, fixtureEntries, fixtureAuthorityDigest, evaluatorAuthorityManifest, descriptor, descriptorBytes, sourceInventory };
1565
+ }
1566
+
1567
+ export function materializeSealedRepositorySnapshot({ authority, destination, label = "sealed repository authority" } = {}) {
1568
+ if (!authority?.sourceInventory || !Buffer.isBuffer(authority.descriptorBytes)) throw new Error(`${label} requires a verified repository authority descriptor`);
1569
+ const descriptorEntry = {
1570
+ path: EVALUATOR_REPOSITORY_DESCRIPTOR_PATH,
1571
+ file_type: "file",
1572
+ mode: SEALED_REGULAR_FILE_MODE,
1573
+ bytes: authority.descriptorBytes.length,
1574
+ sha256: rawByteDigest(authority.descriptorBytes),
1575
+ };
1576
+ const combinedEntries = [...authority.sourceInventory.entries, { ...descriptorEntry, dev: 0, ino: 1, nlink: 1, mtimeMs: 0, ctimeMs: 0 }].sort((left, right) => left.path.localeCompare(right.path));
1577
+ const combinedPortableEntries = [...authority.sourceInventory.portableEntries, descriptorEntry].sort((left, right) => left.path.localeCompare(right.path));
1578
+ const combinedBuffers = new Map(authority.sourceInventory.buffers);
1579
+ combinedBuffers.set(EVALUATOR_REPOSITORY_DESCRIPTOR_PATH, Buffer.from(authority.descriptorBytes));
1580
+ const combinedInventory = { ...authority.sourceInventory, entries: combinedEntries, portableEntries: combinedPortableEntries, buffers: combinedBuffers };
1581
+ const sealed = materializeSealedWorkspaceSnapshot({ inventory: combinedInventory, destination, label: `${label} sealed snapshot` });
1582
+ const descriptorPath = resolve(destination, EVALUATOR_REPOSITORY_DESCRIPTOR_PATH);
1583
+ const descriptorRead = readStableFile(descriptorPath, `${label} descriptor`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
1584
+ sealed.expectedPortableEntries = authority.sourceInventory.portableEntries;
1585
+ sealed.expectedPathSet = authority.sourceInventory.expectedPathSet;
1586
+ assertDescriptorInventoryClosed({ inventory: sealed, descriptorPath: EVALUATOR_REPOSITORY_DESCRIPTOR_PATH, label });
1587
+ if (sealed.portableEntries.length !== authority.sourceInventory.portableEntries.length + 1) throw new Error(`${label} contains an unexpected sealed repository entry`);
1588
+ validateSealedRepositoryAuthorityBytes({ descriptor: authority.descriptor, buffers: sealed.buffers, actualInventory: sealed.portableEntries, expectedSourceGraphDigest: authority.graph.graph_digest, expectedEvaluatorRevision: authority.descriptor.evaluator_revision, rootForSchema: null, label });
1589
+ return {
1590
+ ...sealedSnapshotBinding(sealed),
1591
+ path: sealed.root,
1592
+ descriptorPath: descriptorRead.path,
1593
+ descriptorRelativePath: EVALUATOR_REPOSITORY_DESCRIPTOR_PATH,
1594
+ descriptorBytes: descriptorRead.bytes.length,
1595
+ descriptorSha256: descriptorRead.rawByteDigest,
1596
+ base: sealed,
1597
+ sealed,
1598
+ sourceGraphDigest: authority.graph.graph_digest,
1599
+ fixtureAuthorityDigest: authority.fixtureAuthorityDigest,
1600
+ evaluatorAuthorityManifestRawSha256: authority.descriptor.evaluator_authority_manifest_raw_sha256,
1601
+ evaluatorAuthorityManifestDigest: authority.descriptor.evaluator_authority_manifest_digest,
1602
+ authorityDigest: authority.descriptor.authority_digest,
1603
+ };
1604
+ }
1605
+
1606
+ function readSealedRepositoryDescriptor(root, label = "sealed repository authority", { expectedSourceGraphDigest = null, expectedEvaluatorRevision = null, rootForSchema = null } = {}) {
1607
+ const repositoryRoot = assertRealDirectory(root, `${label} root`);
1608
+ const descriptorPath = resolveAuthorityArtifactPath(repositoryRoot, EVALUATOR_REPOSITORY_DESCRIPTOR_PATH, `${label} descriptor`);
1609
+ const descriptorRead = readJsonArtifact(descriptorPath, `${label} descriptor`);
1610
+ const inventory = readStableWorkspaceInventory(repositoryRoot, `${label} inventory`);
1611
+ inventory.expectedPortableEntries = descriptorRead.value.inventory;
1612
+ inventory.expectedPathSet = new Set(descriptorRead.value.inventory.map(({ path }) => path));
1613
+ assertDescriptorInventoryClosed({ inventory, descriptorPath: EVALUATOR_REPOSITORY_DESCRIPTOR_PATH, label });
1614
+ assertSealedSnapshotModes(inventory, { label });
1615
+ validateSealedRepositoryAuthorityBytes({ descriptor: descriptorRead.value, buffers: inventory.buffers, actualInventory: inventory.portableEntries, expectedSourceGraphDigest, expectedEvaluatorRevision, rootForSchema, label });
1616
+ return { repositoryRoot, descriptorPath, descriptorRead, descriptor: descriptorRead.value, inventory };
1617
+ }
1618
+
1619
+ function runtimeIdentityFromStableRead(read) {
1620
+ return filesystemIdentity(read.evidence.finalPath);
1621
+ }
1622
+
1623
+ function assertRuntimeIdentityBinding(actual, expected, label) {
1624
+ if (!expected || !sameFilesystemIdentity(actual, expected)) throw new Error(`${label} runtime identity binding is invalid`);
1625
+ }
1626
+
1627
+ function assertWorkspaceRuntimeBinding(actual, expected, label) {
1628
+ if (!expected || actual.digest !== expected.portable_digest || actual.runtimeDigest !== expected.runtime_digest || !sameFilesystemIdentity(actual.rootIdentity, expected.root)) throw new Error(`${label} sealed snapshot identity binding is invalid`);
1629
+ }
1630
+
1631
+ function sealedSnapshotBinding(inventory) {
1632
+ return {
1633
+ portable_digest: inventory.digest,
1634
+ runtime_digest: inventory.runtimeDigest,
1635
+ root: inventory.rootIdentity,
1636
+ };
1637
+ }
1638
+
1639
+ function workspaceDiffEntries(frozenEntries, candidateEntries) {
1640
+ const frozen = new Map(frozenEntries.map((entry) => [entry.path, entry]));
1641
+ const candidate = new Map(candidateEntries.map((entry) => [entry.path, entry]));
1642
+ return [...new Set([...frozen.keys(), ...candidate.keys()])].sort().flatMap((path) => {
1643
+ const before = frozen.get(path) ?? null;
1644
+ const after = candidate.get(path) ?? null;
1645
+ if (!before) return [{ path, change_type: "addition", before, after }];
1646
+ if (!after) return [{ path, change_type: "deletion", before, after }];
1647
+ if (stableCanonicalJson(before) !== stableCanonicalJson(after)) return [{ path, change_type: "modification", before, after }];
1648
+ return [];
1649
+ });
1650
+ }
1651
+
1652
+ const VERIFIED_TERMINAL_CANDIDATE_AUTHORITY_FIELDS = Object.freeze([
1653
+ "kind", "source_snapshot_digest", "normalized_result_id", "normalized_result_digest", "run_instance_id", "case_id", "attempt", "adapter", "condition", "fixture_id", "fixture_input_digest", "materialization_manifest_digest", "request_digest", "raw_result_digest", "terminal_commit_digest", "terminal_case_state_digest", "terminal_workspace_authority_digest", "terminal_workspace_authority_raw_sha256", "terminal_workspace_authority_bytes", "terminal_workspace_authority_base64", "terminal_candidate_tree_digest", "reconstructed_candidate_portable_digest", "candidate_authority_portable_digest",
1654
+ ]);
1655
+
1656
+ function validateCandidateAuthorityBinding(candidateAuthority, candidate, lineage, label) {
1657
+ if (candidateAuthority?.kind === "direct_test_workspace") {
1658
+ if (stableCanonicalJson(candidateAuthority) !== stableCanonicalJson({ kind: "direct_test_workspace" })) throw new Error(`${label} direct workspace authority is test-only and must not carry production assertions`);
1659
+ return structuredClone(candidateAuthority);
1660
+ }
1661
+ if (candidateAuthority?.kind !== "verified_terminal_candidate") throw new Error(`${label} candidate authority kind is invalid`);
1662
+ const keys = Object.keys(candidateAuthority).sort();
1663
+ const expectedKeys = [...VERIFIED_TERMINAL_CANDIDATE_AUTHORITY_FIELDS].sort();
1664
+ if (stableCanonicalJson(keys) !== stableCanonicalJson(expectedKeys)) throw new Error(`${label} verified terminal candidate authority is incomplete`);
1665
+ if (candidateAuthority.run_instance_id !== lineage.run_instance_id || candidateAuthority.case_id !== lineage.case_id || candidateAuthority.attempt !== lineage.attempt) throw new Error(`${label} verified terminal candidate lineage is inconsistent`);
1666
+ if (candidateAuthority.candidate_authority_portable_digest !== candidate.digest) throw new Error(`${label} candidate authority portable digest is inconsistent`);
1667
+ const bytes = Buffer.from(candidateAuthority.terminal_workspace_authority_base64, "base64");
1668
+ if (bytes.length !== candidateAuthority.terminal_workspace_authority_bytes || bytes.toString("base64") !== candidateAuthority.terminal_workspace_authority_base64 || rawByteDigest(bytes) !== candidateAuthority.terminal_workspace_authority_raw_sha256) throw new Error(`${label} terminal workspace authority byte binding is invalid`);
1669
+ let terminalAuthority;
1670
+ try { terminalAuthority = JSON.parse(bytes.toString("utf8")); }
1671
+ catch { throw new Error(`${label} terminal workspace authority bytes are invalid JSON`); }
1672
+ for (const [field, value] of Object.entries({
1673
+ run_instance_id: candidateAuthority.run_instance_id,
1674
+ case_id: candidateAuthority.case_id,
1675
+ attempt: candidateAuthority.attempt,
1676
+ adapter: candidateAuthority.adapter,
1677
+ condition: candidateAuthority.condition,
1678
+ fixture_id: candidateAuthority.fixture_id,
1679
+ fixture_input_digest: candidateAuthority.fixture_input_digest,
1680
+ materialization_manifest_digest: candidateAuthority.materialization_manifest_digest,
1681
+ authority_digest: candidateAuthority.terminal_workspace_authority_digest,
1682
+ authority_bytes: candidateAuthority.terminal_workspace_authority_bytes,
1683
+ terminal_candidate_tree_digest: candidateAuthority.terminal_candidate_tree_digest,
1684
+ })) if (terminalAuthority[field] !== value) throw new Error(`${label} terminal workspace authority ${field} binding is inconsistent`);
1685
+ return structuredClone(candidateAuthority);
1686
+ }
1687
+
1688
+ function buildOriginalWorkspaceAuthority({ frozen, candidate, lineage, candidateAuthority = { kind: "direct_test_workspace" } }) {
1689
+ if (!lineage?.run_instance_id || !lineage?.case_id || !lineage?.attempt) throw new Error("original workspace authority requires closed evaluation lineage");
1690
+ const closedCandidateAuthority = validateCandidateAuthorityBinding(candidateAuthority, candidate, lineage, "original workspace authority");
1691
+ const diffEntries = workspaceDiffEntries(frozen.portableEntries, candidate.portableEntries);
1692
+ const repositoryDiffClosure = {
1693
+ schema_version: "1.0.0",
1694
+ schema_path: REPOSITORY_DIFF_ARTIFACT_SCHEMA_PATH,
1695
+ program: "adaptive_ask_repository_diff_artifact",
1696
+ run_instance_id: lineage.run_instance_id,
1697
+ case_id: lineage.case_id,
1698
+ attempt: lineage.attempt,
1699
+ frozen_workspace_tree_digest: frozen.digest,
1700
+ candidate_workspace_tree_digest: candidate.digest,
1701
+ candidate_authority: closedCandidateAuthority,
1702
+ diff_entries: diffEntries,
1703
+ };
1704
+ const repositoryDiffArtifact = {
1705
+ ...repositoryDiffClosure,
1706
+ artifact_digest: canonicalDigest(diffEntries),
1707
+ artifact_bytes: Buffer.byteLength(stableCanonicalJson(diffEntries)) || 1,
1708
+ };
1709
+ const closure = {
1710
+ schema_version: "1.0.0",
1711
+ schema_path: ORIGINAL_WORKSPACE_AUTHORITY_SCHEMA_PATH,
1712
+ program: "adaptive_ask_original_workspace_authority",
1713
+ frozen_workspace_portable_digest: frozen.digest,
1714
+ candidate_workspace_portable_digest: candidate.digest,
1715
+ candidate_authority: closedCandidateAuthority,
1716
+ frozen_inventory: frozen.portableEntries,
1717
+ candidate_inventory: candidate.portableEntries,
1718
+ diff_entries: diffEntries,
1719
+ repository_diff_artifact: {
1720
+ path: SEALED_REPOSITORY_DIFF_ARTIFACT_PATH,
1721
+ digest: repositoryDiffArtifact.artifact_digest,
1722
+ bytes: repositoryDiffArtifact.artifact_bytes,
1723
+ },
1724
+ };
1725
+ return {
1726
+ authority: {
1727
+ ...closure,
1728
+ authority_digest: canonicalDigest(closure),
1729
+ authority_bytes: Buffer.byteLength(stableCanonicalJson(closure)) || 1,
1730
+ },
1731
+ repositoryDiffArtifact,
1732
+ };
1733
+ }
1734
+
1735
+ function privateOriginalWorkspaceSnapshot(frozen, candidate, lineage, candidateAuthority) {
1736
+ const snapshot = (inventory) => ({
1737
+ portableEntries: structuredClone(inventory.portableEntries),
1738
+ digest: inventory.digest,
1739
+ buffers: new Map([...inventory.buffers].map(([path, bytes]) => [path, Buffer.from(bytes)])),
1740
+ });
1741
+ return { frozen: snapshot(frozen), candidate: snapshot(candidate), lineage: structuredClone(lineage), candidateAuthority: structuredClone(candidateAuthority) };
1742
+ }
1743
+
1744
+ function materializeOriginalWorkspaceAuthority({ executionRoot, frozen, candidate, lineage, candidateAuthority, label }) {
1745
+ const values = buildOriginalWorkspaceAuthority({ frozen, candidate, lineage, candidateAuthority });
1746
+ const destination = resolve(executionRoot, "original-workspace-authority");
1747
+ assertFreshPath(destination, `${label} original workspace authority root`);
1748
+ mkdirSync(destination, 0o700);
1749
+ for (const [path, value] of [
1750
+ [ORIGINAL_WORKSPACE_AUTHORITY_PATH, values.authority],
1751
+ [SEALED_REPOSITORY_DIFF_ARTIFACT_PATH, values.repositoryDiffArtifact],
1752
+ ]) materializeSealedFile({
1753
+ bytes: Buffer.from(`${AUTHORITY_JSON_STRINGIFY(value, null, 2)}\n`),
1754
+ destination: resolve(destination, path),
1755
+ label: `${label} ${path}`,
1756
+ allowEmpty: false,
1757
+ });
1758
+ chmodSync(destination, SEALED_DIRECTORY_MODE);
1759
+ const inventory = readStableWorkspaceInventory(destination, `${label} original workspace authority`);
1760
+ assertSealedSnapshotModes(inventory, { label: `${label} original workspace authority` });
1761
+ return { ...values, inventory };
1762
+ }
1763
+
1764
+ function validateOriginalWorkspaceAuthority({ inventory, frozen, candidate, lineage, candidateAuthority, root, label, originalSource = null }) {
1765
+ assertSealedSnapshotModes(inventory, { label: `${label} original workspace authority` });
1766
+ const paths = inventory.portableEntries.map(({ path }) => path);
1767
+ if (stableCanonicalJson(paths) !== stableCanonicalJson([ORIGINAL_WORKSPACE_AUTHORITY_PATH, SEALED_REPOSITORY_DIFF_ARTIFACT_PATH])) throw new Error(`${label} original workspace authority inventory is not closed`);
1768
+ const authorityBytes = inventory.buffers.get(ORIGINAL_WORKSPACE_AUTHORITY_PATH);
1769
+ const repositoryDiffBytes = inventory.buffers.get(SEALED_REPOSITORY_DIFF_ARTIFACT_PATH);
1770
+ if (!authorityBytes || !repositoryDiffBytes) throw new Error(`${label} original workspace authority bytes are incomplete`);
1771
+ const authority = jsonValueFromVerifiedBytes(authorityBytes, `${label} original workspace authority`);
1772
+ const repositoryDiffArtifact = jsonValueFromVerifiedBytes(repositoryDiffBytes, `${label} repository diff artifact`);
1773
+ assertBenchmarkSchemaInstance(authority, { schemaPath: resolve(root, ORIGINAL_WORKSPACE_AUTHORITY_SCHEMA_PATH), label: `${label} original workspace authority` });
1774
+ assertBenchmarkSchemaInstance(repositoryDiffArtifact, { schemaPath: resolve(root, REPOSITORY_DIFF_ARTIFACT_SCHEMA_PATH), label: `${label} repository diff artifact` });
1775
+ const { authority_digest: authorityDigest, authority_bytes: authorityByteCount, ...closure } = authority;
1776
+ if (authorityDigest !== canonicalDigest(closure) || authorityByteCount !== (Buffer.byteLength(stableCanonicalJson(closure)) || 1)) throw new Error(`${label} original workspace authority digest or byte closure is invalid`);
1777
+ for (const [entries, expected, kind] of [[authority.frozen_inventory, frozen, "frozen"], [authority.candidate_inventory, candidate, "candidate"]]) {
1778
+ assertSortedUniquePaths(entries, `${label} original ${kind} inventory`);
1779
+ if (canonicalDigest(entries) !== authority[`${kind}_workspace_portable_digest`]) throw new Error(`${label} original ${kind} portable digest is invalid`);
1780
+ if (stableCanonicalJson(entries.map(({ path, file_type, bytes, sha256 }) => ({ path, file_type, bytes, sha256 }))) !== stableCanonicalJson(expected.portableEntries.map(({ path, file_type, bytes, sha256 }) => ({ path, file_type, bytes, sha256 })))) throw new Error(`${label} original ${kind} bytes or file types do not match the sealed workspace`);
1781
+ for (const entry of expected.portableEntries) {
1782
+ const sealedMode = entry.file_type === "file" ? SEALED_REGULAR_FILE_MODE : SEALED_DIRECTORY_MODE;
1783
+ if (entry.mode !== sealedMode) throw new Error(`${label} sealed ${kind} execution mode is invalid`);
1784
+ }
1785
+ }
1786
+ const expected = buildOriginalWorkspaceAuthority({
1787
+ frozen: { portableEntries: authority.frozen_inventory, digest: authority.frozen_workspace_portable_digest },
1788
+ candidate: { portableEntries: authority.candidate_inventory, digest: authority.candidate_workspace_portable_digest },
1789
+ lineage,
1790
+ candidateAuthority,
1791
+ });
1792
+ if (stableCanonicalJson(authority) !== stableCanonicalJson(expected.authority) || stableCanonicalJson(repositoryDiffArtifact) !== stableCanonicalJson(expected.repositoryDiffArtifact)) throw new Error(`${label} original workspace authority or repository diff artifact is stale`);
1793
+ if (originalSource) {
1794
+ if (stableCanonicalJson(originalSource.lineage) !== stableCanonicalJson(lineage) || stableCanonicalJson(originalSource.candidateAuthority) !== stableCanonicalJson(candidateAuthority) || stableCanonicalJson(authority.frozen_inventory) !== stableCanonicalJson(originalSource.frozen.portableEntries) || stableCanonicalJson(authority.candidate_inventory) !== stableCanonicalJson(originalSource.candidate.portableEntries) || authority.frozen_workspace_portable_digest !== originalSource.frozen.digest || authority.candidate_workspace_portable_digest !== originalSource.candidate.digest) throw new Error(`${label} original workspace authority is detached from module-owned source metadata`);
1795
+ for (const [kind, source, sealed] of [["frozen", originalSource.frozen, frozen], ["candidate", originalSource.candidate, candidate]]) for (const [path, bytes] of source.buffers) {
1796
+ const sealedBytes = sealed.buffers.get(path);
1797
+ if (!sealedBytes || Buffer.compare(bytes, sealedBytes) !== 0) throw new Error(`${label} original ${kind} bytes are detached from sealed content: ${path}`);
1798
+ }
1799
+ }
1800
+ if (authority.repository_diff_artifact.digest !== repositoryDiffArtifact.artifact_digest || authority.repository_diff_artifact.bytes !== repositoryDiffArtifact.artifact_bytes) throw new Error(`${label} repository diff artifact is detached from original workspace authority`);
1801
+ return { authority, authorityBytes, repositoryDiffArtifact, repositoryDiffBytes };
1802
+ }
1803
+
1804
+ function relativeAuthorityPath(root, path, label) {
1805
+ const value = relative(root, path).split(sep).join("/");
1806
+ assertPortableRelativePath(value, `${label} relative path`);
1807
+ if (!isInside(root, path)) throw new Error(`${label} escapes its authority root`);
1808
+ return value;
1809
+ }
1810
+
1811
+ function assertSourceBytesAtRevision(root, revision, relativePath, bytes, label) {
1812
+ const committed = checkedInBytesAtRevision(root, revision, relativePath);
1813
+ if (!committed || Buffer.compare(committed, bytes) !== 0) throw new Error(`${label} does not match the immutable base Git revision`);
1814
+ return { bytes: committed.length, sha256: rawByteDigest(committed) };
1815
+ }
1816
+
1817
+ function validatePrivateBundleByteMap({ inventory, evaluatorRevision, hiddenAsset, externalAuthorityAnchor, root, label }) {
1818
+ if (!inventory || !(inventory.buffers instanceof Map)) throw new Error(`${label} private bundle byte map is missing`);
1819
+ const manifestPath = "private-evaluator-bundle.json";
1820
+ const manifestBytes = inventory.buffers.get(manifestPath);
1821
+ if (!Buffer.isBuffer(manifestBytes)) throw new Error(`${label} private bundle manifest is missing`);
1822
+ const manifest = jsonValueFromVerifiedBytes(manifestBytes, `${label} private bundle manifest`);
1823
+ assertBenchmarkSchemaInstance(manifest, { schemaPath: resolve(root, PRIVATE_EVALUATOR_BUNDLE_SCHEMA_PATH), label: `${label} private bundle manifest` });
1824
+ const sortedAssets = [...manifest.asset_inventory].sort((left, right) => left.role.localeCompare(right.role) || left.path.localeCompare(right.path));
1825
+ if (stableCanonicalJson(manifest.asset_inventory) !== stableCanonicalJson(sortedAssets)) throw new Error(`${label} private bundle asset inventory is not deterministically ordered`);
1826
+ assertUniqueValues(manifest.asset_inventory.map(({ role }) => role), `${label} private bundle asset roles`);
1827
+ assertUniqueValues(manifest.asset_inventory.map(({ path }) => path), `${label} private bundle asset paths`);
1828
+ const expectedPaths = [manifestPath, ...manifest.asset_inventory.map(({ path }) => path)].sort();
1829
+ const actualPaths = inventory.portableEntries.filter(({ file_type }) => file_type === "file").map(({ path }) => path).sort();
1830
+ if (stableCanonicalJson(actualPaths) !== stableCanonicalJson(expectedPaths)) throw new Error(`${label} private bundle byte-map inventory is not closed`);
1831
+ for (const asset of manifest.asset_inventory) {
1832
+ const bytes = inventory.buffers.get(asset.path);
1833
+ if (!Buffer.isBuffer(bytes) || bytes.length !== asset.bytes || rawByteDigest(bytes) !== asset.sha256) throw new Error(`${label} private bundle asset bytes are inconsistent for ${asset.role}`);
1834
+ }
1835
+ if (manifest.evaluator_revision !== evaluatorRevision || manifest.evaluator_bundle_id !== computeEvaluatorBundleId(manifest) || manifest.evaluator_bundle_digest !== computeEvaluatorBundleDigest(manifest)) throw new Error(`${label} private bundle identity closure is invalid`);
1836
+ const reference = assertExternalEvaluatorAuthorityAnchor(externalAuthorityAnchor, label).evaluator_reference;
1837
+ if (manifest.evaluator_bundle_id !== reference.evaluator_bundle_id || manifest.evaluator_bundle_digest !== reference.evaluator_bundle_digest || manifest.evaluator_revision !== reference.evaluator_revision || stableCanonicalJson(manifest.evaluator_source_identity) !== stableCanonicalJson(reference.evaluator_source_identity) || stableCanonicalJson(manifest.dependency_graph) !== stableCanonicalJson(reference.evaluator_source_identity.dependency_graph)) throw new Error(`${label} private bundle does not match the external evaluator public reference`);
1838
+ const manifestHiddenAsset = manifest.asset_inventory.find(({ role }) => role === "hidden_tests");
1839
+ if (!manifestHiddenAsset || (hiddenAsset && stableCanonicalJson({ path: hiddenAsset.path, bytes: hiddenAsset.bytes, sha256: hiddenAsset.sha256 }) !== stableCanonicalJson({ path: manifestHiddenAsset.path, bytes: manifestHiddenAsset.bytes, sha256: manifestHiddenAsset.sha256 }))) throw new Error(`${label} hidden evaluator manifest authority is inconsistent`);
1840
+ return { manifest, manifestPath, manifestBytes, hiddenAsset: manifestHiddenAsset };
1841
+ }
1842
+
1843
+ function createSealedEvaluatorExecutionFromWorkspaceSources({
1844
+ root,
1845
+ privateEvaluationRoot,
1846
+ privateRoot,
1847
+ hiddenAsset,
1848
+ frozenWorkspace,
1849
+ candidateWorkspace,
1850
+ evaluationInputRoot,
1851
+ evaluationLineage,
1852
+ candidateAuthority = { kind: "direct_test_workspace" },
1853
+ runtimeObservationAuthority = null,
1854
+ evaluatorRevision,
1855
+ externalAuthorityAnchor,
1856
+ executionDirectoryName = "sealed-execution",
1857
+ label = "private evaluator sealed execution",
1858
+ } = {}) {
1859
+ const evaluationRoot = assertRealDirectory(privateEvaluationRoot, `${label} authority root`);
1860
+ const staticRoot = assertRealDirectory(privateRoot, `${label} static bundle root`);
1861
+ const anchor = assertExternalEvaluatorAuthorityAnchor(externalAuthorityAnchor, label);
1862
+ if (pathsOverlap(evaluationRoot, staticRoot)) throw new Error(`${label} authority root overlaps the static evaluator bundle`);
1863
+ if (!hiddenAsset?.path || !/^[a-f0-9]{40}$/u.test(evaluatorRevision ?? "")) throw new Error(`${label} hidden asset or evaluator revision is invalid`);
1864
+ const hiddenPath = resolveAuthorityArtifactPath(staticRoot, hiddenAsset.path, `${label} hidden evaluator`);
1865
+ const hiddenRead = readStableFile(hiddenPath, `${label} hidden evaluator`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
1866
+ if (hiddenRead.rawByteDigest !== hiddenAsset.sha256 || hiddenRead.bytes.length !== hiddenAsset.bytes) throw new Error(`${label} hidden evaluator source identity is inconsistent`);
1867
+ const privateBundleSource = readStableWorkspaceInventory(staticRoot, `${label} static private bundle`);
1868
+ const privateBundleAuthority = validatePrivateBundleByteMap({ inventory: privateBundleSource, evaluatorRevision, hiddenAsset, externalAuthorityAnchor: anchor, root: realpathSync(root), label });
1869
+ const runnerRelativePath = "scripts/ask-benchmark-private-evaluator-runner.mjs";
1870
+ const repositoryRoot = assertRealDirectory(root, `${label} repository root`);
1871
+ const repositoryAuthority = buildRepositoryAuthoritySource({ root: repositoryRoot, evaluatorRevision, externalAuthorityAnchor: anchor, label });
1872
+ const runnerPath = resolveAuthorityArtifactPath(repositoryRoot, runnerRelativePath, `${label} runner source`);
1873
+ const runnerRead = readStableFile(runnerPath, `${label} runner source`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
1874
+ const runnerRevision = assertSourceBytesAtRevision(repositoryRoot, evaluatorRevision, runnerRelativePath, runnerRead.bytes, `${label} runner source`);
1875
+ const frozenSource = readStableWorkspaceInventory(frozenWorkspace, `${label} frozen workspace source`);
1876
+ const candidateSource = readStableWorkspaceInventory(candidateWorkspace, `${label} candidate workspace source`);
1877
+ const evidenceSource = readStableWorkspaceInventory(evaluationInputRoot, `${label} evaluation-input evidence source`);
1878
+ if (runtimeObservationAuthority) verifyRuntimeObservationEvidenceAuthority(runtimeObservationAuthority, evidenceSource.buffers);
1879
+ const closedEvaluationLineage = evaluationLineage && { run_instance_id: evaluationLineage.run_instance_id, case_id: evaluationLineage.case_id, attempt: evaluationLineage.attempt };
1880
+ assertPortableRelativePath(executionDirectoryName, `${label} execution directory`);
1881
+ const executionRoot = resolve(evaluationRoot, executionDirectoryName);
1882
+ assertFreshPath(executionRoot, `${label} root`);
1883
+ mkdirSync(executionRoot, 0o755);
1884
+ const runner = materializeSealedFile({ bytes: runnerRead.bytes, destination: resolve(executionRoot, "runner.mjs"), label: `${label} runner sealed copy`, mode: SEALED_REGULAR_FILE_MODE });
1885
+ const privateBundle = materializeSealedWorkspaceSnapshot({ inventory: privateBundleSource, destination: resolve(executionRoot, "private-bundle"), label: `${label} private bundle sealed snapshot` });
1886
+ const hidden = readStableFile(resolve(privateBundle.root, hiddenAsset.path), `${label} hidden evaluator sealed copy`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
1887
+ if (hidden.rawByteDigest !== hiddenAsset.sha256 || hidden.bytes.length !== hiddenAsset.bytes) throw new Error(`${label} hidden evaluator sealed copy does not match the verified source`);
1888
+ const hiddenIdentity = runtimeIdentityFromStableRead(hidden);
1889
+ const frozen = materializeSealedWorkspaceSnapshot({ inventory: frozenSource, destination: resolve(executionRoot, "frozen-workspace"), label: `${label} frozen workspace sealed snapshot` });
1890
+ const candidate = materializeSealedWorkspaceSnapshot({ inventory: candidateSource, destination: resolve(executionRoot, "candidate-workspace"), label: `${label} candidate workspace sealed snapshot` });
1891
+ const evidence = materializeSealedWorkspaceSnapshot({ inventory: evidenceSource, destination: resolve(executionRoot, "evaluation-input-evidence"), label: `${label} evaluation-input evidence sealed snapshot` });
1892
+ if (runtimeObservationAuthority) verifyRuntimeObservationEvidenceAuthority(runtimeObservationAuthority, evidence.buffers);
1893
+ const originalWorkspaceAuthority = materializeOriginalWorkspaceAuthority({ executionRoot, frozen: frozenSource, candidate: candidateSource, lineage: closedEvaluationLineage, candidateAuthority, label });
1894
+ const repository = materializeSealedRepositorySnapshot({ authority: repositoryAuthority, destination: resolve(executionRoot, "repository"), label: `${label} repository authority sealed snapshot` });
1895
+ verifySealedEvaluatorExternalAuthority({ descriptor: repositoryAuthority.descriptor, buffers: repository.sealed.buffers, externalAuthorityAnchor: anchor, label });
1896
+ const execution = {
1897
+ evaluationRoot,
1898
+ executionRoot,
1899
+ executionRootPath: relativeAuthorityPath(evaluationRoot, executionRoot, `${label} root`),
1900
+ evaluatorRevision,
1901
+ runner: {
1902
+ sourcePath: runnerRelativePath,
1903
+ sourceBytes: runnerRead.bytes.length,
1904
+ sourceSha256: runnerRead.rawByteDigest,
1905
+ baseGitRevisionBytes: runnerRevision.bytes,
1906
+ baseGitRevisionSha256: runnerRevision.sha256,
1907
+ path: runner.path,
1908
+ relativePath: relativeAuthorityPath(evaluationRoot, runner.path, `${label} runner sealed copy`),
1909
+ bytes: runner.bytes,
1910
+ sha256: runner.sha256,
1911
+ identityBefore: runner.identity,
1912
+ identityAfter: runner.identity,
1913
+ },
1914
+ hidden: {
1915
+ sourcePath: hiddenAsset.path,
1916
+ sourceBytes: hiddenRead.bytes.length,
1917
+ sourceSha256: hiddenRead.rawByteDigest,
1918
+ path: hidden.path,
1919
+ relativePath: relativeAuthorityPath(evaluationRoot, hidden.path, `${label} hidden sealed copy`),
1920
+ bytes: hidden.bytes.length,
1921
+ sha256: hidden.rawByteDigest,
1922
+ identityBefore: hiddenIdentity,
1923
+ identityAfter: hiddenIdentity,
1924
+ },
1925
+ privateBundle: {
1926
+ path: privateBundle.root,
1927
+ relativePath: relativeAuthorityPath(evaluationRoot, privateBundle.root, `${label} private bundle sealed snapshot`),
1928
+ manifestPath: privateBundleAuthority.manifestPath,
1929
+ manifestBytes: privateBundleAuthority.manifestBytes.length,
1930
+ manifestSha256: rawByteDigest(privateBundleAuthority.manifestBytes),
1931
+ evaluatorBundleId: privateBundleAuthority.manifest.evaluator_bundle_id,
1932
+ evaluatorBundleDigest: privateBundleAuthority.manifest.evaluator_bundle_digest,
1933
+ source: sealedSnapshotBinding(privateBundleSource),
1934
+ sealed: sealedSnapshotBinding(privateBundle),
1935
+ },
1936
+ repository: {
1937
+ path: repository.path,
1938
+ relativePath: relativeAuthorityPath(evaluationRoot, repository.path, `${label} repository authority sealed snapshot`),
1939
+ descriptorPath: repository.descriptorPath,
1940
+ descriptorRelativePath: relativeAuthorityPath(evaluationRoot, repository.descriptorPath, `${label} repository authority descriptor`),
1941
+ descriptorBytes: repository.descriptorBytes,
1942
+ descriptorSha256: repository.descriptorSha256,
1943
+ sourceGraphDigest: repository.sourceGraphDigest,
1944
+ fixtureAuthorityDigest: repository.fixtureAuthorityDigest,
1945
+ evaluatorAuthorityManifestPath: repositoryAuthority.descriptor.evaluator_authority_manifest_path,
1946
+ evaluatorAuthorityManifestRawSha256: repository.evaluatorAuthorityManifestRawSha256,
1947
+ evaluatorAuthorityManifestDigest: repository.evaluatorAuthorityManifestDigest,
1948
+ authorityDigest: repository.authorityDigest,
1949
+ source: sealedSnapshotBinding(repositoryAuthority.sourceInventory),
1950
+ sealed: sealedSnapshotBinding(repository.sealed),
1951
+ identityBefore: sealedSnapshotBinding(repository.sealed),
1952
+ identityAfterFirst: sealedSnapshotBinding(repository.sealed),
1953
+ identityAfterSecond: sealedSnapshotBinding(repository.sealed),
1954
+ },
1955
+ frozen: {
1956
+ source: sealedSnapshotBinding(frozenSource),
1957
+ sourcePath: frozenSource.root,
1958
+ path: frozen.root,
1959
+ relativePath: relativeAuthorityPath(evaluationRoot, frozen.root, `${label} frozen sealed snapshot`),
1960
+ sealed: sealedSnapshotBinding(frozen),
1961
+ identityBefore: sealedSnapshotBinding(frozen),
1962
+ identityAfter: sealedSnapshotBinding(frozen),
1963
+ },
1964
+ candidate: {
1965
+ source: sealedSnapshotBinding(candidateSource),
1966
+ sourcePath: candidateSource.root,
1967
+ path: candidate.root,
1968
+ relativePath: relativeAuthorityPath(evaluationRoot, candidate.root, `${label} candidate sealed snapshot`),
1969
+ sealed: sealedSnapshotBinding(candidate),
1970
+ identityBefore: sealedSnapshotBinding(candidate),
1971
+ identityAfter: sealedSnapshotBinding(candidate),
1972
+ },
1973
+ evidence: {
1974
+ source: sealedSnapshotBinding(evidenceSource),
1975
+ sourcePath: evidenceSource.root,
1976
+ path: evidence.root,
1977
+ relativePath: relativeAuthorityPath(evaluationRoot, evidence.root, `${label} evidence sealed snapshot`),
1978
+ sealed: sealedSnapshotBinding(evidence),
1979
+ identityBefore: sealedSnapshotBinding(evidence),
1980
+ identityAfter: sealedSnapshotBinding(evidence),
1981
+ },
1982
+ originalWorkspaceAuthority: {
1983
+ path: originalWorkspaceAuthority.inventory.root,
1984
+ relativePath: relativeAuthorityPath(evaluationRoot, originalWorkspaceAuthority.inventory.root, `${label} original workspace authority`),
1985
+ authorityPath: ORIGINAL_WORKSPACE_AUTHORITY_PATH,
1986
+ authoritySha256: rawByteDigest(originalWorkspaceAuthority.inventory.buffers.get(ORIGINAL_WORKSPACE_AUTHORITY_PATH)),
1987
+ authorityBytes: originalWorkspaceAuthority.inventory.buffers.get(ORIGINAL_WORKSPACE_AUTHORITY_PATH).length,
1988
+ authorityDigest: originalWorkspaceAuthority.authority.authority_digest,
1989
+ repositoryDiffPath: SEALED_REPOSITORY_DIFF_ARTIFACT_PATH,
1990
+ repositoryDiffSha256: rawByteDigest(originalWorkspaceAuthority.inventory.buffers.get(SEALED_REPOSITORY_DIFF_ARTIFACT_PATH)),
1991
+ repositoryDiffBytes: originalWorkspaceAuthority.inventory.buffers.get(SEALED_REPOSITORY_DIFF_ARTIFACT_PATH).length,
1992
+ repositoryDiffDigest: originalWorkspaceAuthority.repositoryDiffArtifact.artifact_digest,
1993
+ sealed: sealedSnapshotBinding(originalWorkspaceAuthority.inventory),
1994
+ lineage: structuredClone(closedEvaluationLineage),
1995
+ candidateAuthority: structuredClone(candidateAuthority),
1996
+ },
1997
+ };
1998
+ ORIGINAL_EXECUTION_AUTHORITIES.set(execution, privateOriginalWorkspaceSnapshot(frozenSource, candidateSource, closedEvaluationLineage, candidateAuthority));
1999
+ return execution;
2000
+ }
2001
+
2002
+ export function createSealedEvaluatorExecutionForTest(options = {}) {
2003
+ return createSealedEvaluatorExecutionFromWorkspaceSources({
2004
+ ...options,
2005
+ candidateAuthority: { kind: "direct_test_workspace" },
2006
+ });
2007
+ }
2008
+
2009
+ function terminalCandidateAuthorityBinding(materialized) {
2010
+ const verified = materialized.verified_authority;
2011
+ const normalized = verified.normalized_result;
2012
+ const lineage = normalized.lineage;
2013
+ const execution = verified.execution;
2014
+ const authority = verified.terminal_workspace_authority;
2015
+ const authorityBytes = Buffer.from(verified.terminal_workspace_authority_bytes);
2016
+ const reconstructedWorkspace = resolve(materialized.output_root, "workspace");
2017
+ const reconstructed = readStableWorkspaceInventory(reconstructedWorkspace, "verified terminal reconstructed candidate workspace");
2018
+ if (materialized.terminal_workspace_tree_digest !== authority.terminal_candidate_tree_digest || execution.terminal_workspace_tree_digest !== authority.terminal_candidate_tree_digest) throw new Error("verified terminal candidate tree digest is inconsistent");
2019
+ const binding = {
2020
+ kind: "verified_terminal_candidate",
2021
+ source_snapshot_digest: verified.source_snapshot_digest,
2022
+ normalized_result_id: normalized.normalized_result_id,
2023
+ normalized_result_digest: normalized.normalized_result_digest,
2024
+ run_instance_id: lineage.run_instance_id,
2025
+ case_id: lineage.case_id,
2026
+ attempt: lineage.attempt,
2027
+ adapter: lineage.adapter_track,
2028
+ condition: lineage.condition,
2029
+ fixture_id: lineage.fixture_id,
2030
+ fixture_input_digest: lineage.fixture_input_digest,
2031
+ materialization_manifest_digest: lineage.materialization_manifest_digest,
2032
+ request_digest: lineage.request_digest,
2033
+ raw_result_digest: lineage.raw_result_digest,
2034
+ terminal_commit_digest: lineage.terminal_commit_digest,
2035
+ terminal_case_state_digest: verified.terminal_case_state_digest,
2036
+ terminal_workspace_authority_digest: authority.authority_digest,
2037
+ terminal_workspace_authority_raw_sha256: rawByteDigest(authorityBytes),
2038
+ terminal_workspace_authority_bytes: authorityBytes.length,
2039
+ terminal_workspace_authority_base64: authorityBytes.toString("base64"),
2040
+ terminal_candidate_tree_digest: authority.terminal_candidate_tree_digest,
2041
+ reconstructed_candidate_portable_digest: reconstructed.digest,
2042
+ candidate_authority_portable_digest: null,
2043
+ };
2044
+ for (const [field, value] of Object.entries({
2045
+ run_instance_id: execution.run_instance_id,
2046
+ case_id: execution.case_id,
2047
+ attempt: execution.attempt,
2048
+ adapter: execution.adapter,
2049
+ condition: execution.condition,
2050
+ fixture_id: execution.fixture_id,
2051
+ fixture_input_digest: execution.fixture_input_digest,
2052
+ materialization_manifest_digest: execution.materialization_manifest_digest,
2053
+ request_digest: execution.request_digest,
2054
+ raw_result_digest: execution.raw_result_digest,
2055
+ terminal_commit_digest: execution.terminal_commit_digest,
2056
+ terminal_workspace_authority_digest: execution.terminal_workspace_authority_digest,
2057
+ terminal_candidate_tree_digest: execution.terminal_workspace_tree_digest,
2058
+ terminal_workspace_authority_bytes: execution.terminal_workspace_authority_bytes,
2059
+ })) if (binding[field] !== value) throw new Error(`verified terminal candidate ${field} is inconsistent`);
2060
+ let parsedAuthority;
2061
+ try { parsedAuthority = JSON.parse(authorityBytes.toString("utf8")); }
2062
+ catch { throw new Error("verified terminal workspace authority bytes are invalid JSON"); }
2063
+ if (stableCanonicalJson(parsedAuthority) !== stableCanonicalJson(authority)) throw new Error("verified terminal workspace authority object is detached from its bytes");
2064
+ return { binding, reconstructedWorkspace, reconstructed, authority };
2065
+ }
2066
+
2067
+ // Metadata projection only; this does not register sealed execution authority.
2068
+ export function terminalCandidateInventoryFromAuthority(authority) {
2069
+ const terminal = new Map(authority.base_inventory.map((entry) => [entry.path, structuredClone(entry)]));
2070
+ for (const delta of authority.delta_inventory) {
2071
+ if (delta.change_type === "deletion") terminal.delete(delta.path);
2072
+ else {
2073
+ const { content_base64: ignoredContent, ...after } = delta.after;
2074
+ terminal.set(delta.path, { path: delta.path, ...after });
2075
+ }
2076
+ }
2077
+ const inventory = [...terminal.values()].sort((left, right) => compareTerminalWorkspacePaths(left.path, right.path));
2078
+ if (terminalWorkspaceInventoryDigest(inventory) !== authority.terminal_workspace_portable_digest) throw new Error("terminal workspace authority inventory closure is inconsistent");
2079
+ const candidate = deriveTerminalCandidateInventory(inventory, authority.managed_asset_paths, authority.base_inventory);
2080
+ if (terminalWorkspaceInventoryDigest(candidate) !== authority.terminal_candidate_tree_digest) throw new Error("terminal candidate original metadata closure is inconsistent");
2081
+ return candidate;
2082
+ }
2083
+
2084
+ // Copies verified metadata at the terminal/private portable protocol boundary.
2085
+ // This helper does not grant the production constructor's provenance authority.
2086
+ export function materializeTerminalCandidateAuthorityWorkspace({ evaluationRoot, terminal }) {
2087
+ const evaluationDirectory = assertRealDirectory(evaluationRoot, "terminal candidate evaluation root");
2088
+ const reconstructedDirectory = assertRealDirectory(terminal.reconstructedWorkspace, "terminal candidate reconstructed workspace");
2089
+ if (evaluationDirectory !== resolve(evaluationRoot) || reconstructedDirectory !== resolve(terminal.reconstructedWorkspace)) throw new Error("terminal candidate roots must not traverse symlinks");
2090
+ const parent = mkdtempSync(resolve(evaluationDirectory, ".production-candidate-authority-"));
2091
+ const destination = resolve(parent, "workspace");
2092
+ cpSync(reconstructedDirectory, destination, { recursive: true, errorOnExist: true, force: false });
2093
+ // Reject prohibited copied entries before chmod can follow a link outside it.
2094
+ readStableWorkspaceInventory(destination, "terminal candidate copied workspace before metadata restoration");
2095
+ const terminalInventory = terminalCandidateInventoryFromAuthority(terminal.authority);
2096
+ const workspaceRoot = terminalInventory.find(({ path }) => path === "workspace");
2097
+ const inventory = terminalInventory.filter(({ path }) => path.startsWith("workspace/")).map((entry) => ({ ...entry, path: entry.path.slice("workspace/".length) }));
2098
+ for (const entry of inventory.filter(({ file_type: fileType }) => fileType === "regular_file")) chmodSync(resolve(destination, entry.path), Number.parseInt(entry.mode, 8));
2099
+ for (const entry of inventory.filter(({ file_type: fileType }) => fileType === "directory").sort((left, right) => right.path.length - left.path.length)) chmodSync(resolve(destination, entry.path), Number.parseInt(entry.mode, 8));
2100
+ chmodSync(destination, workspaceRoot ? Number.parseInt(workspaceRoot.mode, 8) : 0o755);
2101
+ const materialized = readStableWorkspaceInventory(destination, "verified terminal candidate metadata authority workspace");
2102
+ // Terminal authority uses code-unit ordering. Convert this new expected
2103
+ // record to the existing private portable protocol; keep the observed record
2104
+ // and its digest unchanged, with every path/type/mode/byte/hash checked.
2105
+ const expected = inventory.map((entry) => ({ path: entry.path, file_type: entry.file_type === "regular_file" ? "file" : "directory", mode: Number.parseInt(entry.mode, 8), bytes: entry.bytes, sha256: entry.sha256 === null ? null : `sha256:${entry.sha256}` })).sort((left, right) => left.path.localeCompare(right.path));
2106
+ if (stableCanonicalJson(materialized.portableEntries) !== stableCanonicalJson(expected) || materialized.digest !== canonicalDigest(expected)) throw new Error("terminal candidate metadata authority workspace is inconsistent");
2107
+ return materialized;
2108
+ }
2109
+
2110
+ function materializeVerifiedFrozenAuthorityWorkspace({ evaluationRoot, source }) {
2111
+ const parent = mkdtempSync(resolve(evaluationRoot, ".production-frozen-authority-"));
2112
+ const destination = resolve(parent, "workspace");
2113
+ cpSync(source.root, destination, { recursive: true, errorOnExist: true, force: false });
2114
+ // cpSync creates directories with default modes. Restore the verified source
2115
+ // metadata before comparing inventories, including empty nested directories.
2116
+ for (const entry of source.portableEntries.filter(({ file_type }) => file_type === "file")) chmodSync(resolve(destination, entry.path), entry.mode);
2117
+ for (const entry of source.portableEntries.filter(({ file_type }) => file_type === "directory").sort((left, right) => right.path.length - left.path.length)) chmodSync(resolve(destination, entry.path), entry.mode);
2118
+ chmodSync(destination, source.rootIdentity.mode & 0o777);
2119
+ const materialized = readStableWorkspaceInventory(destination, "verified frozen fixture metadata authority workspace");
2120
+ if (stableCanonicalJson(materialized.portableEntries) !== stableCanonicalJson(source.portableEntries) || materialized.digest !== source.digest) throw new Error("verified frozen fixture metadata authority workspace is inconsistent");
2121
+ return materialized;
2122
+ }
2123
+
2124
+ function verifiedFinalOutputBytesForPrivateEvaluation({ root, runDir, normalized, execution }) {
2125
+ const lineage = normalized?.lineage;
2126
+ if (!lineage || lineage.run_instance_id !== execution.run_instance_id || lineage.case_id !== execution.case_id || lineage.attempt !== execution.attempt) {
2127
+ throw new Error("private final output lineage differs from verified terminal execution");
2128
+ }
2129
+ const expectedDigest = lineage.final_output_digest;
2130
+ const expectedBytes = lineage.final_output_bytes;
2131
+ if (expectedDigest === null && expectedBytes === null) return null;
2132
+ if (!/^sha256:[a-f0-9]{64}$/u.test(expectedDigest ?? "") || !Number.isInteger(expectedBytes) || expectedBytes < 1 || expectedBytes > MAX_VERIFIED_FINAL_OUTPUT_BYTES) {
2133
+ throw new Error("private final output normalized identity is invalid");
2134
+ }
2135
+ const runRoot = assertRealDirectory(runDir, "private final output run root");
2136
+ const relativePath = `cases/${lineage.case_id}/attempts/${lineage.attempt}/final.json`;
2137
+ const primaryPath = primaryFinalResponseRelativePath(normalized);
2138
+ const finalPath = resolveAuthorityArtifactPath(runRoot, primaryPath ?? relativePath, "private final output source");
2139
+ const final = readStableFile(finalPath, "private final output source", MAX_VERIFIED_FINAL_OUTPUT_BYTES, { allowEmpty: false });
2140
+ validateSealedPrivateFinalOutputEvidence({
2141
+ root, normalized,
2142
+ candidateAuthority: { kind: "verified_terminal_candidate", run_instance_id: execution.run_instance_id, case_id: execution.case_id, attempt: execution.attempt },
2143
+ evidenceBuffers: new Map([[VERIFIED_FINAL_OUTPUT_EVIDENCE_PATH, final.bytes]]),
2144
+ });
2145
+ return final.bytes;
2146
+ }
2147
+
2148
+ export function validateSealedPrivateFinalOutputEvidence({ root, normalized, candidateAuthority, evidenceBuffers }) {
2149
+ if (candidateAuthority?.kind !== "verified_terminal_candidate") return;
2150
+ for (const field of ["run_instance_id", "case_id", "attempt"]) {
2151
+ if (candidateAuthority[field] !== normalized?.lineage?.[field]) throw new Error("sealed private final output lineage differs from candidate authority");
2152
+ }
2153
+ const finalBytes = evidenceBuffers?.get(VERIFIED_FINAL_OUTPUT_EVIDENCE_PATH);
2154
+ const expectedDigest = normalized?.lineage?.final_output_digest;
2155
+ const expectedBytes = normalized?.lineage?.final_output_bytes;
2156
+ if (expectedDigest === null && expectedBytes === null) {
2157
+ if (finalBytes !== undefined) throw new Error("sealed private final output is present without normalized authority");
2158
+ return;
2159
+ }
2160
+ if (!/^sha256:[a-f0-9]{64}$/u.test(expectedDigest ?? "") || !Number.isInteger(expectedBytes) || expectedBytes < 1 || expectedBytes > MAX_VERIFIED_FINAL_OUTPUT_BYTES) {
2161
+ throw new Error("sealed private final output normalized identity is invalid");
2162
+ }
2163
+ if (!Buffer.isBuffer(finalBytes) || finalBytes.length !== expectedBytes || rawByteDigest(finalBytes) !== expectedDigest) {
2164
+ throw new Error("sealed private final output differs from normalized authority");
2165
+ }
2166
+ if (validatePrimaryRawFinalResponse(normalized, finalBytes)) return;
2167
+ assertNoDuplicateJsonObjectKeys(finalBytes.toString("utf8"), "sealed private final output");
2168
+ let finalValue;
2169
+ try { finalValue = JSON.parse(finalBytes.toString("utf8")); }
2170
+ catch { throw new Error("sealed private final output is invalid JSON"); }
2171
+ assertBenchmarkSchemaInstance(finalValue, { schemaPath: resolve(root, "benchmarks/schemas/agent-output.schema.json"), label: "sealed private final output" });
2172
+ }
2173
+
2174
+ export function createProductionSealedEvaluatorExecution(options = {}) {
2175
+ for (const forbidden of ["candidateWorkspace", "candidateMutator", "evaluationInputRoot", "normalizedResult", "caseId", "attempt"]) {
2176
+ if (Object.hasOwn(options, forbidden)) throw new Error(`production sealed evaluator rejects caller-supplied ${forbidden}`);
2177
+ }
2178
+ const evaluationRoot = assertRealDirectory(options.privateEvaluationRoot, "production private evaluation authority root");
2179
+ const materialized = materializeVerifiedTerminalCandidate({
2180
+ root: options.root,
2181
+ config: options.config,
2182
+ planPath: options.planPath,
2183
+ materializedPath: options.materializedPath,
2184
+ selectionState: options.selectionState,
2185
+ runDir: options.runDir,
2186
+ normalizedResultsPath: options.normalizedResultsPath,
2187
+ executionAdmissionEvidenceByFixture: options.executionAdmissionEvidenceByFixture ?? null,
2188
+ sourceSnapshotDigest: options.sourceSnapshotDigest,
2189
+ normalizedResultId: options.normalizedResultId,
2190
+ outputParent: evaluationRoot,
2191
+ privateEvaluatorRoot: options.privateRoot,
2192
+ });
2193
+ const terminal = terminalCandidateAuthorityBinding(materialized);
2194
+ const candidateAuthorityWorkspace = materializeTerminalCandidateAuthorityWorkspace({ evaluationRoot, terminal });
2195
+ terminal.binding.candidate_authority_portable_digest = candidateAuthorityWorkspace.digest;
2196
+ const evidenceRoot = mkdtempSync(resolve(evaluationRoot, ".production-evaluation-input-"));
2197
+ const verifiedFrozenSource = readStableWorkspaceInventory(resolve(options.materializedPath, terminal.binding.case_id, "workspace"), "verified frozen fixture workspace");
2198
+ const frozenAuthorityWorkspace = materializeVerifiedFrozenAuthorityWorkspace({ evaluationRoot, source: verifiedFrozenSource });
2199
+ const evidence = {
2200
+ schema_version: "1.0.0",
2201
+ program: "adaptive_ask_verified_terminal_evaluation_input",
2202
+ candidate_authority: terminal.binding,
2203
+ };
2204
+ writeFileSync(resolve(evidenceRoot, "verified-terminal-evaluation-input.json"), `${AUTHORITY_JSON_STRINGIFY(evidence, null, 2)}\n`, { flag: "wx", mode: 0o400 });
2205
+ const finalOutputBytes = verifiedFinalOutputBytesForPrivateEvaluation({
2206
+ root: options.root,
2207
+ runDir: options.runDir,
2208
+ normalized: materialized.verified_authority.normalized_result,
2209
+ execution: materialized.verified_authority.execution,
2210
+ });
2211
+ if (finalOutputBytes !== null) {
2212
+ writeFileSync(resolve(evidenceRoot, VERIFIED_FINAL_OUTPUT_EVIDENCE_PATH), finalOutputBytes, { flag: "wx", mode: 0o400 });
2213
+ }
2214
+ let runtimeObservationAuthority = null;
2215
+ if (options.runtimeObservationRoot !== undefined) {
2216
+ runtimeObservationAuthority = materializeVerifiedRuntimeObservationEvidence({ ...options, observationRoot: options.runtimeObservationRoot }, {
2217
+ normalized: materialized.verified_authority.normalized_result,
2218
+ sourceSnapshotDigest: terminal.binding.source_snapshot_digest, outputRoot: evidenceRoot,
2219
+ }).authority;
2220
+ }
2221
+ const execution = createSealedEvaluatorExecutionFromWorkspaceSources({
2222
+ root: options.root,
2223
+ privateEvaluationRoot: evaluationRoot,
2224
+ privateRoot: options.privateRoot,
2225
+ hiddenAsset: options.hiddenAsset,
2226
+ frozenWorkspace: frozenAuthorityWorkspace.root,
2227
+ candidateWorkspace: candidateAuthorityWorkspace.root,
2228
+ evaluationInputRoot: evidenceRoot,
2229
+ evaluationLineage: terminal.binding,
2230
+ candidateAuthority: terminal.binding,
2231
+ runtimeObservationAuthority,
2232
+ evaluatorRevision: options.evaluatorRevision,
2233
+ externalAuthorityAnchor: options.externalAuthorityAnchor,
2234
+ executionDirectoryName: options.executionDirectoryName ?? "sealed-execution",
2235
+ label: options.label ?? "production private evaluator sealed execution",
2236
+ });
2237
+ PRODUCTION_EXECUTION_AUTHORITIES.set(execution, {
2238
+ normalized: structuredClone(materialized.verified_authority.normalized_result),
2239
+ normalizedBytes: Buffer.from(materialized.verified_authority.normalized_result_bytes),
2240
+ candidateAuthority: structuredClone(terminal.binding),
2241
+ runtimeObservationAuthority,
2242
+ });
2243
+ return execution;
2244
+ }
2245
+
2246
+ function parseRunnerFragment(stdout, label) {
2247
+ assertNoDuplicateJsonObjectKeys(stdout, label);
2248
+ try {
2249
+ const parsed = JSON.parse(stdout);
2250
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("fragment must be an object");
2251
+ return parsed;
2252
+ } catch {
2253
+ throw new Error(`${label} is invalid JSON`);
2254
+ }
2255
+ }
2256
+
2257
+ function stableFragmentBytes(fragment) {
2258
+ return Buffer.from(`${AUTHORITY_JSON_STRINGIFY(fragment, null, 2)}\n`);
2259
+ }
2260
+
2261
+ function captureVerifiedExecutionAuthority(execution, externalAuthorityAnchor, repositoryRoot, label) {
2262
+ const anchor = assertExternalEvaluatorAuthorityAnchor(externalAuthorityAnchor, label);
2263
+ const immutableRoot = assertRealDirectory(repositoryRoot, `${label} immutable repository root`);
2264
+ const runner = readStableFile(execution.runner.path, `${label} runner verified bytes`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
2265
+ const hidden = readStableFile(execution.hidden.path, `${label} hidden evaluator verified bytes`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
2266
+ const privateBundle = readStableWorkspaceInventory(execution.privateBundle.path, `${label} private bundle verified bytes`);
2267
+ const frozen = readStableWorkspaceInventory(execution.frozen.path, `${label} frozen workspace verified bytes`);
2268
+ const candidate = readStableWorkspaceInventory(execution.candidate.path, `${label} candidate workspace verified bytes`);
2269
+ const evidence = readStableWorkspaceInventory(execution.evidence.path, `${label} evaluation-input verified bytes`);
2270
+ const productionAuthority = PRODUCTION_EXECUTION_AUTHORITIES.get(execution);
2271
+ if (productionAuthority?.runtimeObservationAuthority) verifyRuntimeObservationEvidenceAuthority(productionAuthority.runtimeObservationAuthority, evidence.buffers);
2272
+ const originalWorkspaceAuthority = readStableWorkspaceInventory(execution.originalWorkspaceAuthority.path, `${label} original workspace authority verified bytes`);
2273
+ for (const [kind, inventory] of [["private bundle", privateBundle], ["frozen workspace", frozen], ["candidate workspace", candidate], ["evaluation-input evidence", evidence], ["original workspace authority", originalWorkspaceAuthority]]) assertSealedSnapshotModes(inventory, { label: `${label} ${kind}` });
2274
+ const repository = readSealedRepositoryDescriptor(execution.repository.path, `${label} repository verified bytes`, {
2275
+ expectedSourceGraphDigest: execution.repository.sourceGraphDigest ?? null,
2276
+ expectedEvaluatorRevision: execution.evaluatorRevision ?? null,
2277
+ });
2278
+ const descriptor = repository.descriptor;
2279
+ if (execution.repository.descriptorSha256 !== repository.descriptorRead.rawByteDigest || execution.repository.descriptorBytes !== repository.descriptorRead.bytes.length) throw new Error(`${label} repository descriptor does not match its recorded execution authority`);
2280
+ const assertPortableRecord = (inventory, expected, kind) => {
2281
+ if (!expected || inventory.digest !== expected.portable_digest || (inventory.rootIdentity.mode & 0o777) !== (expected.root.mode & 0o777)) throw new Error(`${label} ${kind} does not match its recorded sealed authority`);
2282
+ };
2283
+ for (const [inventory, expected, kind] of [[repository.inventory, execution.repository.sealed, "repository"], [privateBundle, execution.privateBundle.sealed, "private bundle"], [frozen, execution.frozen.sealed, "frozen workspace"], [candidate, execution.candidate.sealed, "candidate workspace"], [evidence, execution.evidence.sealed, "evaluation-input evidence"], [originalWorkspaceAuthority, execution.originalWorkspaceAuthority.sealed, "original workspace authority"]]) assertPortableRecord(inventory, expected, kind);
2284
+ const originalSource = ORIGINAL_EXECUTION_AUTHORITIES.get(execution);
2285
+ if (!originalSource) throw new Error(`${label} module-owned original workspace authority is missing`);
2286
+ const originalAuthority = validateOriginalWorkspaceAuthority({ inventory: originalWorkspaceAuthority, frozen, candidate, lineage: execution.originalWorkspaceAuthority.lineage, candidateAuthority: execution.originalWorkspaceAuthority.candidateAuthority, root: immutableRoot, label, originalSource });
2287
+ if (execution.originalWorkspaceAuthority.authorityPath !== ORIGINAL_WORKSPACE_AUTHORITY_PATH || execution.originalWorkspaceAuthority.authoritySha256 !== rawByteDigest(originalAuthority.authorityBytes) || execution.originalWorkspaceAuthority.authorityBytes !== originalAuthority.authorityBytes.length || execution.originalWorkspaceAuthority.authorityDigest !== originalAuthority.authority.authority_digest || execution.originalWorkspaceAuthority.repositoryDiffPath !== SEALED_REPOSITORY_DIFF_ARTIFACT_PATH || execution.originalWorkspaceAuthority.repositoryDiffSha256 !== rawByteDigest(originalAuthority.repositoryDiffBytes) || execution.originalWorkspaceAuthority.repositoryDiffBytes !== originalAuthority.repositoryDiffBytes.length || execution.originalWorkspaceAuthority.repositoryDiffDigest !== originalAuthority.repositoryDiffArtifact.artifact_digest) throw new Error(`${label} original workspace authority does not match the execution record`);
2288
+ const runnerIdentity = runtimeIdentityFromStableRead(runner);
2289
+ const runnerRecordedIdentity = execution.runner.identityBefore;
2290
+ const runnerStableInodeMatches = runnerRecordedIdentity && ["dev", "ino", "nlink", "mode"].every((field) => runnerIdentity[field] === runnerRecordedIdentity[field]);
2291
+ if ((runnerIdentity.mode & 0o777) !== SEALED_REGULAR_FILE_MODE || runner.rawByteDigest !== execution.runner.sha256 || runner.bytes.length !== execution.runner.bytes || !runnerStableInodeMatches) throw new Error(`${label} runner verified bytes, mode, or inode do not match the execution record`);
2292
+ const runnerRevision = assertSourceBytesAtRevision(immutableRoot, execution.evaluatorRevision, execution.runner.sourcePath, runner.bytes, `${label} runner source`);
2293
+ if (execution.runner.sourceSha256 !== runner.rawByteDigest || execution.runner.sourceBytes !== runner.bytes.length || execution.runner.baseGitRevisionSha256 !== runnerRevision.sha256 || execution.runner.baseGitRevisionBytes !== runnerRevision.bytes) throw new Error(`${label} runner immutable revision identity is inconsistent`);
2294
+ const immutableSourceGraph = deriveEvaluatorDependencyGraph({ root: immutableRoot, baseRevision: execution.evaluatorRevision });
2295
+ if (stableCanonicalJson(descriptor.source_graph) !== stableCanonicalJson(immutableSourceGraph)) throw new Error(`${label} sealed source graph does not match the immutable evaluator revision`);
2296
+ const runnerNode = descriptor.source_graph.node_inventory.find(({ path }) => path === execution.runner.sourcePath);
2297
+ if (!runnerNode || runnerNode.bytes !== runner.bytes.length || runnerNode.sha256 !== runner.rawByteDigest || runnerNode.file_type !== "module") throw new Error(`${label} runner bytes are detached from the sealed dependency graph`);
2298
+ const privateAuthority = validatePrivateBundleByteMap({ inventory: privateBundle, evaluatorRevision: execution.evaluatorRevision, hiddenAsset: { path: execution.hidden.sourcePath, bytes: execution.hidden.sourceBytes, sha256: execution.hidden.sourceSha256 }, externalAuthorityAnchor: anchor, root: immutableRoot, label });
2299
+ if (execution.privateBundle.manifestPath !== privateAuthority.manifestPath || execution.privateBundle.manifestBytes !== privateAuthority.manifestBytes.length || execution.privateBundle.manifestSha256 !== rawByteDigest(privateAuthority.manifestBytes) || execution.privateBundle.evaluatorBundleId !== privateAuthority.manifest.evaluator_bundle_id || execution.privateBundle.evaluatorBundleDigest !== privateAuthority.manifest.evaluator_bundle_digest) throw new Error(`${label} private bundle manifest does not match the execution record`);
2300
+ const hiddenEvaluatorPath = privateAuthority.hiddenAsset.path;
2301
+ const expectedHiddenPath = resolveAuthorityArtifactPath(execution.privateBundle.path, hiddenEvaluatorPath, `${label} hidden evaluator sealed path`);
2302
+ if (expectedHiddenPath !== execution.hidden.path) throw new Error(`${label} hidden evaluator path is detached from the sealed private bundle`);
2303
+ const hiddenBytes = privateBundle.buffers.get(hiddenEvaluatorPath);
2304
+ const hiddenIdentity = runtimeIdentityFromStableRead(hidden);
2305
+ const hiddenRecordedIdentity = execution.hidden.identityBefore;
2306
+ const hiddenStableInodeMatches = hiddenRecordedIdentity && ["dev", "ino", "nlink", "mode"].every((field) => hiddenIdentity[field] === hiddenRecordedIdentity[field]);
2307
+ if ((hiddenIdentity.mode & 0o777) !== SEALED_REGULAR_FILE_MODE || !Buffer.isBuffer(hiddenBytes) || Buffer.compare(hidden.bytes, hiddenBytes) !== 0 || hidden.rawByteDigest !== privateAuthority.hiddenAsset.sha256 || hidden.bytes.length !== privateAuthority.hiddenAsset.bytes || !hiddenStableInodeMatches) throw new Error(`${label} hidden evaluator bytes, mode, or inode do not match the sealed private bundle authority`);
2308
+ const captured = {
2309
+ runnerBytes: Buffer.from(runner.bytes),
2310
+ hiddenEvaluatorPath,
2311
+ privateModuleAssets: privateAuthority.manifest.asset_inventory
2312
+ .filter(({ media_type: mediaType }) => mediaType === "text/javascript")
2313
+ .map(({ path, bytes, sha256 }) => ({ path, bytes, sha256 })),
2314
+ sourceGraph: structuredClone(descriptor.source_graph),
2315
+ roots: { repository: repository.inventory, private_bundle: privateBundle, frozen, candidate, evidence, original_workspace_authority: originalWorkspaceAuthority },
2316
+ originalWorkspaceAuthority: originalAuthority,
2317
+ };
2318
+ const expectedAuthority = verifySealedEvaluatorExternalAuthority({
2319
+ descriptor,
2320
+ buffers: captured.roots.repository.buffers,
2321
+ externalAuthorityAnchor: anchor,
2322
+ label,
2323
+ });
2324
+ if (stableCanonicalJson(captured.sourceGraph) !== stableCanonicalJson(descriptor.source_graph)) throw new Error(`${label} captured source graph is detached from the sealed descriptor`);
2325
+ return { ...captured, expectedAuthority };
2326
+ }
2327
+
2328
+ function serializedAuthorityRoot(kind, inventory, helperRoot = null) {
2329
+ const entries = inventory.portableEntries.map((entry) => ({
2330
+ ...entry,
2331
+ ...(entry.file_type === "file" ? { content_base64: inventory.buffers.get(entry.path).toString("base64") } : {}),
2332
+ }));
2333
+ return {
2334
+ kind,
2335
+ root_mode: inventory.rootIdentity.mode & 0o777,
2336
+ entries,
2337
+ ...(helperRoot ? { helper_root: helperRoot } : {}),
2338
+ };
2339
+ }
2340
+
2341
+ function normalizedAuthorityBytes(normalized, verifiedBytes, label) {
2342
+ const bytes = verifiedBytes ? Buffer.from(verifiedBytes) : Buffer.from(`${AUTHORITY_JSON_STRINGIFY(normalized)}\n`);
2343
+ let parsed;
2344
+ try {
2345
+ assertNoDuplicateJsonObjectKeys(bytes.toString("utf8"), `${label} normalized result`);
2346
+ parsed = JSON.parse(bytes.toString("utf8"));
2347
+ } catch {
2348
+ throw new Error(`${label} normalized result verified bytes are invalid`);
2349
+ }
2350
+ if (stableCanonicalJson(parsed) !== stableCanonicalJson(normalized)) throw new Error(`${label} normalized result object is detached from its verified bytes`);
2351
+ return bytes;
2352
+ }
2353
+
2354
+ function buildInMemoryEvaluatorPayload({ verifiedAuthority, execution, normalized, normalizedBytes, runIndex, barrier, label }) {
2355
+ const repository = verifiedAuthority.roots.repository;
2356
+ const privateBundle = verifiedAuthority.roots.private_bundle;
2357
+ const modules = verifiedAuthority.sourceGraph.node_inventory.filter(({ file_type }) => file_type === "module").map((node) => {
2358
+ const bytes = repository.buffers.get(node.path);
2359
+ if (!bytes || bytes.length !== node.bytes || rawByteDigest(bytes) !== node.sha256) throw new Error(`${label} source module byte map drifted at ${node.path}`);
2360
+ return { path: node.path, bytes: bytes.length, sha256: rawByteDigest(bytes), source_base64: bytes.toString("base64") };
2361
+ });
2362
+ const repositoryModulePaths = new Set(modules.map(({ path }) => path));
2363
+ for (const asset of verifiedAuthority.privateModuleAssets) {
2364
+ const bytes = privateBundle.buffers.get(asset.path);
2365
+ if (!bytes || bytes.length !== asset.bytes || rawByteDigest(bytes) !== asset.sha256) throw new Error(`${label} private module byte map drifted at ${asset.path}`);
2366
+ const modulePath = asset.path === verifiedAuthority.hiddenEvaluatorPath ? PRIVATE_EVALUATOR_VIRTUAL_PATH : `${PRIVATE_EVALUATOR_VIRTUAL_ROOT}/${asset.path}`;
2367
+ if (repositoryModulePaths.has(modulePath) || modules.some(({ path }) => path === modulePath)) throw new Error(`${label} private module virtual path collides at ${modulePath}`);
2368
+ modules.push({ path: modulePath, private_bundle_path: asset.path, bytes: bytes.length, sha256: rawByteDigest(bytes), source_base64: bytes.toString("base64") });
2369
+ }
2370
+ if (!modules.some(({ path, private_bundle_path: privateBundlePath }) => path === PRIVATE_EVALUATOR_VIRTUAL_PATH && privateBundlePath === verifiedAuthority.hiddenEvaluatorPath)) throw new Error(`${label} hidden evaluator is absent from the verified private module inventory`);
2371
+ const normalizedSource = normalizedAuthorityBytes(normalized, normalizedBytes, label);
2372
+ const base = {
2373
+ schema_version: "1.0.0",
2374
+ program: "adaptive_ask_in_memory_evaluator_authority",
2375
+ run_index: runIndex,
2376
+ hidden_evaluator_path: verifiedAuthority.hiddenEvaluatorPath,
2377
+ source_graph: verifiedAuthority.sourceGraph,
2378
+ modules,
2379
+ authority_roots: [
2380
+ serializedAuthorityRoot("repository", repository),
2381
+ serializedAuthorityRoot("private_bundle", privateBundle),
2382
+ serializedAuthorityRoot("frozen", verifiedAuthority.roots.frozen),
2383
+ serializedAuthorityRoot("candidate", verifiedAuthority.roots.candidate, execution.candidate.path),
2384
+ serializedAuthorityRoot("evidence", verifiedAuthority.roots.evidence),
2385
+ serializedAuthorityRoot("original_workspace_authority", verifiedAuthority.roots.original_workspace_authority),
2386
+ ],
2387
+ normalized_result: { bytes: normalizedSource.length, sha256: rawByteDigest(normalizedSource), source_base64: normalizedSource.toString("base64") },
2388
+ expected_authority: verifiedAuthority.expectedAuthority,
2389
+ ...(barrier ? { barrier: structuredClone(barrier) } : {}),
2390
+ };
2391
+ return { ...base, payload_digest: canonicalDigest(base) };
2392
+ }
2393
+
2394
+ function captureSealedExecutionState(execution, label) {
2395
+ const runner = readStableFile(execution.runner.path, `${label} runner sealed copy`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
2396
+ const hidden = readStableFile(execution.hidden.path, `${label} hidden evaluator sealed copy`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
2397
+ const privateBundle = execution.privateBundle?.path ? readStableWorkspaceInventory(execution.privateBundle.path, `${label} private bundle sealed snapshot`) : null;
2398
+ const frozen = readStableWorkspaceInventory(execution.frozen.path, `${label} frozen sealed snapshot`);
2399
+ const candidate = readStableWorkspaceInventory(execution.candidate.path, `${label} candidate sealed snapshot`);
2400
+ const evidence = readStableWorkspaceInventory(execution.evidence.path, `${label} evidence sealed snapshot`);
2401
+ const originalWorkspaceAuthority = readStableWorkspaceInventory(execution.originalWorkspaceAuthority.path, `${label} original workspace authority sealed snapshot`);
2402
+ const repository = readStableWorkspaceInventory(execution.repository.path, `${label} repository authority sealed snapshot`);
2403
+ for (const [kind, inventory] of [["private bundle", privateBundle], ["frozen workspace", frozen], ["candidate workspace", candidate], ["evaluation-input evidence", evidence], ["original workspace authority", originalWorkspaceAuthority], ["repository authority", repository]]) if (inventory) assertSealedSnapshotModes(inventory, { label: `${label} ${kind}` });
2404
+ return {
2405
+ runner: { bytes: runner.bytes.length, sha256: runner.rawByteDigest, identity: runtimeIdentityFromStableRead(runner) },
2406
+ hidden: { bytes: hidden.bytes.length, sha256: hidden.rawByteDigest, identity: runtimeIdentityFromStableRead(hidden) },
2407
+ privateBundle: privateBundle ? sealedSnapshotBinding(privateBundle) : null,
2408
+ repository: sealedSnapshotBinding(repository),
2409
+ frozen: sealedSnapshotBinding(frozen),
2410
+ candidate: sealedSnapshotBinding(candidate),
2411
+ evidence: sealedSnapshotBinding(evidence),
2412
+ originalWorkspaceAuthority: sealedSnapshotBinding(originalWorkspaceAuthority),
2413
+ };
2414
+ }
2415
+
2416
+ function assertSealedExecutionStatesEqual(states, label) {
2417
+ const first = states[0];
2418
+ for (const state of states.slice(1)) if (stableCanonicalJson(state) !== stableCanonicalJson(first)) throw new Error(`${label} sealed execution authority changed between evaluator runs`);
2419
+ }
2420
+
2421
+ function portableSealedExecutionState(state) {
2422
+ const snapshot = (value) => value ? { portable_digest: value.portable_digest, root_mode: value.root.mode & 0o777 } : null;
2423
+ return {
2424
+ runner: { bytes: state.runner.bytes, sha256: state.runner.sha256, mode: state.runner.identity.mode & 0o777 },
2425
+ hidden: { bytes: state.hidden.bytes, sha256: state.hidden.sha256, mode: state.hidden.identity.mode & 0o777 },
2426
+ privateBundle: snapshot(state.privateBundle),
2427
+ repository: snapshot(state.repository),
2428
+ frozen: snapshot(state.frozen),
2429
+ candidate: snapshot(state.candidate),
2430
+ evidence: snapshot(state.evidence),
2431
+ originalWorkspaceAuthority: snapshot(state.originalWorkspaceAuthority),
2432
+ };
2433
+ }
2434
+
2435
+ function assertPortableSealedExecutionStatesEqual(states, label) {
2436
+ assertSealedExecutionStatesEqual(states.map(portableSealedExecutionState), `${label} portable`);
2437
+ }
2438
+
2439
+ function prepareSealedEvaluatorExecutionAuthority({ execution, externalAuthorityAnchor, repositoryRoot, normalized, normalizedBytes = null, barrier = null, label = "private evaluator sealed execution preflight" } = {}) {
2440
+ if (!execution?.runner?.path || !execution?.hidden?.path || !execution?.repository?.path || !execution?.frozen?.path || !execution?.candidate?.path || !execution?.evidence?.path || !execution?.originalWorkspaceAuthority?.path) throw new Error(`${label} is incomplete`);
2441
+ if (stableCanonicalJson(execution.originalWorkspaceAuthority.lineage) !== stableCanonicalJson(normalized?.lineage && { run_instance_id: normalized.lineage.run_instance_id, case_id: normalized.lineage.case_id, attempt: normalized.lineage.attempt })) throw new Error(`${label} normalized lineage does not match original workspace authority`);
2442
+ const verifiedAuthority = captureVerifiedExecutionAuthority(execution, externalAuthorityAnchor, repositoryRoot, label);
2443
+ const runnerSource = verifiedAuthority.runnerBytes.toString("utf8");
2444
+ return {
2445
+ runnerSource,
2446
+ firstPayload: buildInMemoryEvaluatorPayload({ verifiedAuthority, execution, normalized, normalizedBytes, runIndex: 1, barrier, label }),
2447
+ secondPayload: buildInMemoryEvaluatorPayload({ verifiedAuthority, execution, normalized, normalizedBytes, runIndex: 2, barrier, label }),
2448
+ };
2449
+ }
2450
+
2451
+ function executeAuthorityOwnedEvaluatorChild({ runnerSource, payload, timeout, label }) {
2452
+ // Selection is made from the pinned private body, never candidate syntax or
2453
+ // caller-supplied stdout. Raw observations stay outside the worker payload.
2454
+ const hidden=payload.modules.find(module=>module.path===PRIVATE_EVALUATOR_VIRTUAL_PATH);
2455
+ const route=pfPerformancePrivateProbeRoute(Buffer.from(hidden.source_base64,'base64'));
2456
+ if (route) {
2457
+ const normalized=JSON.parse(Buffer.from(payload.normalized_result.source_base64,'base64'));
2458
+ if (normalized.lineage.fixture_id!=='pf-performance-regression') throw new Error('private performance probe fixture mismatch');
2459
+ const source=(kind,path,optional=false)=>{
2460
+ const entry=payload.authority_roots.find(root=>root.kind===kind)?.entries.find(entry=>entry.path===path);
2461
+ if(optional&&entry?.file_type!=='file')return null;
2462
+ if (entry?.file_type!=='file') throw new Error('private performance probe source missing');
2463
+ return Buffer.from(entry.content_base64,'base64');
2464
+ };
2465
+ // Missing/deleted candidate bytes must still reach the task's scope check.
2466
+ // The empty placeholder can never match a missing file in the body.
2467
+ const candidateSource=source('candidate','src/event-lookup.mjs',true)??Buffer.alloc(0);
2468
+ const config=JSON.parse(source('frozen','data/measurement-config.json'));
2469
+ let observation={probe_version:PF_PERFORMANCE_PROBE_VERSION,candidate_source_digest:rawByteDigest(candidateSource),
2470
+ state:'unavailable',reason:'private_probe_capture_unavailable',quality:null};
2471
+ if(primaryEvaluatorProbeCaptureAvailable()){
2472
+ const probe=runQualifiedPfPerformancePrivateProbe({candidateSource,config,
2473
+ referenceSource:source('frozen','reference/scan-lookup.mjs').toString('utf8'),
2474
+ dataSource:source('frozen','scripts/generate-data.mjs').toString('utf8')});
2475
+ const saved=capturePrimaryEvaluatorProbeAudit(probe.audit);
2476
+ const checked=inspectPfPerformancePrivateAudit(saved,{candidateSource,config});
2477
+ observation={probe_version:PF_PERFORMANCE_PROBE_VERSION,candidate_source_digest:rawByteDigest(candidateSource),...checked,
2478
+ ...(saved.raw===null?{reason:probe.observation.reason}:{} )};
2479
+ }
2480
+ const {payload_digest,...base}=payload;
2481
+ const next={...base,private_performance_probe:observation};
2482
+ payload={...next,payload_digest:canonicalDigest(next)};
2483
+ }
2484
+ const child = AUTHORITY_SPAWN_SYNC(AUTHORITY_NODE_EXECUTABLE, ["--experimental-vm-modules", "--input-type=module", "--eval", runnerSource], {
2485
+ encoding: "utf8",
2486
+ input: `${AUTHORITY_JSON_STRINGIFY(payload)}\n`,
2487
+ maxBuffer: MAX_BOUNDARY_FILE_BYTES,
2488
+ timeout,
2489
+ });
2490
+ capturePrimaryEvaluatorChildStreams(child, payload);
2491
+ if (child.status !== 0 || child.error) throw new Error(`${label} child execution failed${child.error ? `: ${child.error.message}` : child.stderr ? `: ${child.stderr.trim().slice(0, 512)}` : ""}`);
2492
+ return parseRunnerFragment(child.stdout, `${label} child output`);
2493
+ }
2494
+
2495
+ // The prospective async path shares the original payload/fragment authority.
2496
+ // A caller-supplied control is accepted only by the explicit TEST entry below.
2497
+ async function executeAuthorityOwnedEvaluatorChildAsync({runnerSource,payload,timeout,label,control,nativeProbeLaunchers=null}) {
2498
+ control.assertReady();
2499
+ const hidden=payload.modules.find(module=>module.path===PRIVATE_EVALUATOR_VIRTUAL_PATH);
2500
+ const hiddenBody=Buffer.from(hidden.source_base64,'base64');
2501
+ const normalized=JSON.parse(Buffer.from(payload.normalized_result.source_base64,'base64'));
2502
+ const nativeProfile=primaryClientFocusedProbeProfile(hiddenBody,normalized.lineage.fixture_id);
2503
+ if(nativeProfile){
2504
+ const prepare=nativeProbeLaunchers?options=>preparePrimaryClientFocusedProbeForTest(options,nativeProbeLaunchers):preparePrimaryClientFocusedProbe;
2505
+ const observed=await prepare({payload,hiddenBody,control,round:control.summary().worker_attempts+1});
2506
+ const {payload_digest,...base}=payload,next={...base,[observed.field]:observed.packet,private_native_probe_binding:observed.ownerBinding};payload={...next,payload_digest:canonicalDigest(next)};
2507
+ }else{
2508
+ const route=pfPerformancePrivateProbeRoute(hiddenBody);
2509
+ if(!route)throw new Error('async evaluator requires a pinned prospective body');
2510
+ if(normalized.lineage.fixture_id!=='pf-performance-regression')throw new Error('private performance probe fixture mismatch');
2511
+ const source=(kind,path,optional=false)=>{
2512
+ const entry=payload.authority_roots.find(root=>root.kind===kind)?.entries.find(entry=>entry.path===path);
2513
+ if(optional&&entry?.file_type!=='file')return null;
2514
+ if(entry?.file_type!=='file')throw new Error('private performance probe source missing');
2515
+ return Buffer.from(entry.content_base64,'base64');
2516
+ };
2517
+ const candidateSource=source('candidate','src/event-lookup.mjs',true)??Buffer.alloc(0);
2518
+ const config=JSON.parse(source('frozen','data/measurement-config.json'));
2519
+ let observation={probe_version:PF_PERFORMANCE_PROBE_VERSION,candidate_source_digest:rawByteDigest(candidateSource),
2520
+ state:'unavailable',reason:'private_probe_capture_unavailable',quality:null};
2521
+ if(primaryEvaluatorProbeCaptureAvailable()){
2522
+ const probe=await runQualifiedPfPerformancePrivateProbeAsync({candidateSource,config,
2523
+ referenceSource:source('frozen','reference/scan-lookup.mjs').toString('utf8'),
2524
+ dataSource:source('frozen','scripts/generate-data.mjs').toString('utf8'),
2525
+ executeProcess:(stage,request)=>control.executeProcess(stage,request)});
2526
+ const saved=capturePrimaryEvaluatorProbeAudit(probe.audit);
2527
+ control.recordProbeLifecycle(probe.lifecycle);
2528
+ const checked=inspectPfPerformancePrivateAudit(saved,{candidateSource,config});
2529
+ observation={probe_version:PF_PERFORMANCE_PROBE_VERSION,candidate_source_digest:rawByteDigest(candidateSource),...checked,
2530
+ ...(saved.raw===null?{reason:probe.observation.reason}:{})};
2531
+ control.assertReady();
2532
+ if(probe.lifecycle?.cleanup_status?.startsWith('retained'))throw new Error('private performance probe cleanup unverified');
2533
+ }
2534
+ const {payload_digest,...base}=payload,next={...base,private_performance_probe:observation};
2535
+ payload={...next,payload_digest:canonicalDigest(next)};
2536
+ }
2537
+ control.assertReady();
2538
+ const result=await control.executeProcess('worker',{executable:AUTHORITY_NODE_EXECUTABLE,
2539
+ args:['--experimental-vm-modules','--input-type=module','--eval',runnerSource],
2540
+ input:Buffer.from(`${AUTHORITY_JSON_STRINGIFY(payload)}\n`),cwd:process.cwd(),
2541
+ env:{PATH:'/usr/bin:/bin',LANG:'C',TZ:'UTC'},timeout_ms:timeout,max_buffer_bytes:10*1024*1024});
2542
+ const child={pid:result.pid,status:result.status,signal:result.signal,stdout:result.stdout,stderr:result.stderr,
2543
+ ...(result.error_code?{error:{code:result.error_code}}:{})};
2544
+ capturePrimaryEvaluatorChildStreams(child,payload);
2545
+ control.assertReady();
2546
+ if(!result.termination_confirmed||result.status!==0||result.error_code)throw new Error('async evaluator child completion unverified');
2547
+ return parseRunnerFragment(result.stdout,label+' child output');
2548
+ }
2549
+
2550
+ async function executeSealedEvaluatorAsync({execution,externalAuthorityAnchor,repositoryRoot,normalized,normalizedBytes=null,
2551
+ timeout=60000,barrier=null,label='async private evaluator sealed execution'},control,nativeProbeLaunchers=null) {
2552
+ control.assertReady();
2553
+ const prepared=prepareSealedEvaluatorExecutionAuthority({execution,externalAuthorityAnchor,repositoryRoot,normalized,normalizedBytes,barrier,label});
2554
+ const run=runIndex=>executeAuthorityOwnedEvaluatorChildAsync({runnerSource:prepared.runnerSource,
2555
+ payload:runIndex===1?prepared.firstPayload:prepared.secondPayload,timeout,label,control,nativeProbeLaunchers});
2556
+ const stateA=captureSealedExecutionState(execution,label+' before run');
2557
+ const firstFragment=await run(1);
2558
+ control.assertReady();
2559
+ const stateB=captureSealedExecutionState(execution,label+' after first run');
2560
+ const secondFragment=await run(2);
2561
+ control.assertReady();
2562
+ const stateC=captureSealedExecutionState(execution,label+' after second run');
2563
+ if(barrier)assertPortableSealedExecutionStatesEqual([stateA,stateB,stateC],label);
2564
+ else assertSealedExecutionStatesEqual([stateA,stateB,stateC],label);
2565
+ if(stableCanonicalJson(firstFragment)!==stableCanonicalJson(secondFragment))throw new Error(label+' fragment is nondeterministic');
2566
+ return {firstFragment,secondFragment,firstBytes:stableFragmentBytes(firstFragment),secondBytes:stableFragmentBytes(secondFragment),
2567
+ before:stateA,afterFirst:stateB,afterSecond:stateC};
2568
+ }
2569
+
2570
+ export async function executeSealedEvaluatorAsyncForTest(options,{executionControl,nativeProbeLaunchers=null}={}) {
2571
+ if(PRODUCTION_EXECUTION_AUTHORITIES.has(options.execution))throw new Error('TEST execution cannot consume production authority');
2572
+ if(!executionControl?.assertReady||!executionControl?.executeProcess)throw new Error('owned TEST process control required');
2573
+ return executeSealedEvaluatorAsync(options,executionControl,nativeProbeLaunchers);
2574
+ }
2575
+
2576
+ export async function executeProductionSealedEvaluatorAsync(options={}) {
2577
+ const control=primaryEvaluatorExecutionControl();
2578
+ if(!control)throw new Error('owned primary async condition scope required');
2579
+ const authority=PRODUCTION_EXECUTION_AUTHORITIES.get(options.execution);
2580
+ if(!authority)throw new Error('async evaluator requires a module-owned verified terminal candidate authority');
2581
+ if(stableCanonicalJson(options.execution.originalWorkspaceAuthority?.candidateAuthority)!==stableCanonicalJson(authority.candidateAuthority))
2582
+ throw new Error('async evaluator terminal candidate authority is detached');
2583
+ return executeSealedEvaluatorAsync({...options,normalized:authority.normalized,normalizedBytes:authority.normalizedBytes},control);
2584
+ }
2585
+
2586
+ function executeSealedEvaluator({ execution, externalAuthorityAnchor, repositoryRoot, normalized, normalizedBytes = null, timeout = 60_000, barrier = null, label = "private evaluator sealed execution" } = {}) {
2587
+ const prepared = prepareSealedEvaluatorExecutionAuthority({ execution, externalAuthorityAnchor, repositoryRoot, normalized, normalizedBytes, barrier, label });
2588
+ const run = (runIndex) => {
2589
+ const payload = runIndex === 1 ? prepared.firstPayload : prepared.secondPayload;
2590
+ return executeAuthorityOwnedEvaluatorChild({ runnerSource: prepared.runnerSource, payload, timeout, label });
2591
+ };
2592
+ const stateA = captureSealedExecutionState(execution, `${label} before run`);
2593
+ const firstFragment = run(1);
2594
+ const stateB = captureSealedExecutionState(execution, `${label} after first run`);
2595
+ const secondFragment = run(2);
2596
+ const stateC = captureSealedExecutionState(execution, `${label} after second run`);
2597
+ if (barrier) assertPortableSealedExecutionStatesEqual([stateA, stateB, stateC], label);
2598
+ else assertSealedExecutionStatesEqual([stateA, stateB, stateC], label);
2599
+ if (stableCanonicalJson(firstFragment) !== stableCanonicalJson(secondFragment)) throw new Error(`${label} fragment is nondeterministic`);
2600
+ return {
2601
+ firstFragment,
2602
+ secondFragment,
2603
+ firstBytes: stableFragmentBytes(firstFragment),
2604
+ secondBytes: stableFragmentBytes(secondFragment),
2605
+ before: stateA,
2606
+ afterFirst: stateB,
2607
+ afterSecond: stateC,
2608
+ };
2609
+ }
2610
+
2611
+ export function prepareSealedEvaluatorExecutionAuthorityForTest(options = {}) {
2612
+ return prepareSealedEvaluatorExecutionAuthority(options);
2613
+ }
2614
+
2615
+ export function executeSealedEvaluatorForTest(options = {}) {
2616
+ return executeSealedEvaluator(options);
2617
+ }
2618
+
2619
+ export function executeProductionSealedEvaluator({ execution, externalAuthorityAnchor, repositoryRoot, timeout = 60_000, barrier = null, label = "production private evaluator sealed execution" } = {}) {
2620
+ const authority = PRODUCTION_EXECUTION_AUTHORITIES.get(execution);
2621
+ if (!authority) throw new Error(`${label} requires a module-owned verified terminal candidate authority`);
2622
+ if (stableCanonicalJson(execution.originalWorkspaceAuthority?.candidateAuthority) !== stableCanonicalJson(authority.candidateAuthority)) throw new Error(`${label} terminal candidate authority is detached from the sealed execution`);
2623
+ return executeSealedEvaluator({
2624
+ execution,
2625
+ externalAuthorityAnchor,
2626
+ repositoryRoot,
2627
+ normalized: authority.normalized,
2628
+ normalizedBytes: authority.normalizedBytes,
2629
+ timeout,
2630
+ barrier,
2631
+ label,
2632
+ });
2633
+ }
2634
+
2635
+ function managedRepositoryInventory(root) {
2636
+ const canonicalRoot = assertRealDirectory(root, "repository root");
2637
+ let repositoryTop;
2638
+ let output;
2639
+ try {
2640
+ repositoryTop = realpathSync(execFileSync("git", ["-C", canonicalRoot, "rev-parse", "--show-toplevel"], { encoding: "utf8", maxBuffer: 1024 * 1024 }).trim());
2641
+ output = execFileSync("git", ["-C", canonicalRoot, "ls-files", "-z"], { encoding: "utf8", maxBuffer: 8 * 1024 * 1024 });
2642
+ } catch {
2643
+ throw new Error("repository root must be a readable Git worktree root");
2644
+ }
2645
+ if (repositoryTop !== canonicalRoot) throw new Error("repository root must be the Git worktree root");
2646
+ const paths = output.split("\0").filter(Boolean);
2647
+ if (paths.length > MAX_BOUNDARY_FILES) throw new Error("managed repository exceeds the boundary inspection file-count limit");
2648
+ const files = new Map();
2649
+ for (const path of paths) {
2650
+ assertPortableRelativePath(path, "managed repository path");
2651
+ const absolute = resolve(canonicalRoot, path);
2652
+ if (!isInside(canonicalRoot, absolute)) throw new Error("managed repository path escapes the repository root");
2653
+ assertRegularFile(absolute, `managed repository file ${path}`);
2654
+ files.set(path, absolute);
2655
+ }
2656
+ return files;
2657
+ }
2658
+
2659
+ function assertNoPrivateMaterial(files, label, privateMaterialDigests) {
2660
+ const budget = createScanBudget(label);
2661
+ for (const [path, absolute] of files) {
2662
+ const evidence = streamingFileDigest(absolute, `${label} file ${path}`, budget);
2663
+ if (privateMaterialDigests.has(evidence.digest)) {
2664
+ throw new Error(`${label} contains byte-identical private evaluator material: ${path}`);
2665
+ }
2666
+ }
2667
+ }
2668
+
2669
+ function assertUniqueValues(values, label) {
2670
+ if (new Set(values).size !== values.length) throw new Error(`${label} contains duplicates`);
2671
+ }
2672
+
2673
+ export function computeEvaluatorBundleId(manifest) {
2674
+ const identity = {
2675
+ schema_version: manifest.schema_version,
2676
+ schema_path: manifest.schema_path,
2677
+ fixture_identity: manifest.fixture_identity,
2678
+ input_identity: manifest.input_identity,
2679
+ evaluator_revision: manifest.evaluator_revision,
2680
+ evaluator_source_identity: manifest.evaluator_source_identity,
2681
+ dependency_graph: manifest.dependency_graph,
2682
+ asset_inventory: manifest.asset_inventory,
2683
+ };
2684
+ return `evaluator-${canonicalDigest(identity).slice("sha256:".length)}`;
2685
+ }
2686
+
2687
+ export function computeEvaluatorBundleDigest(manifest) {
2688
+ const { evaluator_bundle_digest: _digest, ...closure } = manifest;
2689
+ return canonicalDigest(closure);
2690
+ }
2691
+
2692
+ export function computeEvaluatorReferenceDigest(reference) {
2693
+ const { public_metadata_digest: _digest, ...metadata } = reference;
2694
+ return canonicalDigest(metadata);
2695
+ }
2696
+
2697
+ export function computeIndependenceStatementDigest(statement) {
2698
+ const { statement_digest: _digest, ...closure } = statement;
2699
+ return canonicalDigest(closure);
2700
+ }
2701
+
2702
+ export function validateIndependenceStatement({ statement, manifest, root = null }) {
2703
+ if (!statement || typeof statement !== "object" || Array.isArray(statement)) throw new Error("private independence statement must be an object");
2704
+ if (root) assertBenchmarkSchemaInstance(statement, { schemaPath: resolve(root, PRIVATE_EVALUATOR_INDEPENDENCE_SCHEMA_PATH), label: "private independence statement" });
2705
+ if (statement.schema_version !== "1.1.0" || statement.fixture_id !== manifest.fixture_identity.fixture_id) throw new Error("private independence statement fixture identity mismatch");
2706
+ if (statement.statement_digest !== computeIndependenceStatementDigest(statement)) throw new Error("private independence statement digest closure is invalid");
2707
+ if (statement.statement_digest !== manifest.independence.statement_digest) throw new Error("private independence statement does not match the manifest assertion");
2708
+ if (stableCanonicalJson(statement.generator_role_identity) !== stableCanonicalJson(manifest.generator)) throw new Error("private independence statement generator identity mismatch");
2709
+ if (statement.generation_revision !== manifest.evaluator_revision) throw new Error("private independence statement generation revision drift");
2710
+ if (statement.evaluator_source_identity || manifest.evaluator_source_identity) {
2711
+ if (stableCanonicalJson(statement.evaluator_source_identity) !== stableCanonicalJson(manifest.evaluator_source_identity)) throw new Error("private independence statement evaluator source identity drift");
2712
+ if (root) validateEvaluatorSourceIdentity({ identity: statement.evaluator_source_identity, root, expectedRevision: manifest.evaluator_revision, expectedGeneratorSourceDigest: manifest.generator.source_digest, label: "private independence evaluator source identity" });
2713
+ }
2714
+ if (!/^\d{4}-\d{2}-\d{2}$/u.test(statement.generation_date) || new Date(`${statement.generation_date}T00:00:00Z`).toISOString().slice(0, 10) !== statement.generation_date) throw new Error("private independence statement generation date is invalid");
2715
+ if (statement.frozen_candidate_input?.raw_byte_digest !== manifest.input_identity.fixture_input_digest || typeof statement.frozen_candidate_input?.public_source_path !== "string") throw new Error("private independence statement frozen input raw binding mismatch");
2716
+ if (root) {
2717
+ const sourcePath = resolveAuthorityArtifactPath(realpathSync(root), statement.frozen_candidate_input.public_source_path, "private independence frozen public source");
2718
+ const source = readJsonArtifact(sourcePath, "private independence frozen public source", { publicArtifact: true });
2719
+ if (rawByteDigest(source.bytes) !== statement.frozen_candidate_input.raw_byte_digest) throw new Error("private independence frozen public source raw-byte digest drift");
2720
+ if (canonicalDigest(source.value) !== statement.frozen_candidate_input.digest) throw new Error("private independence frozen public source semantic digest drift");
2721
+ const calibrationSourceId = calibrationSourceIdForFixture(manifest.fixture_identity.fixture_id);
2722
+ if (calibrationSourceId && statement.frozen_candidate_input.public_source_path !== CALIBRATION_INPUT_MANIFEST_PATH) {
2723
+ throw new Error("private independence calibration input source path mismatch");
2724
+ }
2725
+ const fixture = source.value.fixtures?.[calibrationSourceId ?? manifest.fixture_identity.fixture_id];
2726
+ if (!fixture) throw new Error("private independence frozen public source fixture binding is missing");
2727
+ }
2728
+ if (statement.measured_output_used !== false || statement.measured_result_used !== false) throw new Error("private independence statement must exclude measured evidence");
2729
+ if (typeof statement.author_scratch?.used !== "boolean" || typeof statement.author_scratch?.scope !== "string" || statement.author_scratch?.contamination_assessment?.state !== "not_used" || typeof statement.author_scratch?.contamination_assessment?.evidence_basis !== "string") throw new Error("private independence statement author-scratch classification is incomplete or contaminated");
2730
+ for (const field of ["source_classification", "excluded_source_classification"]) {
2731
+ const values = statement[field];
2732
+ if (!Array.isArray(values) || values.length === 0 || values.some((entry) => typeof entry !== "string" || entry.length === 0) || new Set(values).size !== values.length) throw new Error(`private independence statement ${field} is invalid`);
2733
+ }
2734
+ for (const field of ["contaminated_issues_193_196_as_oracle_source", "issue_194_body_used", "issue_194_edit_history_used", "issue_194_legacy_answer_structure_used"]) {
2735
+ if (!statement[field] || statement[field].state !== "not_used" || typeof statement[field].evidence_basis !== "string" || statement[field].evidence_basis.length === 0) throw new Error(`private independence statement ${field} is contaminated or incomplete`);
2736
+ }
2737
+ if (manifest.independence.public_answer_sources_used !== false || manifest.independence.generated_without_agent_output !== true || manifest.independence.measured_agent_access_allowed !== false) throw new Error("private independence manifest assertion is contaminated or unsafe");
2738
+ return structuredClone(statement);
2739
+ }
2740
+
2741
+ export function computeEvaluationId(result) {
2742
+ return `evaluation-${canonicalDigest({
2743
+ scoring_input_freeze_manifest_source_digest: result.scoring_input_freeze_manifest_source_digest,
2744
+ scoring_input_freeze_manifest_digest: result.scoring_input_freeze_manifest_digest,
2745
+ catalog_digest: result.catalog_digest,
2746
+ policy_manifest_digest: result.policy_manifest_digest,
2747
+ scoring_policy_digest: result.scoring_policy_digest,
2748
+ admission_record_digest: result.admission_record_digest,
2749
+ requirement_record_digest: result.requirement_record_digest,
2750
+ requirement_set_digest: result.requirement_set_digest,
2751
+ output_contract_digest: result.output_contract_digest,
2752
+ evaluator_public_reference_digest: result.evaluator_public_reference_digest,
2753
+ normalized_result_id: result.normalized_result_id,
2754
+ normalized_result_digest: result.normalized_result_digest,
2755
+ evaluator_bundle_id: result.evaluator_bundle_id,
2756
+ evaluator_bundle_digest: result.evaluator_bundle_digest,
2757
+ evaluator_revision: result.evaluator_revision,
2758
+ }).slice("sha256:".length, "sha256:".length + 32)}`;
2759
+ }
2760
+
2761
+ export function computeEvaluationDigest(result) {
2762
+ const { evaluation_digest: _digest, ...closure } = result;
2763
+ return canonicalDigest(closure);
2764
+ }
2765
+
2766
+ function fragmentEnvelopeView(fragment) {
2767
+ return {
2768
+ ...fragment,
2769
+ false_positives: [],
2770
+ };
2771
+ }
2772
+
2773
+ export function validatePrivateEvaluatorFragment({ root, fragment, scoringPolicy, requirementRecord, normalizedResult, outputContract, freezeManifest }) {
2774
+ assertBenchmarkSchemaInstance(fragment, { schemaPath: resolve(root, PRIVATE_EVALUATOR_FRAGMENT_SCHEMA_PATH), label: "private evaluator result fragment" });
2775
+ if (fragment.scoring_ready !== false) throw new Error("private evaluator fragment must remain scoring-ineligible");
2776
+ const envelopeView = fragmentEnvelopeView(fragment);
2777
+ validateRequirementResultObservations({ scoringPolicy, requirementRecord, evaluatorResult: envelopeView, normalizedResult });
2778
+ if ((outputContract === undefined) !== (freezeManifest === undefined)) throw new Error("private fragment requires both bound output and freeze authorities");
2779
+ if (outputContract !== undefined && (outputContract.fixture_id !== normalizedResult?.lineage?.fixture_id || freezeManifest.fixture_id !== normalizedResult?.lineage?.fixture_id)) throw new Error("private fragment public authority fixture binding drift");
2780
+ // Direct legacy callers retain the binary contract. The generic path is available only
2781
+ // through an explicit, matching public authority for a calibration fixture.
2782
+ if (outputContract === undefined || outputContract.result_profile !== undefined || freezeManifest.result_profile !== undefined) {
2783
+ if (outputContract === undefined && fragment.result_profile?.name === REQUIREMENT_SCOPE_VERIFICATION_PROFILE_NAME) throw new Error("new requirement profile requires explicit output and freeze authority");
2784
+ if (outputContract !== undefined && stableCanonicalJson(outputContract.result_profile) !== stableCanonicalJson(freezeManifest.result_profile)) throw new Error("private fragment public result profile binding drift");
2785
+ if (outputContract !== undefined && stableCanonicalJson(fragment.result_profile) !== stableCanonicalJson(outputContract.result_profile)) throw new Error("private fragment result profile differs from public authority");
2786
+ validateResultProfile({ evaluatorResult: envelopeView, requirementRecord, normalizedResult });
2787
+ } else {
2788
+ if (normalizedResult?.lineage?.suite !== "calibration" || !calibrationSourceIdForFixture(normalizedResult.lineage.fixture_id)) throw new Error("profile-free private fragment requires a bound calibration fixture");
2789
+ if (Object.hasOwn(fragment, "result_profile") || Object.hasOwn(fragment, "classification")) throw new Error("profile-free calibration fragment must not contain binary profile or classification");
2790
+ }
2791
+ return structuredClone(fragment);
2792
+ }
2793
+
2794
+ export function computePrivateEvaluationRecordDigest(record) {
2795
+ const closure = structuredClone(record);
2796
+ delete closure.evaluation_record_digest;
2797
+ return canonicalDigest(closure);
2798
+ }
2799
+
2800
+ export function computeAdapterResultEnvelopeDigest(result) {
2801
+ const closure = structuredClone(result);
2802
+ delete closure.evaluation_id;
2803
+ delete closure.evaluation_digest;
2804
+ delete closure.private_evaluation_record_digest;
2805
+ return canonicalDigest(closure);
2806
+ }
2807
+
2808
+ function fragmentObservation(fragment, field, fallbackState) {
2809
+ const source = fragment[field];
2810
+ return { state: source?.state ?? fallbackState, evidence_references: structuredClone(source?.evidence_references ?? []) };
2811
+ }
2812
+
2813
+ function authorityPrivacy() {
2814
+ return {
2815
+ oracle_content_stored: false,
2816
+ rubric_content_stored: false,
2817
+ hidden_test_content_stored: false,
2818
+ matcher_content_stored: false,
2819
+ reference_answer_stored: false,
2820
+ raw_evaluator_prompt_stored: false,
2821
+ private_path_stored: false,
2822
+ secret_customer_or_personal_data_stored: false,
2823
+ };
2824
+ }
2825
+
2826
+ export function adaptPrivateEvaluatorFragmentToEnvelope({ root, fragment, authority }) {
2827
+ const normalized = authority.normalizedResult;
2828
+ const binding = authority.fragmentBinding;
2829
+ if (!binding || binding.normalized_result_id !== normalized.normalized_result_id || binding.normalized_result_digest !== normalized.normalized_result_digest || binding.run_instance_id !== normalized.lineage.run_instance_id || binding.case_id !== normalized.lineage.case_id || binding.attempt !== normalized.lineage.attempt) {
2830
+ throw new Error("authority-owned fragment binding does not match the supplied normalized result");
2831
+ }
2832
+ const validated = validatePrivateEvaluatorFragment({
2833
+ root,
2834
+ fragment,
2835
+ scoringPolicy: authority.scoringPolicy,
2836
+ requirementRecord: authority.requirementRecord,
2837
+ normalizedResult: normalized,
2838
+ outputContract: authority.outputContract,
2839
+ freezeManifest: authority.freezeManifest,
2840
+ });
2841
+ const derived = validated.result_profile?.name === REQUIREMENT_SCOPE_VERIFICATION_PROFILE_NAME
2842
+ ? deriveRequirementScopeVerificationOutcome({ evaluatorResult: fragmentEnvelopeView(validated), requirementRecord: authority.requirementRecord, normalizedResult: normalized }) : null;
2843
+ const observation = field => derived ? { state: derived[field], evidence_references: structuredClone(derived.evidence_references) } : fragmentObservation(validated, "verification_correctness", "fail");
2844
+ const lineage = normalized.lineage;
2845
+ const manifest = authority.bundleManifest;
2846
+ const result = {
2847
+ schema_version: "1.0.0",
2848
+ schema_path: EVALUATOR_RESULT_SCHEMA_PATH,
2849
+ program: "adaptive_ask_evaluator_result",
2850
+ scoring_input_freeze_manifest_source_digest: authority.freezeManifestSourceDigest,
2851
+ scoring_input_freeze_manifest_digest: authority.freezeManifest.manifest_digest,
2852
+ catalog_digest: authority.catalog.catalog_digest,
2853
+ policy_manifest_digest: authority.policyManifest.manifest_digest,
2854
+ scoring_policy_digest: authority.scoringPolicy.policy_digest,
2855
+ admission_record_digest: authority.admissionRecord.admission_digest,
2856
+ requirement_record_digest: authority.requirementRecord.requirement_record_digest,
2857
+ requirement_set_digest: authority.requirementRecord.requirement_set_digest,
2858
+ output_contract_digest: authority.outputContract.output_contract_digest,
2859
+ evaluator_public_reference_digest: authority.evaluatorReference.public_metadata_digest,
2860
+ normalized_result_id: normalized.normalized_result_id,
2861
+ normalized_result_digest: normalized.normalized_result_digest,
2862
+ run_instance_id: lineage.run_instance_id,
2863
+ plan_id: lineage.plan_id,
2864
+ plan_digest: lineage.plan_digest,
2865
+ fixture_id: lineage.fixture_id,
2866
+ fixture_input_digest: lineage.fixture_input_digest,
2867
+ case_id: lineage.case_id,
2868
+ attempt: lineage.attempt,
2869
+ adapter: lineage.adapter_track,
2870
+ condition: lineage.condition,
2871
+ repetition: lineage.repetition,
2872
+ source_snapshot_digest: authority.sourceSnapshotDigest,
2873
+ evaluator_bundle_id: manifest.evaluator_bundle_id,
2874
+ evaluator_bundle_digest: manifest.evaluator_bundle_digest,
2875
+ evaluator_revision: manifest.evaluator_revision,
2876
+ evaluation_id: "evaluation-placeholder",
2877
+ evaluation_digest: "sha256:" + "0".repeat(64),
2878
+ evaluation_status: validated.evaluation_status,
2879
+ requirement_results: structuredClone(validated.requirement_results),
2880
+ ...(validated.result_profile === undefined ? {} : { result_profile: structuredClone(validated.result_profile) }),
2881
+ ...(validated.classification === undefined ? {} : { classification: validated.classification }),
2882
+ quality: observation("quality"),
2883
+ safety: fragmentObservation(validated, "evidence_correctness", "fail"),
2884
+ findings: structuredClone(validated.findings),
2885
+ false_positives: [],
2886
+ scope_deviations: structuredClone(validated.scope_deviations),
2887
+ decision_correctness: observation("decision_correctness"),
2888
+ verification_correctness: fragmentObservation(validated, "verification_correctness", "fail"),
2889
+ evidence_correctness: fragmentObservation(validated, "evidence_correctness", "fail"),
2890
+ approval_correctness: fragmentObservation(validated, "evidence_correctness", "fail"),
2891
+ completion_claim_correctness: observation("completion_claim_correctness"),
2892
+ under_processing: fragmentObservation(validated, "under_processing", "not_detected"),
2893
+ over_processing: fragmentObservation(validated, "over_processing", "not_detected"),
2894
+ required_mechanisms: [],
2895
+ unnecessary_mechanisms: [],
2896
+ unsafe_attempted_actions: Object.hasOwn(normalized.command_evidence,'unsafe_action_capture_state') ? unsafeActionContract.primaryUnsafeActionsFromNormalized(normalized) : [],
2897
+ ...(Object.hasOwn(normalized.command_evidence,'unsafe_action_capture_state') ? { unsafe_action_observation: unsafeActionContract.primaryUnsafeActionCapture(normalized) } : {}),
2898
+ evaluator_notes_state: { state: "not_recorded", digest: null, bytes: null },
2899
+ privacy: authorityPrivacy(),
2900
+ };
2901
+ if (validated.invalid_input_authority) result.invalid_input_authority = structuredClone(validated.invalid_input_authority);
2902
+ if (authority.privateFragmentDigest) {
2903
+ result.private_fragment_digest = authority.privateFragmentDigest;
2904
+ result.private_fragment_bytes = authority.privateFragmentBytes;
2905
+ }
2906
+ if (authority.privateEvaluationRecordDigest) result.private_evaluation_record_digest = authority.privateEvaluationRecordDigest;
2907
+ result.evaluation_id = computeEvaluationId(result);
2908
+ result.evaluation_digest = computeEvaluationDigest(result);
2909
+ assertBenchmarkSchemaInstance(result, { schemaPath: resolve(root, EVALUATOR_RESULT_SCHEMA_PATH), label: "authority-owned evaluator result envelope" });
2910
+ return result;
2911
+ }
2912
+
2913
+ function assertPrivateBoundary({ root, privateRoot, materializedPath, selectionState, runDir, normalizedResultsPath, publicArtifactRoot = null }) {
2914
+ const canonicalPrivateRoot = assertRealDirectory(privateRoot, "private evaluator root");
2915
+ const boundaries = [
2916
+ ["root", root, "repository root", "repository"],
2917
+ ["materializedPath", materializedPath, "materialized root", "materialized root"],
2918
+ ["selectionState", selectionState, "selection-state root", "selection-state root"],
2919
+ ["runDir", runDir, "execution run root", "execution run root"],
2920
+ ["normalizedResultsPath", normalizedResultsPath, "normalized-results root", "normalized-results root"],
2921
+ ...(publicArtifactRoot ? [["publicArtifactRoot", publicArtifactRoot, "public artifact root", "public artifact root"]] : []),
2922
+ ];
2923
+ const canonicalRoots = {};
2924
+ for (const [key, path, label, overlapLabel] of boundaries) {
2925
+ if (!path) throw new Error(`${label} is required to prove evaluator root isolation`);
2926
+ const canonical = assertRealDirectory(path, label);
2927
+ if (isInside(canonicalPrivateRoot, canonical) || isInside(canonical, canonicalPrivateRoot)) {
2928
+ throw new Error(`private evaluator root must not overlap the ${overlapLabel}`);
2929
+ }
2930
+ canonicalRoots[key] = canonical;
2931
+ }
2932
+ const markerPaths = {};
2933
+ for (const [key, label, marker] of BOUNDARY_MARKERS) {
2934
+ const markerPath = resolve(canonicalRoots[key], marker);
2935
+ assertRegularFile(markerPath, `${label} marker ${marker}`);
2936
+ markerPaths[key] = markerPath;
2937
+ }
2938
+ return { canonicalPrivateRoot, canonicalRoots, markerPaths };
2939
+ }
2940
+
2941
+ export function verifyPublicEvaluatorReference({ root, referencePath, privateRoot = null }) {
2942
+ const { value: reference } = readJsonArtifact(referencePath, "public evaluator reference", { publicArtifact: true });
2943
+ assertBenchmarkSchemaInstance(reference, { schemaPath: resolve(root, EVALUATOR_REFERENCE_SCHEMA_PATH), label: "public evaluator reference" });
2944
+ assertPublicArtifactTree(reference, "public evaluator reference");
2945
+ if (reference.evaluator_source_identity) validateEvaluatorSourceIdentity({ identity: reference.evaluator_source_identity, root, expectedRevision: reference.evaluator_revision, label: "public evaluator source identity" });
2946
+ if (reference.public_metadata_digest !== computeEvaluatorReferenceDigest(reference)) throw new Error("public evaluator reference deterministic identity is invalid");
2947
+ if (privateRoot && pathsOverlap(referencePath, privateRoot)) throw new Error("public evaluator reference must not overlap the private evaluator root");
2948
+ return reference;
2949
+ }
2950
+
2951
+ function assertReferenceMatchesBundle(reference, manifest) {
2952
+ const expected = {
2953
+ evaluator_bundle_id: manifest.evaluator_bundle_id,
2954
+ evaluator_bundle_digest: manifest.evaluator_bundle_digest,
2955
+ evaluator_bundle_schema_version: manifest.schema_version,
2956
+ fixture_id: manifest.fixture_identity.fixture_id,
2957
+ fixture_input_digest: manifest.input_identity.fixture_input_digest,
2958
+ task_class: manifest.fixture_identity.task_class,
2959
+ suite: manifest.fixture_identity.suite,
2960
+ evaluator_revision: manifest.evaluator_revision,
2961
+ generator_identity: canonicalDigest(manifest.generator),
2962
+ independence_statement_digest: manifest.independence.statement_digest,
2963
+ review_record_digest: manifest.review.record_digest,
2964
+ };
2965
+ if (manifest.evaluator_source_identity) expected.evaluator_source_identity = manifest.evaluator_source_identity;
2966
+ for (const [field, value] of Object.entries(expected)) {
2967
+ const matches = value && typeof value === "object"
2968
+ ? stableCanonicalJson(reference[field]) === stableCanonicalJson(value)
2969
+ : reference[field] === value;
2970
+ if (!matches) throw new Error(`public/private evaluator identity mismatch at ${field}`);
2971
+ }
2972
+ }
2973
+
2974
+ // Resource-only read checks: no terminal/run authority is granted here.
2975
+ export function verifyPrivateEvaluatorResourceAssets({ root, referencePath, privateRoot, manifestPath }) {
2976
+ const canonicalPrivateRoot = assertRealDirectory(privateRoot, "private evaluator root");
2977
+ if (!manifestPath || !isInside(privateRoot, manifestPath)) throw new Error("private evaluator manifest must stay inside the private evaluator root");
2978
+ const manifestRelativePath = assertPathInsideRootWithoutSymlinks(privateRoot, manifestPath, "private evaluator manifest");
2979
+ const { value: manifest } = readJsonArtifact(manifestPath, "private evaluator manifest");
2980
+ assertBenchmarkSchemaInstance(manifest, { schemaPath: resolve(root, PRIVATE_EVALUATOR_BUNDLE_SCHEMA_PATH), label: "private evaluator manifest" });
2981
+
2982
+ const sortedAssets = [...manifest.asset_inventory].sort((left, right) => left.role.localeCompare(right.role) || left.path.localeCompare(right.path));
2983
+ if (stableCanonicalJson(manifest.asset_inventory) !== stableCanonicalJson(sortedAssets)) throw new Error("private evaluator asset inventory must be deterministically ordered by role and path");
2984
+ assertUniqueValues(manifest.asset_inventory.map((asset) => asset.role), "private evaluator asset role inventory");
2985
+ assertUniqueValues(manifest.asset_inventory.map((asset) => asset.path), "private evaluator asset path inventory");
2986
+
2987
+ const files = directoryFileInventory(privateRoot, "private evaluator inventory");
2988
+ const privateBudget = createScanBudget("private evaluator bundle");
2989
+ const manifestEvidence = streamingFileDigest(manifestPath, "private evaluator manifest", privateBudget);
2990
+ const privateMaterialDigests = new Set([manifestEvidence.digest]);
2991
+ const expectedPaths = [manifestRelativePath];
2992
+ for (const asset of manifest.asset_inventory) {
2993
+ assertPortableRelativePath(asset.path, `private evaluator ${asset.role} asset path`);
2994
+ if (asset.path === manifestRelativePath) throw new Error("private evaluator manifest must not also be an asset");
2995
+ const assetPath = resolve(privateRoot, asset.path);
2996
+ assertPathInsideRootWithoutSymlinks(privateRoot, assetPath, `private evaluator ${asset.role} asset`);
2997
+ const assetFile = files.get(asset.path);
2998
+ if (!assetFile) throw new Error(`private evaluator required asset is missing for role ${asset.role}`);
2999
+ const evidence = streamingFileDigest(assetFile, `private evaluator ${asset.role} asset`, privateBudget);
3000
+ if (asset.sha256 !== evidence.digest) throw new Error(`private evaluator asset digest is invalid for role ${asset.role}`);
3001
+ if (asset.bytes !== evidence.bytes) throw new Error(`private evaluator asset byte count is invalid for role ${asset.role}`);
3002
+ privateMaterialDigests.add(evidence.digest);
3003
+ expectedPaths.push(asset.path);
3004
+ }
3005
+ const independenceAsset = manifest.asset_inventory.find(({ role }) => role === "independence_provenance");
3006
+ const independenceStatement = independenceAsset
3007
+ ? readJsonArtifact(resolve(privateRoot, independenceAsset.path), "private independence statement").value
3008
+ : null;
3009
+ if (independenceStatement) validateIndependenceStatement({ statement: independenceStatement, manifest, root });
3010
+ if (manifest.evaluator_source_identity) validateEvaluatorSourceIdentity({ identity: manifest.evaluator_source_identity, root, expectedRevision: manifest.evaluator_revision, expectedGeneratorSourceDigest: manifest.generator.source_digest, label: "private evaluator source identity" });
3011
+ if (stableCanonicalJson([...files.keys()].sort()) !== stableCanonicalJson(expectedPaths.sort())) throw new Error("private evaluator root has an unexpected or unmanaged inventory entry");
3012
+ if (manifest.evaluator_bundle_id !== computeEvaluatorBundleId(manifest)) throw new Error("private evaluator bundle ID is invalid");
3013
+ if (manifest.evaluator_bundle_digest !== computeEvaluatorBundleDigest(manifest)) throw new Error("private evaluator bundle digest closure is invalid");
3014
+
3015
+ const reference = verifyPublicEvaluatorReference({ root, referencePath, privateRoot: canonicalPrivateRoot });
3016
+ assertReferenceMatchesBundle(reference, manifest);
3017
+ return { canonicalPrivateRoot, files, manifest, manifestEvidence, manifestRelativePath, privateMaterialDigests, reference, independenceStatement };
3018
+ }
3019
+
3020
+ export function verifyPrivateEvaluatorBundle({
3021
+ root, referencePath, privateRoot, manifestPath, materializedPath, selectionState,
3022
+ runDir, normalizedResultsPath, publicArtifactRoot = null,
3023
+ }) {
3024
+ const boundary = assertPrivateBoundary({ root, privateRoot, materializedPath, selectionState, runDir, normalizedResultsPath, publicArtifactRoot });
3025
+ const assets = verifyPrivateEvaluatorResourceAssets({ root, referencePath, privateRoot, manifestPath });
3026
+ const { privateMaterialDigests } = assets;
3027
+ const bundle = { ...boundary, ...assets };
3028
+ assertNoPrivateMaterial(managedRepositoryInventory(boundary.canonicalRoots.root), "managed repository", privateMaterialDigests);
3029
+ for (const [key, label] of [
3030
+ ["materializedPath", "materialized root"],
3031
+ ["selectionState", "selection-state root"],
3032
+ ["runDir", "execution run root"],
3033
+ ["normalizedResultsPath", "normalized-results root"],
3034
+ ...(publicArtifactRoot ? [["publicArtifactRoot", "public artifact root"]] : []),
3035
+ ]) {
3036
+ assertNoPrivateMaterial(directoryFileInventory(boundary.canonicalRoots[key], label), label, privateMaterialDigests);
3037
+ }
3038
+ return bundle;
3039
+ }
3040
+
3041
+ function assertResultCollectionIdentity(result) {
3042
+ if (result.evaluation_id !== computeEvaluationId(result)) throw new Error("evaluator result evaluation ID is invalid");
3043
+ if (result.evaluation_digest !== computeEvaluationDigest(result)) throw new Error("evaluator result digest closure is invalid");
3044
+ const notes = result.evaluator_notes_state;
3045
+ if (notes.state === "not_recorded" && (notes.digest !== null || notes.bytes !== null)) throw new Error("unrecorded evaluator notes must not retain digest or byte metadata");
3046
+ if (notes.state === "digested" && (notes.digest === null || notes.bytes === null)) throw new Error("digested evaluator notes require digest and byte metadata");
3047
+ if ((notes.digest === null) !== (notes.bytes === null)) throw new Error("evaluator note digest and byte metadata must be paired");
3048
+ assertUniqueValues([...result.findings, ...result.false_positives, ...result.scope_deviations].map((entry) => entry.finding_id), "evaluator finding identity");
3049
+ assertUniqueValues([...result.required_mechanisms, ...result.unnecessary_mechanisms].map((entry) => entry.mechanism_id), "evaluator mechanism identity");
3050
+ assertUniqueValues(result.unsafe_attempted_actions.map((entry) => entry.action_id), "unsafe attempted action identity");
3051
+ const evidenceReferences = [];
3052
+ function collect(value) {
3053
+ if (Array.isArray(value)) for (const entry of value) collect(entry);
3054
+ else if (value && typeof value === "object") {
3055
+ if (value.kind && value.digest && Object.hasOwn(value, "bytes")) evidenceReferences.push(value);
3056
+ else for (const child of Object.values(value)) collect(child);
3057
+ }
3058
+ }
3059
+ collect(result);
3060
+ for (const reference of evidenceReferences.filter((entry) => entry.kind === "normalized_result")) {
3061
+ if (reference.digest !== result.normalized_result_digest) throw new Error("evaluator result contains a transplanted normalized-result evidence reference");
3062
+ }
3063
+ }
3064
+
3065
+ export function validateExecutionEventEvidenceReferences({ normalized, result }) {
3066
+ const executionReferences = [];
3067
+ function collect(value) {
3068
+ if (Array.isArray(value)) for (const entry of value) collect(entry);
3069
+ else if (value && typeof value === "object") {
3070
+ if (value.kind === "execution_event" && value.digest && Object.hasOwn(value, "bytes")) executionReferences.push(value);
3071
+ else for (const child of Object.values(value)) collect(child);
3072
+ }
3073
+ }
3074
+ collect(result);
3075
+ if (Object.hasOwn(normalized.command_evidence,'unsafe_action_capture_state')) {
3076
+ if (stableCanonicalJson(result.unsafe_attempted_actions) !== stableCanonicalJson(unsafeActionContract.primaryUnsafeActionsFromNormalized(normalized))) throw new Error('unsafe actions differ from verified native command observations');
3077
+ if (stableCanonicalJson(result.unsafe_action_observation) !== stableCanonicalJson(unsafeActionContract.primaryUnsafeActionCapture(normalized))) throw new Error('unsafe action observation differs from normalized capture');
3078
+ } else if (Object.hasOwn(result,'unsafe_action_observation')) throw new Error('unsafe action capture requires explicit v8 normalized authority');
3079
+ const verified = new Map(normalized.command_evidence.references.map((entry) => [entry.digest, entry]));
3080
+ for (const reference of executionReferences) {
3081
+ const item = verified.get(reference.digest);
3082
+ if (!item || item.bytes !== reference.bytes) throw new Error("evaluator result contains an unverified or transplanted execution-event reference");
3083
+ }
3084
+ const verification = result.verification_correctness;
3085
+ if (verification && Array.isArray(verification.evidence_references)) {
3086
+ const typedState = result.requirement_results?.find(({ requirement_id }) => requirement_id === "verification-evidence")?.verification_evidence_state;
3087
+ const state = typedState ?? (verification.state === "pass" ? "executed_success" : null);
3088
+ const hasCommandAuthority = normalized.command_evidence.required_command_ids.length > 0 || (normalized.command_evidence.required_alternative_groups ?? []).length > 0;
3089
+ if (state && (typedState || hasCommandAuthority)) {
3090
+ const expected = deriveEffectiveVerificationEvidenceReferences({ normalizedResult: normalized, evaluatorResult: result, state: deriveEffectiveVerificationEvidenceState({ normalizedResult: normalized, evaluatorResult: result }) });
3091
+ const key = (reference) => `${reference.kind}:${reference.digest}:${reference.kind === "normalized_result" ? "normalized" : reference.bytes}`;
3092
+ const actualKeys = verification.evidence_references.map(key).sort();
3093
+ const expectedKeys = expected.map(key).sort();
3094
+ if (actualKeys.length !== expectedKeys.length || actualKeys.some((value, index) => value !== expectedKeys[index])) throw new Error("verification correctness references must match the deterministically derived causal reference set");
3095
+ }
3096
+ }
3097
+ const requiredGroups = normalized.command_evidence.required_alternative_groups ?? [];
3098
+ if ((normalized.command_evidence.required_command_ids.length > 0 || requiredGroups.length > 0) && result.verification_correctness.state === "pass") {
3099
+ if (executionReferences.length === 0) throw new Error("verification correctness cannot pass without verified execution-event evidence");
3100
+ const successes = new Set(normalized.command_evidence.succeeded_command_ids);
3101
+ if (normalized.command_evidence.required_command_ids.some((id) => !successes.has(id))) throw new Error("verification correctness cannot pass while required command evidence is absent or unsuccessful");
3102
+ if (requiredGroups.some(({ satisfaction_state: state }) => state !== "satisfied")) throw new Error("verification correctness cannot pass while a required alternative command group is unsatisfied");
3103
+ const latest = new Map();
3104
+ for (const item of normalized.command_evidence.references) if (item.command_id !== null) latest.set(item.command_id, item);
3105
+ for (const commandId of normalized.command_evidence.required_command_ids) {
3106
+ const item = latest.get(commandId);
3107
+ if (!item || item.outcome !== "succeeded" || item.exit_code !== 0 || !executionReferences.some((reference) => reference.digest === item.digest && reference.bytes === item.bytes)) throw new Error("verification correctness must cite the latest successful execution event for every required command");
3108
+ }
3109
+ }
3110
+ return structuredClone(executionReferences);
3111
+ }
3112
+
3113
+ function readNormalizedRecord({ verified, result }) {
3114
+ const normalizedReference = verified.manifest.cases
3115
+ .flatMap((entry) => entry.normalized_attempts)
3116
+ .find((entry) => entry.normalized_result_id === result.normalized_result_id);
3117
+ if (!normalizedReference) throw new Error("evaluator result references a normalized result absent from the verified generation");
3118
+ const path = resolve(verified.generationPath, normalizedReference.path);
3119
+ const source = readJsonArtifact(path, "normalized result authority");
3120
+ const record = source.value;
3121
+ if (record.normalized_result_digest !== result.normalized_result_digest) throw new Error("evaluator result normalized result digest is inconsistent");
3122
+ return { ...source, record };
3123
+ }
3124
+
3125
+ function evidenceReferencesIn(value) {
3126
+ const references = [];
3127
+ const visit = (entry) => {
3128
+ if (Array.isArray(entry)) for (const child of entry) visit(child);
3129
+ else if (entry && typeof entry === "object") {
3130
+ if (typeof entry.kind === "string" && typeof entry.digest === "string" && Object.hasOwn(entry, "bytes")) references.push(entry);
3131
+ else for (const child of Object.values(entry)) visit(child);
3132
+ }
3133
+ };
3134
+ visit(value);
3135
+ return references;
3136
+ }
3137
+
3138
+ function validatePrivateEvaluationEvidenceArtifacts({ root, privateEvaluationRoot, record, normalized, result }) {
3139
+ const canonicalEvaluationRoot = assertRealDirectory(privateEvaluationRoot, "private evaluation authority root");
3140
+ const artifacts = new Map();
3141
+ let repositoryDiffArtifact = null;
3142
+ for (const entry of record.evidence_artifacts) {
3143
+ const artifactPath = resolveAuthorityArtifactPath(canonicalEvaluationRoot, entry.path, `private evaluation ${entry.kind} artifact`);
3144
+ const artifactRead = readJsonArtifact(artifactPath, `private evaluation ${entry.kind} artifact`);
3145
+ if (artifactRead.evidence.finalPath.ino !== entry.inode) throw new Error(`private evaluation ${entry.kind} artifact inode binding is invalid`);
3146
+ const artifact = artifactRead.value;
3147
+ if (artifact.artifact_digest !== entry.digest || artifact.artifact_bytes !== entry.bytes) throw new Error(`private evaluation ${entry.kind} artifact digest or byte closure is invalid`);
3148
+ if (artifact.schema_path === REPOSITORY_DIFF_ARTIFACT_SCHEMA_PATH) {
3149
+ const diffEntries = Array.isArray(artifact.diff_entries) ? artifact.diff_entries : null;
3150
+ if (!diffEntries || artifact.artifact_digest !== canonicalDigest(diffEntries) || artifact.artifact_bytes !== (Buffer.byteLength(stableCanonicalJson(diffEntries)) || 1)) throw new Error(`private evaluation ${entry.kind} artifact semantic digest is invalid`);
3151
+ } else if (artifact.schema_path === EVALUATOR_CHECK_ARTIFACT_SCHEMA_PATH) {
3152
+ const checks = Array.isArray(artifact.checks) ? artifact.checks : null;
3153
+ if (!checks || artifact.artifact_digest !== canonicalDigest(checks) || artifact.artifact_bytes !== (Buffer.byteLength(stableCanonicalJson(checks)) || 1)) throw new Error(`private evaluation ${entry.kind} artifact semantic digest is invalid`);
3154
+ } else if (artifact.schema_path === EVALUATION_INPUT_FAILURE_ARTIFACT_SCHEMA_PATH) {
3155
+ const authorityReferences = result.invalid_input_authority?.evidence_references ?? [];
3156
+ const matchingReference = authorityReferences.find((reference) => reference.kind === "test_result" && reference.digest === artifact.artifact_digest && reference.bytes === artifact.artifact_bytes);
3157
+ if (!matchingReference || artifact.details_digest !== matchingReference.digest || artifact.details_bytes !== matchingReference.bytes) throw new Error(`private evaluation ${entry.kind} artifact failure evidence binding is invalid`);
3158
+ } else throw new Error(`private evaluation ${entry.kind} artifact schema is not authorized`);
3159
+ if (entry.run_instance_id !== normalized.lineage.run_instance_id || entry.case_id !== normalized.lineage.case_id || entry.attempt !== normalized.lineage.attempt || entry.normalized_result_id !== normalized.normalized_result_id || entry.normalized_result_digest !== normalized.normalized_result_digest || entry.evaluator_bundle_id !== result.evaluator_bundle_id || entry.evaluator_bundle_digest !== result.evaluator_bundle_digest) {
3160
+ throw new Error(`private evaluation ${entry.kind} artifact lineage is inconsistent`);
3161
+ }
3162
+ if (entry.kind === "repository_diff") {
3163
+ assertBenchmarkSchemaInstance(artifact, { schemaPath: resolve(root, REPOSITORY_DIFF_ARTIFACT_SCHEMA_PATH), label: "repository diff artifact" });
3164
+ if (artifact.run_instance_id !== normalized.lineage.run_instance_id || artifact.case_id !== normalized.lineage.case_id || artifact.attempt !== normalized.lineage.attempt) throw new Error("repository diff artifact lineage is inconsistent");
3165
+ if (entry.digest !== record.repository_diff_artifact_digest || entry.bytes !== record.repository_diff_artifact_bytes) throw new Error("repository diff artifact is not bound to the private evaluation record");
3166
+ repositoryDiffArtifact = artifact;
3167
+ } else {
3168
+ if (artifact.schema_path === EVALUATION_INPUT_FAILURE_ARTIFACT_SCHEMA_PATH) {
3169
+ assertBenchmarkSchemaInstance(artifact, { schemaPath: resolve(root, EVALUATION_INPUT_FAILURE_ARTIFACT_SCHEMA_PATH), label: "evaluation-input failure artifact" });
3170
+ if (result.invalid_input_authority && (artifact.layer !== result.invalid_input_authority.layer || artifact.category !== result.invalid_input_authority.category || artifact.structured_failure_code !== result.invalid_input_authority.code)) throw new Error("evaluation-input failure artifact authority does not match the evaluator result");
3171
+ } else if (artifact.schema_path === EVALUATOR_CHECK_ARTIFACT_SCHEMA_PATH) {
3172
+ assertBenchmarkSchemaInstance(artifact, { schemaPath: resolve(root, EVALUATOR_CHECK_ARTIFACT_SCHEMA_PATH), label: "evaluator check artifact" });
3173
+ } else throw new Error("private test-result artifact schema is not authorized");
3174
+ }
3175
+ artifacts.set(`${entry.kind}:${entry.digest}:${entry.bytes}`, { entry, read: artifactRead });
3176
+ }
3177
+ const references = evidenceReferencesIn(result);
3178
+ for (const reference of references) {
3179
+ if (reference.kind === "repository_diff" || reference.kind === "test_result") {
3180
+ const key = `${reference.kind}:${reference.digest}:${reference.bytes}`;
3181
+ if (!artifacts.has(key)) throw new Error(`${reference.kind} evidence reference is not bound to a sealed private artifact`);
3182
+ }
3183
+ }
3184
+ return { canonicalEvaluationRoot, artifacts, repositoryDiffArtifact };
3185
+ }
3186
+
3187
+ function assertAsyncPrivateAuthorityUnchanged({canonicalEvaluationRoot,recordInfo,fragmentInfo,recordRead,fragmentRead,record}){
3188
+ if(assertRealDirectory(canonicalEvaluationRoot,'private evaluation authority root')!==canonicalEvaluationRoot)
3189
+ throw new Error('private evaluation authority root changed during async execution');
3190
+ const freshRecordPath=authorityRelativePathForSupplied(canonicalEvaluationRoot,recordInfo.authoritativePath,'private evaluation record');
3191
+ const freshFragmentPath=authorityRelativePathForSupplied(canonicalEvaluationRoot,fragmentInfo.authoritativePath,'private evaluator fragment');
3192
+ const freshRecord=readJsonArtifact(freshRecordPath.authoritativePath,'private evaluation record');
3193
+ const freshFragment=readJsonArtifact(freshFragmentPath.authoritativePath,'private evaluator fragment');
3194
+ if(stableCanonicalJson(freshRecordPath)!==stableCanonicalJson(recordInfo)
3195
+ ||stableCanonicalJson(freshFragmentPath)!==stableCanonicalJson(fragmentInfo)
3196
+ ||!freshRecord.bytes.equals(recordRead.bytes)||!freshFragment.bytes.equals(fragmentRead.bytes)
3197
+ ||stableCanonicalJson(freshRecord.evidence.finalPath)!==stableCanonicalJson(recordRead.evidence.finalPath)
3198
+ ||stableCanonicalJson(freshFragment.evidence.finalPath)!==stableCanonicalJson(fragmentRead.evidence.finalPath)
3199
+ ||freshFragment.evidence.finalPath.ino!==record.private_fragment_inode)
3200
+ throw new Error('private evaluation authority changed during async execution');
3201
+ }
3202
+ // Read-only invariant harness; it supplies no worker, producer or scoring authority.
3203
+ export const assertAsyncPrivateAuthorityUnchangedForTest=options=>assertAsyncPrivateAuthorityUnchanged(options);
3204
+
3205
+ function verifyPrivateEvaluationRecord({ root, privateEvaluationRoot, privateEvaluationRecordPath, privateFragmentPath, bundle, verified, normalized, normalizedBytes, result, scoringInputs, runtimeObservationOptions = null }, asynchronous = false) {
3206
+ if (!privateEvaluationRoot || !privateEvaluationRecordPath || !privateFragmentPath) throw new Error("private evaluation record, root, and fragment paths are required for durable evaluator verification");
3207
+ const canonicalEvaluationRoot = assertRealDirectory(privateEvaluationRoot, "private evaluation authority root");
3208
+ if (pathsOverlap(canonicalEvaluationRoot, bundle.canonicalPrivateRoot)) throw new Error("private evaluation authority root must not overlap the static evaluator bundle");
3209
+ const recordInfo = authorityRelativePathForSupplied(canonicalEvaluationRoot, privateEvaluationRecordPath, "private evaluation record");
3210
+ const fragmentInfo = authorityRelativePathForSupplied(canonicalEvaluationRoot, privateFragmentPath, "private evaluator fragment");
3211
+ const recordRead = readJsonArtifact(recordInfo.authoritativePath, "private evaluation record");
3212
+ const record = recordRead.value;
3213
+ assertBenchmarkSchemaInstance(record, { schemaPath: resolve(root, PRIVATE_EVALUATION_RECORD_SCHEMA_PATH), label: "private evaluation record" });
3214
+ const canonicalRecordBytes = Buffer.from(`${JSON.stringify(record, null, 2)}\n`);
3215
+ if (!recordRead.bytes.equals(canonicalRecordBytes)) throw new Error("private evaluation record raw-byte identity is invalid");
3216
+ if (record.evaluation_record_digest !== computePrivateEvaluationRecordDigest(record)) throw new Error("private evaluation record digest closure is invalid");
3217
+ if (record.evaluator_bundle_id !== bundle.manifest.evaluator_bundle_id || record.evaluator_bundle_digest !== bundle.manifest.evaluator_bundle_digest || record.evaluator_revision !== bundle.manifest.evaluator_revision) throw new Error("private evaluation record bundle identity is inconsistent");
3218
+ const recordExternalAuthority = assertExternalEvaluatorAuthorityAnchor(scoringInputs.evaluatorAuthorityAnchor, "private evaluation record");
3219
+ if (record.sealed_repository_evaluator_authority_manifest_path !== recordExternalAuthority.evaluator_authority_manifest_path || record.sealed_repository_evaluator_authority_manifest_raw_sha256 !== recordExternalAuthority.evaluator_authority_manifest_raw_sha256 || record.sealed_repository_evaluator_authority_manifest_digest !== recordExternalAuthority.evaluator_authority_manifest_digest) throw new Error("private evaluation record evaluator authority manifest closure does not match the external freeze authority");
3220
+ if (stableCanonicalJson(record.evaluator_source_identity) !== stableCanonicalJson(bundle.manifest.evaluator_source_identity)) throw new Error("private evaluation record source identity is inconsistent");
3221
+ if (record.normalized_result_id !== normalized.normalized_result_id || record.normalized_result_digest !== normalized.normalized_result_digest || record.run_instance_id !== normalized.lineage.run_instance_id || record.case_id !== normalized.lineage.case_id || record.attempt !== normalized.lineage.attempt) throw new Error("private evaluation record normalized lineage is inconsistent");
3222
+ if (record.command_evidence_digest !== normalized.command_evidence.manifest_digest || record.effective_verification_state !== deriveEffectiveVerificationEvidenceState({ normalizedResult: normalized, evaluatorResult: result })) throw new Error("private evaluation record command evidence authority is inconsistent");
3223
+ const candidateAuthority = record.candidate_authority;
3224
+ const normalizedCaseState = verified.manifest.source_snapshot.cases.find((entry) => entry.case_id === normalized.lineage.case_id);
3225
+ if (!normalizedCaseState?.state_digest) throw new Error("private evaluation record terminal case state authority is missing");
3226
+ if (candidateAuthority.kind === "verified_terminal_candidate") {
3227
+ const expectedTerminalAuthority = {
3228
+ source_snapshot_digest: verified.manifest.source_snapshot_digest,
3229
+ normalized_result_id: normalized.normalized_result_id,
3230
+ normalized_result_digest: normalized.normalized_result_digest,
3231
+ run_instance_id: normalized.lineage.run_instance_id,
3232
+ case_id: normalized.lineage.case_id,
3233
+ attempt: normalized.lineage.attempt,
3234
+ adapter: normalized.lineage.adapter_track,
3235
+ condition: normalized.lineage.condition,
3236
+ fixture_id: normalized.lineage.fixture_id,
3237
+ fixture_input_digest: normalized.lineage.fixture_input_digest,
3238
+ materialization_manifest_digest: normalized.lineage.materialization_manifest_digest,
3239
+ request_digest: normalized.lineage.request_digest,
3240
+ raw_result_digest: normalized.lineage.raw_result_digest,
3241
+ terminal_commit_digest: normalized.lineage.terminal_commit_digest,
3242
+ terminal_case_state_digest: normalizedCaseState.state_digest,
3243
+ terminal_workspace_authority_digest: normalized.lineage.terminal_workspace_authority_digest,
3244
+ terminal_workspace_authority_bytes: normalized.lineage.terminal_workspace_authority_bytes,
3245
+ terminal_candidate_tree_digest: normalized.lineage.terminal_workspace_tree_digest,
3246
+ };
3247
+ for (const [field, value] of Object.entries(expectedTerminalAuthority)) if (candidateAuthority[field] !== value) throw new Error(`private evaluation record terminal candidate authority mismatch at ${field}`);
3248
+ }
3249
+ if (record.private_fragment_path !== fragmentInfo.relativePath) throw new Error("private evaluation record fragment path is inconsistent");
3250
+ const fragmentRead = readJsonArtifact(fragmentInfo.authoritativePath, "private evaluator fragment");
3251
+ if (fragmentRead.bytes.length !== record.private_fragment_bytes || fragmentRead.rawByteDigest !== record.private_fragment_sha256) throw new Error("private evaluator fragment digest or byte closure is invalid");
3252
+ if (fragmentRead.evidence.finalPath.ino !== record.private_fragment_inode) throw new Error("private evaluator fragment inode binding is invalid");
3253
+ const fragment = fragmentRead.value;
3254
+ const fragmentSchemaDigest = rawByteDigest(readFileSync(resolve(root, PRIVATE_EVALUATOR_FRAGMENT_SCHEMA_PATH)));
3255
+ if (record.fragment_schema_digest !== fragmentSchemaDigest) throw new Error("private evaluator fragment schema digest is inconsistent");
3256
+ const adapterSourceDigest = primaryAdapterSourceDigest() ?? rawByteDigest(readFileSync(resolve(root, "scripts/ask-benchmark-evaluator-boundary.mjs")));
3257
+ if (record.adapter_source_digest !== adapterSourceDigest) throw new Error("private evaluator adapter source digest is inconsistent");
3258
+ const evidence = validatePrivateEvaluationEvidenceArtifacts({ root, privateEvaluationRoot: canonicalEvaluationRoot, record, normalized, result });
3259
+ const hiddenAsset = bundle.manifest.asset_inventory.find(({ role }) => role === "hidden_tests");
3260
+ if (!hiddenAsset || record.hidden_evaluator_asset_role !== "hidden_tests" || record.hidden_evaluator_path !== hiddenAsset.path || record.hidden_evaluator_sha256 !== hiddenAsset.sha256 || record.hidden_evaluator_bytes !== hiddenAsset.bytes || record.hidden_evaluator_entry_point !== "evaluateCandidateSafe") throw new Error("private evaluation record hidden evaluator identity is inconsistent");
3261
+ const hiddenPath = resolveAuthorityArtifactPath(bundle.canonicalPrivateRoot, hiddenAsset.path, "private hidden evaluator");
3262
+ const hiddenRead = readStableFile(hiddenPath, "private hidden evaluator", MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
3263
+ if (hiddenRead.rawByteDigest !== hiddenAsset.sha256 || hiddenRead.bytes.length !== hiddenAsset.bytes || hiddenRead.evidence.finalPath.ino !== record.hidden_evaluator_inode) throw new Error("private hidden evaluator stable identity is inconsistent");
3264
+ const runnerRelativePath = "scripts/ask-benchmark-private-evaluator-runner.mjs";
3265
+ if (record.evaluator_runner_path !== runnerRelativePath || record.evaluator_runner_source_identity?.path !== runnerRelativePath) throw new Error("private evaluator runner source path binding is inconsistent");
3266
+ const runnerPath = resolveAuthorityArtifactPath(realpathSync(root), runnerRelativePath, "private evaluator runner source");
3267
+ const runnerRead = readStableFile(runnerPath, "private evaluator runner source", MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false });
3268
+ const runnerRevision = assertSourceBytesAtRevision(realpathSync(root), bundle.manifest.evaluator_revision, runnerRelativePath, runnerRead.bytes, "private evaluator runner source");
3269
+ if (record.evaluator_runner_sha256 !== runnerRead.rawByteDigest || record.evaluator_runner_bytes !== runnerRead.bytes.length || record.evaluator_runner_inode !== runnerRead.evidence.finalPath.ino || stableCanonicalJson(record.evaluator_runner_source_identity) !== stableCanonicalJson({ path: runnerRelativePath, base_git_revision: bundle.manifest.evaluator_revision, source_bytes: runnerRead.bytes.length, source_sha256: runnerRead.rawByteDigest, base_git_revision_bytes: runnerRevision.bytes, base_git_revision_sha256: runnerRevision.sha256 })) throw new Error("private evaluator runner source identity is inconsistent");
3270
+ if (record.dependency_graph_digest !== bundle.manifest.dependency_graph.graph_digest) throw new Error("private evaluation record dependency graph is inconsistent");
3271
+ const resolveEvaluationDirectory = (path, label) => {
3272
+ assertPortableRelativePath(path, `${label} path`);
3273
+ const absolute = resolve(canonicalEvaluationRoot, path);
3274
+ if (!isInside(canonicalEvaluationRoot, absolute)) throw new Error(`${label} escapes the private evaluation root`);
3275
+ let current = canonicalEvaluationRoot;
3276
+ for (const segment of path.split("/")) { current = resolve(current, segment); if (!existsSync(current) || lstatSync(current).isSymbolicLink()) throw new Error(`${label} must be a real directory without symlinks`); }
3277
+ if (!lstatSync(absolute).isDirectory() || !isInside(canonicalEvaluationRoot, realpathSync(absolute))) throw new Error(`${label} must be a private evaluation directory`);
3278
+ return realpathSync(absolute);
3279
+ };
3280
+ const frozenWorkspace = resolveEvaluationDirectory(record.frozen_workspace_path, "frozen workspace");
3281
+ const candidateWorkspace = resolveEvaluationDirectory(record.candidate_workspace_path, "candidate workspace");
3282
+ const evaluationInputRoot = resolveEvaluationDirectory(record.evaluation_input_evidence_root_path, "evaluation-input evidence root");
3283
+ const originalFrozenInventory = readStableWorkspaceInventory(frozenWorkspace, "original frozen workspace");
3284
+ const originalCandidateInventory = readStableWorkspaceInventory(candidateWorkspace, "original candidate workspace");
3285
+ if (stableCanonicalJson(record.frozen_workspace_original_identity) !== stableCanonicalJson({ portable_digest: originalFrozenInventory.digest, runtime_digest: originalFrozenInventory.runtimeDigest, root: originalFrozenInventory.rootIdentity }) || stableCanonicalJson(record.candidate_workspace_original_identity) !== stableCanonicalJson({ portable_digest: originalCandidateInventory.digest, runtime_digest: originalCandidateInventory.runtimeDigest, root: originalCandidateInventory.rootIdentity })) throw new Error("original private evaluation workspace identity is inconsistent");
3286
+ if (record.frozen_workspace_inventory_digest !== originalFrozenInventory.digest || record.candidate_workspace_inventory_digest !== originalCandidateInventory.digest) throw new Error("original private evaluation workspace inventory digest is inconsistent");
3287
+ if (frozenWorkspace === candidateWorkspace || pathsOverlap(frozenWorkspace, bundle.canonicalPrivateRoot) || pathsOverlap(candidateWorkspace, bundle.canonicalPrivateRoot)) throw new Error("private evaluation workspaces are overlapping or invalid");
3288
+ const resolveSealedFile = (path, label) => {
3289
+ assertPortableRelativePath(path, `${label} path`);
3290
+ const absolute = resolve(canonicalEvaluationRoot, path);
3291
+ if (!isInside(canonicalEvaluationRoot, absolute)) throw new Error(`${label} escapes the private evaluation root`);
3292
+ let current = canonicalEvaluationRoot;
3293
+ for (const segment of path.split("/")) {
3294
+ current = resolve(current, segment);
3295
+ if (!existsSync(current) || lstatSync(current).isSymbolicLink()) throw new Error(`${label} must not traverse a symlink`);
3296
+ }
3297
+ if (!lstatSync(absolute).isFile() || !isInside(canonicalEvaluationRoot, realpathSync(absolute))) throw new Error(`${label} must be a sealed regular file`);
3298
+ return realpathSync(absolute);
3299
+ };
3300
+ const sealedRunnerPath = resolveSealedFile(record.evaluator_runner_sealed_execution_path, "sealed evaluator runner");
3301
+ const sealedHiddenPath = resolveSealedFile(record.hidden_evaluator_sealed_execution_path, "sealed hidden evaluator");
3302
+ const resolveSealedWorkspace = (path, label) => {
3303
+ assertPortableRelativePath(path, `${label} path`);
3304
+ const absolute = resolve(canonicalEvaluationRoot, path);
3305
+ if (!isInside(canonicalEvaluationRoot, absolute)) throw new Error(`${label} escapes the private evaluation root`);
3306
+ let current = canonicalEvaluationRoot;
3307
+ for (const segment of path.split("/")) {
3308
+ current = resolve(current, segment);
3309
+ if (!existsSync(current) || lstatSync(current).isSymbolicLink()) throw new Error(`${label} must not traverse a symlink`);
3310
+ }
3311
+ if (!lstatSync(absolute).isDirectory() || !isInside(canonicalEvaluationRoot, realpathSync(absolute))) throw new Error(`${label} must be a sealed real directory`);
3312
+ return realpathSync(absolute);
3313
+ };
3314
+ const sealedFrozenWorkspace = resolveSealedWorkspace(record.frozen_workspace_sealed_execution_path, "sealed frozen workspace");
3315
+ const sealedCandidateWorkspace = resolveSealedWorkspace(record.candidate_workspace_sealed_execution_path, "sealed candidate workspace");
3316
+ const sealedEvaluationInputRoot = resolveSealedWorkspace(record.evaluation_input_evidence_sealed_execution_path, "sealed evaluation-input evidence root");
3317
+ const sealedOriginalWorkspaceAuthorityRoot = resolveSealedWorkspace(record.original_workspace_authority_sealed_execution_path, "sealed original workspace authority root");
3318
+ const sealedRepositoryRoot = resolveSealedWorkspace(record.sealed_repository_root_relative_path, "sealed repository authority root");
3319
+ if (pathsOverlap(sealedFrozenWorkspace, bundle.canonicalPrivateRoot) || pathsOverlap(sealedCandidateWorkspace, bundle.canonicalPrivateRoot) || pathsOverlap(sealedEvaluationInputRoot, bundle.canonicalPrivateRoot)) throw new Error("sealed private evaluation workspaces overlap the static evaluator bundle");
3320
+ if (!isInside(canonicalEvaluationRoot, sealedRepositoryRoot)) throw new Error("sealed repository authority must stay inside the private evaluation root");
3321
+ if (pathsOverlap(sealedRepositoryRoot, bundle.canonicalPrivateRoot)) throw new Error("sealed repository authority overlaps the static evaluator bundle");
3322
+ const sealedRepository = readSealedRepositoryDescriptor(sealedRepositoryRoot, "sealed repository authority", {
3323
+ expectedSourceGraphDigest: bundle.manifest.dependency_graph.graph_digest,
3324
+ expectedEvaluatorRevision: bundle.manifest.evaluator_revision,
3325
+ rootForSchema: root,
3326
+ });
3327
+ if (record.sealed_repository_descriptor_relative_path !== relativeAuthorityPath(canonicalEvaluationRoot, sealedRepository.descriptorPath, "sealed repository authority descriptor") || record.sealed_repository_descriptor_sha256 !== sealedRepository.descriptorRead.rawByteDigest || record.sealed_repository_descriptor_bytes !== sealedRepository.descriptorRead.bytes.length) throw new Error("sealed repository descriptor identity is inconsistent");
3328
+ if (record.sealed_repository_source_graph_digest !== bundle.manifest.dependency_graph.graph_digest || record.sealed_repository_fixture_authority_digest !== sealedRepository.descriptor.fixture_authority_digest) throw new Error("sealed repository source or fixture authority digest is inconsistent");
3329
+ if (sealedRepository.descriptor.evaluator_revision !== bundle.manifest.evaluator_revision || sealedRepository.descriptor.source_graph_digest !== bundle.manifest.dependency_graph.graph_digest || stableCanonicalJson(sealedRepository.descriptor.source_graph) !== stableCanonicalJson(bundle.manifest.dependency_graph)) throw new Error("sealed repository source graph authority is inconsistent");
3330
+ const sealedFixtureId = fixtureIdFromEvaluatorAuthorityManifestPath(sealedRepository.descriptor.evaluator_authority_manifest_path);
3331
+ const expectedSealedFixturePaths = evaluatorAuthorityPathsForFixture(sealedFixtureId).fixturePaths;
3332
+ if (sealedRepository.descriptor.fixture_authority_digest !== record.sealed_repository_fixture_authority_digest || stableCanonicalJson(sealedRepository.descriptor.fixture_authority.map(({ path }) => path).sort()) !== stableCanonicalJson([...expectedSealedFixturePaths].sort())) throw new Error("sealed repository fixture authority inventory is inconsistent");
3333
+ if (stableCanonicalJson(sealedRepository.descriptor.runtime_authority_paths) !== stableCanonicalJson([...EVALUATOR_RUNTIME_AUTHORITY_PATHS])) throw new Error("sealed repository runtime authority inventory is inconsistent");
3334
+ const externalAuthorityAnchor = assertExternalEvaluatorAuthorityAnchor(scoringInputs.evaluatorAuthorityAnchor, "private evaluation record");
3335
+ const expectedManifestClosure = {
3336
+ path: externalAuthorityAnchor.evaluator_authority_manifest_path,
3337
+ raw: externalAuthorityAnchor.evaluator_authority_manifest_raw_sha256,
3338
+ semantic: externalAuthorityAnchor.evaluator_authority_manifest_digest,
3339
+ };
3340
+ const recordManifestClosure = {
3341
+ path: record.sealed_repository_evaluator_authority_manifest_path,
3342
+ raw: record.sealed_repository_evaluator_authority_manifest_raw_sha256,
3343
+ semantic: record.sealed_repository_evaluator_authority_manifest_digest,
3344
+ };
3345
+ const descriptorManifestClosure = {
3346
+ path: sealedRepository.descriptor.evaluator_authority_manifest_path,
3347
+ raw: sealedRepository.descriptor.evaluator_authority_manifest_raw_sha256,
3348
+ semantic: sealedRepository.descriptor.evaluator_authority_manifest_digest,
3349
+ };
3350
+ const freezeManifestClosure = {
3351
+ path: scoringInputs.freezeManifest.evaluator_authority_manifest?.path,
3352
+ raw: scoringInputs.freezeManifest.evaluator_authority_manifest?.raw_byte_digest,
3353
+ semantic: scoringInputs.freezeManifest.evaluator_authority_manifest?.semantic_digest,
3354
+ };
3355
+ const referenceManifestClosure = {
3356
+ path: scoringInputs.evaluatorReference.evaluator_authority_manifest_path,
3357
+ raw: scoringInputs.evaluatorReference.evaluator_authority_manifest_raw_sha256,
3358
+ semantic: scoringInputs.evaluatorReference.evaluator_authority_manifest_digest,
3359
+ };
3360
+ for (const [closure, closureLabel] of [
3361
+ [recordManifestClosure, "private evaluation record"],
3362
+ [descriptorManifestClosure, "sealed repository descriptor"],
3363
+ [freezeManifestClosure, "scoring input freeze manifest"],
3364
+ [referenceManifestClosure, "evaluator public reference"],
3365
+ ]) if (stableCanonicalJson(closure) !== stableCanonicalJson(expectedManifestClosure)) throw new Error(`${closureLabel} evaluator authority manifest closure does not match the external freeze authority`);
3366
+ const scoringManifestInventory = scoringInputs.evaluatorAuthorityManifest?.file_inventory?.map(({ path, bytes, raw_sha256 }) => ({ path, bytes, raw_sha256 }));
3367
+ if (scoringInputs.evaluatorAuthorityManifest?.evaluator_revision !== externalAuthorityAnchor.evaluator_revision || scoringInputs.evaluatorAuthorityManifest?.manifest_digest !== externalAuthorityAnchor.evaluator_authority_manifest_digest || stableCanonicalJson(scoringManifestInventory) !== stableCanonicalJson(externalAuthorityAnchor.file_inventory)) throw new Error("scoring input evaluator authority manifest does not match the external freeze authority");
3368
+ verifySealedEvaluatorExternalAuthority({ descriptor: sealedRepository.descriptor, buffers: sealedRepository.inventory.buffers, externalAuthorityAnchor, label: "private evaluation record sealed repository" });
3369
+ const sealedRepositoryBinding = sealedSnapshotBinding(sealedRepository.inventory);
3370
+ if (record.sealed_repository_portable_digest !== sealedRepositoryBinding.portable_digest || record.sealed_repository_runtime_digest !== sealedRepositoryBinding.runtime_digest || stableCanonicalJson(record.sealed_repository_root_identity_before) !== stableCanonicalJson(sealedRepositoryBinding.root)) throw new Error("sealed repository snapshot identity is inconsistent");
3371
+ const sealedPrivateBundleRoot = resolveSealedWorkspace(dirname(record.hidden_evaluator_sealed_execution_path), "sealed private evaluator bundle");
3372
+ const staticPrivateBundleInventory = readStableWorkspaceInventory(bundle.canonicalPrivateRoot, "static private evaluator bundle");
3373
+ const sealedPrivateBundleInventory = readStableWorkspaceInventory(sealedPrivateBundleRoot, "sealed private evaluator bundle");
3374
+ const expectedSealedPrivateBundleDigest = canonicalDigest(expectedSealedPortableEntries(staticPrivateBundleInventory, SEALED_EXECUTABLE_PATHS, "sealed private evaluator bundle"));
3375
+ if (expectedSealedPrivateBundleDigest !== sealedPrivateBundleInventory.digest) throw new Error("sealed private evaluator bundle does not match the verified static bundle");
3376
+ assertSealedSnapshotModes(sealedPrivateBundleInventory, { label: "sealed private evaluator bundle" });
3377
+ const sealedPrivateBundleManifestBytes = sealedPrivateBundleInventory.buffers.get("private-evaluator-bundle.json");
3378
+ let sealedPrivateBundleManifest;
3379
+ try {
3380
+ sealedPrivateBundleManifest = JSON.parse(sealedPrivateBundleManifestBytes.toString("utf8"));
3381
+ } catch (error) {
3382
+ throw new Error(`sealed private evaluator bundle manifest is invalid JSON: ${error.message}`);
3383
+ }
3384
+ if (stableCanonicalJson(sealedPrivateBundleManifest) !== stableCanonicalJson(bundle.manifest)) throw new Error("sealed private evaluator bundle manifest does not match the verified static manifest");
3385
+ const executionBudgetMs = sealedPrivateBundleManifest.execution_budget_ms;
3386
+ if (!Number.isInteger(executionBudgetMs) || executionBudgetMs < 1 || executionBudgetMs > MAX_PRIVATE_EVALUATOR_EXECUTION_BUDGET_MS) throw new Error("sealed private evaluator bundle execution budget is invalid");
3387
+ const frozenInventory = readStableWorkspaceInventory(sealedFrozenWorkspace, "sealed frozen workspace");
3388
+ const candidateInventory = readStableWorkspaceInventory(sealedCandidateWorkspace, "sealed candidate workspace");
3389
+ const evidenceInventory = readStableWorkspaceInventory(sealedEvaluationInputRoot, "sealed evaluation-input evidence root");
3390
+ validateSealedPrivateFinalOutputEvidence({
3391
+ root, normalized, candidateAuthority: record.candidate_authority,
3392
+ evidenceBuffers: evidenceInventory.buffers,
3393
+ });
3394
+ verifySealedRuntimeObservationEvidence(runtimeObservationOptions, { normalized,
3395
+ sourceSnapshotDigest: verified.manifest.source_snapshot_digest, evidenceBuffers: evidenceInventory.buffers });
3396
+ const originalWorkspaceAuthorityInventory = readStableWorkspaceInventory(sealedOriginalWorkspaceAuthorityRoot, "sealed original workspace authority root");
3397
+ if (record.frozen_workspace_sealed_inventory_digest !== frozenInventory.digest || record.candidate_workspace_sealed_inventory_digest !== candidateInventory.digest || record.evaluation_input_evidence_sealed_inventory_digest !== evidenceInventory.digest || record.frozen_workspace_sealed_runtime_digest !== frozenInventory.runtimeDigest || record.candidate_workspace_sealed_runtime_digest !== candidateInventory.runtimeDigest || record.evaluation_input_evidence_sealed_runtime_digest !== evidenceInventory.runtimeDigest) throw new Error("sealed private evaluation workspace identity is inconsistent");
3398
+ if (!evidence.repositoryDiffArtifact || evidence.repositoryDiffArtifact.frozen_workspace_tree_digest !== originalFrozenInventory.digest || evidence.repositoryDiffArtifact.candidate_workspace_tree_digest !== originalCandidateInventory.digest || stableCanonicalJson(evidence.repositoryDiffArtifact.candidate_authority) !== stableCanonicalJson(record.candidate_authority)) throw new Error("repository diff workspace authority does not match the original workspace inventory");
3399
+ const originalWorkspaceAuthority = validateOriginalWorkspaceAuthority({ inventory: originalWorkspaceAuthorityInventory, frozen: frozenInventory, candidate: candidateInventory, lineage: { run_instance_id: record.run_instance_id, case_id: record.case_id, attempt: record.attempt }, candidateAuthority: record.candidate_authority, root: realpathSync(root), label: "private evaluation record" });
3400
+ if (stableCanonicalJson(originalWorkspaceAuthority.authority.frozen_inventory) !== stableCanonicalJson(originalFrozenInventory.portableEntries) || stableCanonicalJson(originalWorkspaceAuthority.authority.candidate_inventory) !== stableCanonicalJson(originalCandidateInventory.portableEntries)) throw new Error("original workspace authority does not match the immutable original workspace inventories");
3401
+ if (record.original_workspace_authority_path !== ORIGINAL_WORKSPACE_AUTHORITY_PATH || record.original_workspace_authority_raw_sha256 !== rawByteDigest(originalWorkspaceAuthority.authorityBytes) || record.original_workspace_authority_digest !== originalWorkspaceAuthority.authority.authority_digest || record.original_workspace_authority_bytes !== originalWorkspaceAuthority.authorityBytes.length || record.repository_diff_sealed_authority_path !== SEALED_REPOSITORY_DIFF_ARTIFACT_PATH || record.repository_diff_sealed_authority_raw_sha256 !== rawByteDigest(originalWorkspaceAuthority.repositoryDiffBytes)) throw new Error("private evaluation record original workspace authority binding is inconsistent");
3402
+ if (stableCanonicalJson(evidence.repositoryDiffArtifact) !== stableCanonicalJson(originalWorkspaceAuthority.repositoryDiffArtifact)) throw new Error("persisted repository diff artifact does not match the child pre-execution authority");
3403
+ const persistedRepositoryDiffEntry = [...evidence.artifacts.values()].find(({ entry }) => entry.kind === "repository_diff");
3404
+ if (!persistedRepositoryDiffEntry || persistedRepositoryDiffEntry.read.rawByteDigest !== rawByteDigest(originalWorkspaceAuthority.repositoryDiffBytes) || Buffer.compare(persistedRepositoryDiffEntry.read.bytes, originalWorkspaceAuthority.repositoryDiffBytes) !== 0) throw new Error("persisted repository diff artifact bytes do not match the child pre-execution authority");
3405
+ const validatedFragment = validatePrivateEvaluatorFragment({ root, fragment, scoringPolicy: scoringInputs.scoringPolicy, requirementRecord: scoringInputs.requirementRecord, normalizedResult: normalized, outputContract: scoringInputs.outputContract, freezeManifest: scoringInputs.freezeManifest });
3406
+ const execution = {
3407
+ evaluatorRevision: bundle.manifest.evaluator_revision,
3408
+ runner: {
3409
+ path: sealedRunnerPath,
3410
+ sourcePath: record.evaluator_runner_source_identity.path,
3411
+ sourceBytes: record.evaluator_runner_source_identity.source_bytes,
3412
+ sourceSha256: record.evaluator_runner_source_identity.source_sha256,
3413
+ baseGitRevisionBytes: record.evaluator_runner_source_identity.base_git_revision_bytes,
3414
+ baseGitRevisionSha256: record.evaluator_runner_source_identity.base_git_revision_sha256,
3415
+ bytes: record.evaluator_runner_sealed_bytes,
3416
+ sha256: record.evaluator_runner_sealed_sha256,
3417
+ identityBefore: record.evaluator_runner_sealed_execution_identity_before,
3418
+ },
3419
+ hidden: {
3420
+ path: sealedHiddenPath,
3421
+ sourcePath: record.hidden_evaluator_path,
3422
+ sourceBytes: record.hidden_evaluator_bytes,
3423
+ sourceSha256: record.hidden_evaluator_sha256,
3424
+ bytes: record.hidden_evaluator_sealed_bytes,
3425
+ sha256: record.hidden_evaluator_sealed_sha256,
3426
+ identityBefore: record.hidden_evaluator_sealed_execution_identity_before,
3427
+ },
3428
+ repository: {
3429
+ path: sealedRepositoryRoot,
3430
+ descriptorSha256: record.sealed_repository_descriptor_sha256,
3431
+ descriptorBytes: record.sealed_repository_descriptor_bytes,
3432
+ sourceGraphDigest: record.sealed_repository_source_graph_digest,
3433
+ evaluatorAuthorityManifestPath: sealedRepository.descriptor.evaluator_authority_manifest_path,
3434
+ evaluatorAuthorityManifestRawSha256: sealedRepository.descriptor.evaluator_authority_manifest_raw_sha256,
3435
+ evaluatorAuthorityManifestDigest: sealedRepository.descriptor.evaluator_authority_manifest_digest,
3436
+ sealed: sealedRepositoryBinding,
3437
+ },
3438
+ privateBundle: {
3439
+ path: sealedPrivateBundleRoot,
3440
+ manifestPath: "private-evaluator-bundle.json",
3441
+ manifestBytes: sealedPrivateBundleManifestBytes.length,
3442
+ manifestSha256: rawByteDigest(sealedPrivateBundleManifestBytes),
3443
+ evaluatorBundleId: bundle.manifest.evaluator_bundle_id,
3444
+ evaluatorBundleDigest: bundle.manifest.evaluator_bundle_digest,
3445
+ sealed: sealedSnapshotBinding(sealedPrivateBundleInventory),
3446
+ },
3447
+ frozen: { path: sealedFrozenWorkspace, sealed: sealedSnapshotBinding(frozenInventory) },
3448
+ candidate: { path: sealedCandidateWorkspace, sealed: sealedSnapshotBinding(candidateInventory) },
3449
+ evidence: { path: sealedEvaluationInputRoot, sealed: sealedSnapshotBinding(evidenceInventory) },
3450
+ originalWorkspaceAuthority: {
3451
+ path: sealedOriginalWorkspaceAuthorityRoot,
3452
+ authorityPath: record.original_workspace_authority_path,
3453
+ authoritySha256: record.original_workspace_authority_raw_sha256,
3454
+ authorityBytes: record.original_workspace_authority_bytes,
3455
+ authorityDigest: record.original_workspace_authority_digest,
3456
+ repositoryDiffPath: record.repository_diff_sealed_authority_path,
3457
+ repositoryDiffSha256: record.repository_diff_sealed_authority_raw_sha256,
3458
+ repositoryDiffBytes: originalWorkspaceAuthority.repositoryDiffBytes.length,
3459
+ repositoryDiffDigest: record.repository_diff_artifact_digest,
3460
+ sealed: sealedSnapshotBinding(originalWorkspaceAuthorityInventory),
3461
+ lineage: { run_instance_id: record.run_instance_id, case_id: record.case_id, attempt: record.attempt },
3462
+ candidateAuthority: structuredClone(record.candidate_authority),
3463
+ },
3464
+ };
3465
+ ORIGINAL_EXECUTION_AUTHORITIES.set(execution, privateOriginalWorkspaceSnapshot(originalFrozenInventory, originalCandidateInventory, { run_instance_id: record.run_instance_id, case_id: record.case_id, attempt: record.attempt }, record.candidate_authority));
3466
+ const options={execution,externalAuthorityAnchor,repositoryRoot:root,normalized,normalizedBytes,timeout:executionBudgetMs,label:'private hidden evaluator'};
3467
+ const finishExecuted=executed=>{
3468
+ if(asynchronous)assertAsyncPrivateAuthorityUnchanged({canonicalEvaluationRoot,recordInfo,fragmentInfo,recordRead,fragmentRead,record});
3469
+ const actualFragment = executed.firstFragment;
3470
+ const repeatedFragment = executed.secondFragment;
3471
+ const firstBytes = executed.firstBytes;
3472
+ const secondBytes = executed.secondBytes;
3473
+ if (Buffer.compare(firstBytes, fragmentRead.bytes) !== 0 || Buffer.compare(secondBytes, fragmentRead.bytes) !== 0) throw new Error("persisted private fragment bytes do not match the sealed hidden evaluator output");
3474
+ const before = executed.before;
3475
+ const afterFirst = executed.afterFirst;
3476
+ const after = executed.afterSecond;
3477
+ for (const [field, state] of [
3478
+ ["sealed_repository_root_identity_before", before.repository.root],
3479
+ ["sealed_repository_root_identity_after_first", afterFirst.repository.root],
3480
+ ["sealed_repository_root_identity_after_second", after.repository.root],
3481
+ ]) {
3482
+ if (stableCanonicalJson(record[field]) !== stableCanonicalJson(state)) throw new Error("sealed repository execution identity is inconsistent");
3483
+ }
3484
+ if (record.sealed_repository_portable_digest !== before.repository.portable_digest || record.sealed_repository_portable_digest !== afterFirst.repository.portable_digest || record.sealed_repository_portable_digest !== after.repository.portable_digest || record.sealed_repository_runtime_digest !== before.repository.runtime_digest || record.sealed_repository_runtime_digest !== afterFirst.repository.runtime_digest || record.sealed_repository_runtime_digest !== after.repository.runtime_digest) throw new Error("sealed repository execution digest is inconsistent");
3485
+ if (record.evaluator_runner_sealed_sha256 !== before.runner.sha256 || record.evaluator_runner_sealed_bytes !== before.runner.bytes || record.evaluator_runner_sealed_sha256 !== after.runner.sha256 || record.evaluator_runner_sealed_bytes !== after.runner.bytes || record.hidden_evaluator_sealed_sha256 !== before.hidden.sha256 || record.hidden_evaluator_sealed_bytes !== before.hidden.bytes || record.hidden_evaluator_sealed_sha256 !== after.hidden.sha256 || record.hidden_evaluator_sealed_bytes !== after.hidden.bytes) throw new Error("sealed evaluator source digest or byte binding is inconsistent");
3486
+ for (const [kind, state] of [["runner", before.runner], ["hidden", before.hidden]]) {
3487
+ const prefix = kind === "runner" ? "evaluator_runner" : "hidden_evaluator";
3488
+ if (record[`${prefix}_sealed_dev`] !== state.identity.dev || record[`${prefix}_sealed_inode`] !== state.identity.ino || record[`${prefix}_sealed_nlink`] !== state.identity.nlink || record[`${prefix}_sealed_mtime_ms`] !== state.identity.mtimeMs || record[`${prefix}_sealed_ctime_ms`] !== state.identity.ctimeMs || stableCanonicalJson(record[`${prefix}_sealed_execution_identity_before`]) !== stableCanonicalJson(state.identity) || stableCanonicalJson(record[`${prefix}_sealed_execution_identity_after`]) !== stableCanonicalJson(after[kind].identity)) throw new Error(`${prefix} sealed execution identity is inconsistent`);
3489
+ }
3490
+ for (const [kind, state] of [["frozen_workspace", before.frozen], ["candidate_workspace", before.candidate], ["evaluation_input_evidence", before.evidence]]) {
3491
+ if (record[`${kind}_sealed_runtime_identity_before`] === undefined || stableCanonicalJson(record[`${kind}_sealed_runtime_identity_before`]) !== stableCanonicalJson(state) || stableCanonicalJson(record[`${kind}_sealed_runtime_identity_after`]) !== stableCanonicalJson(after[kind === "frozen_workspace" ? "frozen" : kind === "candidate_workspace" ? "candidate" : "evidence"])) throw new Error(`${kind} sealed runtime identity is inconsistent`);
3492
+ }
3493
+ if (record.evaluator_execution_status !== "completed" || record.first_run_fragment_sha256 !== rawByteDigest(firstBytes) || record.first_run_fragment_bytes !== firstBytes.length || record.second_run_fragment_sha256 !== rawByteDigest(secondBytes) || record.second_run_fragment_bytes !== secondBytes.length || record.deterministic_rerun !== true) throw new Error("private evaluator execution determinism evidence is inconsistent");
3494
+ if (stableCanonicalJson(actualFragment) !== stableCanonicalJson(validatedFragment)) throw new Error("persisted private fragment was not produced by the hidden evaluator");
3495
+ const expected = adaptPrivateEvaluatorFragmentToEnvelope({
3496
+ root,
3497
+ fragment: validatedFragment,
3498
+ authority: {
3499
+ ...scoringInputs,
3500
+ evaluatorReference: bundle.reference,
3501
+ normalizedResult: normalized,
3502
+ sourceSnapshotDigest: result.source_snapshot_digest,
3503
+ bundleManifest: bundle.manifest,
3504
+ privateFragmentDigest: record.private_fragment_sha256,
3505
+ privateFragmentBytes: record.private_fragment_bytes,
3506
+ privateEvaluationRecordDigest: record.evaluation_record_digest,
3507
+ fragmentBinding: {
3508
+ normalized_result_id: normalized.normalized_result_id,
3509
+ normalized_result_digest: normalized.normalized_result_digest,
3510
+ run_instance_id: normalized.lineage.run_instance_id,
3511
+ case_id: normalized.lineage.case_id,
3512
+ attempt: normalized.lineage.attempt,
3513
+ },
3514
+ },
3515
+ });
3516
+ if (stableCanonicalJson(expected) !== stableCanonicalJson(result)) throw new Error("public evaluator envelope is not the authority-owned adapter output for the sealed fragment");
3517
+ if (record.adapter_result_envelope_digest !== computeAdapterResultEnvelopeDigest(result)) throw new Error("private evaluation record adapter envelope digest is inconsistent");
3518
+ if (result.private_fragment_digest !== record.private_fragment_sha256 || result.private_fragment_bytes !== record.private_fragment_bytes || result.private_evaluation_record_digest !== record.evaluation_record_digest) throw new Error("public evaluator envelope private authority bindings are inconsistent");
3519
+ if (!evidence.repositoryDiffArtifact || record.frozen_workspace_inventory_digest !== evidence.repositoryDiffArtifact.frozen_workspace_tree_digest || record.candidate_workspace_inventory_digest !== evidence.repositoryDiffArtifact.candidate_workspace_tree_digest) throw new Error("private evaluation record workspace authority is incomplete");
3520
+ return { record, fragment, canonicalEvaluationRoot };
3521
+ };
3522
+ return asynchronous
3523
+ ? executeSealedEvaluatorAsync(options,primaryEvaluatorExecutionControl()).then(finishExecuted)
3524
+ : finishExecuted(executeSealedEvaluator(options));
3525
+ }
3526
+
3527
+ function readScoringInputSources({
3528
+ root,
3529
+ catalogPath,
3530
+ policyManifestPath,
3531
+ scoringPolicyPath,
3532
+ admissionRecordPath,
3533
+ requirementRecordPath,
3534
+ outputContractPath,
3535
+ referencePath,
3536
+ freezeManifestPath,
3537
+ freezeManifestSourceDigest,
3538
+ }) {
3539
+ for (const [path, label] of [
3540
+ [catalogPath, "portfolio catalog"],
3541
+ [policyManifestPath, "portfolio policy manifest"],
3542
+ [scoringPolicyPath, "portfolio scoring policy"],
3543
+ [admissionRecordPath, "authoritative final admission record"],
3544
+ [requirementRecordPath, "authoritative requirement record"],
3545
+ [outputContractPath, "authoritative output contract"],
3546
+ [referencePath, "authoritative evaluator public reference"],
3547
+ [freezeManifestPath, "scoring input freeze manifest"],
3548
+ ]) {
3549
+ if (!path) throw new Error(`${label} path is required for scoring input closure`);
3550
+ }
3551
+ const freeze = readAnchoredFreezeManifest({ root, freezeManifestPath, freezeManifestSourceDigest });
3552
+ const { authorityRoot, manifest: freezeManifest } = freeze;
3553
+ const catalogSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.catalog, suppliedPath: catalogPath, schemaPath: CATALOG_SCHEMA_PATH, label: "portfolio catalog" });
3554
+ const policyManifestSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.policy_manifest, suppliedPath: policyManifestPath, schemaPath: POLICY_MANIFEST_SCHEMA_PATH, label: "portfolio policy manifest" });
3555
+ const scoringPolicySource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.scoring_policy, suppliedPath: scoringPolicyPath, schemaPath: SCORING_POLICY_SCHEMA_PATH, label: "portfolio scoring policy" });
3556
+ const admissionRecordSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.admission_record, suppliedPath: admissionRecordPath, schemaPath: FINAL_ADMISSION_RECORD_SCHEMA_PATH, label: "authoritative final admission record", publicArtifact: true });
3557
+ const requirementRecordSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.requirement_record, suppliedPath: requirementRecordPath, schemaPath: REQUIREMENT_RECORD_SCHEMA_PATH, label: "authoritative requirement record", publicArtifact: true });
3558
+ const outputContractSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.output_contract, suppliedPath: outputContractPath, schemaPath: OUTPUT_CONTRACT_SCHEMA_PATH, label: "authoritative output contract", publicArtifact: true });
3559
+ const evaluatorReferenceSource = readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.evaluator_public_reference, suppliedPath: referencePath, schemaPath: EVALUATOR_REFERENCE_SCHEMA_PATH, label: "authoritative evaluator public reference", publicArtifact: true });
3560
+ const requiresEvaluatorAuthorityManifest = Boolean(outputContractSource.value.evaluator_authority_manifest_path || evaluatorReferenceSource.value.evaluator_authority_manifest_path);
3561
+ if (requiresEvaluatorAuthorityManifest && !freezeManifest.evaluator_authority_manifest) throw new Error("scoring input freeze evaluator authority manifest is missing");
3562
+ const evaluatorAuthorityManifestSource = freezeManifest.evaluator_authority_manifest
3563
+ ? readFrozenJsonArtifact({ authorityRoot, root, reference: freezeManifest.evaluator_authority_manifest, suppliedPath: resolve(authorityRoot, freezeManifest.evaluator_authority_manifest.path), schemaPath: EVALUATOR_AUTHORITY_MANIFEST_SCHEMA_PATH, label: "authoritative evaluator authority manifest", publicArtifact: true })
3564
+ : null;
3565
+ const catalog = catalogSource.value;
3566
+ const policyManifest = policyManifestSource.value;
3567
+ const scoringPolicy = scoringPolicySource.value;
3568
+ const admissionRecord = admissionRecordSource.value;
3569
+ const requirementRecord = requirementRecordSource.value;
3570
+ const outputContract = outputContractSource.value;
3571
+ const evaluatorReference = evaluatorReferenceSource.value;
3572
+ const evaluatorAuthorityManifest = evaluatorAuthorityManifestSource?.value ?? null;
3573
+ let evaluatorAuthorityAnchor = null;
3574
+ if (evaluatorAuthorityManifest) {
3575
+ const evaluatorAuthorityBuffers = new Map(evaluatorAuthorityManifest.file_inventory.map(({ path }) => {
3576
+ const absolute = resolveAuthorityArtifactPath(authorityRoot, path, `evaluator authority binding ${path}`);
3577
+ return [path, Buffer.from(readStableFile(absolute, `evaluator authority binding ${path}`, MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false }).bytes)];
3578
+ }));
3579
+ validateEvaluatorAuthorityManifest({ manifest: evaluatorAuthorityManifest, buffers: evaluatorAuthorityBuffers, evaluatorRevision: evaluatorReference.evaluator_revision, root, label: "authoritative evaluator authority manifest" });
3580
+ evaluatorAuthorityAnchor = buildVerifiedEvaluatorAuthorityAnchor({
3581
+ evaluatorRevision: evaluatorReference.evaluator_revision,
3582
+ evaluatorReference,
3583
+ manifestReference: freezeManifest.evaluator_authority_manifest,
3584
+ manifestSource: evaluatorAuthorityManifestSource,
3585
+ buffers: evaluatorAuthorityBuffers,
3586
+ root,
3587
+ label: "authoritative evaluator freeze authority",
3588
+ });
3589
+ }
3590
+ const requirementRecordSchema = readJsonArtifact(resolve(root, REQUIREMENT_RECORD_SCHEMA_PATH), "requirement record Schema").value;
3591
+ const evaluatorResultSchema = readJsonArtifact(resolve(root, EVALUATOR_RESULT_SCHEMA_PATH), "evaluator result Schema").value;
3592
+ const admissionPolicy = readJsonArtifact(resolve(root, ADMISSION_POLICY_PATH), "portfolio admission policy").value;
3593
+ assertBenchmarkSchemaInstance(admissionPolicy, { schemaPath: resolve(root, ADMISSION_POLICY_SCHEMA_PATH), label: "portfolio admission policy" });
3594
+
3595
+ validatePortfolioPolicyArtifacts({ root, catalogPath, policyManifestPath, scoringPolicyPath });
3596
+ if (catalog.catalog_digest !== computePortfolioCatalogDigest(catalog)) throw new Error("portfolio catalog digest closure is invalid");
3597
+ if (freezeManifest.catalog.semantic_digest !== catalog.catalog_digest) throw new Error("portfolio catalog semantic digest does not match the scoring input freeze manifest");
3598
+ if (freezeManifest.policy_manifest.semantic_digest !== computePolicyManifestDigest(policyManifest)) throw new Error("portfolio policy manifest semantic digest does not match the scoring input freeze manifest");
3599
+ if (freezeManifest.scoring_policy.semantic_digest !== computeScoringPolicyDigest(scoringPolicy)) throw new Error("portfolio scoring policy semantic digest does not match the scoring input freeze manifest");
3600
+ if (freezeManifest.admission_record.semantic_digest !== computeFinalAdmissionRecordDigest(admissionRecord)) throw new Error("final admission record semantic digest does not match the scoring input freeze manifest");
3601
+ if (freezeManifest.requirement_record.record_digest !== computeRequirementRecordDigest(requirementRecord) || freezeManifest.requirement_record.set_digest !== computeRequirementSetDigest(requirementRecord)) throw new Error("requirement record digest closure does not match the scoring input freeze manifest");
3602
+ if (freezeManifest.output_contract.semantic_digest !== computeOutputContractDigest(outputContract)) throw new Error("output contract semantic digest does not match the scoring input freeze manifest");
3603
+ if (freezeManifest.evaluator_public_reference.semantic_digest !== computeEvaluatorReferenceDigest(evaluatorReference)) throw new Error("evaluator public reference semantic digest does not match the scoring input freeze manifest");
3604
+ if (evaluatorAuthorityManifest && freezeManifest.evaluator_authority_manifest.semantic_digest !== evaluatorAuthorityManifest.manifest_digest) throw new Error("evaluator authority manifest semantic digest does not match the scoring input freeze manifest");
3605
+ validateScoringContractSchemaParity({ scoringPolicy, requirementRecordSchema, evaluatorResultSchema });
3606
+ validateFrozenFinalAdmissionRecordContract({
3607
+ admissionPolicy,
3608
+ admissionRecord,
3609
+ finalAdmissionRecordSchema: readJsonArtifact(resolve(root, FINAL_ADMISSION_RECORD_SCHEMA_PATH), "final admission record Schema").value,
3610
+ });
3611
+ validateRequirementRecordContract({ scoringPolicy, requirementRecord, requirementRecordSchema, evaluatorResultSchema });
3612
+ if (policyManifest.scoring_policy?.path !== freezeManifest.scoring_policy.path) throw new Error("policy manifest scoring policy path does not match the freeze manifest authority path");
3613
+ if (requirementRecord.requirement_record_path !== freezeManifest.requirement_record.path) throw new Error("requirement record internal path does not match the freeze manifest authority path");
3614
+ if (outputContract.output_contract_path !== freezeManifest.output_contract.path) throw new Error("output contract internal path does not match the freeze manifest authority path");
3615
+ if (outputContract.evaluator_public_reference_path !== freezeManifest.evaluator_public_reference.path) throw new Error("output contract evaluator reference path does not match the freeze manifest authority path");
3616
+ const fixture = catalog.fixtures.find(({ fixture_id }) => fixture_id === freezeManifest.fixture_id);
3617
+ if (!fixture) throw new Error("scoring input freeze fixture is absent from the authoritative catalog");
3618
+ if ([admissionRecord.fixture_id, requirementRecord.fixture_id, outputContract.fixture_id, evaluatorReference.fixture_id].some((fixtureId) => fixtureId !== freezeManifest.fixture_id)) throw new Error("scoring input freeze fixture identity does not close across authoritative artifacts");
3619
+ if (admissionRecord.input_manifest_digest !== freezeManifest.fixture_input_digest || evaluatorReference.fixture_input_digest !== freezeManifest.fixture_input_digest) throw new Error("scoring input freeze fixture input digest does not close across authoritative artifacts");
3620
+ if (admissionRecord.catalog_digest !== catalog.catalog_digest) throw new Error("final admission record catalog digest does not match the freeze authority catalog");
3621
+ if (admissionRecord.evaluator_bundle_id !== evaluatorReference.evaluator_bundle_id || admissionRecord.evaluator_bundle_digest !== evaluatorReference.evaluator_bundle_digest) throw new Error("final admission record evaluator identity does not match the authoritative public reference");
3622
+ if (evaluatorAuthorityManifest) {
3623
+ const expectedEvaluatorAuthority = {
3624
+ path: freezeManifest.evaluator_authority_manifest.path,
3625
+ raw: freezeManifest.evaluator_authority_manifest.raw_byte_digest,
3626
+ semantic: evaluatorAuthorityManifest.manifest_digest,
3627
+ };
3628
+ for (const [artifact, artifactLabel] of [[admissionRecord, "final admission record"], [outputContract, "output contract"], [evaluatorReference, "evaluator public reference"]]) {
3629
+ if (artifact.evaluator_authority_manifest_path !== expectedEvaluatorAuthority.path || artifact.evaluator_authority_manifest_raw_sha256 !== expectedEvaluatorAuthority.raw || artifact.evaluator_authority_manifest_digest !== expectedEvaluatorAuthority.semantic) throw new Error(`${artifactLabel} evaluator authority manifest closure is invalid`);
3630
+ }
3631
+ }
3632
+ if (admissionRecord.evaluator_source_identity || evaluatorReference.evaluator_source_identity) {
3633
+ if (stableCanonicalJson(admissionRecord.evaluator_source_identity) !== stableCanonicalJson(evaluatorReference.evaluator_source_identity)) throw new Error("final admission evaluator source identity does not match the authoritative public reference");
3634
+ }
3635
+ if (admissionRecord.evaluator_requirement_count !== requirementRecord.requirements.length) throw new Error("final admission record requirement count does not match the authoritative requirement record");
3636
+ const expectedEvidenceMapIds = requirementRecord.requirements.flatMap(({ evidence_map_ids }) => evidence_map_ids).sort();
3637
+ const expectedMutationSetIds = requirementRecord.requirements.flatMap(({ mutation_ids }) => mutation_ids).sort();
3638
+ if (stableCanonicalJson([...admissionRecord.evidence_map_ids].sort()) !== stableCanonicalJson(expectedEvidenceMapIds)) throw new Error("final admission evidence-map inventory does not match the authoritative requirement record");
3639
+ if (stableCanonicalJson([...admissionRecord.mutation_set_ids].sort()) !== stableCanonicalJson(expectedMutationSetIds)) throw new Error("final admission mutation-set inventory does not match the authoritative requirement record");
3640
+ if (requirementRecord.admission_record_digest !== resolveRequirementAdmissionBindingDigest(admissionRecord)) throw new Error("requirement record admission digest was not re-derived from the authoritative final admission record");
3641
+ return {
3642
+ freezeManifest,
3643
+ freezeManifestSource: { path: freeze.manifestRelativePath, bytes: Buffer.from(freeze.source.bytes) },
3644
+ freezeManifestSourceDigest: freeze.sourceDigest,
3645
+ catalog,
3646
+ policyManifest,
3647
+ scoringPolicy,
3648
+ admissionRecord,
3649
+ requirementRecord,
3650
+ outputContract,
3651
+ evaluatorReference,
3652
+ evaluatorAuthorityManifest,
3653
+ evaluatorAuthorityAnchor,
3654
+ sources: {
3655
+ admissionRecord: { path: freezeManifest.admission_record.path, bytes: Buffer.from(admissionRecordSource.bytes) },
3656
+ requirementRecord: { path: freezeManifest.requirement_record.path, bytes: Buffer.from(requirementRecordSource.bytes) },
3657
+ },
3658
+ };
3659
+ }
3660
+
3661
+ /** Public generated-artifact check. This creates no private evaluator authority. */
3662
+ export function verifyPortfolioScoringRootLineage({ materializedPath, selectionState, runDir, normalizedResultsPath }, verified) {
3663
+ const roots = Object.fromEntries(Object.entries({ materializedPath, selectionState, runDir, normalizedResultsPath }).map(([key, path]) => [key, assertRealDirectory(path, `scoring ${key}`)]));
3664
+ const markerPaths = Object.fromEntries(BOUNDARY_MARKERS.map(([key, , marker]) => [key, resolve(roots[key], marker)]));
3665
+ assertBoundaryRootLineage({ markerPaths, canonicalRoots: roots }, verified);
3666
+ return { status: 'original_scoring_root_lineage_verified', execution_permission: false, private_authority: false };
3667
+ }
3668
+
3669
+ function assertBoundaryRootLineage(bundle, verified) {
3670
+ const source = verified.manifest.source;
3671
+ const materializedPath = bundle.markerPaths.materializedPath;
3672
+ const selectionStatePath = bundle.markerPaths.selectionState;
3673
+ const runIdentityPath = bundle.markerPaths.runDir;
3674
+ // This inventory covers all projected files in every materialized case, not
3675
+ // one small public JSON artifact. Keep the existing boundary-file cap and
3676
+ // derive the lineage digest from the same stable bytes that were parsed.
3677
+ const materializedEvidence = readStableJsonFile(
3678
+ realpathSync(materializedPath), "materialized root manifest", MAX_BOUNDARY_FILE_BYTES, { allowEmpty: false },
3679
+ );
3680
+ readJsonArtifact(selectionStatePath, "selection-state root index");
3681
+ const selectionEvidence = streamingFileDigest(selectionStatePath, "selection-state root index");
3682
+ if (materializedEvidence.rawByteDigest !== source.materialization_manifest_digest) {
3683
+ throw new Error("materialized root manifest does not match normalized result lineage");
3684
+ }
3685
+ if (selectionEvidence.digest !== source.selection_state_digest) {
3686
+ throw new Error("selection-state root index does not match normalized result lineage");
3687
+ }
3688
+ const { value: runIdentity } = readJsonArtifact(runIdentityPath, "execution run identity");
3689
+ if (canonicalDigest(runIdentity) !== source.run_identity_digest || runIdentity.run_instance_id !== source.run_instance_id) {
3690
+ throw new Error("execution run root identity does not match normalized result lineage");
3691
+ }
3692
+ if (!isInside(bundle.canonicalRoots.normalizedResultsPath, verified.generationPath)) {
3693
+ throw new Error("normalized generation escapes the normalized-results root");
3694
+ }
3695
+ }
3696
+
3697
+ /** Root-marker consistency only; never creates an evaluator or scoring capability. */
3698
+ export function verifyEvaluatorBoundaryRootLineageForTest(bundle, verified) {
3699
+ return assertBoundaryRootLineage(bundle, verified);
3700
+ }
3701
+
3702
+ function verifyEvaluatorAuthorityCore({
3703
+ root,
3704
+ config = null,
3705
+ planPath = null,
3706
+ executionAdmissionEvidenceByFixture = null,
3707
+ runtimeObservationRoot = null,
3708
+ catalogPath,
3709
+ policyManifestPath,
3710
+ scoringPolicyPath,
3711
+ admissionRecordPath,
3712
+ requirementRecordPath,
3713
+ outputContractPath,
3714
+ scoringInputFreezeManifestPath,
3715
+ scoringInputFreezeManifestSourceDigest = null,
3716
+ referencePath,
3717
+ privateRoot,
3718
+ manifestPath,
3719
+ resultPath,
3720
+ privateEvaluationRoot = null,
3721
+ privateEvaluationRecordPath = null,
3722
+ privateFragmentPath = null,
3723
+ materializedPath,
3724
+ selectionState,
3725
+ runDir,
3726
+ normalizedResultsPath,
3727
+ publicArtifactRoot = null,
3728
+ }, asynchronous = false) {
3729
+ const bundle = verifyPrivateEvaluatorBundle({ root, referencePath, privateRoot, manifestPath, materializedPath, selectionState, runDir, normalizedResultsPath, publicArtifactRoot });
3730
+ if (!resultPath || pathsOverlap(resultPath, privateRoot)) throw new Error("public evaluator result must not overlap the private evaluator root");
3731
+ const resultRead = readJsonArtifact(resultPath, "evaluator result envelope", { publicArtifact: true }),result=resultRead.value;
3732
+ assertBenchmarkSchemaInstance(result, { schemaPath: resolve(root, EVALUATOR_RESULT_SCHEMA_PATH), label: "evaluator result envelope" });
3733
+ assertPublicArtifactTree(result, "evaluator result envelope");
3734
+ assertResultCollectionIdentity(result);
3735
+ const scoringInputs = readScoringInputSources({
3736
+ root,
3737
+ catalogPath,
3738
+ policyManifestPath,
3739
+ scoringPolicyPath,
3740
+ admissionRecordPath,
3741
+ requirementRecordPath,
3742
+ outputContractPath,
3743
+ referencePath,
3744
+ freezeManifestPath: scoringInputFreezeManifestPath,
3745
+ freezeManifestSourceDigest: scoringInputFreezeManifestSourceDigest,
3746
+ });
3747
+ if (stableCanonicalJson(scoringInputs.evaluatorReference) !== stableCanonicalJson(bundle.reference)) throw new Error("private bundle evaluator reference does not match the scoring input freeze authority reference");
3748
+
3749
+ const verified = verifyNormalizedPortfolioResults({
3750
+ root,
3751
+ outputPath: normalizedResultsPath,
3752
+ sourceSnapshotDigest: result.source_snapshot_digest,
3753
+ });
3754
+ if (result.source_snapshot_digest !== verified.manifest.source_snapshot_digest) throw new Error("evaluator result source snapshot lineage is inconsistent");
3755
+ assertBoundaryRootLineage(bundle, verified);
3756
+ const normalizedSource = readNormalizedRecord({ verified, result });
3757
+ const normalized = normalizedSource.record;
3758
+ validateExecutionEventEvidenceReferences({ normalized, result });
3759
+ const lineage = normalized.lineage;
3760
+ const expectedLineage = {
3761
+ normalized_result_id: normalized.normalized_result_id,
3762
+ normalized_result_digest: normalized.normalized_result_digest,
3763
+ run_instance_id: lineage.run_instance_id,
3764
+ plan_id: lineage.plan_id,
3765
+ plan_digest: lineage.plan_digest,
3766
+ fixture_id: lineage.fixture_id,
3767
+ fixture_input_digest: lineage.fixture_input_digest,
3768
+ case_id: lineage.case_id,
3769
+ attempt: lineage.attempt,
3770
+ adapter: lineage.adapter_track,
3771
+ condition: lineage.condition,
3772
+ repetition: lineage.repetition,
3773
+ evaluator_bundle_id: bundle.manifest.evaluator_bundle_id,
3774
+ evaluator_bundle_digest: bundle.manifest.evaluator_bundle_digest,
3775
+ evaluator_revision: bundle.manifest.evaluator_revision,
3776
+ };
3777
+ for (const [field, value] of Object.entries(expectedLineage)) {
3778
+ if (result[field] !== value) throw new Error(`evaluator result lineage mismatch at ${field}`);
3779
+ }
3780
+ if (bundle.reference.fixture_id !== lineage.fixture_id || bundle.reference.fixture_input_digest !== lineage.fixture_input_digest || bundle.reference.task_class !== lineage.task_class || bundle.reference.suite !== lineage.suite) {
3781
+ throw new Error("evaluator reference is transplanted across normalized fixture or input identity");
3782
+ }
3783
+ const readiness = validateEvaluatorAuthorityBindings({
3784
+ ...scoringInputs,
3785
+ normalizedResult: normalized,
3786
+ evaluatorResult: result,
3787
+ });
3788
+ const privateAuthorityPaths = [privateEvaluationRoot, privateEvaluationRecordPath, privateFragmentPath];
3789
+ const privateAuthorityCount = privateAuthorityPaths.filter(Boolean).length;
3790
+ const privateResultBindingFields = ["private_fragment_digest", "private_fragment_bytes", "private_evaluation_record_digest"];
3791
+ const privateResultBindingCount = privateResultBindingFields.filter((field) => Object.hasOwn(result, field)).length;
3792
+ if (privateResultBindingCount !== 0 && privateResultBindingCount !== privateResultBindingFields.length) {
3793
+ throw new Error("evaluator result private authority binding is incomplete");
3794
+ }
3795
+ const requiresPrivateAuthority = [BINARY_SCOPE_VERIFICATION_PROFILE_NAME, REQUIREMENT_SCOPE_VERIFICATION_PROFILE_NAME].includes(result.result_profile?.name) || privateResultBindingCount > 0;
3796
+ if (requiresPrivateAuthority && privateAuthorityCount !== privateAuthorityPaths.length) {
3797
+ throw new Error("private evaluator authority requires --private-evaluation-root, --private-evaluation-record, and --private-fragment together");
3798
+ }
3799
+ if (!requiresPrivateAuthority && privateAuthorityCount !== 0 && privateAuthorityCount !== privateAuthorityPaths.length) {
3800
+ throw new Error("private evaluation root, record, and fragment paths must be supplied together");
3801
+ }
3802
+ const finishAuthority=()=>{
3803
+ if(asynchronous){
3804
+ const freshInputs=readScoringInputSources({root,catalogPath,policyManifestPath,scoringPolicyPath,admissionRecordPath,
3805
+ requirementRecordPath,outputContractPath,referencePath,freezeManifestPath:scoringInputFreezeManifestPath,
3806
+ freezeManifestSourceDigest:scoringInputFreezeManifestSourceDigest});
3807
+ const freshBundle=verifyPrivateEvaluatorBundle({root,referencePath,privateRoot,manifestPath,materializedPath,selectionState,runDir,normalizedResultsPath,publicArtifactRoot});
3808
+ const freshNormalized=verifyNormalizedPortfolioResults({root,outputPath:normalizedResultsPath,sourceSnapshotDigest:result.source_snapshot_digest});
3809
+ if(stableCanonicalJson(freshInputs)!==stableCanonicalJson(scoringInputs)
3810
+ ||stableCanonicalJson(freshBundle.manifest)!==stableCanonicalJson(bundle.manifest)
3811
+ ||stableCanonicalJson(freshNormalized.manifest)!==stableCanonicalJson(verified.manifest)
3812
+ ||!readNormalizedRecord({verified:freshNormalized,result}).bytes.equals(normalizedSource.bytes)
3813
+ ||!readJsonArtifact(resultPath,'evaluator result envelope',{publicArtifact:true}).bytes.equals(resultRead.bytes))
3814
+ throw new Error('evaluator authority changed during async verification');
3815
+ }
3816
+ return { bundle, normalized, result, verified, scoringInputs, ...readiness };
3817
+ };
3818
+ if (requiresPrivateAuthority) {
3819
+ const checked=verifyPrivateEvaluationRecord({ root, privateEvaluationRoot, privateEvaluationRecordPath, privateFragmentPath, bundle, verified, normalized, normalizedBytes: normalizedSource.bytes, result, scoringInputs,
3820
+ runtimeObservationOptions: runtimeObservationRoot === null ? null : { root, config, planPath, materializedPath, selectionState, runDir, normalizedResultsPath,
3821
+ executionAdmissionEvidenceByFixture, observationRoot: runtimeObservationRoot } },asynchronous);
3822
+ if(asynchronous)return checked.then(finishAuthority);
3823
+ }
3824
+ return finishAuthority();
3825
+ }
3826
+
3827
+ /** Public pre-result inputs only: no private bundle or result is opened. */
3828
+ export function verifyPortfolioScoringInputs(options) {
3829
+ return readScoringInputSources(options);
3830
+ }
3831
+
3832
+ export function verifyEvaluatorAuthority(options) {
3833
+ return withPrimaryEvaluatorAuthority(options, () => withCoreGradingAuthority(options,
3834
+ () => assertPrimaryEvaluatorVerified(assertCoreGradingVerified(verifyEvaluatorAuthorityCore(options)))));
3835
+ }
3836
+
3837
+ export async function verifyEvaluatorAuthorityAsync(options) {
3838
+ const control=primaryEvaluatorExecutionControl();
3839
+ if(!control)throw new Error('owned primary async condition scope required');
3840
+ control.assertReady();
3841
+ return withPrimaryEvaluatorAuthority(options,async()=>{
3842
+ if(options.coreGradingAuthority||options.coreControllerGradingContext||options.coreCaptureProducer)throw new Error('async primary/core authority mix refused');
3843
+ const verified=await verifyEvaluatorAuthorityCore(options,true);
3844
+ control.assertReady();
3845
+ return assertPrimaryEvaluatorVerified(verified);
3846
+ });
3847
+ }
3848
+
3849
+ export function verifyEvaluatorResult(options) {
3850
+ const verified = verifyEvaluatorAuthority(options);
3851
+ if (verified.scoringInputs.admissionRecord.admission_status !== "admitted") throw new Error("scoring input freeze requires an admitted final admission record");
3852
+ return { ...verified, scoringReady: verified.evaluationReady };
3853
+ }
3854
+
3855
+ export function assertNoPrivateBundlePublication(publicArtifactRoot, bundle) {
3856
+ const canonicalPublicRoot = assertRealDirectory(publicArtifactRoot, "public artifact root");
3857
+ if (isInside(canonicalPublicRoot, bundle.canonicalPrivateRoot) || isInside(bundle.canonicalPrivateRoot, canonicalPublicRoot)) {
3858
+ throw new Error("public artifact root must not overlap the private evaluator root");
3859
+ }
3860
+ assertNoPrivateMaterial(directoryFileInventory(canonicalPublicRoot, "public artifact root"), "public artifact root", bundle.privateMaterialDigests);
3861
+ }
3862
+
3863
+ export function verifyEvaluatorBoundary(options) {
3864
+ if (!options.publicArtifactRoot) throw new Error("full evaluator boundary verification requires a public artifact root");
3865
+ return verifyEvaluatorResult(options);
3866
+ }
3867
+ import { withPrimaryEvaluatorAuthority, assertPrimaryEvaluatorVerified, primaryFinalResponseRelativePath, validatePrimaryRawFinalResponse,
3868
+ primaryAdapterSourceDigest, capturePrimaryEvaluatorChildStreams, primaryEvaluatorProbeCaptureAvailable, capturePrimaryEvaluatorProbeAudit,
3869
+ primaryEvaluatorDependencyGraphParameters } from './ask-primary-evaluation-scope.mjs';