@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,2442 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { coreProducerInspection } from './ask-core-producer-scope.mjs';
3
+ import { CLAUDE_NATIVE_KIND, isNativeClaudeRuntime, validateNativeClaudeRuntime, nativeClaudeCommand,
4
+ nativeClaudeEnvironment, nativeClaudeProbeEnvironment, decodeNativeClaudeResult, assertNativeClaudeAuthentication,
5
+ assertNativeClaudeInstructions, validateNativeClaudeEnvironmentPolicy, nativeClaudeInput } from './claude-native-runtime.mjs';
6
+ import { verifyCoreProducedTerminal } from './ask-core-capture-producer.mjs';
7
+ import { primaryProducerInspection } from './ask-primary-evaluation-scope.mjs';
8
+ import { verifyPrimaryProducedTerminal } from './ask-primary-evaluation-producer.mjs';
9
+ import { spawnSync } from "node:child_process";
10
+ import {
11
+ chmodSync,
12
+ copyFileSync,
13
+ existsSync,
14
+ lstatSync,
15
+ linkSync,
16
+ mkdirSync,
17
+ mkdtempSync,
18
+ readFileSync,
19
+ readdirSync,
20
+ realpathSync,
21
+ renameSync,
22
+ rmSync,
23
+ rmdirSync,
24
+ statSync,
25
+ symlinkSync,
26
+ writeFileSync,
27
+ } from "node:fs";
28
+ import { tmpdir } from "node:os";
29
+ import { basename, dirname, parse, relative, resolve, sep } from "node:path";
30
+ import { assertBenchmarkSchemaInstance } from "./ask-benchmark-schema.mjs";
31
+ import { assertNoSymlinkPathSegments } from "./content-addressed-store.mjs";
32
+ import { captureSuccessorUsage, validateSuccessorUsage } from "./ask-benchmark-prompt-successor-usage.mjs";
33
+ import { assertSuccessorNativeExecutable } from "./ask-benchmark-prompt-successor-native.mjs";
34
+ import { assertTrackedRepositoryMatchesHead, canonicalDigest, stableCanonicalJson, validateMaterializedPortfolio } from "./ask-benchmark-materialize.mjs";
35
+ import { verifyAdaptiveSelection } from "./ask-benchmark-selection.mjs";
36
+ import { assertStableFileEvidence, readStableFile } from "./ask-benchmark-stable-file.mjs";
37
+ import { buildCodexProjectionPlan, resolveCodexSkillClosure } from "./install-codex-adapter.mjs";
38
+ import { buildClaudeProjectionPlan, resolveClaudeSkillClosure } from "./install-claude-adapter.mjs";
39
+ import {
40
+ buildCodexCommandEvidence,
41
+ buildUnavailableCommandEvidence,
42
+ CODEX_COMMAND_EVENT_FORMAT_REVISION,
43
+ COMMAND_EVIDENCE_PARSER_REVISION,
44
+ COMMAND_EVIDENCE_PATH,
45
+ COMMAND_EVIDENCE_SCHEMA_PATH,
46
+ validateCommandEvidenceManifest,
47
+ validateVerificationCommandContract,
48
+ } from "./ask-benchmark-command-evidence.mjs";
49
+ import {
50
+ buildTerminalWorkspaceAuthority,
51
+ captureTerminalWorkspaceInventory,
52
+ readVerifiedTerminalWorkspaceAuthority,
53
+ TERMINAL_WORKSPACE_AUTHORITY_PATH,
54
+ terminalWorkspaceAuthorityReference,
55
+ } from "./ask-benchmark-terminal-workspace.mjs";
56
+ import {
57
+ assertSuccessorInputRun, prepareSuccessorInputForAttempt, successorInputProjection,
58
+ successorRuntimeForInput, successorEffectiveCommand, assertSuccessorAdapterFacts, assertSuccessorExecutableDescriptor,
59
+ assertSuccessorVersionOutput,
60
+ } from "./ask-benchmark-prompt-successor-delivery.mjs";
61
+
62
+ export const EXECUTION_RUNNER_VERSION = "1.0.0";
63
+ export const RUNTIME_CONFIG_SCHEMA_PATH = "benchmarks/schemas/portfolio-runtime-config.schema.json";
64
+ export const RUN_IDENTITY_SCHEMA_PATH = "benchmarks/schemas/portfolio-run-identity.schema.json";
65
+ export const CASE_STATE_SCHEMA_PATH = "benchmarks/schemas/portfolio-case-state.schema.json";
66
+ export const ATTEMPT_REQUEST_SCHEMA_PATH = "benchmarks/schemas/portfolio-attempt-request.schema.json";
67
+ export const ATTEMPT_RESULT_SCHEMA_PATH = "benchmarks/schemas/portfolio-attempt-result.schema.json";
68
+ export const ATTEMPT_COMMIT_SCHEMA_PATH = "benchmarks/schemas/portfolio-attempt-commit.schema.json";
69
+ export const CLAIM_SCHEMA_PATH = "benchmarks/schemas/portfolio-claim.schema.json";
70
+ export const ADAPTER_IDENTITY_SCHEMA_PATH = "benchmarks/schemas/portfolio-adapter-identity.schema.json";
71
+ export const OUTPUT_SCHEMA_PATH = "benchmarks/schemas/agent-output.schema.json";
72
+ export const TERMINAL_WORKSPACE_AUTHORITY_SCHEMA_PATH = "benchmarks/schemas/portfolio-terminal-workspace-authority.schema.json";
73
+
74
+ const CLAIM_GRACE_MS = 30_000;
75
+ const MAX_PROCESS_OUTPUT_BYTES = 20 * 1024 * 1024;
76
+ const MAX_FINAL_OUTPUT_BYTES = 1024 * 1024;
77
+ const RUN_IDENTITY_FILE = "run-identity.json";
78
+ const TERMINAL_STATUSES = new Set(["completed", "failed", "unavailable", "interrupted", "invalid"]);
79
+ const CASE_ID_PATTERN = /^case-[a-f0-9]{16}-[a-f0-9]{16}$/u;
80
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
81
+ const ATTEMPT_PATTERN = /^[0-9]{4}$/u;
82
+ const WORKSPACE_PARENT_PATTERN = /^ask-portfolio-workspaces-[A-Za-z0-9_-]{6,}$/u;
83
+ const DURABLE_SCALAR_MAX_LENGTH = 160;
84
+ const WORKSPACE_OWNERSHIP_FILE = "ownership.json";
85
+ const PRE_CLAIM_FILE = "pre-claim.json";
86
+ const RESULT_STAGING_FILE = "result.pending.json";
87
+ const TEMP_ROOT = realpathSync(tmpdir());
88
+ const SHELL_CAPABILITY_UNAVAILABLE_CODES = new Set(["unsupported_shell"]);
89
+ const MAX_COMMAND_EVIDENCE_FILE_BYTES = MAX_PROCESS_OUTPUT_BYTES + (2 * 1024 * 1024);
90
+
91
+ class RuntimeIntegrityError extends Error {}
92
+
93
+ // A published terminal result must survive an incomplete cleanup unchanged.
94
+ class TerminalCleanupError extends Error {}
95
+
96
+ class RuntimeContractError extends Error {
97
+ constructor(reason, executable) {
98
+ super(`runtime contract is unconfirmed: ${reason}`);
99
+ this.contractReason = reason;
100
+ this.executable = executable;
101
+ }
102
+ }
103
+
104
+ function sha256(value) {
105
+ return createHash("sha256").update(value).digest("hex");
106
+ }
107
+
108
+ function readJson(path) {
109
+ return JSON.parse(readFileSync(path, "utf8"));
110
+ }
111
+
112
+ function writeJsonAtomic(path, value, { stagingOwner = null, faultName = null } = {}) {
113
+ const parent = dirname(path);
114
+ mkdirSync(parent, { recursive: true });
115
+ if (stagingOwner !== null) assertClaimId(stagingOwner);
116
+ const owner = stagingOwner ? `.${stagingOwner}` : "";
117
+ const temporary = resolve(parent, `.${basename(path)}${owner}.${randomUUID()}.staging`);
118
+ writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { flag: "wx" });
119
+ if (faultName) fault(faultName);
120
+ renameSync(temporary, path);
121
+ }
122
+
123
+ function writeJsonExclusive(path, value) {
124
+ mkdirSync(dirname(path), { recursive: true });
125
+ writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`, { flag: "wx" });
126
+ }
127
+
128
+ function writeJsonIdempotent(path, value, label, options = {}) {
129
+ if (existsSync(path)) {
130
+ const existing = readJson(path);
131
+ if (stableCanonicalJson(existing) !== stableCanonicalJson(value)) throw new Error(`${label} already exists with different content`);
132
+ return false;
133
+ }
134
+ writeJsonAtomic(path, value, options);
135
+ return true;
136
+ }
137
+
138
+ function publishJsonExclusive(path, value) {
139
+ const parent = dirname(path);
140
+ mkdirSync(parent, { recursive: true });
141
+ const temporary = resolve(parent, `.${basename(path)}.${randomUUID()}.staging`);
142
+ writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { flag: "wx" });
143
+ try {
144
+ linkSync(temporary, path);
145
+ return true;
146
+ } catch (error) {
147
+ if (error?.code === "EEXIST") return false;
148
+ throw error;
149
+ } finally {
150
+ rmSync(temporary, { force: true });
151
+ }
152
+ }
153
+
154
+ function prefixedFileDigest(path) {
155
+ return `sha256:${fileDigest(path)}`;
156
+ }
157
+
158
+ function stableJsonValue(file, label) {
159
+ try {
160
+ return JSON.parse(file.bytes.toString("utf8"));
161
+ } catch {
162
+ throw new Error(`${label} contains invalid JSON`);
163
+ }
164
+ }
165
+
166
+ function readStableCommandEvidence(path, label, options = {}) {
167
+ const file = readStableFile(path, label, MAX_COMMAND_EVIDENCE_FILE_BYTES, { allowEmpty: false, ...options });
168
+ return { file, manifest: stableJsonValue(file, label) };
169
+ }
170
+
171
+ function commandEvidenceFileIdentity(file) {
172
+ const status = file.evidence.openedDescriptor;
173
+ return {
174
+ device: String(status.dev),
175
+ inode: String(status.ino),
176
+ size: status.size,
177
+ mtime_ms: status.mtimeMs,
178
+ ctime_ms: status.ctimeMs,
179
+ raw_digest: file.rawByteDigest,
180
+ canonical_path: { classification: "attempt_relative", digest: `sha256:${sha256(Buffer.from(file.canonicalPath))}` },
181
+ };
182
+ }
183
+
184
+ function commandEvidenceReference(file, manifest) {
185
+ return {
186
+ path: COMMAND_EVIDENCE_PATH,
187
+ digest: file.rawByteDigest,
188
+ bytes: file.bytes.length,
189
+ capture_status: manifest.capture.evidence_level,
190
+ evidence_count: manifest.command_event_count,
191
+ file_identity: commandEvidenceFileIdentity(file),
192
+ };
193
+ }
194
+
195
+ function sameCommandEvidenceReference(left, right) {
196
+ return stableCanonicalJson(left) === stableCanonicalJson(right);
197
+ }
198
+
199
+ function fault(name) {
200
+ if (process.env.ASK_BENCHMARK_FAULT === name) process.exit(86);
201
+ }
202
+
203
+ function assertNoSymlinkSegments(path, label) {
204
+ const absolute = resolve(path);
205
+ const root = parse(absolute).root;
206
+ let current = root;
207
+ for (const segment of absolute.slice(root.length).split(sep).filter(Boolean)) {
208
+ current = resolve(current, segment);
209
+ if (!existsSync(current)) break;
210
+ if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} traverses a symlink: ${current}`);
211
+ }
212
+ return absolute;
213
+ }
214
+
215
+ function isInside(root, path) {
216
+ const resolvedRoot = resolve(root);
217
+ const resolvedPath = resolve(path);
218
+ return resolvedPath === resolvedRoot || resolvedPath.startsWith(`${resolvedRoot}${sep}`);
219
+ }
220
+
221
+ function assertInside(root, path, label) {
222
+ if (!isInside(root, path)) throw new Error(`${label} escapes its allowed root`);
223
+ return resolve(path);
224
+ }
225
+
226
+ function assertPortableRelativePath(path, label) {
227
+ if (typeof path !== "string" || path.length === 0 || path.startsWith("/") || path.includes("\\") || path.split("/").includes("..") || path.startsWith("./")) {
228
+ throw new Error(`${label} must be a portable relative path`);
229
+ }
230
+ return path;
231
+ }
232
+
233
+ function assertCaseId(caseId) {
234
+ if (typeof caseId !== "string" || !CASE_ID_PATTERN.test(caseId)) throw new Error("case ID is invalid");
235
+ return caseId;
236
+ }
237
+
238
+ function assertClaimId(claimId) {
239
+ if (typeof claimId !== "string" || !UUID_PATTERN.test(claimId)) throw new Error("claim ID is invalid");
240
+ return claimId;
241
+ }
242
+
243
+ function assertAttempt(attempt) {
244
+ if (typeof attempt !== "string" || !ATTEMPT_PATTERN.test(attempt)) throw new Error("attempt ID is invalid");
245
+ return attempt;
246
+ }
247
+
248
+ function caseRootPath(runDir, caseId) {
249
+ const casesRoot = resolve(runDir, "cases");
250
+ return assertInside(casesRoot, resolve(casesRoot, assertCaseId(caseId)), `${caseId} case root`);
251
+ }
252
+
253
+ function attemptRootPath(runDir, caseId, attempt) {
254
+ const attemptsRoot = resolve(caseRootPath(runDir, caseId), "attempts");
255
+ const path = assertInside(attemptsRoot, resolve(attemptsRoot, assertAttempt(attempt)), `${caseId} attempt`);
256
+ assertNoSymlinkSegments(path, `${caseId} attempt`);
257
+ return path;
258
+ }
259
+
260
+ function git(root, args) {
261
+ const result = spawnSync("git", args, { cwd: root, encoding: "utf8" });
262
+ if (result.status !== 0) throw new Error(`git ${args.join(" ")} failed: ${result.stderr || result.stdout}`);
263
+ return result.stdout.trim();
264
+ }
265
+
266
+ function schema(root, path) {
267
+ return resolve(root, path);
268
+ }
269
+
270
+ function validate(root, value, schemaPath, label) {
271
+ return assertBenchmarkSchemaInstance(value, { schemaPath: schema(root, schemaPath), label });
272
+ }
273
+
274
+ function fileDigest(path) {
275
+ return sha256(readFileSync(path));
276
+ }
277
+
278
+ function streamEvidence(value) {
279
+ const bytes = Buffer.from(value ?? "");
280
+ return { bytes: bytes.length, sha256: sha256(bytes) };
281
+ }
282
+
283
+ function normalizeDurableScalar(value, fallback = "unavailable") {
284
+ const normalized = String(value ?? "")
285
+ .normalize("NFKC")
286
+ .replace(/[\u0000-\u001f\u007f-\u009f]+/gu, " ")
287
+ .replace(/\s+/gu, " ")
288
+ .trim()
289
+ .slice(0, DURABLE_SCALAR_MAX_LENGTH);
290
+ return normalized || fallback;
291
+ }
292
+
293
+ function durableScalarEvidence(rawValue, normalizedValue, fallback) {
294
+ const bytes = Buffer.from(String(rawValue ?? ""));
295
+ return {
296
+ value: normalizeDurableScalar(normalizedValue, fallback),
297
+ digest: `sha256:${sha256(bytes)}`,
298
+ bytes: bytes.length,
299
+ };
300
+ }
301
+
302
+ function jsonLineCount(value) {
303
+ return String(value ?? "").split("\n").filter((line) => {
304
+ try {
305
+ JSON.parse(line);
306
+ return true;
307
+ } catch {
308
+ return false;
309
+ }
310
+ }).length;
311
+ }
312
+
313
+ function readRuntimeConfig(root, path, adapter) {
314
+ if (!path || !existsSync(path) || !lstatSync(path).isFile()) throw new Error("execute-portfolio requires a regular --runtime-config file");
315
+ assertNoSymlinkSegments(path, "runtime config");
316
+ const bytes = readFileSync(path);
317
+ const value = JSON.parse(bytes);
318
+ validate(root, value, RUNTIME_CONFIG_SCHEMA_PATH, "runtime config");
319
+ if (value.adapter !== adapter) throw new Error(`runtime config adapter ${value.adapter} does not match --adapter ${adapter}`);
320
+ // Environment snapshots exist even for declared-unavailable runtimes.
321
+ if (isNativeClaudeRuntime(value)) validateNativeClaudeEnvironmentPolicy(value);
322
+ if (value.availability === "available" && (!value.expected_executable_version || (adapter === "claude" && !value.claude_cli))) {
323
+ throw new Error("available runtime config requires expected executable version and an explicit Claude CLI contract where applicable");
324
+ }
325
+ if (value.availability === "unavailable" && (!value.unavailable_reason || value.unavailable_reason.trim() === "")) {
326
+ throw new Error("unavailable runtime config requires unavailable_reason");
327
+ }
328
+ if (adapter === "codex" && value.claude_cli !== null) throw new Error("Codex runtime config must not provide a Claude CLI contract");
329
+ const capture = value.command_evidence;
330
+ if (capture.support === "supported" && (capture.event_transport !== "codex_exec_jsonl" || capture.event_format_revision !== CODEX_COMMAND_EVENT_FORMAT_REVISION || capture.parser_revision !== COMMAND_EVIDENCE_PARSER_REVISION || capture.shell_capability.support_status !== "supported" || capture.shell_capability.family !== "posix_bash" || capture.shell_capability.executable !== "/bin/bash" || stableCanonicalJson(capture.shell_capability.envelope_arguments) !== stableCanonicalJson(["-lc"]) || capture.shell_capability.authority_source !== "codex_exec_jsonl_command_rendering" || capture.shell_capability.probe_status !== "runtime_event_required" || capture.shell_capability.downgrade_reason !== null)) throw new Error("supported command evidence requires runtime event shell authority");
331
+ if (capture.support !== "supported" && (capture.event_transport !== "none" || capture.event_format_revision !== null || capture.parser_revision !== null || capture.shell_capability.support_status !== capture.support || capture.shell_capability.family !== null || capture.shell_capability.executable !== null || capture.shell_capability.envelope_arguments !== null || capture.shell_capability.authority_source !== "none" || capture.shell_capability.downgrade_reason === null)) throw new Error("unavailable command evidence shell capability is inconsistent");
332
+ if (adapter === "claude" && (capture.support !== "unsupported" || capture.event_transport !== "none" || capture.event_format_revision !== null || capture.parser_revision !== null)) throw new Error("Claude command evidence must remain explicitly unsupported");
333
+ if (adapter === "claude" && value.availability === "available") validateClaudeCommandTemplate(value);
334
+ if (value.environment_value_allowlist.some((key) => !value.environment_allowlist.includes(key))) throw new Error("environment value allowlist must be a subset of environment allowlist");
335
+ return { value, digest: sha256(bytes) };
336
+ }
337
+
338
+ function placeholderCount(command, placeholder) {
339
+ return command.reduce((count, part) => count + part.split(placeholder).length - 1, 0);
340
+ }
341
+
342
+ function validateClaudeCommandTemplate(runtime) {
343
+ if (isNativeClaudeRuntime(runtime)) { validateNativeClaudeRuntime(runtime); return; }
344
+ const contract = runtime.claude_cli;
345
+ if (!contract) throw new Error("available Claude runtime requires a CLI contract");
346
+ for (const placeholder of ["{task}", "{output}", "{sandbox_policy}", "{permission_policy}"]) {
347
+ if (placeholderCount(contract.command, placeholder) !== 1) throw new Error(`Claude CLI contract requires exactly one ${placeholder} placeholder`);
348
+ }
349
+ for (const part of contract.command) {
350
+ if (!/^(?:[^{}]|\{output\}|\{task\}|\{sandbox_policy\}|\{permission_policy\})+$/u.test(part)) throw new Error("Claude CLI contract uses an unsupported placeholder");
351
+ }
352
+ const sandboxIndex = contract.command.indexOf(contract.sandbox_argument);
353
+ const permissionIndex = contract.command.indexOf(contract.permission_argument);
354
+ if (sandboxIndex < 0 || contract.command[sandboxIndex + 1] !== "{sandbox_policy}") throw new Error("Claude CLI contract does not apply the declared sandbox policy");
355
+ if (permissionIndex < 0 || contract.command[permissionIndex + 1] !== "{permission_policy}") throw new Error("Claude CLI contract does not apply the declared permission policy");
356
+ const expected = ["--benchmark-output", "{output}", "--benchmark-task", "{task}", contract.sandbox_argument, "{sandbox_policy}", contract.permission_argument, "{permission_policy}"];
357
+ if (stableCanonicalJson(contract.command) !== stableCanonicalJson(expected)) throw new Error("Claude CLI contract contains unsupported or conflicting arguments");
358
+ }
359
+
360
+ function environmentSnapshotRecord(runtime, values) {
361
+ const valueKeys = new Set(runtime.environment_value_allowlist);
362
+ const entries = [...runtime.environment_allowlist].sort().map((name) => {
363
+ const present = Object.hasOwn(values, name);
364
+ if (!present) return { name, present: false, value: null, digest: null, bytes: 0 };
365
+ const evidence = durableScalarEvidence(values[name], values[name], "present");
366
+ return { name, present: true, value: valueKeys.has(name) ? evidence.value : null, digest: evidence.digest, bytes: evidence.bytes };
367
+ });
368
+ return { digest: canonicalDigest(entries), entries };
369
+ }
370
+
371
+ function captureEnvironment(runtime) {
372
+ const values = {};
373
+ for (const key of runtime.environment_allowlist) {
374
+ if (Object.hasOwn(process.env, key)) values[key] = process.env[key];
375
+ }
376
+ return { runtime, values, record: environmentSnapshotRecord(runtime, values) };
377
+ }
378
+
379
+ function environmentFor(snapshot, extra = {}) {
380
+ if (stableCanonicalJson(environmentSnapshotRecord(snapshot.runtime, snapshot.values)) !== stableCanonicalJson(snapshot.record)) throw new RuntimeIntegrityError("captured environment snapshot changed in memory");
381
+ return { ...snapshot.values, ...extra };
382
+ }
383
+
384
+ export function effectiveCommand(root, runtime) {
385
+ if (runtime.availability === "unavailable") {
386
+ return { argv: [], task_transport: "none", output_transport: "none", output_schema_digest: null };
387
+ }
388
+ if (runtime.adapter === "codex") {
389
+ return {
390
+ argv: [
391
+ "exec",
392
+ "--ephemeral",
393
+ "--ignore-user-config",
394
+ "--ignore-rules",
395
+ "--skip-git-repo-check",
396
+ "--json",
397
+ "--model", runtime.model,
398
+ "-c", `model_reasoning_effort=\"${runtime.reasoning_effort}\"`,
399
+ "-c", `approval_policy=\"${runtime.permission_policy}\"`,
400
+ "--sandbox", runtime.sandbox_policy,
401
+ "--output-schema", "{output_schema}",
402
+ "--output-last-message", "{output}",
403
+ "-",
404
+ ],
405
+ task_transport: "stdin",
406
+ output_transport: "file",
407
+ output_schema_digest: `sha256:${fileDigest(schema(root, OUTPUT_SCHEMA_PATH))}`,
408
+ };
409
+ }
410
+ validateClaudeCommandTemplate(runtime);
411
+ if (isNativeClaudeRuntime(runtime)) return nativeClaudeCommand(runtime, `sha256:${fileDigest(schema(root, OUTPUT_SCHEMA_PATH))}`);
412
+ return {
413
+ argv: runtime.claude_cli.command,
414
+ task_transport: "file",
415
+ output_transport: "file",
416
+ output_schema_digest: null,
417
+ };
418
+ }
419
+
420
+ function validateAgentExecutable(agentBin) {
421
+ if (!agentBin || !existsSync(agentBin) || !lstatSync(agentBin).isFile()) throw new Error("available runtime requires a regular --agent-bin");
422
+ assertNoSymlinkSegments(agentBin, "agent executable");
423
+ const executable = realpathSync(agentBin);
424
+ return {
425
+ path: executable,
426
+ descriptor: {
427
+ executable_basename: basename(executable),
428
+ executable_sha256: fileDigest(executable),
429
+ },
430
+ };
431
+ }
432
+
433
+ function assertExecutableIdentity(verifiedExecutable) {
434
+ const executable = verifiedExecutable.path;
435
+ try {
436
+ assertNoSymlinkSegments(executable, "agent executable");
437
+ if (!existsSync(executable) || !lstatSync(executable).isFile() || realpathSync(executable) !== executable) throw new Error("agent executable is no longer the verified regular file");
438
+ if (fileDigest(executable) !== verifiedExecutable.descriptor.executable_sha256) throw new Error("agent executable digest changed after runtime identity capture");
439
+ } catch (error) {
440
+ throw new RuntimeIntegrityError(error instanceof Error ? error.message : String(error));
441
+ }
442
+ return executable;
443
+ }
444
+
445
+ function probeAvailableRuntime(runtime, verifiedExecutable, command, environmentSnapshot, successorRuntime = null) {
446
+ if (!isNativeClaudeRuntime(runtime)) return probeRuntimeCommands(runtime, verifiedExecutable, command, environmentSnapshot, successorRuntime);
447
+ const directory = mkdtempSync(resolve(TEMP_ROOT, 'ask-claude-probe-')); chmodSync(directory, 0o700);
448
+ try { return probeRuntimeCommands(runtime, verifiedExecutable, command, environmentSnapshot, successorRuntime, nativeClaudeProbeEnvironment(directory)); }
449
+ finally { rmSync(directory, { recursive: true, force: true }); }
450
+ }
451
+
452
+ function probeRuntimeCommands(runtime, verifiedExecutable, command, environmentSnapshot, successorRuntime = null, extraEnvironment = {}) {
453
+ const executable = assertExecutableIdentity(verifiedExecutable);
454
+ const version = spawnSync(executable, ["--version"], { encoding: "utf8", env: environmentFor(environmentSnapshot, extraEnvironment), timeout: 10000, killSignal: "SIGKILL", maxBuffer: 1024 * 1024 });
455
+ assertExecutableIdentity(verifiedExecutable);
456
+ const observedVersionOutput = `${version.stdout ?? ""}${version.stderr ?? ""}`;
457
+ let successorVersion = null;
458
+ if (successorRuntime !== null) {
459
+ assertSuccessorVersionOutput(successorRuntime.cli_version, observedVersionOutput);
460
+ successorVersion = successorRuntime.cli_version;
461
+ }
462
+ const versionConfirmed = version.status === 0 && observedVersionOutput.includes(runtime.expected_executable_version);
463
+ const versionEvidence = durableScalarEvidence(
464
+ observedVersionOutput,
465
+ versionConfirmed ? (successorVersion ?? runtime.expected_executable_version) : "unconfirmed",
466
+ "unconfirmed",
467
+ );
468
+ const executableEvidence = {
469
+ ...verifiedExecutable.descriptor,
470
+ observed_version: versionEvidence.value,
471
+ observed_version_digest: versionEvidence.digest,
472
+ observed_version_bytes: versionEvidence.bytes,
473
+ };
474
+ if (!versionConfirmed) throw new RuntimeContractError("version_mismatch", executableEvidence);
475
+ {
476
+ const helpArgs = runtime.adapter === "codex" ? ["exec", "--help"] : ["--help"];
477
+ assertExecutableIdentity(verifiedExecutable);
478
+ const help = spawnSync(executable, helpArgs, { encoding: "utf8", env: environmentFor(environmentSnapshot, extraEnvironment), timeout: 10000, killSignal: "SIGKILL", maxBuffer: 1024 * 1024 });
479
+ assertExecutableIdentity(verifiedExecutable);
480
+ const helpOutput = `${help.stdout ?? ""}${help.stderr ?? ""}`;
481
+ const requiredFlags = runtime.adapter === "codex"
482
+ ? ["--ephemeral", "--ignore-user-config", "--ignore-rules", "--skip-git-repo-check", "--json", "--model", "--config", "--sandbox", "--output-schema", "--output-last-message"]
483
+ : command.argv.filter((part) => part.startsWith("-") && part !== "-");
484
+ const markerMatches = runtime.adapter === "codex" || (isNativeClaudeRuntime(runtime) ? helpOutput.includes('Claude') : helpOutput.includes(runtime.claude_cli.help_marker));
485
+ if (help.status !== 0 || !markerMatches || !requiredFlags.every((flag) => helpOutput.includes(flag))) {
486
+ throw new RuntimeContractError("help_contract_mismatch", executableEvidence);
487
+ }
488
+ }
489
+ return executableEvidence;
490
+ }
491
+
492
+ // Public no-model preflight over the same executable/config/version/help
493
+ // boundary as execution. It creates no run, request, grading or runtime trust.
494
+ export function inspectPortfolioRuntimeContract({ root, runtimeConfigPath, adapter, agentBin = null }) {
495
+ const runtime = readRuntimeConfig(root, runtimeConfigPath, adapter);
496
+ if (runtime.value.availability === 'unavailable' || agentBin === null) return {
497
+ availability: 'unavailable', reason: runtime.value.availability === 'unavailable' ? runtime.value.unavailable_reason : 'cli_not_supplied',
498
+ model_calls: 0, runtime_execution_implied: false, command_events_observed: false };
499
+ const verified = validateAgentExecutable(agentBin), command = effectiveCommand(root, runtime.value);
500
+ const snapshot = captureEnvironment(runtime.value);
501
+ try {
502
+ const executable = probeAvailableRuntime(runtime.value, verified, command, snapshot);
503
+ return { availability: 'available', reason: null, executable, runtime_config_digest: `sha256:${runtime.digest}`,
504
+ effective_command_digest: canonicalDigest(command), model_calls: 0, runtime_execution_implied: false, command_events_observed: false };
505
+ } catch (error) {
506
+ if (!(error instanceof RuntimeContractError)) throw error;
507
+ return { availability: 'unavailable', reason: error.contractReason, model_calls: 0, runtime_execution_implied: false, command_events_observed: false };
508
+ }
509
+ }
510
+
511
+ function adapterIdentity({ adapter, runtime, runtimeConfigDigest, executable, command, environmentSnapshot, availabilityEvidence = null }) {
512
+ const captureSupported = runtime.command_evidence.support === "supported";
513
+ return {
514
+ schema_version: "1.2.0",
515
+ adapter,
516
+ runtime_config_sha256: runtimeConfigDigest,
517
+ availability: runtime.availability,
518
+ unavailable_reason: runtime.unavailable_reason,
519
+ executor: runtime.executor,
520
+ model: runtime.model,
521
+ reasoning_effort: runtime.reasoning_effort,
522
+ sandbox_policy: runtime.sandbox_policy,
523
+ permission_policy: runtime.permission_policy,
524
+ case_timeout_ms: runtime.case_timeout_ms,
525
+ thermal_state: runtime.thermal_state,
526
+ environment_allowlist: runtime.environment_allowlist,
527
+ environment_value_allowlist: runtime.environment_value_allowlist,
528
+ environment_snapshot: environmentSnapshot.record,
529
+ executable,
530
+ effective_command: command,
531
+ effective_command_digest: canonicalDigest(command),
532
+ policy_enforcement: {
533
+ sandbox_policy: runtime.sandbox_policy,
534
+ permission_policy: runtime.permission_policy,
535
+ ephemeral: adapter === "codex" || isNativeClaudeRuntime(runtime),
536
+ user_config_isolated: adapter === "codex" || isNativeClaudeRuntime(runtime),
537
+ rules_isolated: adapter === "codex",
538
+ },
539
+ availability_evidence: availabilityEvidence ?? (runtime.availability === "available" ? "local_version_and_contract_probe" : "declared_unavailable"),
540
+ command_evidence: {
541
+ support: runtime.command_evidence.support,
542
+ evidence_level: "unavailable",
543
+ event_transport: captureSupported ? runtime.command_evidence.event_transport : "none",
544
+ event_format_revision: captureSupported ? runtime.command_evidence.event_format_revision : null,
545
+ parser_revision: captureSupported ? runtime.command_evidence.parser_revision : null,
546
+ contract_probe_evidence: captureSupported && runtime.availability === "available" ? "runtime_event_required" : (runtime.availability === "unavailable" ? "declared_unavailable" : adapter === "claude" ? "adapter_event_contract_not_implemented" : "contract_probe_failed"),
547
+ downgrade_reason: runtime.unavailable_reason ?? (adapter === "claude" ? "adapter_event_contract_not_implemented" : captureSupported ? "runtime_event_not_observed" : runtime.command_evidence.shell_capability.downgrade_reason),
548
+ shell_capability: structuredClone(runtime.command_evidence.shell_capability),
549
+ },
550
+ };
551
+ }
552
+
553
+ function assertRunBoundary(runDir, materialized, selectionState) {
554
+ const run = resolve(runDir);
555
+ const materializedRoot = resolve(materialized);
556
+ const selectionRoot = resolve(selectionState);
557
+ if (isInside(materializedRoot, run) || isInside(selectionRoot, run) || isInside(run, materializedRoot) || isInside(run, selectionRoot)) {
558
+ throw new Error("run root must stay outside materialized and selection-state roots");
559
+ }
560
+ const parent = dirname(run);
561
+ if (!existsSync(parent) || !lstatSync(parent).isDirectory()) throw new Error("run root parent must be an existing directory");
562
+ assertNoSymlinkSegments(parent, "run root parent");
563
+ if (existsSync(run) && (!lstatSync(run).isDirectory() || lstatSync(run).isSymbolicLink())) throw new Error("run root must be a directory and not a symlink");
564
+ return run;
565
+ }
566
+
567
+ function runIdentityPath(runDir) {
568
+ const path = assertInside(runDir, resolve(runDir, RUN_IDENTITY_FILE), "run identity");
569
+ assertNoSymlinkSegments(path, "run identity");
570
+ return path;
571
+ }
572
+
573
+ function adapterIdentityPath(runDir, adapter) {
574
+ if (!["codex", "claude"].includes(adapter)) throw new Error("adapter identity uses an unsupported adapter");
575
+ const adaptersRoot = assertInside(runDir, resolve(runDir, "adapters"), "adapter identity root");
576
+ assertNoSymlinkSegments(adaptersRoot, "adapter identity root");
577
+ if (!existsSync(adaptersRoot) || !lstatSync(adaptersRoot).isDirectory() || lstatSync(adaptersRoot).isSymbolicLink()) throw new Error("adapter identity root must be a real directory");
578
+ const path = assertInside(adaptersRoot, resolve(adaptersRoot, `${adapter}.json`), `${adapter} runtime identity`);
579
+ assertNoSymlinkSegments(path, `${adapter} runtime identity`);
580
+ return path;
581
+ }
582
+
583
+ function readPlan(planPath) {
584
+ if (!planPath || !existsSync(planPath) || !lstatSync(planPath).isFile()) throw new Error("execution requires a regular --plan file");
585
+ assertNoSymlinkSegments(planPath, "execution plan");
586
+ return readJson(planPath);
587
+ }
588
+
589
+ function loadSelections({ root, config, planPath, materializedPath, selectionState, repositoryRevision, plan, executionAdmissionEvidenceByFixture = null }) {
590
+ if (!selectionState || !existsSync(selectionState) || !lstatSync(selectionState).isDirectory()) throw new Error("execution requires an existing --selection-state directory");
591
+ assertNoSymlinkSegments(selectionState, "selection state");
592
+ const indexPath = resolve(selectionState, "selection-state.json");
593
+ if (!existsSync(indexPath) || !lstatSync(indexPath).isFile()) throw new Error("selection state index is missing");
594
+ const selections = new Map();
595
+ for (const entry of plan.cases.filter((caseRecord) => caseRecord.condition === "adaptive_ask")) {
596
+ const record = verifyAdaptiveSelection({ root, config, planPath, materializedPath, stateDir: selectionState, caseId: entry.case_id, repositoryRevision, executionAdmissionEvidenceByFixture });
597
+ selections.set(entry.case_id, record);
598
+ }
599
+ return { selections, stateDigest: `sha256:${fileDigest(indexPath)}` };
600
+ }
601
+
602
+ // Bind the actual filesystem root, not only its environment-variable spelling.
603
+ // A changed TMPDIR or a same-path directory replacement cannot prove that an
604
+ // earlier attempt's private workspace disappeared.
605
+ function workspaceRootIdentity() {
606
+ assertNoSymlinkPathSegments(TEMP_ROOT, "execution workspace root");
607
+ const status = lstatSync(TEMP_ROOT, { bigint: true });
608
+ if (!status.isDirectory()) throw new Error("execution workspace root is not a directory");
609
+ return canonicalDigest({ canonical_path: realpathSync(TEMP_ROOT), device: String(status.dev), inode: String(status.ino) });
610
+ }
611
+
612
+ function assertWorkspaceRootIdentity(identity) {
613
+ if (identity.schema_version !== "1.1.0" || identity.workspace_root_identity !== workspaceRootIdentity()) {
614
+ throw new TerminalCleanupError("execution workspace root identity is missing or changed; cleanup cannot be inferred");
615
+ }
616
+ }
617
+
618
+ function runIdentity({ root, plan, materialized, selections, repositoryRevision, config }) {
619
+ return {
620
+ schema_version: "1.1.0",
621
+ workspace_root_identity: workspaceRootIdentity(),
622
+ program: "adaptive_ask_portfolio_execution",
623
+ plan: { id: plan.plan_id, digest: canonicalDigest(plan) },
624
+ materialization: {
625
+ manifest_digest: materialized.manifestDigest,
626
+ output_root_identity: materialized.manifest.output_root_identity,
627
+ },
628
+ repository_revision: repositoryRevision,
629
+ runner: { version: EXECUTION_RUNNER_VERSION, source_revision: repositoryRevision },
630
+ config: { sha256: plan.config_sha256, protocol_sha256: plan.protocol_sha256 },
631
+ case_namespace: canonicalDigest(plan.cases.map((entry) => entry.case_id)),
632
+ selection_state_digest: selections.stateDigest,
633
+ output_schema_digest: `sha256:${fileDigest(schema(root, OUTPUT_SCHEMA_PATH))}`,
634
+ };
635
+ }
636
+
637
+ function initialCaseState(entry, selection) {
638
+ return {
639
+ schema_version: "1.1.0",
640
+ case_id: entry.case_id,
641
+ adapter: entry.adapter_track,
642
+ condition: entry.condition,
643
+ status: "pending",
644
+ attempt_count: 0,
645
+ active_claim_id: null,
646
+ terminal_attempt: null,
647
+ terminal_commit_digest: null,
648
+ selection_digest: selection?.selection_digest?.value ?? null,
649
+ };
650
+ }
651
+
652
+ function statePath(runDir, caseId) {
653
+ const path = resolve(caseRootPath(runDir, caseId), "state.json");
654
+ assertNoSymlinkSegments(path, `${caseId} state`);
655
+ return path;
656
+ }
657
+
658
+ function readCaseState(root, runDir, entry) {
659
+ const path = statePath(runDir, entry.case_id);
660
+ if (!existsSync(path) || !lstatSync(path).isFile()) throw new Error(`case state is missing: ${entry.case_id}`);
661
+ assertNoSymlinkSegments(path, `${entry.case_id} state`);
662
+ const state = readJson(path);
663
+ validate(root, state, CASE_STATE_SCHEMA_PATH, `${entry.case_id} state`);
664
+ if (state.case_id !== entry.case_id || state.adapter !== entry.adapter_track || state.condition !== entry.condition) throw new Error(`${entry.case_id} state identity mismatch`);
665
+ if (state.status === "pending" && (state.attempt_count !== 0 || state.active_claim_id !== null || state.terminal_attempt !== null)) throw new Error(`${entry.case_id} pending state is inconsistent`);
666
+ if (state.status === "active" && (state.attempt_count < 1 || !UUID_PATTERN.test(state.active_claim_id ?? "") || state.terminal_attempt !== null)) throw new Error(`${entry.case_id} active state is inconsistent`);
667
+ if (TERMINAL_STATUSES.has(state.status) && (state.attempt_count < 1 || state.active_claim_id !== null || state.terminal_attempt === null)) throw new Error(`${entry.case_id} terminal state is inconsistent`);
668
+ if ((entry.condition === "adaptive_ask") !== (typeof state.selection_digest === "string")) throw new Error(`${entry.case_id} state selection identity is inconsistent`);
669
+ return state;
670
+ }
671
+
672
+ function writeCaseState(runDir, entry, state) {
673
+ writeJsonAtomic(statePath(runDir, entry.case_id), state);
674
+ }
675
+
676
+ function initializeRun({ root, runDir, identity, plan, selections }) {
677
+ const identityPath = runIdentityPath(runDir);
678
+ if (existsSync(runDir) && readdirSync(runDir).length > 0) {
679
+ if (!existsSync(identityPath)) throw new Error("non-empty run root is missing run identity");
680
+ const existing = readJson(identityPath);
681
+ validate(root, existing, RUN_IDENTITY_SCHEMA_PATH, "run identity");
682
+ if (stableCanonicalJson(existing) !== stableCanonicalJson({ ...identity, run_instance_id: existing.run_instance_id })) throw new Error("run identity changed; refusing resume");
683
+ return { initialized: false, identity: existing };
684
+ }
685
+ const persistedIdentity = { ...identity, run_instance_id: randomUUID() };
686
+ validate(root, persistedIdentity, RUN_IDENTITY_SCHEMA_PATH, "run identity");
687
+ const parent = dirname(runDir);
688
+ const staging = mkdtempSync(resolve(parent, `.${basename(runDir)}.staging-`));
689
+ try {
690
+ writeJsonAtomic(runIdentityPath(staging), persistedIdentity);
691
+ mkdirSync(resolve(staging, "adapters"));
692
+ for (const entry of plan.cases) {
693
+ const caseRoot = resolve(staging, "cases", entry.case_id);
694
+ mkdirSync(resolve(caseRoot, "attempts"), { recursive: true });
695
+ writeJsonAtomic(resolve(caseRoot, "state.json"), initialCaseState(entry, selections.selections.get(entry.case_id)));
696
+ }
697
+ if (existsSync(runDir)) rmdirSync(runDir);
698
+ renameSync(staging, runDir);
699
+ return { initialized: true, identity: persistedIdentity };
700
+ } catch (error) {
701
+ rmSync(staging, { recursive: true, force: true });
702
+ throw error;
703
+ }
704
+ }
705
+
706
+ function loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, initialize = true, executionAdmissionEvidenceByFixture = null }) {
707
+ assertTrackedRepositoryMatchesHead(root);
708
+ const repositoryRevision = git(root, ["rev-parse", "HEAD"]);
709
+ const plan = readPlan(planPath);
710
+ const materialized = validateMaterializedPortfolio({ root, config, plan, materializedRoot: materializedPath, repositoryRevision, executionAdmissionEvidenceByFixture });
711
+ const selections = loadSelections({ root, config, planPath, materializedPath, selectionState, repositoryRevision, plan, executionAdmissionEvidenceByFixture });
712
+ const identity = runIdentity({ root, plan, materialized, selections, repositoryRevision, config });
713
+ const safeRunDir = assertRunBoundary(runDir, materializedPath, selectionState);
714
+ const initializedRun = initialize
715
+ ? initializeRun({ root, runDir: safeRunDir, identity, plan, selections })
716
+ : (() => {
717
+ const path = runIdentityPath(safeRunDir);
718
+ if (!existsSync(path)) throw new Error("run identity is missing");
719
+ const existing = readJson(path);
720
+ validate(root, existing, RUN_IDENTITY_SCHEMA_PATH, "run identity");
721
+ if (stableCanonicalJson(existing) !== stableCanonicalJson({ ...identity, run_instance_id: existing.run_instance_id })) throw new Error("run identity changed; refusing verification");
722
+ return { initialized: false, identity: existing };
723
+ })();
724
+ return { repositoryRevision, plan, materialized, selections, identity: initializedRun.identity, runDir: safeRunDir, initialized: initializedRun.initialized, executionAdmissionEvidenceByFixture };
725
+ }
726
+
727
+ function adapterHasAttempts(runDir, plan, adapter) {
728
+ return plan.cases.some((entry) => entry.adapter_track === adapter && readdirSync(resolve(caseRootPath(runDir, entry.case_id), "attempts")).length > 0);
729
+ }
730
+
731
+ function readAdapterIdentity(root, runDir, adapter) {
732
+ const path = adapterIdentityPath(runDir, adapter);
733
+ if (!existsSync(path) || !lstatSync(path).isFile()) throw new Error(`${adapter} runtime identity is missing`);
734
+ const identity = readJson(path);
735
+ validate(root, identity, ADAPTER_IDENTITY_SCHEMA_PATH, `${adapter} runtime identity`);
736
+ if (identity.adapter !== adapter || identity.effective_command_digest !== canonicalDigest(identity.effective_command)) throw new Error(`${adapter} runtime identity is invalid`);
737
+ if (identity.environment_snapshot.digest !== canonicalDigest(identity.environment_snapshot.entries)) throw new Error(`${adapter} environment snapshot digest is invalid`);
738
+ assertCanonicalEqual(identity.environment_snapshot.entries.map((entry) => entry.name).sort(), [...identity.environment_allowlist].sort(), `${adapter} environment snapshot names`);
739
+ if (identity.environment_value_allowlist.some((name) => !identity.environment_allowlist.includes(name))) throw new Error(`${adapter} environment value allowlist is invalid`);
740
+ for (const entry of identity.environment_snapshot.entries) {
741
+ if (!entry.present && (entry.value !== null || entry.digest !== null || entry.bytes !== 0)) throw new Error(`${adapter} absent environment entry has evidence`);
742
+ if (entry.present && entry.digest === null) throw new Error(`${adapter} present environment entry is missing its digest`);
743
+ if (entry.value !== null && !identity.environment_value_allowlist.includes(entry.name)) throw new Error(`${adapter} environment snapshot exposes a non-declared value`);
744
+ }
745
+ if (identity.policy_enforcement.sandbox_policy !== identity.sandbox_policy || identity.policy_enforcement.permission_policy !== identity.permission_policy) throw new Error(`${adapter} runtime policy identity is inconsistent`);
746
+ const capture = identity.command_evidence;
747
+ if (capture.evidence_level === "executed") throw new Error(`${adapter} runtime identity cannot claim executed command evidence before event inspection`);
748
+ if (capture.evidence_level === "unavailable" && capture.downgrade_reason === null) throw new Error(`${adapter} unavailable command evidence identity lacks a downgrade reason`);
749
+ if (capture.support === "supported" && (capture.event_transport !== "codex_exec_jsonl" || capture.event_format_revision !== CODEX_COMMAND_EVENT_FORMAT_REVISION || capture.parser_revision !== COMMAND_EVIDENCE_PARSER_REVISION || capture.shell_capability.support_status !== "supported" || capture.shell_capability.family !== "posix_bash" || capture.shell_capability.executable !== "/bin/bash" || stableCanonicalJson(capture.shell_capability.envelope_arguments) !== stableCanonicalJson(["-lc"]) || capture.shell_capability.authority_source !== "codex_exec_jsonl_command_rendering" || capture.shell_capability.probe_status !== "runtime_event_required")) throw new Error(`${adapter} supported command evidence identity is inconsistent`);
750
+ if (capture.support !== "supported" && (capture.event_transport !== "none" || capture.event_format_revision !== null || capture.parser_revision !== null || capture.evidence_level !== "unavailable" || capture.shell_capability.support_status !== capture.support || capture.shell_capability.family !== null || capture.shell_capability.executable !== null || capture.shell_capability.envelope_arguments !== null || capture.shell_capability.authority_source !== "none" || capture.shell_capability.downgrade_reason === null)) throw new Error(`${adapter} unsupported command evidence identity is inconsistent`);
751
+ if (identity.availability === "available" && adapter === "codex") {
752
+ const argv = identity.effective_command.argv;
753
+ if (identity.effective_command.task_transport !== 'stdin' || identity.effective_command.output_transport !== 'file') throw new Error('Codex effective transport is invalid');
754
+ if (!argv.includes("--ephemeral") || !argv.includes("--ignore-user-config") || !argv.includes("--ignore-rules") || !argv.includes("--skip-git-repo-check") || !argv.includes("--json") || argv[argv.indexOf("--sandbox") + 1] !== identity.sandbox_policy || !argv.includes(`approval_policy=\"${identity.permission_policy}\"`) || argv[argv.indexOf("--output-schema") + 1] !== "{output_schema}") throw new Error("Codex effective command does not enforce its runtime policy");
755
+ }
756
+ if (identity.availability === "available" && adapter === "claude") {
757
+ const argv = identity.effective_command.argv;
758
+ if (identity.effective_command.output_transport === 'structured_stdout') {
759
+ const expected = nativeClaudeCommand({ ...identity, expected_executable_version: identity.executable?.observed_version,
760
+ claude_cli: { kind: CLAUDE_NATIVE_KIND } }, `sha256:${fileDigest(schema(root, OUTPUT_SCHEMA_PATH))}`);
761
+ assertCanonicalEqual(identity.effective_command, expected, 'native Claude effective command');
762
+ if (!identity.policy_enforcement.ephemeral || !identity.policy_enforcement.user_config_isolated || identity.policy_enforcement.rules_isolated) throw new Error('native Claude policy identity drift');
763
+ } else if (placeholderCount(argv, "{task}") !== 1 || placeholderCount(argv, "{output}") !== 1 || placeholderCount(argv, "{sandbox_policy}") !== 1 || placeholderCount(argv, "{permission_policy}") !== 1) throw new Error("Claude effective command contract is incomplete");
764
+ }
765
+ return identity;
766
+ }
767
+
768
+ function ensureAdapterIdentity({ root, runDir, plan, adapter, runtimeConfig, verifiedExecutable, environmentSnapshot, successorRuntime = null }) {
769
+ let effectiveRuntime = runtimeConfig.value;
770
+ let command = effectiveCommand(root, effectiveRuntime);
771
+ if (successorRuntime !== null) command = successorEffectiveCommand(command);
772
+ let executable = null;
773
+ let availabilityEvidence = null;
774
+ if (effectiveRuntime.availability === "available") {
775
+ if (successorRuntime !== null) {
776
+ assertSuccessorExecutableDescriptor(successorRuntime, verifiedExecutable.descriptor);
777
+ // Tie native format/CPU checks to the same exact bytes as the runtime pin.
778
+ // A script named "codex" must fail before --version or --help can run.
779
+ assertSuccessorNativeExecutable({
780
+ path: verifiedExecutable.path,
781
+ expectedDigest: successorRuntime.executable_digest,
782
+ os: successorRuntime.os,
783
+ arch: successorRuntime.arch,
784
+ });
785
+ }
786
+ try {
787
+ executable = probeAvailableRuntime(effectiveRuntime, verifiedExecutable, command, environmentSnapshot, successorRuntime);
788
+ } catch (error) {
789
+ if (error instanceof RuntimeIntegrityError) throw error;
790
+ effectiveRuntime = {
791
+ ...effectiveRuntime,
792
+ availability: "unavailable",
793
+ unavailable_reason: `runtime_contract_unconfirmed:${error instanceof RuntimeContractError ? error.contractReason : "probe_failed"}`,
794
+ };
795
+ executable = error instanceof RuntimeContractError ? error.executable : null;
796
+ command = effectiveCommand(root, effectiveRuntime);
797
+ availabilityEvidence = "contract_probe_failed";
798
+ }
799
+ }
800
+ const identity = adapterIdentity({ adapter, runtime: effectiveRuntime, runtimeConfigDigest: runtimeConfig.digest, executable, command, environmentSnapshot, availabilityEvidence });
801
+ if (successorRuntime !== null) assertSuccessorAdapterFacts(successorRuntime, identity, { checkHost: true });
802
+ const path = adapterIdentityPath(runDir, adapter);
803
+ if (!existsSync(path) && adapterHasAttempts(runDir, plan, adapter)) throw new Error(`${adapter} runtime identity is missing after attempts were created; refusing replacement`);
804
+ const published = publishJsonExclusive(path, identity);
805
+ const existing = published ? identity : readAdapterIdentity(root, runDir, adapter);
806
+ if (stableCanonicalJson(existing) !== stableCanonicalJson(identity)) throw new Error(`${adapter} runtime identity changed; refusing resume`);
807
+ return { identity: existing, digest: canonicalDigest(existing) };
808
+ }
809
+
810
+ function claimPath(runDir, caseId) {
811
+ const path = resolve(caseRootPath(runDir, caseId), "claim");
812
+ assertNoSymlinkSegments(path, `${caseId} claim`);
813
+ return path;
814
+ }
815
+
816
+ function claimStagingPath(runDir, caseId, claimId) {
817
+ const caseRoot = caseRootPath(runDir, caseId);
818
+ const path = assertInside(caseRoot, resolve(caseRoot, `.claim-${assertClaimId(claimId)}.staging`), `${caseId} staged claim`);
819
+ assertNoSymlinkSegments(path, `${caseId} staged claim`);
820
+ return path;
821
+ }
822
+
823
+ function readClaim(root, runDir, caseId) {
824
+ const directory = claimPath(runDir, caseId);
825
+ if (!existsSync(directory)) return null;
826
+ if (!lstatSync(directory).isDirectory() || lstatSync(directory).isSymbolicLink()) throw new Error(`${caseId} claim is invalid`);
827
+ const path = resolve(directory, "claim.json");
828
+ if (!existsSync(path) || !lstatSync(path).isFile()) throw new Error(`${caseId} claim is incomplete; explicit recovery is required`);
829
+ const claim = readJson(path);
830
+ validate(root, claim, CLAIM_SCHEMA_PATH, `${caseId} claim`);
831
+ if (claim.case_id !== caseId) throw new Error(`${caseId} claim identity mismatch`);
832
+ if ((claim.condition === "adaptive_ask") !== (claim.selection !== null)) throw new Error(`${caseId} claim selection identity is inconsistent`);
833
+ return claim;
834
+ }
835
+
836
+ function readStagedClaim(root, runDir, caseId, claimId) {
837
+ const directory = claimStagingPath(runDir, caseId, claimId);
838
+ if (!existsSync(directory)) return null;
839
+ if (!lstatSync(directory).isDirectory() || lstatSync(directory).isSymbolicLink()) throw new Error("staged claim directory is invalid");
840
+ const claimPath = resolve(directory, "claim.json");
841
+ const preClaimPath = resolve(directory, PRE_CLAIM_FILE);
842
+ const path = existsSync(claimPath) ? claimPath : preClaimPath;
843
+ assertNoSymlinkSegments(path, `${caseId} staged claim evidence`);
844
+ if (!existsSync(path)) return null;
845
+ if (!lstatSync(path).isFile()) throw new Error("staged claim evidence must be a regular file");
846
+ const claim = readJson(path);
847
+ validate(root, claim, CLAIM_SCHEMA_PATH, `${caseId} staged claim`);
848
+ if (claim.case_id !== caseId || claim.claim_id !== claimId) throw new Error("staged claim identity mismatch");
849
+ if ((claim.condition === "adaptive_ask") !== (claim.selection !== null)) throw new Error("staged claim selection identity is inconsistent");
850
+ return { claim, directory };
851
+ }
852
+
853
+ function claimIsExpired(claim, now = Date.now()) {
854
+ return Number.isFinite(Date.parse(claim.lease_expires_at)) && Date.parse(claim.lease_expires_at) < now;
855
+ }
856
+
857
+ function inputIdentityFor(context, entry) {
858
+ return {
859
+ plan_id: context.identity.plan.id,
860
+ plan_digest: context.identity.plan.digest,
861
+ materialization_manifest_digest: context.materialized.manifestDigest,
862
+ frozen_input_digest: context.materialized.casesById.get(entry.case_id).frozen_input_digest,
863
+ fixture_id: entry.fixture_id,
864
+ repetition: entry.repetition,
865
+ fixture_input_digest: `sha256:${entry.input_manifest_sha256}`,
866
+ verification_command_contract_digest: entry.verification_command_contract?.contract_digest ?? null,
867
+ };
868
+ }
869
+
870
+ function loadVerificationCommandContract(root, entry) {
871
+ const reference = entry.verification_command_contract;
872
+ if (!reference) return null;
873
+ const path = assertInside(root, resolve(root, reference.path), `${entry.case_id} verification command contract`);
874
+ if (relative(root, path).startsWith("..") || !existsSync(path) || !lstatSync(path).isFile()) throw new Error(`${entry.case_id} verification command contract is missing`);
875
+ assertNoSymlinkSegments(path, `${entry.case_id} verification command contract`);
876
+ if (prefixedFileDigest(path) !== reference.file_digest) throw new Error(`${entry.case_id} verification command contract file digest mismatch`);
877
+ const contract = validateVerificationCommandContract(readJson(path), { root });
878
+ if (contract.fixture_id !== entry.fixture_id || contract.fixture_input_digest !== `sha256:${entry.input_manifest_sha256}` || contract.contract_digest !== reference.contract_digest) throw new Error(`${entry.case_id} verification command contract identity mismatch`);
879
+ return contract;
880
+ }
881
+
882
+ function selectionIdentityFor(context, entry) {
883
+ const selection = context.selections.selections.get(entry.case_id);
884
+ return selection ? { digest: selection.selection_digest.value, selected_mechanisms: selection.selected_mechanisms, required_gates: selection.required_gates } : null;
885
+ }
886
+
887
+ function workspaceOwnership(claim, runIdentity) {
888
+ if (claim.run_instance_id !== runIdentity.run_instance_id) throw new Error("claim run instance does not match workspace owner");
889
+ return {
890
+ schema_version: "1.0.0",
891
+ claim_id: assertClaimId(claim.claim_id),
892
+ case_id: assertCaseId(claim.case_id),
893
+ run_instance_id: assertClaimId(claim.run_instance_id),
894
+ attempt: assertAttempt(claim.attempt),
895
+ lease_expires_at: claim.lease_expires_at,
896
+ claim_digest: canonicalDigest(claim),
897
+ workspace_parent: claim.workspace_parent,
898
+ workspace_token: assertClaimId(claim.workspace_token),
899
+ };
900
+ }
901
+
902
+ function lstatWorkspaceIfPresent(path) {
903
+ try { return lstatSync(path); }
904
+ catch (error) {
905
+ // existsSync follows symlinks and also hides errors other than absence.
906
+ if (error?.code === "ENOENT") return null;
907
+ throw error;
908
+ }
909
+ }
910
+
911
+ function assertEphemeralWorkspaceOwnership(claim, runIdentity) {
912
+ assertWorkspaceRootIdentity(runIdentity);
913
+ if (!WORKSPACE_PARENT_PATTERN.test(claim.workspace_parent ?? "")) throw new Error("claim workspace parent is invalid");
914
+ const parent = assertInside(TEMP_ROOT, resolve(TEMP_ROOT, claim.workspace_parent), "claim workspace parent");
915
+ assertNoSymlinkPathSegments(parent, "claim workspace parent", { allowMissingLeaf: true });
916
+ const status = lstatWorkspaceIfPresent(parent);
917
+ if (status === null) return null;
918
+ if (!status.isDirectory() || status.isSymbolicLink()) throw new Error("claim workspace parent is not a real directory");
919
+ const markerPath = assertInside(parent, resolve(parent, WORKSPACE_OWNERSHIP_FILE), "claim workspace ownership marker");
920
+ assertNoSymlinkSegments(markerPath, "claim workspace ownership marker");
921
+ if (!existsSync(markerPath) || !lstatSync(markerPath).isFile()) throw new Error("claim workspace ownership marker is missing or invalid");
922
+ assertCanonicalEqual(readJson(markerPath), workspaceOwnership(claim, runIdentity), "claim workspace ownership");
923
+ return parent;
924
+ }
925
+
926
+ function acquireClaim({ root, context, entry, attempt, runtime, adapter }) {
927
+ const claimId = randomUUID();
928
+ const directory = claimPath(context.runDir, entry.case_id);
929
+ const staging = claimStagingPath(context.runDir, entry.case_id, claimId);
930
+ const workspaceToken = randomUUID();
931
+ // Carry the root identity in the existing committed workspace name. The run
932
+ // header alone must not be enough to redirect cleanup to a different root.
933
+ const workspaceParentPath = mkdtempSync(resolve(TEMP_ROOT, `ask-portfolio-workspaces-${workspaceRootIdentity().slice("sha256:".length)}-`));
934
+ chmodSync(workspaceParentPath, 0o700);
935
+ const workspaceParent = basename(workspaceParentPath);
936
+ mkdirSync(staging, { recursive: false });
937
+ const acquiredAt = new Date().toISOString();
938
+ const injectedLeaseMs = process.env.ASK_BENCHMARK_FAULT ? Number(process.env.ASK_BENCHMARK_FAULT_LEASE_MS) : Number.NaN;
939
+ const leaseMs = Number.isFinite(injectedLeaseMs) ? injectedLeaseMs : runtime.case_timeout_ms + CLAIM_GRACE_MS;
940
+ const claim = {
941
+ schema_version: "1.1.0",
942
+ run_instance_id: context.identity.run_instance_id,
943
+ claim_id: claimId,
944
+ case_id: entry.case_id,
945
+ attempt,
946
+ adapter: entry.adapter_track,
947
+ condition: entry.condition,
948
+ worker_id: `${process.pid}`,
949
+ pid: process.pid,
950
+ acquired_at: acquiredAt,
951
+ lease_expires_at: new Date(Date.now() + leaseMs).toISOString(),
952
+ workspace_parent: workspaceParent,
953
+ workspace_token: workspaceToken,
954
+ input_identity: inputIdentityFor(context, entry),
955
+ selection: selectionIdentityFor(context, entry),
956
+ runtime_identity_digest: adapter.digest,
957
+ effective_command_digest: adapter.identity.effective_command_digest,
958
+ environment_snapshot_digest: adapter.identity.environment_snapshot.digest,
959
+ };
960
+ validate(root, claim, CLAIM_SCHEMA_PATH, `${entry.case_id} claim`);
961
+ try {
962
+ const preClaimPath = resolve(staging, PRE_CLAIM_FILE);
963
+ writeJsonExclusive(preClaimPath, claim);
964
+ writeJsonExclusive(resolve(workspaceParentPath, WORKSPACE_OWNERSHIP_FILE), workspaceOwnership(claim, context.identity));
965
+ fault("after_workspace_ownership_published");
966
+ writeJsonExclusive(resolve(staging, "claim.json"), claim);
967
+ rmSync(preClaimPath, { force: true });
968
+ fault("after_claim_record_written");
969
+ fault("after_claim_staged");
970
+ renameSync(staging, directory);
971
+ } catch (error) {
972
+ rmSync(staging, { recursive: true, force: true });
973
+ removeEphemeralWorkspace(claim, context.identity);
974
+ if (["EEXIST", "ENOTEMPTY"].includes(error?.code)) return null;
975
+ throw error;
976
+ }
977
+ fault("after_claim_published");
978
+ return claim;
979
+ }
980
+
981
+ function releaseClaim(root, runDir, caseId, claimId) {
982
+ const path = claimPath(runDir, caseId);
983
+ if (!existsSync(path)) return false;
984
+ const claim = readClaim(root, runDir, caseId);
985
+ if (claim.claim_id !== claimId) throw new Error("claim ID changed before release");
986
+ rmSync(path, { recursive: true, force: true });
987
+ return true;
988
+ }
989
+
990
+ function nextAttempt(runDir, entry) {
991
+ const directory = resolve(caseRootPath(runDir, entry.case_id), "attempts");
992
+ assertNoSymlinkSegments(directory, `${entry.case_id} attempts`);
993
+ const existing = readdirSync(directory, { withFileTypes: true })
994
+ .filter((item) => item.isDirectory() && /^[0-9]{4}$/u.test(item.name))
995
+ .map((item) => Number(item.name));
996
+ return String((Math.max(0, ...existing) + 1)).padStart(4, "0");
997
+ }
998
+
999
+ function ephemeralWorkspacePath(claim) {
1000
+ if (!WORKSPACE_PARENT_PATTERN.test(claim.workspace_parent ?? "")) throw new Error("claim workspace parent is invalid");
1001
+ if (!claim.workspace_parent.startsWith(`ask-portfolio-workspaces-${workspaceRootIdentity().slice("sha256:".length)}-`)) {
1002
+ throw new TerminalCleanupError("claim workspace root identity is missing or changed; cleanup cannot be inferred");
1003
+ }
1004
+ assertClaimId(claim.workspace_token);
1005
+ const parent = assertInside(TEMP_ROOT, resolve(TEMP_ROOT, claim.workspace_parent), "claim workspace parent");
1006
+ const path = assertInside(parent, resolve(parent, claim.workspace_token), "claim workspace");
1007
+ assertNoSymlinkPathSegments(path, "claim workspace", { allowMissingLeaf: true });
1008
+ return path;
1009
+ }
1010
+
1011
+ function assertTerminalWorkspaceCleanup(request) {
1012
+ const parent = dirname(ephemeralWorkspacePath(request.claim));
1013
+ if (lstatWorkspaceIfPresent(parent) !== null) {
1014
+ throw new TerminalCleanupError(`${request.case_id} terminal workspace cleanup is unresolved; explicit recovery is required`);
1015
+ }
1016
+ }
1017
+
1018
+ function removeEphemeralWorkspace(claim, runIdentity) {
1019
+ assertWorkspaceRootIdentity(runIdentity);
1020
+ const workspace = ephemeralWorkspacePath(claim);
1021
+ const parent = dirname(workspace);
1022
+ if (lstatWorkspaceIfPresent(parent) === null) return;
1023
+ assertEphemeralWorkspaceOwnership(claim, runIdentity);
1024
+ if (lstatWorkspaceIfPresent(workspace) !== null) rmSync(workspace, { recursive: true, force: true });
1025
+ // Recheck ownership before removing the parent, including its marker.
1026
+ if (assertEphemeralWorkspaceOwnership(claim, runIdentity) !== null) {
1027
+ rmSync(parent, { recursive: true, force: true });
1028
+ }
1029
+ if (lstatWorkspaceIfPresent(parent) !== null) throw new TerminalCleanupError("claim workspace parent remains after cleanup");
1030
+ }
1031
+
1032
+ function copyWorkspace({ materializedRoot, record, claim, runIdentity }) {
1033
+ const sourceRoot = resolve(materializedRoot, record.case_id);
1034
+ assertEphemeralWorkspaceOwnership(claim, runIdentity);
1035
+ const ephemeralRoot = ephemeralWorkspacePath(claim);
1036
+ mkdirSync(ephemeralRoot, { recursive: false, mode: 0o700 });
1037
+ const workspace = resolve(ephemeralRoot, "workspace");
1038
+ mkdirSync(workspace, { mode: 0o700 });
1039
+ const inventory = [...record.agent_visible_files, ...record.projected_asset_inventory];
1040
+ for (const file of inventory) {
1041
+ const relativePath = assertPortableRelativePath(file.path, `${record.case_id} materialized path`);
1042
+ const source = assertInside(sourceRoot, resolve(sourceRoot, relativePath), `${record.case_id} materialized source`);
1043
+ const destination = assertInside(workspace, resolve(workspace, relativePath), `${record.case_id} execution destination`);
1044
+ assertNoSymlinkSegments(source, `${record.case_id} materialized source`);
1045
+ if (!lstatSync(source).isFile() || fileDigest(source) !== file.sha256 || statSync(source).size !== file.bytes) throw new Error(`${record.case_id} materialized source drifted before execution copy`);
1046
+ mkdirSync(dirname(destination), { recursive: true });
1047
+ copyFileSync(source, destination, 0);
1048
+ chmodSync(destination, Number.parseInt(file.mode, 8));
1049
+ }
1050
+ return { ephemeralRoot, workspace };
1051
+ }
1052
+
1053
+ function applyAdaptiveSelection({ root, adapter, selection, workspace }) {
1054
+ const requested = [...new Set([...selection.selected_mechanisms, ...selection.required_gates])];
1055
+ if (selection.lightweight_bypass.used) {
1056
+ if (requested.length !== 0) throw new Error("lightweight bypass must not project additional skills");
1057
+ return { status: "lightweight_bypass", selected_skills: [], inventory: [], source_digests: [], projection_fingerprint: null, capability_downgrades: selection.capability_downgrades };
1058
+ }
1059
+ const closure = adapter === "codex" ? resolveCodexSkillClosure(requested) : resolveClaudeSkillClosure(requested);
1060
+ const plan = adapter === "codex"
1061
+ ? buildCodexProjectionPlan({ profileName: "minimal", skills: closure, skipPrompts: true, skipCommand: true })
1062
+ : buildClaudeProjectionPlan({ profileName: "implementation", skills: closure, skipHooks: true, skipRuntime: true, skipCommands: true });
1063
+ // Use the installer's bounded, validated source inventory for entries and
1064
+ // references alike. An arbitrary projected path never becomes a source path.
1065
+ const prefix = adapter === "codex" ? ".agents/skills/" : ".claude/skills/";
1066
+ const sources = new Map(plan.skillFiles.map(({ skill, relativePath, sourcePath }) => [
1067
+ `${prefix}${skill}/${relativePath}`, resolve(root, sourcePath),
1068
+ ]));
1069
+ const inventory = [];
1070
+ for (const asset of plan.projectedManagedAssets) {
1071
+ const source = sources.get(asset.path);
1072
+ if (asset.asset_kind !== "skills" || !source) throw new Error(`selection projection contains an unbound skill asset: ${asset.path}`);
1073
+ assertNoSymlinkSegments(source, "selection projection source");
1074
+ if (!existsSync(source) || !lstatSync(source).isFile()) throw new Error(`selection projection source is unavailable: ${asset.path}`);
1075
+ const destination = assertInside(workspace, resolve(workspace, asset.path), "selection projection destination");
1076
+ mkdirSync(dirname(destination), { recursive: true });
1077
+ copyFileSync(source, destination, 0);
1078
+ chmodSync(destination, statSync(source).mode & 0o777);
1079
+ inventory.push({ path: asset.path, sha256: fileDigest(destination), bytes: statSync(destination).size, mode: `0${(statSync(destination).mode & 0o777).toString(8).padStart(3, "0")}` });
1080
+ }
1081
+ return {
1082
+ status: selection.capability_downgrades.length > 0 ? "capability_downgraded" : "projected",
1083
+ selected_skills: closure,
1084
+ inventory: inventory.sort((left, right) => left.path.localeCompare(right.path)),
1085
+ source_digests: Object.values(plan.renderer_inputs).flat().map((item) => ({ path: item.path, sha256: item.digest })).sort((left, right) => left.path.localeCompare(right.path)),
1086
+ projection_fingerprint: plan.fingerprint,
1087
+ capability_downgrades: selection.capability_downgrades,
1088
+ };
1089
+ }
1090
+
1091
+ function isolatedCodexHome(environment) {
1092
+ const sourceHome = environment.CODEX_HOME ? resolve(environment.CODEX_HOME) : environment.HOME ? resolve(environment.HOME, ".codex") : null;
1093
+ const home = mkdtempSync(resolve(tmpdir(), "ask-portfolio-codex-home-"));
1094
+ chmodSync(home, 0o700);
1095
+ const auth = sourceHome ? resolve(sourceHome, "auth.json") : null;
1096
+ if (auth && existsSync(auth) && lstatSync(auth).isFile()) symlinkSync(auth, resolve(home, "auth.json"));
1097
+ return home;
1098
+ }
1099
+
1100
+ function materializeCommand(root, command, runtime, outputTemporary) {
1101
+ return command.argv.map((part) => part
1102
+ .replaceAll("{output}", outputTemporary)
1103
+ .replaceAll("{output_schema}", resolve(root, OUTPUT_SCHEMA_PATH))
1104
+ .replaceAll("{output_schema_json}", JSON.stringify(readJson(schema(root, OUTPUT_SCHEMA_PATH))))
1105
+ .replaceAll("{task}", "BENCHMARK_TASK.md")
1106
+ .replaceAll("{sandbox_policy}", runtime.sandbox_policy)
1107
+ .replaceAll("{permission_policy}", runtime.permission_policy));
1108
+ }
1109
+
1110
+ export function terminateResidualAgentProcessGroup(pid) {
1111
+ if (process.platform === "win32" || !Number.isInteger(pid) || pid < 1) return false;
1112
+ let present = false;
1113
+ try {
1114
+ process.kill(-pid, 0);
1115
+ present = true;
1116
+ } catch (error) {
1117
+ if (error?.code !== "ESRCH") throw error;
1118
+ return false;
1119
+ }
1120
+ for (const signal of ["SIGTERM", "SIGKILL"]) {
1121
+ try {
1122
+ process.kill(-pid, signal);
1123
+ } catch (error) {
1124
+ if (error?.code === "ESRCH") return present;
1125
+ throw error;
1126
+ }
1127
+ for (let index = 0; index < 50; index += 1) {
1128
+ try {
1129
+ process.kill(-pid, 0);
1130
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
1131
+ } catch (error) {
1132
+ if (error?.code === "ESRCH") return present;
1133
+ throw error;
1134
+ }
1135
+ }
1136
+ }
1137
+ throw new Error("terminal workspace residual agent process group could not be terminated");
1138
+ }
1139
+
1140
+ export function executeContainedAgent(executable, args, { recordCleanupFailure = false, ...options }) {
1141
+ // Keep original stdout/stderr bytes until evidence hashing and usage parsing.
1142
+ // Decoding here would silently replace malformed UTF-8 before either check.
1143
+ const result = spawnSync(executable, args, { ...options, encoding: null, detached: process.platform !== "win32" });
1144
+ try {
1145
+ return { ...result, workspace_descendants_detected: terminateResidualAgentProcessGroup(result.pid) };
1146
+ } catch (error) {
1147
+ if (!recordCleanupFailure) throw error;
1148
+ // Callers opting in can persist the original PID, streams and exit evidence
1149
+ // even when cleanup fails. Default callers retain the existing throw.
1150
+ return { ...result, workspace_descendants_detected: true, cleanup_error: true };
1151
+ }
1152
+ }
1153
+
1154
+ function executeAgent({ root, runtime, executable, workspace, outputTemporary, command, environmentSnapshot, successorStdin = null }) {
1155
+ if (successorStdin !== null && (!Buffer.isBuffer(successorStdin) || runtime.adapter !== "codex")) throw new Error("invalid successor stdin transport");
1156
+ const task = successorStdin === null ? readFileSync(resolve(workspace, "BENCHMARK_TASK.md"), "utf8") : successorStdin;
1157
+ const environment = environmentFor(environmentSnapshot);
1158
+ if (runtime.adapter === "codex") {
1159
+ const codexHome = isolatedCodexHome(environment);
1160
+ try {
1161
+ return executeContainedAgent(executable, materializeCommand(root, command, runtime, outputTemporary), {
1162
+ cwd: workspace,
1163
+ input: task,
1164
+ env: { ...environment, CODEX_HOME: codexHome },
1165
+ timeout: runtime.case_timeout_ms,
1166
+ maxBuffer: MAX_PROCESS_OUTPUT_BYTES,
1167
+ });
1168
+ } finally {
1169
+ rmSync(codexHome, { recursive: true, force: true });
1170
+ }
1171
+ }
1172
+ if (isNativeClaudeRuntime(runtime)) {
1173
+ assertNativeClaudeInstructions(workspace);
1174
+ const configDirectory = mkdtempSync(resolve(TEMP_ROOT, 'ask-portfolio-claude-config-'));
1175
+ chmodSync(configDirectory, 0o700);
1176
+ try {
1177
+ const raw = executeContainedAgent(executable, materializeCommand(root, command, runtime, outputTemporary), {
1178
+ cwd: workspace, input: nativeClaudeInput(), env: nativeClaudeEnvironment(environment, configDirectory),
1179
+ timeout: runtime.case_timeout_ms, maxBuffer: MAX_PROCESS_OUTPUT_BYTES,
1180
+ });
1181
+ return raw;
1182
+ } finally { rmSync(configDirectory, { recursive: true, force: true }); }
1183
+ }
1184
+ const args = materializeCommand(root, command, runtime, outputTemporary);
1185
+ return executeContainedAgent(executable, args, {
1186
+ cwd: workspace,
1187
+ env: environment,
1188
+ timeout: runtime.case_timeout_ms,
1189
+ maxBuffer: MAX_PROCESS_OUTPUT_BYTES,
1190
+ });
1191
+ }
1192
+
1193
+ function executeVerifiedAgent({ verifiedExecutable, ...options }) {
1194
+ const executable = assertExecutableIdentity(verifiedExecutable);
1195
+ const result = executeAgent({ ...options, executable });
1196
+ assertExecutableIdentity(verifiedExecutable);
1197
+ return result;
1198
+ }
1199
+
1200
+ function inspectFinal(root, outputTemporary) {
1201
+ if (!existsSync(outputTemporary) || !lstatSync(outputTemporary).isFile()) throw new Error("agent final structured output is missing");
1202
+ if (statSync(outputTemporary).size > MAX_FINAL_OUTPUT_BYTES) throw new Error("agent final structured output exceeds the maximum byte size");
1203
+ const bytes = readFileSync(outputTemporary);
1204
+ const final = JSON.parse(bytes);
1205
+ validate(root, final, OUTPUT_SCHEMA_PATH, "agent final structured output");
1206
+ return { record: { path: "final.json", sha256: sha256(bytes), bytes: bytes.length }, bytes };
1207
+ }
1208
+
1209
+ function publishFinal(root, attemptRoot, source, record, claimId) {
1210
+ assertClaimId(claimId);
1211
+ const destination = resolve(attemptRoot, "final.json");
1212
+ assertInside(attemptRoot, destination, "attempt final output");
1213
+ assertNoSymlinkSegments(destination, "attempt final output");
1214
+ if (existsSync(destination)) {
1215
+ const size = statSync(destination).size;
1216
+ if (size > MAX_FINAL_OUTPUT_BYTES || size !== record.bytes || fileDigest(destination) !== record.sha256) throw new Error("attempt final output already exists with different content");
1217
+ validate(root, readJson(destination), OUTPUT_SCHEMA_PATH, "durable agent final structured output");
1218
+ return false;
1219
+ }
1220
+ const inspected = inspectFinal(root, source);
1221
+ if (stableCanonicalJson(inspected.record) !== stableCanonicalJson(record)) throw new Error("agent final structured output identity changed");
1222
+ const staging = resolve(attemptRoot, `.final.json.${claimId}.${randomUUID()}.staging`);
1223
+ writeFileSync(staging, inspected.bytes, { flag: "wx" });
1224
+ fault("after_final_staged");
1225
+ renameSync(staging, destination);
1226
+ return true;
1227
+ }
1228
+
1229
+ function normalizedProjection(projection) {
1230
+ return {
1231
+ status: projection.status,
1232
+ selected_skills: projection.selected_skills ?? [],
1233
+ inventory: projection.inventory ?? [],
1234
+ source_digests: projection.source_digests ?? [],
1235
+ projection_fingerprint: projection.projection_fingerprint ?? null,
1236
+ capability_downgrades: projection.capability_downgrades ?? [],
1237
+ };
1238
+ }
1239
+
1240
+ function terminalWorkspaceIdentity(entry, claim) {
1241
+ return {
1242
+ run_instance_id: claim.run_instance_id,
1243
+ case_id: entry.case_id,
1244
+ attempt: claim.attempt,
1245
+ adapter: entry.adapter_track,
1246
+ condition: entry.condition,
1247
+ fixture_id: claim.input_identity.fixture_id,
1248
+ fixture_input_digest: claim.input_identity.fixture_input_digest,
1249
+ materialization_manifest_digest: claim.input_identity.materialization_manifest_digest,
1250
+ };
1251
+ }
1252
+
1253
+ function managedAssetPaths(record, projection) {
1254
+ return [...new Set([
1255
+ ...record.projected_asset_inventory.map((entry) => entry.path),
1256
+ ...(projection.inventory ?? []).map((entry) => entry.path),
1257
+ ])].sort((left, right) => left.localeCompare(right));
1258
+ }
1259
+
1260
+ function expectedBaseRegularInventory(record, projection) {
1261
+ const byPath = new Map();
1262
+ for (const entry of [...record.agent_visible_files, ...record.projected_asset_inventory, ...(projection.inventory ?? [])]) {
1263
+ const normalized = { path: entry.path, file_type: "regular_file", mode: entry.mode, bytes: entry.bytes, sha256: entry.sha256 };
1264
+ const existing = byPath.get(entry.path);
1265
+ if (existing && stableCanonicalJson(existing) !== stableCanonicalJson(normalized)) throw new Error(`terminal workspace base inventory conflicts at ${entry.path}`);
1266
+ byPath.set(entry.path, normalized);
1267
+ }
1268
+ // Match the terminal-workspace contract's locale-independent path order.
1269
+ // SKILL.md sorts before references/, even in locales that fold letter case.
1270
+ return [...byPath.values()].sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
1271
+ }
1272
+
1273
+ function terminalWorkspaceAuthorityPath(attemptRoot) {
1274
+ const path = resolve(attemptRoot, TERMINAL_WORKSPACE_AUTHORITY_PATH);
1275
+ assertInside(attemptRoot, path, "terminal workspace authority");
1276
+ assertNoSymlinkSegments(path, "terminal workspace authority");
1277
+ return path;
1278
+ }
1279
+
1280
+ function terminalWorkspaceStagingPrefix(claimId) {
1281
+ return `.${TERMINAL_WORKSPACE_AUTHORITY_PATH}.${assertClaimId(claimId)}.`;
1282
+ }
1283
+
1284
+ function publishTerminalWorkspaceAuthority({ root, attemptRoot, entry, claim, baseSnapshot, workspace, record, projection }) {
1285
+ const destination = terminalWorkspaceAuthorityPath(attemptRoot);
1286
+ const identity = terminalWorkspaceIdentity(entry, claim);
1287
+ const managedPaths = managedAssetPaths(record, projection);
1288
+ const expectedBase = expectedBaseRegularInventory(record, projection);
1289
+ let staging = null;
1290
+ let publishedHere = false;
1291
+ try {
1292
+ if (!existsSync(destination)) {
1293
+ const built = buildTerminalWorkspaceAuthority({ root, baseSnapshot, terminalWorkspaceRoot: workspace, identity, managedAssetPaths: managedPaths });
1294
+ staging = resolve(attemptRoot, `${terminalWorkspaceStagingPrefix(claim.claim_id)}${randomUUID()}.staging`);
1295
+ assertInside(attemptRoot, staging, "terminal workspace authority staging");
1296
+ writeFileSync(staging, built.bytes, { flag: "wx", mode: 0o444 });
1297
+ chmodSync(staging, 0o444);
1298
+ fault("after_terminal_workspace_authority_staged");
1299
+ renameSync(staging, destination);
1300
+ staging = null;
1301
+ publishedHere = true;
1302
+ chmodSync(destination, 0o444);
1303
+ }
1304
+ fault("after_terminal_workspace_authority_published");
1305
+ const verified = readVerifiedTerminalWorkspaceAuthority({ root, authorityPath: destination, expected: identity, expectedBaseInventory: expectedBase, expectedManagedAssetPaths: managedPaths });
1306
+ return terminalWorkspaceAuthorityReference(verified.file, verified.authority);
1307
+ } catch (error) {
1308
+ if (staging && existsSync(staging)) {
1309
+ chmodSync(staging, 0o600);
1310
+ rmSync(staging, { force: true });
1311
+ }
1312
+ if (publishedHere && existsSync(destination)) {
1313
+ chmodSync(destination, 0o600);
1314
+ rmSync(destination, { force: true });
1315
+ }
1316
+ throw error;
1317
+ }
1318
+ }
1319
+
1320
+ function terminalWorkspaceReferenceFromResult(result) {
1321
+ if (result.terminal_workspace_authority_availability !== "captured") return null;
1322
+ return {
1323
+ path: result.terminal_workspace_authority_path,
1324
+ sha256: result.terminal_workspace_authority_sha256,
1325
+ bytes: result.terminal_workspace_authority_bytes,
1326
+ digest: result.terminal_workspace_authority_digest,
1327
+ tree_digest: result.terminal_workspace_tree_digest,
1328
+ file_identity: result.terminal_workspace_authority_file_identity,
1329
+ };
1330
+ }
1331
+
1332
+ function terminalWorkspaceResultFields(reference) {
1333
+ return reference ? {
1334
+ terminal_workspace_authority_availability: "captured",
1335
+ terminal_workspace_authority_support: "supported",
1336
+ terminal_workspace_authority_path: reference.path,
1337
+ terminal_workspace_authority_sha256: reference.sha256,
1338
+ terminal_workspace_authority_bytes: reference.bytes,
1339
+ terminal_workspace_authority_digest: reference.digest,
1340
+ terminal_workspace_tree_digest: reference.tree_digest,
1341
+ terminal_workspace_authority_file_identity: reference.file_identity,
1342
+ } : {
1343
+ terminal_workspace_authority_availability: "unavailable",
1344
+ terminal_workspace_authority_support: "supported",
1345
+ terminal_workspace_authority_path: null,
1346
+ terminal_workspace_authority_sha256: null,
1347
+ terminal_workspace_authority_bytes: null,
1348
+ terminal_workspace_authority_digest: null,
1349
+ terminal_workspace_tree_digest: null,
1350
+ terminal_workspace_authority_file_identity: null,
1351
+ };
1352
+ }
1353
+
1354
+ function requestClaimRecord(claim) {
1355
+ return {
1356
+ id: claim.claim_id,
1357
+ worker_id: claim.worker_id,
1358
+ pid: claim.pid,
1359
+ acquired_at: claim.acquired_at,
1360
+ lease_expires_at: claim.lease_expires_at,
1361
+ workspace_parent: claim.workspace_parent,
1362
+ workspace_token: claim.workspace_token,
1363
+ };
1364
+ }
1365
+
1366
+ function claimFromVerifiedRequest(root, request) {
1367
+ const claim = {
1368
+ schema_version: "1.1.0",
1369
+ run_instance_id: request.run_instance_id,
1370
+ claim_id: request.claim.id,
1371
+ case_id: request.case_id,
1372
+ attempt: request.attempt,
1373
+ adapter: request.adapter,
1374
+ condition: request.condition,
1375
+ worker_id: request.claim.worker_id,
1376
+ pid: request.claim.pid,
1377
+ acquired_at: request.claim.acquired_at,
1378
+ lease_expires_at: request.claim.lease_expires_at,
1379
+ workspace_parent: request.claim.workspace_parent,
1380
+ workspace_token: request.claim.workspace_token,
1381
+ input_identity: request.input_identity,
1382
+ selection: request.selection,
1383
+ runtime_identity_digest: request.agent.runtime_identity_digest,
1384
+ effective_command_digest: request.agent.effective_command_digest,
1385
+ environment_snapshot_digest: request.agent.environment_snapshot_digest,
1386
+ };
1387
+ validate(root, claim, CLAIM_SCHEMA_PATH, `${request.case_id} recovered claim`);
1388
+ return claim;
1389
+ }
1390
+
1391
+ function requestRecord({ entry, attempt, claim, projection }) {
1392
+ return {
1393
+ schema_version: "1.1.0",
1394
+ kind: "request",
1395
+ run_instance_id: claim.run_instance_id,
1396
+ case_id: entry.case_id,
1397
+ attempt,
1398
+ adapter: entry.adapter_track,
1399
+ condition: entry.condition,
1400
+ claim: requestClaimRecord(claim),
1401
+ input_identity: claim.input_identity,
1402
+ selection: claim.selection,
1403
+ projection: normalizedProjection(projection),
1404
+ agent: {
1405
+ adapter: entry.adapter_track,
1406
+ runtime_identity_digest: claim.runtime_identity_digest,
1407
+ effective_command_digest: claim.effective_command_digest,
1408
+ environment_snapshot_digest: claim.environment_snapshot_digest,
1409
+ autonomous_agents_started: 0,
1410
+ },
1411
+ };
1412
+ }
1413
+
1414
+ function commandEvidenceIdentity({ entry, claim }) {
1415
+ return {
1416
+ run_instance_id: claim.run_instance_id,
1417
+ case_id: entry.case_id,
1418
+ attempt: claim.attempt,
1419
+ adapter: entry.adapter_track,
1420
+ condition: entry.condition,
1421
+ fixture_id: claim.input_identity.fixture_id,
1422
+ repetition: claim.input_identity.repetition,
1423
+ fixture_input_digest: claim.input_identity.fixture_input_digest,
1424
+ verification_command_contract_digest: claim.input_identity.verification_command_contract_digest,
1425
+ runtime_identity_digest: claim.runtime_identity_digest,
1426
+ effective_command_digest: claim.effective_command_digest,
1427
+ };
1428
+ }
1429
+
1430
+ function sealCommandEvidence({ root, attemptRoot, entry, claim, adapterIdentity, processResult = null, contract = null, workspaceRoot = null, forceUnavailable = null }) {
1431
+ const path = resolve(attemptRoot, COMMAND_EVIDENCE_PATH);
1432
+ assertNoSymlinkSegments(path, `${entry.case_id} command evidence`);
1433
+ let manifest;
1434
+ let captureError = null;
1435
+ const identity = commandEvidenceIdentity({ entry, claim });
1436
+ if (!forceUnavailable && adapterIdentity.command_evidence.support === "supported" && contract && processResult) {
1437
+ try {
1438
+ manifest = buildCodexCommandEvidence({ identity, stream: processResult.stdout ?? "", contract });
1439
+ } catch (error) {
1440
+ const shellUnavailable = SHELL_CAPABILITY_UNAVAILABLE_CODES.has(error?.code);
1441
+ captureError = shellUnavailable ? null : error;
1442
+ manifest = buildUnavailableCommandEvidence({ identity, support: "supported", probe: shellUnavailable ? "shell_capability_unavailable" : "capture_invalid", reason: shellUnavailable ? `shell_capability_unavailable:${error.code}` : `capture_invalid:${error?.code ?? "unclassified"}`, stream: processResult.stdout ?? "" });
1443
+ }
1444
+ } else {
1445
+ const support = adapterIdentity.command_evidence.support;
1446
+ const probe = forceUnavailable?.probe ?? (adapterIdentity.availability === "unavailable" ? "runtime_unavailable" : contract ? "adapter_event_contract_not_implemented" : "command_contract_unavailable");
1447
+ const reason = forceUnavailable?.reason ?? adapterIdentity.command_evidence.downgrade_reason ?? probe;
1448
+ manifest = buildUnavailableCommandEvidence({ identity, support, probe, reason, stream: processResult?.stdout ?? "" });
1449
+ }
1450
+ validateCommandEvidenceManifest(manifest, { root, contract, expectedContractDigest: identity.verification_command_contract_digest });
1451
+ if (existsSync(path)) {
1452
+ const existing = readStableCommandEvidence(path, `${entry.case_id} existing command evidence`);
1453
+ if (stableCanonicalJson(existing.manifest) !== stableCanonicalJson(manifest)) throw new Error(`${entry.case_id} command evidence already exists with different content`);
1454
+ } else {
1455
+ writeJsonAtomic(path, manifest, { stagingOwner: claim.claim_id, faultName: "after_command_evidence_staged" });
1456
+ }
1457
+ fault("after_command_evidence_published");
1458
+ const published = readStableCommandEvidence(path, `${entry.case_id} published command evidence`);
1459
+ const verifiedPublishedManifest = validateCommandEvidenceManifest(published.manifest, { root, contract, expectedContractDigest: identity.verification_command_contract_digest });
1460
+ const publishedAfter = readStableCommandEvidence(path, `${entry.case_id} published command evidence`);
1461
+ assertStableFileEvidence(published.file, publishedAfter.file, `${entry.case_id} published command evidence`);
1462
+ return {
1463
+ manifest: verifiedPublishedManifest,
1464
+ captureError,
1465
+ reference: commandEvidenceReference(published.file, verifiedPublishedManifest),
1466
+ };
1467
+ }
1468
+
1469
+ function resultRecord({ entry, attempt, claim, requestPath, commandEvidence, status, processResult = null, finalOutput = null, failureKind = null, recoveryReason = null, terminalWorkspaceAuthority = null, successorUsage = false }) {
1470
+ const stdout = streamEvidence(processResult?.stdout ?? "");
1471
+ const stderr = streamEvidence(processResult?.stderr ?? "");
1472
+ return {
1473
+ schema_version: successorUsage ? "1.3.0" : "1.2.0",
1474
+ kind: "result",
1475
+ run_instance_id: claim.run_instance_id,
1476
+ case_id: entry.case_id,
1477
+ attempt,
1478
+ adapter: entry.adapter_track,
1479
+ condition: entry.condition,
1480
+ runtime_identity_digest: claim.runtime_identity_digest,
1481
+ effective_command_digest: claim.effective_command_digest,
1482
+ request_sha256: prefixedFileDigest(requestPath),
1483
+ command_evidence: commandEvidence,
1484
+ ...terminalWorkspaceResultFields(terminalWorkspaceAuthority),
1485
+ status,
1486
+ exit_code: processResult?.status ?? null,
1487
+ duration_ms: processResult?.duration_ms ?? null,
1488
+ failure_kind: failureKind,
1489
+ recovery_reason: recoveryReason,
1490
+ final_output: finalOutput,
1491
+ stdout,
1492
+ stderr,
1493
+ event_counts: { json_lines: jsonLineCount(processResult?.stdout ?? "") },
1494
+ ...(successorUsage ? { successor_usage: captureSuccessorUsage(processResult) } : {}),
1495
+ };
1496
+ }
1497
+
1498
+ function commitRecord({ claim, result, requestPath, commandEvidenceReference, resultPath }) {
1499
+ return {
1500
+ schema_version: "1.2.0",
1501
+ kind: "terminal_commit",
1502
+ run_instance_id: claim.run_instance_id,
1503
+ claim_id: claim.claim_id,
1504
+ claim_lease_expires_at: claim.lease_expires_at,
1505
+ case_id: claim.case_id,
1506
+ attempt: claim.attempt,
1507
+ adapter: claim.adapter,
1508
+ condition: claim.condition,
1509
+ status: result.status,
1510
+ runtime_identity_digest: claim.runtime_identity_digest,
1511
+ effective_command_digest: claim.effective_command_digest,
1512
+ request_sha256: prefixedFileDigest(requestPath),
1513
+ command_evidence_sha256: commandEvidenceReference.digest,
1514
+ result_sha256: prefixedFileDigest(resultPath),
1515
+ terminal_workspace_authority_path: result.terminal_workspace_authority_path,
1516
+ terminal_workspace_authority_sha256: result.terminal_workspace_authority_sha256,
1517
+ terminal_workspace_authority_bytes: result.terminal_workspace_authority_bytes,
1518
+ terminal_workspace_authority_digest: result.terminal_workspace_authority_digest,
1519
+ terminal_workspace_tree_digest: result.terminal_workspace_tree_digest,
1520
+ };
1521
+ }
1522
+
1523
+ function completeCase({ root, runDir, entry, state, claim, attempt, attemptRoot, result, finalSource = null }) {
1524
+ const requestPath = resolve(attemptRoot, "request.json");
1525
+ assertNoSymlinkSegments(requestPath, `${entry.case_id} attempt request`);
1526
+ if (!existsSync(requestPath)) throw new Error("terminal attempt request is missing");
1527
+ const commandEvidencePath = resolve(attemptRoot, COMMAND_EVIDENCE_PATH);
1528
+ assertNoSymlinkSegments(commandEvidencePath, `${entry.case_id} command evidence`);
1529
+ const stableCommandEvidence = readStableCommandEvidence(commandEvidencePath, `${entry.case_id} terminal command evidence`);
1530
+ const observedCommandEvidenceReference = commandEvidenceReference(stableCommandEvidence.file, stableCommandEvidence.manifest);
1531
+ if (!sameCommandEvidenceReference(result.command_evidence, observedCommandEvidenceReference)) throw new Error("terminal result command evidence reference mismatch");
1532
+ const terminalWorkspaceReference = terminalWorkspaceReferenceFromResult(result);
1533
+ if (terminalWorkspaceReference) {
1534
+ const authorityPath = terminalWorkspaceAuthorityPath(attemptRoot);
1535
+ readVerifiedTerminalWorkspaceAuthority({ root, authorityPath, reference: terminalWorkspaceReference, expected: terminalWorkspaceIdentity(entry, claim) });
1536
+ } else if (result.status === "completed") {
1537
+ throw new Error("completed terminal result is missing terminal workspace authority");
1538
+ } else if (existsSync(terminalWorkspaceAuthorityPath(attemptRoot))) {
1539
+ throw new Error("terminal result omits a published terminal workspace authority");
1540
+ }
1541
+ validate(root, result, ATTEMPT_RESULT_SCHEMA_PATH, `${entry.case_id} attempt result`);
1542
+ const resultPath = resolve(attemptRoot, "result.json");
1543
+ assertNoSymlinkSegments(resultPath, `${entry.case_id} attempt result`);
1544
+ if (result.status === "completed") {
1545
+ const pendingResultPath = resolve(attemptRoot, RESULT_STAGING_FILE);
1546
+ assertNoSymlinkSegments(pendingResultPath, `${entry.case_id} pending attempt result`);
1547
+ writeJsonIdempotent(pendingResultPath, result, `${entry.case_id} pending attempt result`, { stagingOwner: claim.claim_id, faultName: "after_pending_result_staged" });
1548
+ const source = finalSource ?? resolve(ephemeralWorkspacePath(claim), "agent-final.json");
1549
+ publishFinal(root, attemptRoot, source, result.final_output, claim.claim_id);
1550
+ fault("after_final_published");
1551
+ if (existsSync(resultPath)) {
1552
+ writeJsonIdempotent(resultPath, result, `${entry.case_id} attempt result`, { stagingOwner: claim.claim_id });
1553
+ rmSync(pendingResultPath, { force: true });
1554
+ } else {
1555
+ renameSync(pendingResultPath, resultPath);
1556
+ }
1557
+ } else {
1558
+ writeJsonIdempotent(resultPath, result, `${entry.case_id} attempt result`, { stagingOwner: claim.claim_id });
1559
+ }
1560
+ fault("after_result_published");
1561
+ const commandEvidenceAfter = readStableCommandEvidence(commandEvidencePath, `${entry.case_id} terminal command evidence`);
1562
+ assertStableFileEvidence(stableCommandEvidence.file, commandEvidenceAfter.file, `${entry.case_id} terminal command evidence`);
1563
+ const commit = commitRecord({ claim, result, requestPath, commandEvidenceReference: observedCommandEvidenceReference, resultPath });
1564
+ validate(root, commit, ATTEMPT_COMMIT_SCHEMA_PATH, `${entry.case_id} terminal commit`);
1565
+ const commitPath = resolve(attemptRoot, "commit.json");
1566
+ assertNoSymlinkSegments(commitPath, `${entry.case_id} terminal commit`);
1567
+ writeJsonIdempotent(commitPath, commit, `${entry.case_id} terminal commit`, { stagingOwner: claim.claim_id, faultName: "after_commit_staged" });
1568
+ const terminalState = {
1569
+ ...state,
1570
+ status: result.status,
1571
+ attempt_count: Math.max(state.attempt_count, Number(attempt)),
1572
+ active_claim_id: null,
1573
+ terminal_attempt: attempt,
1574
+ terminal_commit_digest: prefixedFileDigest(commitPath),
1575
+ selection_digest: claim.selection?.digest ?? null,
1576
+ };
1577
+ validate(root, terminalState, CASE_STATE_SCHEMA_PATH, `${entry.case_id} terminal state`);
1578
+ writeCaseState(runDir, entry, terminalState);
1579
+ fault("after_state_published");
1580
+ // Retain this attempt's claim until its private workspace is gone. Terminal
1581
+ // publication alone must not be treated as successful cleanup by callers.
1582
+ const identity = readJson(runIdentityPath(runDir));
1583
+ validate(root, identity, RUN_IDENTITY_SCHEMA_PATH, "terminal cleanup run identity");
1584
+ try { removeEphemeralWorkspace(claim, identity); }
1585
+ catch (error) { throw new TerminalCleanupError("terminal evidence retained; workspace cleanup is unresolved", { cause: error }); }
1586
+ fault("after_workspace_cleanup");
1587
+ releaseClaim(root, runDir, entry.case_id, claim.claim_id);
1588
+ return terminalState;
1589
+ }
1590
+
1591
+ function assertCanonicalEqual(actual, expected, label) {
1592
+ if (stableCanonicalJson(actual) !== stableCanonicalJson(expected)) throw new Error(`${label} mismatch`);
1593
+ }
1594
+
1595
+ function recursivelyFreeze(value) {
1596
+ if (value && typeof value === "object" && !Object.isFrozen(value)) {
1597
+ for (const child of Object.values(value)) recursivelyFreeze(child);
1598
+ Object.freeze(value);
1599
+ }
1600
+ return value;
1601
+ }
1602
+
1603
+ function validateTerminalAttemptEvidence({ root, runDir, runIdentity, entry, attempt, expectedInput, expectedSelection, claim = null, materializedRecord = null }) {
1604
+ const runInstanceId = runIdentity.run_instance_id;
1605
+ const attemptRoot = attemptRootPath(runDir, entry.case_id, attempt);
1606
+ const requestPath = resolve(attemptRoot, "request.json");
1607
+ const commandEvidencePath = resolve(attemptRoot, COMMAND_EVIDENCE_PATH);
1608
+ const resultPath = resolve(attemptRoot, "result.json");
1609
+ const commitPath = resolve(attemptRoot, "commit.json");
1610
+ for (const [path, label] of [[requestPath, "request"], [commandEvidencePath, "command evidence"], [resultPath, "result"], [commitPath, "terminal commit"]]) {
1611
+ assertNoSymlinkSegments(path, `${entry.case_id} ${label}`);
1612
+ if (!existsSync(path) || !lstatSync(path).isFile()) throw new Error(`${entry.case_id} ${label} is missing`);
1613
+ }
1614
+ const request = readJson(requestPath);
1615
+ const stableCommandEvidence = readStableCommandEvidence(commandEvidencePath, `${entry.case_id} command evidence`);
1616
+ const commandEvidence = stableCommandEvidence.manifest;
1617
+ const result = readJson(resultPath);
1618
+ const commit = readJson(commitPath);
1619
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${entry.case_id} request`);
1620
+ const contract = entry.verification_command_contract === undefined ? null : loadVerificationCommandContract(root, entry);
1621
+ const verifiedCommandEvidence = validateCommandEvidenceManifest(commandEvidence, { root, contract, expectedContractDigest: request.input_identity.verification_command_contract_digest });
1622
+ validate(root, result, ATTEMPT_RESULT_SCHEMA_PATH, `${entry.case_id} result`);
1623
+ if (result.successor_usage !== undefined) {
1624
+ validateSuccessorUsage(result.successor_usage, { stdout: result.stdout });
1625
+ if (result.adapter !== "codex" || result.condition !== "full_ask") throw new Error("successor usage requires a Codex full_ask result");
1626
+ }
1627
+ validate(root, commit, ATTEMPT_COMMIT_SCHEMA_PATH, `${entry.case_id} terminal commit`);
1628
+ const adapterIdentity = readAdapterIdentity(root, runDir, entry.adapter_track);
1629
+ const runtimeIdentityDigest = canonicalDigest(adapterIdentity);
1630
+ if (request.run_instance_id !== runInstanceId || request.case_id !== entry.case_id || request.attempt !== attempt || request.adapter !== entry.adapter_track || request.condition !== entry.condition) throw new Error(`${entry.case_id} request identity mismatch`);
1631
+ if (request.claim.id !== commit.claim_id || request.claim.lease_expires_at !== commit.claim_lease_expires_at) throw new Error(`${entry.case_id} request claim evidence mismatch`);
1632
+ if ((entry.condition === "adaptive_ask") !== (request.selection !== null)) throw new Error(`${entry.case_id} request selection shape mismatch`);
1633
+ if (expectedInput !== undefined) assertCanonicalEqual(request.input_identity, expectedInput, `${entry.case_id} request input identity`);
1634
+ if (expectedSelection !== undefined) assertCanonicalEqual(request.selection, expectedSelection, `${entry.case_id} request selection`);
1635
+ if (request.agent.adapter !== entry.adapter_track || request.agent.runtime_identity_digest !== runtimeIdentityDigest || request.agent.effective_command_digest !== adapterIdentity.effective_command_digest || request.agent.environment_snapshot_digest !== adapterIdentity.environment_snapshot.digest) throw new Error(`${entry.case_id} request runtime identity mismatch`);
1636
+ if (result.run_instance_id !== runInstanceId || result.case_id !== entry.case_id || result.attempt !== attempt || result.adapter !== entry.adapter_track || result.condition !== entry.condition) throw new Error(`${entry.case_id} result identity mismatch`);
1637
+ if (result.status === "completed") {
1638
+ if (result.exit_code !== 0 || result.failure_kind !== null || result.recovery_reason !== null || result.final_output === null) throw new Error(`${entry.case_id} completed result semantics mismatch`);
1639
+ } else if (result.failure_kind === null || result.final_output !== null || (result.failure_kind === "stale_claim_recovered") !== (result.recovery_reason !== null)) throw new Error(`${entry.case_id} terminal failure result semantics mismatch`);
1640
+ if (commandEvidence.capture.contract_probe_evidence === "shell_capability_unavailable" && result.status === "invalid") throw new Error(`${entry.case_id} unsupported shell capability must not invalidate the outer attempt`);
1641
+ if (result.runtime_identity_digest !== runtimeIdentityDigest || result.effective_command_digest !== adapterIdentity.effective_command_digest || result.request_sha256 !== prefixedFileDigest(requestPath)) throw new Error(`${entry.case_id} result evidence mismatch`);
1642
+ if (commandEvidence.run_instance_id !== runInstanceId || commandEvidence.case_id !== entry.case_id || commandEvidence.attempt !== attempt || commandEvidence.adapter !== entry.adapter_track || commandEvidence.condition !== entry.condition || commandEvidence.fixture_id !== request.input_identity.fixture_id || commandEvidence.repetition !== request.input_identity.repetition || commandEvidence.fixture_input_digest !== request.input_identity.fixture_input_digest || commandEvidence.runtime_identity_digest !== runtimeIdentityDigest || commandEvidence.effective_command_digest !== adapterIdentity.effective_command_digest) throw new Error(`${entry.case_id} command evidence identity mismatch`);
1643
+ const observedCommandEvidenceReference = commandEvidenceReference(stableCommandEvidence.file, commandEvidence);
1644
+ if (!sameCommandEvidenceReference(result.command_evidence, observedCommandEvidenceReference)) throw new Error(`${entry.case_id} result command evidence binding mismatch`);
1645
+ if (commit.run_instance_id !== runInstanceId || commit.case_id !== entry.case_id || commit.attempt !== attempt || commit.adapter !== entry.adapter_track || commit.condition !== entry.condition || commit.status !== result.status) throw new Error(`${entry.case_id} terminal commit identity mismatch`);
1646
+ if (commit.runtime_identity_digest !== runtimeIdentityDigest || commit.effective_command_digest !== adapterIdentity.effective_command_digest || commit.request_sha256 !== prefixedFileDigest(requestPath) || commit.command_evidence_sha256 !== stableCommandEvidence.file.rawByteDigest || commit.result_sha256 !== prefixedFileDigest(resultPath)) throw new Error(`${entry.case_id} terminal commit evidence mismatch`);
1647
+ const terminalWorkspaceReference = terminalWorkspaceReferenceFromResult(result);
1648
+ let terminalWorkspaceAuthority = null;
1649
+ if (terminalWorkspaceReference) {
1650
+ const authorityPath = terminalWorkspaceAuthorityPath(attemptRoot);
1651
+ const expectedAuthorityIdentity = {
1652
+ run_instance_id: runInstanceId,
1653
+ case_id: entry.case_id,
1654
+ attempt,
1655
+ adapter: entry.adapter_track,
1656
+ condition: entry.condition,
1657
+ fixture_id: request.input_identity.fixture_id,
1658
+ fixture_input_digest: request.input_identity.fixture_input_digest,
1659
+ materialization_manifest_digest: request.input_identity.materialization_manifest_digest,
1660
+ };
1661
+ terminalWorkspaceAuthority = readVerifiedTerminalWorkspaceAuthority({
1662
+ root,
1663
+ authorityPath,
1664
+ reference: terminalWorkspaceReference,
1665
+ expected: expectedAuthorityIdentity,
1666
+ expectedBaseInventory: materializedRecord ? expectedBaseRegularInventory(materializedRecord, request.projection) : null,
1667
+ expectedManagedAssetPaths: materializedRecord ? managedAssetPaths(materializedRecord, request.projection) : null,
1668
+ });
1669
+ } else if (result.status === "completed") {
1670
+ throw new Error(`${entry.case_id} completed attempt lacks terminal workspace authority`);
1671
+ } else if (existsSync(terminalWorkspaceAuthorityPath(attemptRoot))) {
1672
+ throw new Error(`${entry.case_id} result omits terminal workspace authority`);
1673
+ }
1674
+ for (const field of ["terminal_workspace_authority_path", "terminal_workspace_authority_sha256", "terminal_workspace_authority_bytes", "terminal_workspace_authority_digest", "terminal_workspace_tree_digest"]) {
1675
+ if (commit[field] !== result[field]) throw new Error(`${entry.case_id} terminal commit workspace authority mismatch`);
1676
+ }
1677
+ if (claim) {
1678
+ if (claim.run_instance_id !== runInstanceId || claim.case_id !== entry.case_id || claim.adapter !== entry.adapter_track || claim.condition !== entry.condition || claim.runtime_identity_digest !== runtimeIdentityDigest || claim.effective_command_digest !== adapterIdentity.effective_command_digest || claim.environment_snapshot_digest !== adapterIdentity.environment_snapshot.digest) throw new Error(`${entry.case_id} recovery claim identity mismatch`);
1679
+ if (claim.input_identity.plan_id !== runIdentity.plan.id || claim.input_identity.plan_digest !== runIdentity.plan.digest || claim.input_identity.materialization_manifest_digest !== runIdentity.materialization.manifest_digest) throw new Error(`${entry.case_id} recovery claim run input mismatch`);
1680
+ assertCanonicalEqual(request.input_identity, claim.input_identity, `${entry.case_id} recovery claim input identity`);
1681
+ assertCanonicalEqual(request.selection, claim.selection, `${entry.case_id} recovery claim selection`);
1682
+ if (claim.attempt === attempt) assertCanonicalEqual(request.claim, requestClaimRecord(claim), `${entry.case_id} recovery request claim`);
1683
+ }
1684
+ const expectedInventory = ["command-evidence.json", "commit.json", "request.json", "result.json"];
1685
+ if (result.status === "completed") expectedInventory.push("final.json");
1686
+ if (terminalWorkspaceReference) expectedInventory.push(TERMINAL_WORKSPACE_AUTHORITY_PATH);
1687
+ expectedInventory.sort();
1688
+ const inventory = readdirSync(attemptRoot).sort();
1689
+ assertCanonicalEqual(inventory, expectedInventory, `${entry.case_id} terminal attempt inventory`);
1690
+ if (result.status === "completed") {
1691
+ const finalPath = resolve(attemptRoot, result.final_output.path);
1692
+ assertInside(attemptRoot, finalPath, `${entry.case_id} final output`);
1693
+ assertNoSymlinkSegments(finalPath, `${entry.case_id} final output`);
1694
+ const size = statSync(finalPath).size;
1695
+ if (size > MAX_FINAL_OUTPUT_BYTES || size !== result.final_output.bytes || fileDigest(finalPath) !== result.final_output.sha256) throw new Error(`${entry.case_id} final output digest mismatch`);
1696
+ validate(root, readJson(finalPath), OUTPUT_SCHEMA_PATH, `${entry.case_id} completed output`);
1697
+ }
1698
+ const commandEvidenceAfter = readStableCommandEvidence(commandEvidencePath, `${entry.case_id} command evidence`);
1699
+ assertStableFileEvidence(stableCommandEvidence.file, commandEvidenceAfter.file, `${entry.case_id} command evidence`);
1700
+ return {
1701
+ request,
1702
+ result,
1703
+ commit,
1704
+ verificationCommandContract: contract ? recursivelyFreeze(structuredClone(contract)) : null,
1705
+ commandEvidence: recursivelyFreeze(structuredClone(verifiedCommandEvidence)),
1706
+ terminalWorkspaceAuthority: terminalWorkspaceAuthority ? recursivelyFreeze(structuredClone(terminalWorkspaceAuthority.authority)) : null,
1707
+ evidence: {
1708
+ request_digest: prefixedFileDigest(requestPath),
1709
+ result_digest: prefixedFileDigest(resultPath),
1710
+ commit_digest: prefixedFileDigest(commitPath),
1711
+ command_evidence_digest: stableCommandEvidence.file.rawByteDigest,
1712
+ final_output_digest: result.final_output ? `sha256:${result.final_output.sha256}` : null,
1713
+ final_output_bytes: result.final_output?.bytes ?? null,
1714
+ terminal_workspace_authority_digest: result.terminal_workspace_authority_digest,
1715
+ terminal_workspace_tree_digest: result.terminal_workspace_tree_digest,
1716
+ terminal_workspace_authority_bytes: result.terminal_workspace_authority_bytes,
1717
+ terminal_workspace_authority_availability: result.terminal_workspace_authority_availability,
1718
+ terminal_workspace_authority_support: result.terminal_workspace_authority_support,
1719
+ },
1720
+ };
1721
+ }
1722
+
1723
+ function validateTerminalAttempt({ root, context, entry, attempt }) {
1724
+ const verified = validateTerminalAttemptEvidence({
1725
+ root,
1726
+ runDir: context.runDir,
1727
+ runIdentity: context.identity,
1728
+ entry,
1729
+ attempt,
1730
+ expectedInput: inputIdentityFor(context, entry),
1731
+ expectedSelection: selectionIdentityFor(context, entry),
1732
+ materializedRecord: context.materialized.casesById.get(entry.case_id),
1733
+ });
1734
+ // Also detect the legacy release-before-cleanup gap. Recovery deliberately
1735
+ // uses the lower-level evidence verifier so it can reconcile the owned root.
1736
+ assertTerminalWorkspaceCleanup(verified.request);
1737
+ return verified;
1738
+ }
1739
+
1740
+ function validateTerminalCase({ root, context, entry, state }) {
1741
+ if (!TERMINAL_STATUSES.has(state.status) || !state.terminal_attempt) throw new Error(`${entry.case_id} terminal state is invalid`);
1742
+ if (Number(state.terminal_attempt) < 1 || Number(state.terminal_attempt) > state.attempt_count) throw new Error(`${entry.case_id} terminal attempt is outside the attempt count`);
1743
+ if (state.terminal_attempt !== String(state.attempt_count).padStart(4, "0")) throw new Error(`${entry.case_id} terminal state does not reference the latest attempt`);
1744
+ for (let number = 1; number <= state.attempt_count; number += 1) {
1745
+ const attempt = String(number).padStart(4, "0");
1746
+ const artifacts = validateTerminalAttempt({ root, context, entry, attempt });
1747
+ if (attempt === state.terminal_attempt && (artifacts.result.status !== state.status || artifacts.evidence.commit_digest !== state.terminal_commit_digest)) throw new Error(`${entry.case_id} terminal state binding mismatch`);
1748
+ }
1749
+ const expectedSelection = selectionIdentityFor(context, entry)?.digest ?? null;
1750
+ if (state.selection_digest !== expectedSelection) throw new Error(`${entry.case_id} state selection digest mismatch`);
1751
+ return true;
1752
+ }
1753
+
1754
+ function assertDirectoryInventory(directory, expected, label) {
1755
+ assertNoSymlinkSegments(directory, label);
1756
+ if (!existsSync(directory) || !lstatSync(directory).isDirectory() || lstatSync(directory).isSymbolicLink()) throw new Error(`${label} must be a real directory`);
1757
+ const actual = readdirSync(directory).sort();
1758
+ assertCanonicalEqual(actual, [...expected].sort(), `${label} inventory`);
1759
+ }
1760
+
1761
+ function inspectExecutionCase({ root, context, entry }) {
1762
+ const caseRoot = caseRootPath(context.runDir, entry.case_id);
1763
+ const attemptsRoot = resolve(caseRoot, "attempts");
1764
+ const state = readCaseState(root, context.runDir, entry);
1765
+ const claim = readClaim(root, context.runDir, entry.case_id);
1766
+ const expectedCaseInventory = claim ? ["attempts", "claim", "state.json"] : ["attempts", "state.json"];
1767
+ assertDirectoryInventory(caseRoot, expectedCaseInventory, `${entry.case_id} case root`);
1768
+
1769
+ assertNoSymlinkSegments(attemptsRoot, `${entry.case_id} attempts root`);
1770
+ if (!existsSync(attemptsRoot) || !lstatSync(attemptsRoot).isDirectory() || lstatSync(attemptsRoot).isSymbolicLink()) throw new Error(`${entry.case_id} attempts root must be a real directory`);
1771
+
1772
+ const attemptNames = readdirSync(attemptsRoot).sort();
1773
+ if (attemptNames.some((name) => !ATTEMPT_PATTERN.test(name))) throw new Error(`${entry.case_id} attempts contain unexpected or incomplete staging evidence`);
1774
+ for (const name of attemptNames) {
1775
+ const path = resolve(attemptsRoot, name);
1776
+ assertNoSymlinkSegments(path, `${entry.case_id} attempt ${name}`);
1777
+ if (!lstatSync(path).isDirectory() || lstatSync(path).isSymbolicLink()) throw new Error(`${entry.case_id} attempt ${name} must be a real directory`);
1778
+ }
1779
+
1780
+ if (claim) {
1781
+ validateClaimAgainstContext({ root, context, entry, claim });
1782
+ if (state.status !== "active" || state.active_claim_id !== claim.claim_id || Number(claim.attempt) !== state.attempt_count) throw new Error(`${entry.case_id} claim does not match active state`);
1783
+ const completedAttemptNames = Array.from({ length: Math.max(0, state.attempt_count - 1) }, (_, index) => String(index + 1).padStart(4, "0"));
1784
+ const allowedAttemptInventories = [completedAttemptNames, [...completedAttemptNames, claim.attempt]];
1785
+ if (!allowedAttemptInventories.some((expected) => stableCanonicalJson(expected) === stableCanonicalJson(attemptNames))) throw new Error(`${entry.case_id} active attempt inventory is not contiguous`);
1786
+ const attempts = completedAttemptNames.map((attempt) => ({ attempt, ...validateTerminalAttempt({ root, context, entry, attempt }) }));
1787
+ if (attemptNames.includes(claim.attempt)) {
1788
+ const activeInventory = readdirSync(attemptRootPath(context.runDir, entry.case_id, claim.attempt)).sort();
1789
+ if (![[], ["request.json"]].some((expected) => stableCanonicalJson(expected) === stableCanonicalJson(activeInventory))) throw new Error(`${entry.case_id} active attempt contains incomplete atomic staging evidence`);
1790
+ }
1791
+ return { entry, state, attempts, stale_claim: claimIsExpired(claim) };
1792
+ }
1793
+
1794
+ if (TERMINAL_STATUSES.has(state.status)) {
1795
+ validateTerminalCase({ root, context, entry, state });
1796
+ const expectedAttempts = Array.from({ length: state.attempt_count }, (_, index) => String(index + 1).padStart(4, "0"));
1797
+ assertCanonicalEqual(attemptNames, expectedAttempts, `${entry.case_id} attempts`);
1798
+ const attempts = expectedAttempts.map((attempt) => ({ attempt, ...validateTerminalAttempt({ root, context, entry, attempt }) }));
1799
+ return { entry, state, attempts, stale_claim: false };
1800
+ }
1801
+
1802
+ if (state.status === "active") throw new Error(`${entry.case_id} active state is missing its claim`);
1803
+ if (state.status !== "pending" || state.attempt_count !== 0) throw new Error(`${entry.case_id} non-terminal state is invalid`);
1804
+ assertCanonicalEqual(attemptNames, [], `${entry.case_id} pending attempts`);
1805
+ return { entry, state, attempts: [], stale_claim: false };
1806
+ }
1807
+
1808
+ function claimPublishedBeforeState(state, claim) {
1809
+ if (!["pending", "failed", "interrupted"].includes(state.status)) return false;
1810
+ return Number(claim.attempt) === state.attempt_count + 1;
1811
+ }
1812
+
1813
+ function preflightCaseClaim({ root, context, entry, state }) {
1814
+ const claim = readClaim(root, context.runDir, entry.case_id);
1815
+ if (!claim) {
1816
+ if (state.status === "active") throw new Error(`${entry.case_id} active state is missing its bound claim; explicit recovery is required`);
1817
+ return null;
1818
+ }
1819
+ validateClaimAgainstContext({ root, context, entry, claim });
1820
+ const claimAttempt = Number(claim.attempt);
1821
+ const publishedBeforeState = claimPublishedBeforeState(state, claim);
1822
+ const boundActive = state.status === "active"
1823
+ && state.active_claim_id === claim.claim_id
1824
+ && state.attempt_count === claimAttempt;
1825
+ if (!publishedBeforeState && !boundActive) throw new Error(`${entry.case_id} claim does not match case state`);
1826
+ if (claimIsExpired(claim)) throw new Error(`${entry.case_id} has an expired claim; run recover-case with claim ID ${claim.claim_id}`);
1827
+ return claim;
1828
+ }
1829
+
1830
+ function verifyFirstAttemptClaim({ root, context, entry, claim }) {
1831
+ if (!context.firstAttemptOnly) return;
1832
+ // Re-read while holding the exclusive existing claim. A competing worker
1833
+ // may have completed between the earlier state read and claim publication.
1834
+ try {
1835
+ const state = readCaseState(root, context.runDir, entry);
1836
+ if (claim.attempt !== '0001' || state.status !== 'pending' || state.attempt_count !== 0
1837
+ || readdirSync(resolve(caseRootPath(context.runDir, entry.case_id), 'attempts')).length !== 0) {
1838
+ throw new Error('first-attempt execution refuses attempted or uncertain cases');
1839
+ }
1840
+ } catch (error) {
1841
+ releaseClaim(root, context.runDir, entry.case_id, claim.claim_id);
1842
+ removeEphemeralWorkspace(claim, context.identity);
1843
+ throw error;
1844
+ }
1845
+ }
1846
+
1847
+ function markUnavailable({ root, context, entry, state, runtime, adapter }) {
1848
+ if (context.firstAttemptOnly && (state.status !== 'pending' || state.attempt_count !== 0)) throw new Error('first-attempt execution refuses attempted or uncertain cases');
1849
+ if (["completed", "unavailable"].includes(state.status)) return;
1850
+ if (preflightCaseClaim({ root, context, entry, state })) return "active";
1851
+ const attempt = nextAttempt(context.runDir, entry);
1852
+ const claim = acquireClaim({ root, context, entry, attempt, runtime, adapter });
1853
+ if (!claim) return "active";
1854
+ verifyFirstAttemptClaim({ root, context, entry, claim });
1855
+ const activeState = { ...state, status: "active", attempt_count: Number(attempt), active_claim_id: claim.claim_id, terminal_attempt: null, terminal_commit_digest: null };
1856
+ writeCaseState(context.runDir, entry, activeState);
1857
+ const attemptRoot = attemptRootPath(context.runDir, entry.case_id, attempt);
1858
+ mkdirSync(attemptRoot, { recursive: false });
1859
+ const request = requestRecord({ entry, attempt, claim, projection: { status: "runtime_unavailable" } });
1860
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${entry.case_id} unavailable request`);
1861
+ const requestPath = resolve(attemptRoot, "request.json");
1862
+ writeJsonAtomic(requestPath, request, { stagingOwner: claim.claim_id, faultName: "after_request_staged" });
1863
+ const contract = loadVerificationCommandContract(root, entry);
1864
+ const sealed = sealCommandEvidence({ root, attemptRoot, entry, claim, adapterIdentity: adapter.identity, contract, forceUnavailable: { probe: "runtime_unavailable", reason: "runtime_unavailable" } });
1865
+ completeCase({ root, runDir: context.runDir, entry, state: activeState, claim, attempt, attemptRoot, result: resultRecord({ entry, attempt, claim, requestPath, commandEvidence: sealed.reference, status: "unavailable", failureKind: "runtime_unavailable", successorUsage: context.successorPromptInput !== null && context.successorPromptInput !== undefined }) });
1866
+ removeEphemeralWorkspace(claim, context.identity);
1867
+ return "unavailable";
1868
+ }
1869
+
1870
+ function executeCase({ root, config, context, entry, runtime, verifiedExecutable, adapter, environmentSnapshot }) {
1871
+ const state = readCaseState(root, context.runDir, entry);
1872
+ if (context.firstAttemptOnly && (state.status !== 'pending' || state.attempt_count !== 0)) throw new Error('first-attempt execution refuses attempted or uncertain cases');
1873
+ if (context.successorPromptInput && state.status !== "pending") throw new Error("successor cases cannot be silently retried or resumed after an uncertain attempt");
1874
+ if (TERMINAL_STATUSES.has(state.status)) validateTerminalCase({ root, context, entry, state });
1875
+ if (preflightCaseClaim({ root, context, entry, state })) return "active";
1876
+ if (TERMINAL_STATUSES.has(state.status) && (["completed", "unavailable", "invalid"].includes(state.status) || (state.status === "failed" && !context.retryFailed))) return state.status;
1877
+ const attempt = nextAttempt(context.runDir, entry);
1878
+ const claim = acquireClaim({ root, context, entry, attempt, runtime, adapter });
1879
+ if (!claim) return "active";
1880
+ verifyFirstAttemptClaim({ root, context, entry, claim });
1881
+ const activeState = { ...state, status: "active", attempt_count: Number(attempt), active_claim_id: claim.claim_id, terminal_attempt: null, terminal_commit_digest: null };
1882
+ writeCaseState(context.runDir, entry, activeState);
1883
+ const attemptRoot = attemptRootPath(context.runDir, entry.case_id, attempt);
1884
+ let processResult = null;
1885
+ let ephemeralRoot = null;
1886
+ let projection = { status: "attempt_setup_failed" };
1887
+ let successorStdin = null;
1888
+ let sealedCommandEvidence = null;
1889
+ let terminalWorkspaceBase = null;
1890
+ let terminalWorkspaceAuthority = null;
1891
+ let materializedRecord = null;
1892
+ let workspace = null;
1893
+ let terminalWorkspaceCaptureAllowed = true;
1894
+ const contract = loadVerificationCommandContract(root, entry);
1895
+ try {
1896
+ mkdirSync(attemptRoot, { recursive: false });
1897
+ let selection = context.selections.selections.get(entry.case_id) ?? null;
1898
+ if (entry.condition === "adaptive_ask") {
1899
+ const observed = verifyAdaptiveSelection({ root, config, planPath: context.planPath, materializedPath: context.materializedPath, stateDir: context.selectionState, caseId: entry.case_id, repositoryRevision: context.repositoryRevision, executionAdmissionEvidenceByFixture: context.executionAdmissionEvidenceByFixture });
1900
+ const expected = context.selections.selections.get(entry.case_id)?.selection_digest.value;
1901
+ if (observed.selection_digest.value !== expected) throw new Error("Adaptive selection changed before execution");
1902
+ }
1903
+ materializedRecord = context.materialized.casesById.get(entry.case_id);
1904
+ const copied = copyWorkspace({ materializedRoot: context.materializedPath, record: materializedRecord, claim, runIdentity: context.identity });
1905
+ ephemeralRoot = copied.ephemeralRoot;
1906
+ workspace = copied.workspace;
1907
+ fault("after_workspace_created");
1908
+ projection = selection ? applyAdaptiveSelection({ root, adapter: entry.adapter_track, selection, workspace }) : { status: "materialized" };
1909
+ if (context.successorPromptInput) {
1910
+ if (selection || entry.condition !== "full_ask") throw new Error("successor Prompt input requires a native full_ask case");
1911
+ const delivery = prepareSuccessorInputForAttempt(context.successorPromptInput, {
1912
+ entry, context, adapterIdentity: adapter.identity, workspace, materializedRecord,
1913
+ });
1914
+ successorStdin = delivery.stdin;
1915
+ projection = successorInputProjection(delivery.binding);
1916
+ }
1917
+ terminalWorkspaceBase = captureTerminalWorkspaceInventory(workspace);
1918
+ if (stableCanonicalJson(terminalWorkspaceBase.inventory.filter((item) => item.file_type === "regular_file")) !== stableCanonicalJson(expectedBaseRegularInventory(materializedRecord, projection))) throw new Error("terminal workspace base does not match verified materialization");
1919
+ if (selection) {
1920
+ const beforeSpawn = verifyAdaptiveSelection({ root, config, planPath: context.planPath, materializedPath: context.materializedPath, stateDir: context.selectionState, caseId: entry.case_id, repositoryRevision: context.repositoryRevision, executionAdmissionEvidenceByFixture: context.executionAdmissionEvidenceByFixture });
1921
+ if (beforeSpawn.selection_digest.value !== claim.selection.digest) throw new Error("Adaptive selection changed before process spawn");
1922
+ }
1923
+ const request = requestRecord({ entry, attempt, claim, projection });
1924
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${entry.case_id} attempt request`);
1925
+ const requestPath = resolve(attemptRoot, "request.json");
1926
+ writeJsonAtomic(requestPath, request, { stagingOwner: claim.claim_id, faultName: "after_request_staged" });
1927
+ fault("after_request_published");
1928
+ const temporaryOutput = resolve(ephemeralRoot, "agent-final.json");
1929
+ const started = process.hrtime.bigint();
1930
+ // Execution or residual-group inspection may throw before returning a result.
1931
+ // Keep catch-path capture disabled until the runner confirms no descendants.
1932
+ terminalWorkspaceCaptureAllowed = false;
1933
+ const raw = executeVerifiedAgent({ root, runtime, verifiedExecutable, workspace, outputTemporary: temporaryOutput, command: adapter.identity.effective_command, environmentSnapshot, successorStdin });
1934
+ processResult = { ...raw, duration_ms: Math.round(Number(process.hrtime.bigint() - started) / 1_000_000) };
1935
+ if (processResult.workspace_descendants_detected) {
1936
+ throw new Error("terminal workspace capture rejected residual agent descendants");
1937
+ }
1938
+ terminalWorkspaceCaptureAllowed = true;
1939
+ terminalWorkspaceAuthority = publishTerminalWorkspaceAuthority({ root, attemptRoot, entry, claim, baseSnapshot: terminalWorkspaceBase, workspace, record: materializedRecord, projection });
1940
+ sealedCommandEvidence = sealCommandEvidence({ root, attemptRoot, entry, claim, adapterIdentity: adapter.identity, processResult, contract, workspaceRoot: workspace });
1941
+ if (selection) {
1942
+ const afterSpawn = verifyAdaptiveSelection({ root, config, planPath: context.planPath, materializedPath: context.materializedPath, stateDir: context.selectionState, caseId: entry.case_id, repositoryRevision: context.repositoryRevision, executionAdmissionEvidenceByFixture: context.executionAdmissionEvidenceByFixture });
1943
+ if (afterSpawn.selection_digest.value !== claim.selection.digest) throw new Error("Adaptive selection changed during process execution");
1944
+ }
1945
+ if (sealedCommandEvidence.captureError) throw new Error(`command evidence invalid:${sealedCommandEvidence.captureError.code ?? "unclassified"}`);
1946
+ if (processResult.error?.code === "ETIMEDOUT") throw new Error("case timeout");
1947
+ if (processResult.status !== 0) throw new Error(`agent exited ${processResult.status}`);
1948
+ if (isNativeClaudeRuntime(runtime)) {
1949
+ const output = decodeNativeClaudeResult(processResult.stdout);
1950
+ validate(root, JSON.parse(output), OUTPUT_SCHEMA_PATH, 'native Claude structured output');
1951
+ writeFileSync(temporaryOutput, output, { flag: 'wx', mode: 0o600 });
1952
+ }
1953
+ const finalOutput = inspectFinal(root, temporaryOutput).record;
1954
+ completeCase({ root, runDir: context.runDir, entry, state: activeState, claim, attempt, attemptRoot, result: resultRecord({ entry, attempt, claim, requestPath, commandEvidence: sealedCommandEvidence.reference, status: "completed", processResult, finalOutput, terminalWorkspaceAuthority, successorUsage: context.successorPromptInput !== null }), finalSource: temporaryOutput });
1955
+ return "completed";
1956
+ } catch (error) {
1957
+ if (error instanceof RuntimeIntegrityError || error instanceof TerminalCleanupError) throw error;
1958
+ const message = error instanceof Error ? error.message : String(error);
1959
+ const invalid = /Adaptive selection|projection|materialized source|selection changed|command evidence invalid|terminal workspace/u.test(message);
1960
+ const temporaryOutput = ephemeralRoot ? resolve(ephemeralRoot, "agent-final.json") : null;
1961
+ if (temporaryOutput && existsSync(temporaryOutput)) rmSync(temporaryOutput, { force: true });
1962
+ const requestPath = resolve(attemptRoot, "request.json");
1963
+ if (existsSync(attemptRoot) && !existsSync(requestPath)) {
1964
+ const request = requestRecord({ entry, attempt, claim, projection });
1965
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${entry.case_id} failed attempt request`);
1966
+ writeJsonAtomic(requestPath, request, { stagingOwner: claim.claim_id, faultName: "after_request_staged" });
1967
+ }
1968
+ if (existsSync(attemptRoot) && !sealedCommandEvidence) sealedCommandEvidence = sealCommandEvidence({ root, attemptRoot, entry, claim, adapterIdentity: adapter.identity, processResult, contract, forceUnavailable: { probe: "capture_invalid", reason: "attempt_failed_before_command_capture" } });
1969
+ if (terminalWorkspaceCaptureAllowed && !terminalWorkspaceAuthority && workspace && terminalWorkspaceBase && materializedRecord) {
1970
+ try {
1971
+ terminalWorkspaceAuthority = publishTerminalWorkspaceAuthority({ root, attemptRoot, entry, claim, baseSnapshot: terminalWorkspaceBase, workspace, record: materializedRecord, projection });
1972
+ } catch {
1973
+ terminalWorkspaceAuthority = null;
1974
+ }
1975
+ }
1976
+ const result = resultRecord({
1977
+ entry,
1978
+ attempt,
1979
+ claim,
1980
+ requestPath,
1981
+ commandEvidence: sealedCommandEvidence?.reference,
1982
+ status: invalid ? "invalid" : "failed",
1983
+ processResult,
1984
+ successorUsage: context.successorPromptInput !== null,
1985
+ failureKind: /timeout/u.test(message) ? "timeout" : invalid ? "invalid_input_or_selection" : "agent_failure",
1986
+ terminalWorkspaceAuthority,
1987
+ });
1988
+ if (existsSync(attemptRoot)) completeCase({ root, runDir: context.runDir, entry, state: activeState, claim, attempt, attemptRoot, result });
1989
+ else releaseClaim(root, context.runDir, entry.case_id, claim.claim_id);
1990
+ return result.status;
1991
+ } finally {
1992
+ removeEphemeralWorkspace(claim, context.identity);
1993
+ }
1994
+ }
1995
+
1996
+ /** Prepare ordinary run custody only. Never resolves/probes an agent binary or starts an attempt. */
1997
+ export function preparePortfolioExecution({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture = null }) {
1998
+ if (!runDir) throw new Error("prepare-execution requires a run directory");
1999
+ let existingRun = null;
2000
+ try { existingRun = lstatSync(runDir); }
2001
+ catch (error) { if (error.code !== "ENOENT") throw error; }
2002
+ if (existingRun && (!existingRun.isDirectory() || readdirSync(runDir).length !== 0)) {
2003
+ throw new Error("prepare-execution refuses a nonempty existing run directory");
2004
+ }
2005
+ const context = loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture });
2006
+ return {
2007
+ run_instance_id: context.identity.run_instance_id,
2008
+ plan_id: context.plan.plan_id,
2009
+ plan_digest: context.identity.plan.digest,
2010
+ repository_revision: context.repositoryRevision,
2011
+ materialization_manifest_digest: context.materialized.manifestDigest,
2012
+ selection_state_digest: context.selections.stateDigest,
2013
+ case_count: context.plan.cases.length,
2014
+ model_calls: 0,
2015
+ case_attempts_created: 0,
2016
+ execution_authorized: false,
2017
+ };
2018
+ }
2019
+
2020
+ // Explicit no-model native preparation: version/help probes and local run state
2021
+ // only. This function never calls executeCase or executeAgent.
2022
+ export function prepareSuccessorPortfolioSource({ root, config, planPath, materializedPath, selectionState, runDir, runtimeConfigPath, agentBin, preparation, executionAdmissionEvidenceByFixture = null }) {
2023
+ const adapter = "codex";
2024
+ const runtimeConfig = readRuntimeConfig(root, runtimeConfigPath, adapter);
2025
+ if (runtimeConfig.value.availability !== "available") throw new Error("successor native preparation requires an available declared runtime");
2026
+ const environmentSnapshot = captureEnvironment(runtimeConfig.value);
2027
+ const verifiedExecutable = validateAgentExecutable(agentBin);
2028
+ const context = loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture });
2029
+ if (context.plan.cases.some((entry) => readCaseState(root, context.runDir, entry).status !== "pending")) throw new Error("successor native preparation rejects a previously started run");
2030
+ const runtimeIdentity = ensureAdapterIdentity({ root, runDir: context.runDir, plan: context.plan, adapter, runtimeConfig, verifiedExecutable, environmentSnapshot, successorRuntime: preparation.runtime });
2031
+ if (runtimeIdentity.identity.availability !== "available") throw new Error("successor runtime contract is unconfirmed; no cases were started");
2032
+ return {
2033
+ run_instance_id: context.identity.run_instance_id,
2034
+ plan_id: context.plan.plan_id, plan_digest: context.identity.plan.digest,
2035
+ repository_revision: context.repositoryRevision,
2036
+ runtime_identity_digest: runtimeIdentity.digest,
2037
+ materialization_manifest_digest: context.materialized.manifestDigest,
2038
+ effective_command_digest: runtimeIdentity.identity.effective_command_digest,
2039
+ environment_snapshot_digest: runtimeIdentity.identity.environment_snapshot.digest,
2040
+ cases: context.plan.cases.filter((entry) => entry.adapter_track === adapter && entry.condition === "full_ask").map((entry) => ({
2041
+ case_id: entry.case_id, fixture_id: entry.fixture_id, repetition: entry.repetition,
2042
+ fixture_input_digest: `sha256:${entry.input_manifest_sha256}`,
2043
+ })),
2044
+ model_calls: 0, case_attempts_created: 0, execution_authorized: false,
2045
+ };
2046
+ }
2047
+
2048
+ export function executePortfolio({ root, config, planPath, materializedPath, selectionState, runDir, adapter, runtimeConfigPath, agentBin, caseId = null, maxCases = null, retryFailed = false, firstAttemptOnly = false, successorPromptInput = null, executionAdmissionEvidenceByFixture = null }) {
2049
+ if (typeof firstAttemptOnly !== 'boolean' || (firstAttemptOnly && retryFailed)) throw new Error('invalid first-attempt execution policy');
2050
+ if (successorPromptInput !== null) assertSuccessorInputRun(successorPromptInput, { adapter, caseId, retryFailed, maxCases });
2051
+ if (!adapter || !["codex", "claude"].includes(adapter)) throw new Error("execute-portfolio requires --adapter codex or claude");
2052
+ if (maxCases !== null && (!Number.isInteger(maxCases) || maxCases < 1)) throw new Error("--max-cases must be a positive integer");
2053
+ const runtimeConfig = readRuntimeConfig(root, runtimeConfigPath, adapter);
2054
+ const environmentSnapshot = captureEnvironment(runtimeConfig.value);
2055
+ if (isNativeClaudeRuntime(runtimeConfig.value) && runtimeConfig.value.availability === 'available') assertNativeClaudeAuthentication(environmentSnapshot.values);
2056
+ const verifiedExecutable = runtimeConfig.value.availability === "available" ? validateAgentExecutable(agentBin) : null;
2057
+ const context = loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture });
2058
+ fault("after_run_initialized");
2059
+ context.planPath = planPath;
2060
+ context.materializedPath = materializedPath;
2061
+ context.selectionState = selectionState;
2062
+ context.retryFailed = retryFailed;
2063
+ context.firstAttemptOnly = firstAttemptOnly;
2064
+ context.successorPromptInput = successorPromptInput;
2065
+ const cases = context.plan.cases.filter((entry) => entry.adapter_track === adapter && (!caseId || entry.case_id === caseId));
2066
+ if (caseId && cases.length === 0) throw new Error(`case ${caseId} does not belong to adapter ${adapter}`);
2067
+ if (firstAttemptOnly && cases.some(entry => {
2068
+ const state = readCaseState(root, context.runDir, entry);
2069
+ return state.status !== 'pending' || state.attempt_count !== 0;
2070
+ })) throw new Error('first-attempt execution refuses attempted or uncertain cases');
2071
+ const runtimeIdentity = ensureAdapterIdentity({ root, runDir: context.runDir, plan: context.plan, adapter, runtimeConfig, verifiedExecutable, environmentSnapshot, successorRuntime: successorPromptInput === null ? null : successorRuntimeForInput(successorPromptInput) });
2072
+ const outcomes = [];
2073
+ let executed = 0;
2074
+ if (runtimeIdentity.identity.availability === "unavailable") {
2075
+ for (const entry of cases) {
2076
+ const state = readCaseState(root, context.runDir, entry);
2077
+ if (TERMINAL_STATUSES.has(state.status)) validateTerminalCase({ root, context, entry, state });
2078
+ if (["completed", "unavailable", "invalid"].includes(state.status)) {
2079
+ outcomes.push({ case_id: entry.case_id, status: state.status });
2080
+ continue;
2081
+ }
2082
+ if (maxCases !== null && executed >= maxCases) break;
2083
+ const status = markUnavailable({ root, context, entry, state, runtime: { ...runtimeConfig.value, availability: "unavailable", unavailable_reason: runtimeIdentity.identity.unavailable_reason }, adapter: runtimeIdentity });
2084
+ outcomes.push({ case_id: entry.case_id, status });
2085
+ if (status !== "active") executed += 1;
2086
+ }
2087
+ } else {
2088
+ for (const entry of cases) {
2089
+ const state = readCaseState(root, context.runDir, entry);
2090
+ const actionable = state.status === "pending" || state.status === "interrupted" || (state.status === "failed" && retryFailed);
2091
+ if (actionable && maxCases !== null && executed >= maxCases) break;
2092
+ const status = executeCase({ root, config, context, entry, runtime: runtimeConfig.value, verifiedExecutable, adapter: runtimeIdentity, environmentSnapshot });
2093
+ outcomes.push({ case_id: entry.case_id, status });
2094
+ if (actionable && status !== "active") executed += 1;
2095
+ }
2096
+ }
2097
+ return { adapter, initialized: context.initialized, outcomes };
2098
+ }
2099
+
2100
+ function validateClaimAgainstContext({ root, context, entry, claim }) {
2101
+ const identity = readAdapterIdentity(root, context.runDir, entry.adapter_track);
2102
+ if (claim.run_instance_id !== context.identity.run_instance_id || claim.adapter !== entry.adapter_track || claim.condition !== entry.condition || claim.runtime_identity_digest !== canonicalDigest(identity) || claim.effective_command_digest !== identity.effective_command_digest || claim.environment_snapshot_digest !== identity.environment_snapshot.digest) throw new Error(`${entry.case_id} claim runtime identity mismatch`);
2103
+ assertCanonicalEqual(claim.input_identity, inputIdentityFor(context, entry), `${entry.case_id} claim input identity`);
2104
+ assertCanonicalEqual(claim.selection, selectionIdentityFor(context, entry), `${entry.case_id} claim selection`);
2105
+ }
2106
+
2107
+ function classificationForCase({ root, context, entry }) {
2108
+ try {
2109
+ const inspected = inspectExecutionCase({ root, context, entry });
2110
+ return { case_id: entry.case_id, status: inspected.state.status, ...(inspected.state.status === "active" ? { stale_claim: inspected.stale_claim } : {}) };
2111
+ } catch (error) {
2112
+ return { case_id: entry.case_id, status: "invalid", reason: error instanceof Error ? error.message : String(error) };
2113
+ }
2114
+ }
2115
+
2116
+ export function inspectVerifiedPortfolioExecution({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture = null }) {
2117
+ const primary = primaryProducerInspection({ root, config, planPath, materializedPath, selectionState, runDir });
2118
+ if (primary) return primary;
2119
+ const producer = coreProducerInspection({ root, config, planPath, materializedPath, selectionState, runDir });
2120
+ if (producer) return producer;
2121
+ const context = loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, initialize: false, executionAdmissionEvidenceByFixture });
2122
+ assertDirectoryInventory(context.runDir, ["adapters", "cases", RUN_IDENTITY_FILE], "run root");
2123
+ const adaptersRoot = resolve(context.runDir, "adapters");
2124
+ const adapterInventory = readdirSync(adaptersRoot).sort();
2125
+ if (adapterInventory.some((name) => !/^(?:codex|claude)\.json$/u.test(name))) throw new Error("adapter identity root contains unmanaged evidence");
2126
+ assertDirectoryInventory(resolve(context.runDir, "cases"), context.plan.cases.map((entry) => entry.case_id), "run cases root");
2127
+ const cases = context.plan.cases.map((entry) => inspectExecutionCase({ root, context, entry }));
2128
+ return {
2129
+ identity: context.identity,
2130
+ plan: context.plan,
2131
+ materialization: context.materialized,
2132
+ selections: context.selections,
2133
+ cases,
2134
+ adapter_identities: new Map(adapterInventory.map((name) => {
2135
+ const adapter = name.slice(0, -".json".length);
2136
+ return [adapter, readAdapterIdentity(root, context.runDir, adapter)];
2137
+ })),
2138
+ };
2139
+ }
2140
+
2141
+ export function verifyExecutionTerminalWorkspaceAuthority({ root, config, planPath, materializedPath, selectionState, runDir, caseId, attempt, executionAdmissionEvidenceByFixture = null }) {
2142
+ const primary = primaryProducerInspection({ root, config, planPath, materializedPath, selectionState, runDir });
2143
+ if (primary) return verifyPrimaryProducedTerminal(primary, { root, runDir, caseId, attempt });
2144
+ const producer = coreProducerInspection({ root, config, planPath, materializedPath, selectionState, runDir });
2145
+ if (producer) return verifyCoreProducedTerminal(producer, { root, runDir, caseId, attempt });
2146
+ const inspection = inspectVerifiedPortfolioExecution({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture });
2147
+ const inspectedCase = inspection.cases.find((item) => item.entry.case_id === caseId);
2148
+ if (!inspectedCase) throw new Error("terminal workspace authority case is absent from the verified execution");
2149
+ const inspectedAttempt = inspectedCase.attempts.find((item) => item.attempt === attempt);
2150
+ if (!inspectedAttempt || !inspectedAttempt.terminalWorkspaceAuthority) throw new Error("terminal workspace authority is unavailable for the requested attempt");
2151
+ const result = inspectedAttempt.result;
2152
+ const attemptRoot = attemptRootPath(resolve(runDir), caseId, attempt);
2153
+ const verified = readVerifiedTerminalWorkspaceAuthority({
2154
+ root,
2155
+ authorityPath: terminalWorkspaceAuthorityPath(attemptRoot),
2156
+ reference: terminalWorkspaceReferenceFromResult(result),
2157
+ expected: {
2158
+ run_instance_id: inspection.identity.run_instance_id,
2159
+ case_id: caseId,
2160
+ attempt,
2161
+ adapter: inspectedCase.entry.adapter_track,
2162
+ condition: inspectedCase.entry.condition,
2163
+ fixture_id: inspectedCase.entry.fixture_id,
2164
+ fixture_input_digest: `sha256:${inspectedCase.entry.input_manifest_sha256}`,
2165
+ materialization_manifest_digest: inspection.materialization.manifestDigest,
2166
+ },
2167
+ expectedBaseInventory: expectedBaseRegularInventory(inspection.materialization.casesById.get(caseId), inspectedAttempt.request.projection),
2168
+ expectedManagedAssetPaths: managedAssetPaths(inspection.materialization.casesById.get(caseId), inspectedAttempt.request.projection),
2169
+ });
2170
+ return {
2171
+ ...verified,
2172
+ execution: {
2173
+ run_instance_id: inspection.identity.run_instance_id,
2174
+ case_id: caseId,
2175
+ attempt,
2176
+ adapter: inspectedCase.entry.adapter_track,
2177
+ condition: inspectedCase.entry.condition,
2178
+ fixture_id: inspectedCase.entry.fixture_id,
2179
+ fixture_input_digest: `sha256:${inspectedCase.entry.input_manifest_sha256}`,
2180
+ materialization_manifest_digest: inspection.materialization.manifestDigest,
2181
+ request_digest: inspectedAttempt.evidence.request_digest,
2182
+ raw_result_digest: inspectedAttempt.evidence.result_digest,
2183
+ terminal_commit_digest: inspectedAttempt.evidence.commit_digest,
2184
+ terminal_workspace_authority_availability: result.terminal_workspace_authority_availability,
2185
+ terminal_workspace_authority_support: result.terminal_workspace_authority_support,
2186
+ terminal_workspace_authority_digest: result.terminal_workspace_authority_digest,
2187
+ terminal_workspace_tree_digest: result.terminal_workspace_tree_digest,
2188
+ terminal_workspace_authority_bytes: result.terminal_workspace_authority_bytes,
2189
+ },
2190
+ };
2191
+ }
2192
+
2193
+ export function verifyPortfolioExecution({ root, config, planPath, materializedPath, selectionState, runDir, executionAdmissionEvidenceByFixture = null }) {
2194
+ const context = loadExecutionContext({ root, config, planPath, materializedPath, selectionState, runDir, initialize: false, executionAdmissionEvidenceByFixture });
2195
+ return {
2196
+ cases: context.plan.cases.map((entry) => classificationForCase({ root, context, entry })),
2197
+ };
2198
+ }
2199
+
2200
+ function assertRecoveryEvidence({ root, run, state, claim, request, result, requestPath }) {
2201
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${claim.case_id} recovery request`);
2202
+ validate(root, result, ATTEMPT_RESULT_SCHEMA_PATH, `${claim.case_id} recovery result`);
2203
+ const runIdentity = readJson(runIdentityPath(run));
2204
+ validate(root, runIdentity, RUN_IDENTITY_SCHEMA_PATH, "recovery run identity");
2205
+ const identity = readAdapterIdentity(root, run, claim.adapter);
2206
+ if (claim.run_instance_id !== runIdentity.run_instance_id || claim.runtime_identity_digest !== canonicalDigest(identity) || claim.effective_command_digest !== identity.effective_command_digest || claim.environment_snapshot_digest !== identity.environment_snapshot.digest) throw new Error("recovery runtime identity mismatch");
2207
+ if (request.run_instance_id !== runIdentity.run_instance_id || request.case_id !== claim.case_id || request.attempt !== claim.attempt || request.adapter !== claim.adapter || request.condition !== claim.condition) throw new Error("recovery request identity mismatch");
2208
+ assertCanonicalEqual(request.claim, requestClaimRecord(claim), "recovery request claim identity");
2209
+ assertCanonicalEqual(request.input_identity, claim.input_identity, "recovery request input identity");
2210
+ assertCanonicalEqual(request.selection, claim.selection, "recovery request selection");
2211
+ if (request.agent.runtime_identity_digest !== claim.runtime_identity_digest || request.agent.effective_command_digest !== claim.effective_command_digest || request.agent.environment_snapshot_digest !== claim.environment_snapshot_digest) throw new Error("recovery request runtime identity mismatch");
2212
+ if (result.run_instance_id !== runIdentity.run_instance_id || result.case_id !== claim.case_id || result.attempt !== claim.attempt || result.adapter !== claim.adapter || result.condition !== claim.condition || result.runtime_identity_digest !== claim.runtime_identity_digest || result.effective_command_digest !== claim.effective_command_digest) throw new Error("recovery result identity mismatch");
2213
+ if (result.request_sha256 !== prefixedFileDigest(requestPath)) throw new Error("recovery result request digest mismatch");
2214
+ if (state.case_id !== claim.case_id || state.adapter !== claim.adapter || state.condition !== claim.condition || state.status !== "active" || state.active_claim_id !== claim.claim_id) throw new Error("recovery state identity mismatch");
2215
+ }
2216
+
2217
+ function recoveryCommandEvidence({ root, run, attemptRoot, entry, claim }) {
2218
+ const path = resolve(attemptRoot, COMMAND_EVIDENCE_PATH);
2219
+ const adapterIdentity = readAdapterIdentity(root, run, claim.adapter);
2220
+ if (!existsSync(path)) {
2221
+ return sealCommandEvidence({
2222
+ root,
2223
+ attemptRoot,
2224
+ entry,
2225
+ claim,
2226
+ adapterIdentity,
2227
+ contract: null,
2228
+ forceUnavailable: { probe: "capture_invalid", reason: "stale_recovery_without_committed_capture" },
2229
+ });
2230
+ }
2231
+ assertNoSymlinkSegments(path, `${entry.case_id} recovered command evidence`);
2232
+ const recovered = readStableCommandEvidence(path, `${entry.case_id} recovered command evidence`);
2233
+ const manifest = validateCommandEvidenceManifest(recovered.manifest, { root, expectedContractDigest: claim.input_identity.verification_command_contract_digest });
2234
+ const recoveredAfter = readStableCommandEvidence(path, `${entry.case_id} recovered command evidence`);
2235
+ assertStableFileEvidence(recovered.file, recoveredAfter.file, `${entry.case_id} recovered command evidence`);
2236
+ return {
2237
+ manifest,
2238
+ captureError: null,
2239
+ reference: commandEvidenceReference(recovered.file, manifest),
2240
+ };
2241
+ }
2242
+
2243
+ function recoveryResult({ root, attemptRoot, entry, claim, requestPath, commandEvidence, reason, terminalWorkspaceAuthority = null }) {
2244
+ const resultPath = resolve(attemptRoot, "result.json");
2245
+ assertNoSymlinkSegments(resultPath, `${entry.case_id} recovery result`);
2246
+ if (existsSync(resultPath)) return readJson(resultPath);
2247
+ const pendingPath = resolve(attemptRoot, RESULT_STAGING_FILE);
2248
+ assertNoSymlinkSegments(pendingPath, `${entry.case_id} pending recovery result`);
2249
+ if (existsSync(pendingPath)) {
2250
+ const pending = readJson(pendingPath);
2251
+ validate(root, pending, ATTEMPT_RESULT_SCHEMA_PATH, `${entry.case_id} pending recovery result`);
2252
+ const finalPath = resolve(attemptRoot, "final.json");
2253
+ assertNoSymlinkSegments(finalPath, `${entry.case_id} recovery final output`);
2254
+ if (pending.status === "completed" && existsSync(finalPath)) return pending;
2255
+ rmSync(pendingPath, { force: true });
2256
+ }
2257
+ return resultRecord({
2258
+ entry,
2259
+ attempt: claim.attempt,
2260
+ claim,
2261
+ requestPath,
2262
+ commandEvidence,
2263
+ status: "interrupted",
2264
+ failureKind: "stale_claim_recovered",
2265
+ recoveryReason: durableScalarEvidence(reason, reason, "operator_recovery"),
2266
+ terminalWorkspaceAuthority,
2267
+ });
2268
+ }
2269
+
2270
+ function recoverTerminalWorkspaceAuthorityPublication({ root, attemptRoot, entry, claim }) {
2271
+ const destination = terminalWorkspaceAuthorityPath(attemptRoot);
2272
+ const prefix = terminalWorkspaceStagingPrefix(claim.claim_id);
2273
+ const stagingNames = readdirSync(attemptRoot).filter((name) => name.startsWith(prefix) && name.endsWith(".staging"));
2274
+ if (stagingNames.length > 1) throw new Error("attempt contains multiple terminal workspace authority staging files");
2275
+ if (stagingNames.length === 1) {
2276
+ const staging = resolve(attemptRoot, stagingNames[0]);
2277
+ const token = stagingNames[0].slice(prefix.length, -".staging".length);
2278
+ if (!UUID_PATTERN.test(token)) throw new Error("attempt contains malformed terminal workspace authority staging evidence");
2279
+ const staged = readVerifiedTerminalWorkspaceAuthority({ root, authorityPath: staging, expected: terminalWorkspaceIdentity(entry, claim) });
2280
+ if (existsSync(destination)) {
2281
+ const published = readVerifiedTerminalWorkspaceAuthority({ root, authorityPath: destination, expected: terminalWorkspaceIdentity(entry, claim) });
2282
+ if (!staged.file.bytes.equals(published.file.bytes)) throw new Error("published terminal workspace authority conflicts with staged authority");
2283
+ rmSync(staging, { force: true });
2284
+ } else {
2285
+ renameSync(staging, destination);
2286
+ chmodSync(destination, 0o444);
2287
+ }
2288
+ }
2289
+ if (!existsSync(destination)) return null;
2290
+ const verified = readVerifiedTerminalWorkspaceAuthority({ root, authorityPath: destination, expected: terminalWorkspaceIdentity(entry, claim) });
2291
+ return terminalWorkspaceAuthorityReference(verified.file, verified.authority);
2292
+ }
2293
+
2294
+ function reconcileAttemptStaging(attemptRoot, claimId) {
2295
+ assertClaimId(claimId);
2296
+ if (!existsSync(attemptRoot)) return;
2297
+ const targets = ["request.json", COMMAND_EVIDENCE_PATH, RESULT_STAGING_FILE, "result.json", "final.json", "commit.json"];
2298
+ for (const name of readdirSync(attemptRoot)) {
2299
+ if (!name.endsWith(".staging")) continue;
2300
+ const target = targets.find((candidate) => name.startsWith(`.${candidate}.${claimId}.`));
2301
+ if (!target) throw new Error("attempt contains staging evidence not owned by the recovered claim");
2302
+ const token = name.slice(`.${target}.${claimId}.`.length, -".staging".length);
2303
+ if (!UUID_PATTERN.test(token)) throw new Error("attempt contains malformed staging evidence");
2304
+ const path = assertInside(attemptRoot, resolve(attemptRoot, name), "attempt staging evidence");
2305
+ assertNoSymlinkSegments(path, "attempt staging evidence");
2306
+ if (!lstatSync(path).isFile()) throw new Error("attempt staging evidence must be a regular file");
2307
+ rmSync(path, { force: true });
2308
+ }
2309
+ }
2310
+
2311
+ function assertCommittedRecoveryEvidence({ root, run, state, commit, claim = null }) {
2312
+ const runIdentity = readJson(runIdentityPath(run));
2313
+ validate(root, runIdentity, RUN_IDENTITY_SCHEMA_PATH, "committed run identity");
2314
+ if (!TERMINAL_STATUSES.has(state.status) || !state.terminal_attempt || state.terminal_attempt !== String(state.attempt_count).padStart(4, "0")) throw new Error("terminal state is invalid for committed recovery");
2315
+ const commitPath = resolve(attemptRootPath(run, state.case_id, state.terminal_attempt), "commit.json");
2316
+ if (state.terminal_commit_digest !== prefixedFileDigest(commitPath)) throw new Error("terminal state commit digest mismatch");
2317
+ const entry = { case_id: state.case_id, adapter_track: state.adapter, condition: state.condition };
2318
+ const artifacts = validateTerminalAttemptEvidence({
2319
+ root,
2320
+ runDir: run,
2321
+ runIdentity,
2322
+ entry,
2323
+ attempt: state.terminal_attempt,
2324
+ expectedInput: claim?.input_identity,
2325
+ expectedSelection: claim?.selection,
2326
+ claim,
2327
+ });
2328
+ assertCanonicalEqual(artifacts.commit, commit, "committed recovery terminal commit");
2329
+ if (artifacts.result.status !== state.status || state.selection_digest !== (artifacts.request.selection?.digest ?? null)) throw new Error("committed recovery state evidence mismatch");
2330
+ return artifacts;
2331
+ }
2332
+
2333
+ export function recoverPortfolioCase({ root, runDir, caseId, claimId, reason }) {
2334
+ if (!caseId || !claimId || !reason?.trim()) throw new Error("recover-case requires --case-id, --claim-id, and --reason");
2335
+ assertCaseId(caseId);
2336
+ assertClaimId(claimId);
2337
+ const run = resolve(runDir);
2338
+ assertNoSymlinkSegments(run, "run root");
2339
+ const identityPath = runIdentityPath(run);
2340
+ const identity = readJson(identityPath);
2341
+ validate(root, identity, RUN_IDENTITY_SCHEMA_PATH, "run identity");
2342
+ // Legacy unbound roots remain readable schema values, not permission to infer
2343
+ // absence or delete a workspace under the caller's current temporary root.
2344
+ assertWorkspaceRootIdentity(identity);
2345
+ const stateFile = statePath(run, caseId);
2346
+ if (!existsSync(stateFile)) throw new Error(`case state is missing: ${caseId}`);
2347
+ let state = readJson(stateFile);
2348
+ validate(root, state, CASE_STATE_SCHEMA_PATH, `${caseId} state`);
2349
+ const claim = readClaim(root, run, caseId);
2350
+ if (!claim) {
2351
+ const staged = readStagedClaim(root, run, caseId, claimId);
2352
+ if (staged) {
2353
+ if (!claimIsExpired(staged.claim)) throw new Error("staged claim lease has not expired");
2354
+ removeEphemeralWorkspace(staged.claim, identity);
2355
+ rmSync(staged.directory, { recursive: true, force: true });
2356
+ return { case_id: caseId, status: state.status };
2357
+ }
2358
+ if (TERMINAL_STATUSES.has(state.status) && state.terminal_attempt) {
2359
+ const commit = readJson(resolve(attemptRootPath(run, caseId, state.terminal_attempt), "commit.json"));
2360
+ validate(root, commit, ATTEMPT_COMMIT_SCHEMA_PATH, `${caseId} terminal commit`);
2361
+ if (commit.claim_id !== claimId) throw new Error("claim ID does not match the terminal commit");
2362
+ const verified = assertCommittedRecoveryEvidence({ root, run, state, commit });
2363
+ // Older writers could release the claim before removing its workspace.
2364
+ // Reconstruct only from fully reverified evidence and check the ownership
2365
+ // marker; do not re-run a trial or rewrite any terminal artifacts.
2366
+ removeEphemeralWorkspace(claimFromVerifiedRequest(root, verified.request), identity);
2367
+ return { case_id: caseId, status: state.status };
2368
+ }
2369
+ if (state.status !== "active" || state.active_claim_id !== claimId) throw new Error("claim ID does not match the active claim");
2370
+ const attempt = String(state.attempt_count).padStart(4, "0");
2371
+ const attemptRoot = attemptRootPath(run, caseId, attempt);
2372
+ const requestPath = resolve(attemptRoot, "request.json");
2373
+ if (!existsSync(requestPath)) throw new Error("active claim is missing and no durable request evidence exists");
2374
+ assertNoSymlinkSegments(requestPath, `${caseId} recovery request`);
2375
+ const request = readJson(requestPath);
2376
+ validate(root, request, ATTEMPT_REQUEST_SCHEMA_PATH, `${caseId} recovery request`);
2377
+ if (request.claim.id !== claimId || !claimIsExpired({ lease_expires_at: request.claim.lease_expires_at })) throw new Error("lost claim evidence is not expired or does not match");
2378
+ const recoveredClaim = claimFromVerifiedRequest(root, request);
2379
+ assertEphemeralWorkspaceOwnership(recoveredClaim, identity);
2380
+ const entry = { case_id: caseId, adapter_track: state.adapter, condition: state.condition };
2381
+ const terminalWorkspaceAuthority = recoverTerminalWorkspaceAuthorityPublication({ root, attemptRoot, entry, claim: recoveredClaim });
2382
+ const commandEvidence = recoveryCommandEvidence({ root, run, attemptRoot, entry, claim: recoveredClaim });
2383
+ const result = recoveryResult({ root, attemptRoot, entry, claim: recoveredClaim, requestPath, commandEvidence: commandEvidence.reference, reason, terminalWorkspaceAuthority });
2384
+ assertRecoveryEvidence({ root, run, state, claim: recoveredClaim, request, result, requestPath });
2385
+ const terminalState = completeCase({ root, runDir: run, entry, state, claim: recoveredClaim, attempt, attemptRoot, result });
2386
+ removeEphemeralWorkspace(recoveredClaim, identity);
2387
+ return { case_id: caseId, status: terminalState.status };
2388
+ }
2389
+ if (claim.claim_id !== claimId) throw new Error("claim ID does not match the active claim");
2390
+ assertEphemeralWorkspaceOwnership(claim, identity);
2391
+ const publishedBeforeState = claimPublishedBeforeState(state, claim);
2392
+ if (TERMINAL_STATUSES.has(state.status) && state.terminal_attempt && !publishedBeforeState) {
2393
+ const commitPath = resolve(attemptRootPath(run, caseId, state.terminal_attempt), "commit.json");
2394
+ assertNoSymlinkSegments(commitPath, `${caseId} terminal commit`);
2395
+ const commit = readJson(commitPath);
2396
+ validate(root, commit, ATTEMPT_COMMIT_SCHEMA_PATH, `${caseId} terminal commit`);
2397
+ if (commit.claim_id !== claimId) throw new Error("claim ID does not match the terminal commit");
2398
+ assertCommittedRecoveryEvidence({ root, run, state, commit, claim });
2399
+ removeEphemeralWorkspace(claim, identity);
2400
+ fault("after_workspace_cleanup");
2401
+ releaseClaim(root, run, caseId, claimId);
2402
+ return { case_id: caseId, status: state.status };
2403
+ }
2404
+ if (publishedBeforeState) {
2405
+ if (state.status === "pending" && (state.attempt_count !== 0 || state.active_claim_id !== null)) throw new Error("published claim does not match pending state");
2406
+ if (TERMINAL_STATUSES.has(state.status)) {
2407
+ const previousCommitPath = resolve(attemptRootPath(run, caseId, state.terminal_attempt), "commit.json");
2408
+ assertNoSymlinkSegments(previousCommitPath, `${caseId} previous terminal commit`);
2409
+ const previousCommit = readJson(previousCommitPath);
2410
+ validate(root, previousCommit, ATTEMPT_COMMIT_SCHEMA_PATH, `${caseId} previous terminal commit`);
2411
+ assertCommittedRecoveryEvidence({ root, run, state, commit: previousCommit, claim });
2412
+ }
2413
+ if (claim.adapter !== state.adapter || claim.condition !== state.condition || (claim.selection?.digest ?? null) !== state.selection_digest) throw new Error("published claim does not match prior state identity");
2414
+ if (!claimIsExpired(claim)) throw new Error("claim lease has not expired");
2415
+ const identity = readAdapterIdentity(root, run, claim.adapter);
2416
+ if (claim.runtime_identity_digest !== canonicalDigest(identity) || claim.effective_command_digest !== identity.effective_command_digest || claim.environment_snapshot_digest !== identity.environment_snapshot.digest) throw new Error("published claim runtime identity mismatch");
2417
+ state = { ...state, status: "active", attempt_count: Number(claim.attempt), active_claim_id: claimId, terminal_attempt: null, terminal_commit_digest: null };
2418
+ validate(root, state, CASE_STATE_SCHEMA_PATH, `${caseId} reconciled active state`);
2419
+ writeCaseState(run, { case_id: caseId }, state);
2420
+ } else if (state.status !== "active" || state.active_claim_id !== claimId) {
2421
+ throw new Error("active state does not bind the supplied claim");
2422
+ }
2423
+ if (!claimIsExpired(claim)) throw new Error("claim lease has not expired");
2424
+ const attemptRoot = attemptRootPath(run, caseId, claim.attempt);
2425
+ mkdirSync(attemptRoot, { recursive: true });
2426
+ const entry = { case_id: caseId, adapter_track: state.adapter, condition: state.condition };
2427
+ const terminalWorkspaceAuthority = recoverTerminalWorkspaceAuthorityPublication({ root, attemptRoot, entry, claim });
2428
+ reconcileAttemptStaging(attemptRoot, claimId);
2429
+ const requestPath = resolve(attemptRoot, "request.json");
2430
+ if (!existsSync(requestPath)) {
2431
+ const recoveryRequest = requestRecord({ entry: { case_id: caseId, adapter_track: claim.adapter, condition: claim.condition }, attempt: claim.attempt, claim, projection: { status: "recovered_interruption" } });
2432
+ validate(root, recoveryRequest, ATTEMPT_REQUEST_SCHEMA_PATH, `${caseId} recovered request`);
2433
+ writeJsonAtomic(requestPath, recoveryRequest, { stagingOwner: claim.claim_id, faultName: "after_request_staged" });
2434
+ }
2435
+ const commandEvidence = recoveryCommandEvidence({ root, run, attemptRoot, entry, claim });
2436
+ const result = recoveryResult({ root, attemptRoot, entry, claim, requestPath, commandEvidence: commandEvidence.reference, reason, terminalWorkspaceAuthority });
2437
+ const request = readJson(requestPath);
2438
+ assertRecoveryEvidence({ root, run, state, claim, request, result, requestPath });
2439
+ const terminalState = completeCase({ root, runDir: run, entry, state, claim, attempt: claim.attempt, attemptRoot, result });
2440
+ removeEphemeralWorkspace(claim, identity);
2441
+ return { case_id: caseId, status: terminalState.status };
2442
+ }