@tiangong-lca/foundry 0.1.2

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 (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +532 -0
  3. package/docs/architecture.md +450 -0
  4. package/docs/foundry-task-contracts.md +147 -0
  5. package/docs/import-profiles/bafu/constraints.md +343 -0
  6. package/docs/import-profiles/bafu/leaf-process-classification-authoring.md +153 -0
  7. package/docs/import-profiles/bafu/profile.md +183 -0
  8. package/docs/import-profiles/uslci/constraints.md +29 -0
  9. package/docs/import-profiles/uslci/profile.md +43 -0
  10. package/docs/import-profiles/worldsteel/constraints.md +77 -0
  11. package/docs/import-profiles/worldsteel/import-coverage.md +93 -0
  12. package/docs/import-profiles/worldsteel/import-plan.md +375 -0
  13. package/docs/import-profiles/worldsteel/profile.md +78 -0
  14. package/docs/package-distribution-contract.md +287 -0
  15. package/docs/public-runtime-contract.md +218 -0
  16. package/docs/runtime-context-contract.md +138 -0
  17. package/docs/safety-policy.md +164 -0
  18. package/docs/task-authorization-contract.md +131 -0
  19. package/docs/uslci-import-runbook.md +336 -0
  20. package/docs/workspace-migration-contract.md +127 -0
  21. package/package-dist/assets/foundry-package-descriptor.json +1661 -0
  22. package/package-dist/scripts/foundry-facade.d.ts +78 -0
  23. package/package-dist/scripts/foundry-facade.js +1317 -0
  24. package/package-dist/scripts/foundry-runtime.d.ts +180 -0
  25. package/package-dist/scripts/foundry-runtime.js +190 -0
  26. package/package-dist/scripts/lib/batch-orchestration/scope-attempt-ledger.d.ts +27 -0
  27. package/package-dist/scripts/lib/batch-orchestration/scope-attempt-ledger.js +85 -0
  28. package/package-dist/scripts/lib/batch-orchestration/scope-resume-contract.d.ts +38 -0
  29. package/package-dist/scripts/lib/batch-orchestration/scope-resume-contract.js +90 -0
  30. package/package-dist/scripts/lib/bundle-row-types.d.ts +44 -0
  31. package/package-dist/scripts/lib/bundle-row-types.js +46 -0
  32. package/package-dist/scripts/lib/bundle-sample-utils.d.ts +183 -0
  33. package/package-dist/scripts/lib/bundle-sample-utils.js +526 -0
  34. package/package-dist/scripts/lib/bundle-source-context.d.ts +31 -0
  35. package/package-dist/scripts/lib/bundle-source-context.js +142 -0
  36. package/package-dist/scripts/lib/canonical-description.d.ts +12 -0
  37. package/package-dist/scripts/lib/canonical-description.js +72 -0
  38. package/package-dist/scripts/lib/canonical-support-rewrites.d.ts +127 -0
  39. package/package-dist/scripts/lib/canonical-support-rewrites.js +527 -0
  40. package/package-dist/scripts/lib/decision-owners/classification.d.ts +245 -0
  41. package/package-dist/scripts/lib/decision-owners/classification.js +754 -0
  42. package/package-dist/scripts/lib/decision-owners/identity-preflight.d.ts +333 -0
  43. package/package-dist/scripts/lib/decision-owners/identity-preflight.js +1353 -0
  44. package/package-dist/scripts/lib/decision-owners/identity-task.d.ts +130 -0
  45. package/package-dist/scripts/lib/decision-owners/identity-task.js +494 -0
  46. package/package-dist/scripts/lib/decision-owners/identity.d.ts +74 -0
  47. package/package-dist/scripts/lib/decision-owners/identity.js +443 -0
  48. package/package-dist/scripts/lib/decision-owners/location.d.ts +239 -0
  49. package/package-dist/scripts/lib/decision-owners/location.js +704 -0
  50. package/package-dist/scripts/lib/decision-task-utils.d.ts +484 -0
  51. package/package-dist/scripts/lib/decision-task-utils.js +735 -0
  52. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +52 -0
  53. package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +146 -0
  54. package/package-dist/scripts/lib/finalize-owners/commit-handoff.d.ts +79 -0
  55. package/package-dist/scripts/lib/finalize-owners/commit-handoff.js +515 -0
  56. package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +234 -0
  57. package/package-dist/scripts/lib/finalize-owners/post-authoring.js +1720 -0
  58. package/package-dist/scripts/lib/finalize-owners/post-write-closeout.d.ts +140 -0
  59. package/package-dist/scripts/lib/finalize-owners/post-write-closeout.js +656 -0
  60. package/package-dist/scripts/lib/foundry-args.d.ts +7 -0
  61. package/package-dist/scripts/lib/foundry-args.js +38 -0
  62. package/package-dist/scripts/lib/foundry-authentication-environment.d.ts +17 -0
  63. package/package-dist/scripts/lib/foundry-authentication-environment.js +55 -0
  64. package/package-dist/scripts/lib/foundry-authorization-input.d.ts +31 -0
  65. package/package-dist/scripts/lib/foundry-authorization-input.js +151 -0
  66. package/package-dist/scripts/lib/foundry-command-metadata.d.ts +32 -0
  67. package/package-dist/scripts/lib/foundry-command-metadata.js +1012 -0
  68. package/package-dist/scripts/lib/foundry-command-registry.d.ts +34 -0
  69. package/package-dist/scripts/lib/foundry-command-registry.js +241 -0
  70. package/package-dist/scripts/lib/foundry-command-spec.d.ts +1 -0
  71. package/package-dist/scripts/lib/foundry-command-spec.js +1 -0
  72. package/package-dist/scripts/lib/foundry-decision-owners.d.ts +17 -0
  73. package/package-dist/scripts/lib/foundry-decision-owners.js +68 -0
  74. package/package-dist/scripts/lib/foundry-decision-routing.d.ts +3 -0
  75. package/package-dist/scripts/lib/foundry-decision-routing.js +38 -0
  76. package/package-dist/scripts/lib/foundry-execution-admission.d.ts +33 -0
  77. package/package-dist/scripts/lib/foundry-execution-admission.js +225 -0
  78. package/package-dist/scripts/lib/foundry-execution-attempt.d.ts +11 -0
  79. package/package-dist/scripts/lib/foundry-execution-attempt.js +33 -0
  80. package/package-dist/scripts/lib/foundry-execution-context-format.d.ts +18 -0
  81. package/package-dist/scripts/lib/foundry-execution-context-format.js +83 -0
  82. package/package-dist/scripts/lib/foundry-facade-store.d.ts +25 -0
  83. package/package-dist/scripts/lib/foundry-facade-store.js +449 -0
  84. package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +21 -0
  85. package/package-dist/scripts/lib/foundry-finalize-owners.js +203 -0
  86. package/package-dist/scripts/lib/foundry-identity-owners.d.ts +13 -0
  87. package/package-dist/scripts/lib/foundry-identity-owners.js +58 -0
  88. package/package-dist/scripts/lib/foundry-managed-host.d.ts +7 -0
  89. package/package-dist/scripts/lib/foundry-managed-host.js +173 -0
  90. package/package-dist/scripts/lib/foundry-migration-adoption-plan.d.ts +39 -0
  91. package/package-dist/scripts/lib/foundry-migration-adoption-plan.js +467 -0
  92. package/package-dist/scripts/lib/foundry-migration-adoption.d.ts +31 -0
  93. package/package-dist/scripts/lib/foundry-migration-adoption.js +187 -0
  94. package/package-dist/scripts/lib/foundry-migration-authority.d.ts +42 -0
  95. package/package-dist/scripts/lib/foundry-migration-authority.js +280 -0
  96. package/package-dist/scripts/lib/foundry-migration-inventory.d.ts +31 -0
  97. package/package-dist/scripts/lib/foundry-migration-inventory.js +148 -0
  98. package/package-dist/scripts/lib/foundry-migration-plan.d.ts +48 -0
  99. package/package-dist/scripts/lib/foundry-migration-plan.js +234 -0
  100. package/package-dist/scripts/lib/foundry-migration-replay.d.ts +3 -0
  101. package/package-dist/scripts/lib/foundry-migration-replay.js +134 -0
  102. package/package-dist/scripts/lib/foundry-migration-stage.d.ts +15 -0
  103. package/package-dist/scripts/lib/foundry-migration-stage.js +152 -0
  104. package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +13 -0
  105. package/package-dist/scripts/lib/foundry-migration-transfer-io.js +226 -0
  106. package/package-dist/scripts/lib/foundry-migration-transfer.d.ts +36 -0
  107. package/package-dist/scripts/lib/foundry-migration-transfer.js +350 -0
  108. package/package-dist/scripts/lib/foundry-operation-result.d.ts +71 -0
  109. package/package-dist/scripts/lib/foundry-operation-result.js +264 -0
  110. package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +319 -0
  111. package/package-dist/scripts/lib/foundry-owner-execution-store.js +293 -0
  112. package/package-dist/scripts/lib/foundry-owner-readback.d.ts +22 -0
  113. package/package-dist/scripts/lib/foundry-owner-readback.js +189 -0
  114. package/package-dist/scripts/lib/foundry-owner-trace-acceptance.d.ts +15 -0
  115. package/package-dist/scripts/lib/foundry-owner-trace-acceptance.js +68 -0
  116. package/package-dist/scripts/lib/foundry-package-contract.d.ts +56 -0
  117. package/package-dist/scripts/lib/foundry-package-contract.js +392 -0
  118. package/package-dist/scripts/lib/foundry-private-path.d.ts +2 -0
  119. package/package-dist/scripts/lib/foundry-private-path.js +20 -0
  120. package/package-dist/scripts/lib/foundry-runtime-cache.d.ts +3 -0
  121. package/package-dist/scripts/lib/foundry-runtime-cache.js +25 -0
  122. package/package-dist/scripts/lib/foundry-runtime-command-policy.d.ts +20 -0
  123. package/package-dist/scripts/lib/foundry-runtime-command-policy.js +173 -0
  124. package/package-dist/scripts/lib/foundry-runtime-context-types.d.ts +59 -0
  125. package/package-dist/scripts/lib/foundry-runtime-context-types.js +1 -0
  126. package/package-dist/scripts/lib/foundry-runtime-context.d.ts +27 -0
  127. package/package-dist/scripts/lib/foundry-runtime-context.js +668 -0
  128. package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +9 -0
  129. package/package-dist/scripts/lib/foundry-runtime-environment.js +90 -0
  130. package/package-dist/scripts/lib/foundry-runtime-error.d.ts +4 -0
  131. package/package-dist/scripts/lib/foundry-runtime-error.js +8 -0
  132. package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +18 -0
  133. package/package-dist/scripts/lib/foundry-runtime-identity.js +127 -0
  134. package/package-dist/scripts/lib/foundry-runtime-paths.d.ts +16 -0
  135. package/package-dist/scripts/lib/foundry-runtime-paths.js +159 -0
  136. package/package-dist/scripts/lib/foundry-runtime-qualification.d.ts +66 -0
  137. package/package-dist/scripts/lib/foundry-runtime-qualification.js +223 -0
  138. package/package-dist/scripts/lib/foundry-runtime-selection-record.d.ts +16 -0
  139. package/package-dist/scripts/lib/foundry-runtime-selection-record.js +32 -0
  140. package/package-dist/scripts/lib/foundry-runtime-selection.d.ts +14 -0
  141. package/package-dist/scripts/lib/foundry-runtime-selection.js +123 -0
  142. package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +178 -0
  143. package/package-dist/scripts/lib/foundry-runtime-utils.js +603 -0
  144. package/package-dist/scripts/lib/foundry-semantic-input.d.ts +30 -0
  145. package/package-dist/scripts/lib/foundry-semantic-input.js +132 -0
  146. package/package-dist/scripts/lib/foundry-task-authorization.d.ts +68 -0
  147. package/package-dist/scripts/lib/foundry-task-authorization.js +350 -0
  148. package/package-dist/scripts/lib/foundry-task-io.d.ts +18 -0
  149. package/package-dist/scripts/lib/foundry-task-io.js +92 -0
  150. package/package-dist/scripts/lib/foundry-task-registration.d.ts +6 -0
  151. package/package-dist/scripts/lib/foundry-task-registration.js +384 -0
  152. package/package-dist/scripts/lib/foundry-task-start-spec.d.ts +34 -0
  153. package/package-dist/scripts/lib/foundry-task-start-spec.js +161 -0
  154. package/package-dist/scripts/lib/foundry-task-store.d.ts +18 -0
  155. package/package-dist/scripts/lib/foundry-task-store.js +466 -0
  156. package/package-dist/scripts/lib/foundry-task-types.d.ts +99 -0
  157. package/package-dist/scripts/lib/foundry-task-types.js +1 -0
  158. package/package-dist/scripts/lib/foundry-workflow-approval-continuation.d.ts +6 -0
  159. package/package-dist/scripts/lib/foundry-workflow-approval-continuation.js +136 -0
  160. package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +3 -0
  161. package/package-dist/scripts/lib/foundry-workflow-assessment.js +231 -0
  162. package/package-dist/scripts/lib/foundry-workflow-authorization.d.ts +22 -0
  163. package/package-dist/scripts/lib/foundry-workflow-authorization.js +174 -0
  164. package/package-dist/scripts/lib/foundry-workflow-context.d.ts +3 -0
  165. package/package-dist/scripts/lib/foundry-workflow-context.js +99 -0
  166. package/package-dist/scripts/lib/foundry-workflow-decisions.d.ts +18 -0
  167. package/package-dist/scripts/lib/foundry-workflow-decisions.js +123 -0
  168. package/package-dist/scripts/lib/foundry-workflow-execution.d.ts +8 -0
  169. package/package-dist/scripts/lib/foundry-workflow-execution.js +248 -0
  170. package/package-dist/scripts/lib/foundry-workflow-finalize.d.ts +13 -0
  171. package/package-dist/scripts/lib/foundry-workflow-finalize.js +264 -0
  172. package/package-dist/scripts/lib/foundry-workflow-identity-apply.d.ts +14 -0
  173. package/package-dist/scripts/lib/foundry-workflow-identity-apply.js +159 -0
  174. package/package-dist/scripts/lib/foundry-workflow-identity.d.ts +6 -0
  175. package/package-dist/scripts/lib/foundry-workflow-identity.js +153 -0
  176. package/package-dist/scripts/lib/foundry-workflow-import.d.ts +4 -0
  177. package/package-dist/scripts/lib/foundry-workflow-import.js +70 -0
  178. package/package-dist/scripts/lib/foundry-workflow-io.d.ts +11 -0
  179. package/package-dist/scripts/lib/foundry-workflow-io.js +77 -0
  180. package/package-dist/scripts/lib/foundry-workflow-reference-verify.d.ts +41 -0
  181. package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +266 -0
  182. package/package-dist/scripts/lib/foundry-workflow-rows.d.ts +2 -0
  183. package/package-dist/scripts/lib/foundry-workflow-rows.js +47 -0
  184. package/package-dist/scripts/lib/foundry-workflow-semantic.d.ts +5 -0
  185. package/package-dist/scripts/lib/foundry-workflow-semantic.js +367 -0
  186. package/package-dist/scripts/lib/foundry-workflow-state.d.ts +37 -0
  187. package/package-dist/scripts/lib/foundry-workflow-state.js +158 -0
  188. package/package-dist/scripts/lib/full-context-proof.d.ts +51 -0
  189. package/package-dist/scripts/lib/full-context-proof.js +932 -0
  190. package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +184 -0
  191. package/package-dist/scripts/lib/identity-preflight-artifacts.js +573 -0
  192. package/package-dist/scripts/lib/identity-preflight-proof.d.ts +117 -0
  193. package/package-dist/scripts/lib/identity-preflight-proof.js +341 -0
  194. package/package-dist/scripts/lib/identity-reference-rewrite-utils.d.ts +147 -0
  195. package/package-dist/scripts/lib/identity-reference-rewrite-utils.js +817 -0
  196. package/package-dist/scripts/lib/import-curation/authoring-packages.d.ts +28 -0
  197. package/package-dist/scripts/lib/import-curation/authoring-packages.js +92 -0
  198. package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +32 -0
  199. package/package-dist/scripts/lib/import-curation/curation-cleanup.js +203 -0
  200. package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +47 -0
  201. package/package-dist/scripts/lib/import-curation/curation-gate.js +528 -0
  202. package/package-dist/scripts/lib/import-curation/internal/artifact-inputs.d.ts +24 -0
  203. package/package-dist/scripts/lib/import-curation/internal/artifact-inputs.js +152 -0
  204. package/package-dist/scripts/lib/import-curation/internal/authoring-patch-workflow.d.ts +3 -0
  205. package/package-dist/scripts/lib/import-curation/internal/authoring-patch-workflow.js +3 -0
  206. package/package-dist/scripts/lib/import-curation/internal/authoring-task-workflow.d.ts +1 -0
  207. package/package-dist/scripts/lib/import-curation/internal/authoring-task-workflow.js +1 -0
  208. package/package-dist/scripts/lib/import-curation/internal/context-inputs.d.ts +56 -0
  209. package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +206 -0
  210. package/package-dist/scripts/lib/import-curation/internal/curation-gate-workflow.d.ts +14 -0
  211. package/package-dist/scripts/lib/import-curation/internal/curation-gate-workflow.js +14 -0
  212. package/package-dist/scripts/lib/import-curation/internal/dataset-payload.d.ts +70 -0
  213. package/package-dist/scripts/lib/import-curation/internal/dataset-payload.js +141 -0
  214. package/package-dist/scripts/lib/import-curation/internal/dataset-types.d.ts +25 -0
  215. package/package-dist/scripts/lib/import-curation/internal/dataset-types.js +45 -0
  216. package/package-dist/scripts/lib/import-curation/internal/full-context-proof.d.ts +129 -0
  217. package/package-dist/scripts/lib/import-curation/internal/full-context-proof.js +552 -0
  218. package/package-dist/scripts/lib/import-curation/internal/hash-utils.d.ts +2 -0
  219. package/package-dist/scripts/lib/import-curation/internal/hash-utils.js +10 -0
  220. package/package-dist/scripts/lib/import-curation/internal/mutation-manifest-workflow.d.ts +15 -0
  221. package/package-dist/scripts/lib/import-curation/internal/mutation-manifest-workflow.js +15 -0
  222. package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.d.ts +31 -0
  223. package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.js +467 -0
  224. package/package-dist/scripts/lib/import-curation/internal/profiles-config.d.ts +47 -0
  225. package/package-dist/scripts/lib/import-curation/internal/profiles-config.js +88 -0
  226. package/package-dist/scripts/lib/import-curation/internal/runtime-io.d.ts +23 -0
  227. package/package-dist/scripts/lib/import-curation/internal/runtime-io.js +132 -0
  228. package/package-dist/scripts/lib/import-curation/internal/trace-summary.d.ts +53 -0
  229. package/package-dist/scripts/lib/import-curation/internal/trace-summary.js +114 -0
  230. package/package-dist/scripts/lib/import-curation/internal/workflow-authoring-tasks.d.ts +141 -0
  231. package/package-dist/scripts/lib/import-curation/internal/workflow-authoring-tasks.js +854 -0
  232. package/package-dist/scripts/lib/import-curation/internal/workflow-decision-apply-context.d.ts +20 -0
  233. package/package-dist/scripts/lib/import-curation/internal/workflow-decision-apply-context.js +46 -0
  234. package/package-dist/scripts/lib/import-curation/internal/workflow-decision-full-context.d.ts +110 -0
  235. package/package-dist/scripts/lib/import-curation/internal/workflow-decision-full-context.js +782 -0
  236. package/package-dist/scripts/lib/import-curation/internal/workflow-dry-run-context.d.ts +24 -0
  237. package/package-dist/scripts/lib/import-curation/internal/workflow-dry-run-context.js +191 -0
  238. package/package-dist/scripts/lib/import-curation/internal/workflow-evidence-scope.d.ts +80 -0
  239. package/package-dist/scripts/lib/import-curation/internal/workflow-evidence-scope.js +359 -0
  240. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-decision-context.d.ts +146 -0
  241. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-decision-context.js +381 -0
  242. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.d.ts +223 -0
  243. package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +1079 -0
  244. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-collect.d.ts +41 -0
  245. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-collect.js +412 -0
  246. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence-context.d.ts +117 -0
  247. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence-context.js +278 -0
  248. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence.d.ts +59 -0
  249. package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence.js +593 -0
  250. package/package-dist/scripts/lib/import-curation/internal/workflow-queue-context.d.ts +58 -0
  251. package/package-dist/scripts/lib/import-curation/internal/workflow-queue-context.js +263 -0
  252. package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.d.ts +177 -0
  253. package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +812 -0
  254. package/package-dist/scripts/lib/import-curation/internal/workflow-row-transform-context.d.ts +159 -0
  255. package/package-dist/scripts/lib/import-curation/internal/workflow-row-transform-context.js +466 -0
  256. package/package-dist/scripts/lib/import-curation/internal/workflow-semantic-actions.d.ts +152 -0
  257. package/package-dist/scripts/lib/import-curation/internal/workflow-semantic-actions.js +1377 -0
  258. package/package-dist/scripts/lib/import-curation/internal/workflow-source-reference-context.d.ts +38 -0
  259. package/package-dist/scripts/lib/import-curation/internal/workflow-source-reference-context.js +116 -0
  260. package/package-dist/scripts/lib/import-curation/mutation-manifest.d.ts +51 -0
  261. package/package-dist/scripts/lib/import-curation/mutation-manifest.js +542 -0
  262. package/package-dist/scripts/lib/import-curation/patch-collect.d.ts +18 -0
  263. package/package-dist/scripts/lib/import-curation/patch-collect.js +172 -0
  264. package/package-dist/scripts/lib/import-curation/profiles.d.ts +1 -0
  265. package/package-dist/scripts/lib/import-curation/profiles.js +1 -0
  266. package/package-dist/scripts/lib/import-curation/trace-summary.d.ts +1 -0
  267. package/package-dist/scripts/lib/import-curation/trace-summary.js +1 -0
  268. package/package-dist/scripts/lib/oauth-session-reference.d.ts +1 -0
  269. package/package-dist/scripts/lib/oauth-session-reference.js +20 -0
  270. package/package-dist/scripts/lib/post-authoring-finalize-utils.d.ts +95 -0
  271. package/package-dist/scripts/lib/post-authoring-finalize-utils.js +548 -0
  272. package/package-dist/scripts/lib/post-write-root-proof.d.ts +44 -0
  273. package/package-dist/scripts/lib/post-write-root-proof.js +169 -0
  274. package/package-dist/scripts/lib/reference-description-text.d.ts +2 -0
  275. package/package-dist/scripts/lib/reference-description-text.js +12 -0
  276. package/package-dist/scripts/lib/remote-verification-accepted-diff.d.ts +42 -0
  277. package/package-dist/scripts/lib/remote-verification-accepted-diff.js +424 -0
  278. package/package-dist/scripts/lib/same-identity-commit-recovery.d.ts +8 -0
  279. package/package-dist/scripts/lib/same-identity-commit-recovery.js +52 -0
  280. package/package-dist/scripts/lib/source-semantics.d.ts +255 -0
  281. package/package-dist/scripts/lib/source-semantics.js +888 -0
  282. package/package-dist/scripts/lib/stage-contract.d.ts +36 -0
  283. package/package-dist/scripts/lib/stage-contract.js +25 -0
  284. package/package-dist/scripts/lib/task-authorization.d.ts +84 -0
  285. package/package-dist/scripts/lib/task-authorization.js +210 -0
  286. package/package-dist/scripts/lib/tidas-adapter.d.ts +113 -0
  287. package/package-dist/scripts/lib/tidas-adapter.js +525 -0
  288. package/package-dist/scripts/lib/tidas-language-utils.d.ts +8 -0
  289. package/package-dist/scripts/lib/tidas-language-utils.js +206 -0
  290. package/package-dist/scripts/lib/tidas-row-utils.d.ts +70 -0
  291. package/package-dist/scripts/lib/tidas-row-utils.js +225 -0
  292. package/package-dist/scripts/lib/trace-coverage.d.ts +53 -0
  293. package/package-dist/scripts/lib/trace-coverage.js +178 -0
  294. package/package-dist/scripts/package-entry.d.ts +2 -0
  295. package/package-dist/scripts/package-entry.js +4 -0
  296. package/package-dist/scripts/public-api.d.ts +80 -0
  297. package/package-dist/scripts/public-api.js +28 -0
  298. package/package-dist/scripts/runtime-entry.d.ts +23 -0
  299. package/package-dist/scripts/runtime-entry.js +424 -0
  300. package/package.json +93 -0
  301. package/specs/canonical-support/flow-properties-unit-groups.json +2692 -0
  302. package/specs/import-profiles.json +118 -0
  303. package/specs/prewrite-content-policy.json +105 -0
  304. package/specs/schemas/authorization-derivation.schema.json +34 -0
  305. package/specs/schemas/execution-context.schema.json +68 -0
  306. package/specs/schemas/foundry-authorization-input.schema.json +120 -0
  307. package/specs/schemas/foundry-facade-request-index.schema.json +78 -0
  308. package/specs/schemas/foundry-managed-runtime.schema.json +122 -0
  309. package/specs/schemas/foundry-migration-activation.schema.json +213 -0
  310. package/specs/schemas/foundry-migration-adoption-plan.schema.json +548 -0
  311. package/specs/schemas/foundry-migration-transfer-receipt.schema.json +93 -0
  312. package/specs/schemas/foundry-operation-result.schema.json +147 -0
  313. package/specs/schemas/foundry-package-descriptor.schema.json +134 -0
  314. package/specs/schemas/foundry-runtime-selection.schema.json +59 -0
  315. package/specs/schemas/foundry-semantic-input.schema.json +36 -0
  316. package/specs/schemas/foundry-task-start.schema.json +123 -0
  317. package/specs/schemas/foundry-workspace-migration-pending.schema.json +17 -0
  318. package/specs/schemas/foundry-workspace-migration-plan.schema.json +59 -0
  319. package/specs/schemas/foundry-workspace-migration-transfer-plan.schema.json +357 -0
  320. package/specs/schemas/foundry-workspace-v2.schema.json +70 -0
  321. package/specs/schemas/runtime-qualification.schema.json +63 -0
  322. package/specs/schemas/task-authorization.schema.json +154 -0
  323. package/specs/schemas/tidas-runtime-expectation.schema.json +54 -0
@@ -0,0 +1,932 @@
1
+ function isJsonRecord(value) {
2
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3
+ }
4
+ function asJsonRecord(value) {
5
+ return isJsonRecord(value) ? value : {};
6
+ }
7
+ function nestedValue(value, ...keys) {
8
+ let current = value;
9
+ for (const key of keys) {
10
+ if (!isJsonRecord(current))
11
+ return undefined;
12
+ current = current[key];
13
+ }
14
+ return current;
15
+ }
16
+ export function createFullContextProofUtils({ asText, classificationDecisionUsedContextKinds, decisionCompletionStatus, decisionContextBundleSha256, ensureArray, fileExists, listImportProfiles, normalizedList, readJson, readJsonArtifactOption, readJsonLines, readText, repoRelativePath, resolveRepoPath, repoRoot, sha256Text, unique, }) {
17
+ function profileFullContextRequirement(profileId, datasetType) {
18
+ const listing = asJsonRecord(listImportProfiles({ repoRoot }));
19
+ const requestedProfileId = asText(profileId || listing.default_profile || "generic").toLowerCase();
20
+ const defaultProfileId = asText(listing.default_profile || "generic").toLowerCase();
21
+ const profiles = asJsonRecord(listing.profiles);
22
+ const profile = asJsonRecord(profiles[requestedProfileId] ?? profiles[defaultProfileId] ?? profiles.generic);
23
+ const requirement = asJsonRecord(profile.full_context_ai_completion);
24
+ if (requirement.required !== true)
25
+ return null;
26
+ const requiredDatasetTypes = normalizedList(requirement.dataset_types ?? requirement.datasetTypes).map((value) => value.toLowerCase());
27
+ const normalizedDatasetType = asText(datasetType).toLowerCase();
28
+ if (requiredDatasetTypes.length > 0 && !requiredDatasetTypes.includes(normalizedDatasetType)) {
29
+ return null;
30
+ }
31
+ return {
32
+ profile_id: profile?.id ?? requestedProfileId,
33
+ dataset_type: normalizedDatasetType || null,
34
+ required_context_kinds: normalizedList(requirement.required_context_kinds ?? requirement.requiredContextKinds),
35
+ required_context_file_patterns: normalizedList(requirement.required_context_file_patterns ?? requirement.requiredContextFilePatterns),
36
+ };
37
+ }
38
+ function taskProfileId(task) {
39
+ return asText(nestedValue(task, "meta", "profile") ??
40
+ nestedValue(task, "meta", "import_profile") ??
41
+ nestedValue(task, "meta", "importProfile") ??
42
+ nestedValue(task, "meta", "dataset_profile") ??
43
+ nestedValue(task, "meta", "datasetProfile"));
44
+ }
45
+ function taskDatasetType(task) {
46
+ return asText(nestedValue(task, "meta", "dataset_type") ?? nestedValue(task, "meta", "datasetType"));
47
+ }
48
+ function fullContextCount(counts, key) {
49
+ const value = Number(asJsonRecord(counts)[key] ?? 0);
50
+ return Number.isFinite(value) && value > 0 ? value : 0;
51
+ }
52
+ function normalizeProofRows(value) {
53
+ if (Array.isArray(value))
54
+ return value.filter(Boolean);
55
+ const record = asJsonRecord(value);
56
+ if (Array.isArray(record.decisions))
57
+ return record.decisions.filter(Boolean);
58
+ if (Array.isArray(record.rows))
59
+ return record.rows.filter(Boolean);
60
+ return value && typeof value === "object" ? [value] : [];
61
+ }
62
+ function readJsonOrJsonlRowsArtifact(value) {
63
+ const resolved = resolveRepoPath(value);
64
+ if (!resolved || !fileExists(resolved)) {
65
+ return { path: resolved, rows: [], error: "missing" };
66
+ }
67
+ try {
68
+ if (resolved.endsWith(".jsonl")) {
69
+ return { path: resolved, rows: readJsonLines(resolved), error: null };
70
+ }
71
+ return {
72
+ path: resolved,
73
+ rows: normalizeProofRows(readJson(resolved)),
74
+ error: null,
75
+ };
76
+ }
77
+ catch (error) {
78
+ return {
79
+ path: resolved,
80
+ rows: [],
81
+ error: error instanceof Error ? error.message : String(error),
82
+ };
83
+ }
84
+ }
85
+ const fullContextPatchResolutionModes = new Set([
86
+ "evidence_backed_completion",
87
+ "source_language_normalization",
88
+ "classification_decision",
89
+ "location_decision",
90
+ "source_trace_verified",
91
+ "deferred_to_common_other",
92
+ ]);
93
+ function patchEvidenceResolution(entry) {
94
+ return asJsonRecord(asJsonRecord(entry).resolution);
95
+ }
96
+ function patchEvidenceResolutionMode(entry) {
97
+ return asText(patchEvidenceResolution(entry).mode);
98
+ }
99
+ function patchEvidenceResolutionContextKinds(entry) {
100
+ return unique(normalizedList(patchEvidenceResolution(entry).used_context_kinds ??
101
+ patchEvidenceResolution(entry).usedContextKinds));
102
+ }
103
+ function readAuthoringPackageProofForFullContext({ packageRef, expectedSha256 = null, source = null, }) {
104
+ const packagePath = resolveRepoPath(packageRef);
105
+ const proof = {
106
+ source,
107
+ path: packageRef || null,
108
+ sha256: null,
109
+ expected_sha256: asText(expectedSha256) || null,
110
+ contract_context_files: [],
111
+ missing_context_files: [],
112
+ blockers: [],
113
+ };
114
+ if (!packageRef || !packagePath || !fileExists(packagePath)) {
115
+ proof.blockers.push({
116
+ code: "authoring_package_missing",
117
+ message: "Patch evidence references no readable full-context authoring package.",
118
+ authoring_package: packageRef || null,
119
+ source,
120
+ });
121
+ return proof;
122
+ }
123
+ proof.path = repoRelativePath(packagePath);
124
+ let payload = null;
125
+ try {
126
+ const rawText = readText(packagePath);
127
+ proof.sha256 = sha256Text(rawText);
128
+ payload = JSON.parse(rawText);
129
+ }
130
+ catch (error) {
131
+ proof.blockers.push({
132
+ code: "authoring_package_invalid",
133
+ message: error instanceof Error ? error.message : String(error),
134
+ authoring_package: proof.path,
135
+ source,
136
+ });
137
+ return proof;
138
+ }
139
+ const payloadRecord = asJsonRecord(payload);
140
+ proof.contract_context_files = ensureArray(payloadRecord.contract_context_files);
141
+ proof.missing_context_files = ensureArray(payloadRecord.missing_context_files);
142
+ if (proof.expected_sha256 && proof.expected_sha256 !== proof.sha256) {
143
+ proof.blockers.push({
144
+ code: "authoring_package_hash_mismatch",
145
+ message: "Recorded authoring_package_sha256 does not match the current authoring package content.",
146
+ authoring_package: proof.path,
147
+ expected_sha256: proof.expected_sha256,
148
+ actual_sha256: proof.sha256,
149
+ source,
150
+ });
151
+ }
152
+ return proof;
153
+ }
154
+ function authoringPackageProofsFromPatchCollect(patchCollectArtifact) {
155
+ const manifestRef = nestedValue(patchCollectArtifact?.value, "task_manifest");
156
+ const manifestArtifact = readJsonArtifactOption(manifestRef);
157
+ if (!manifestArtifact)
158
+ return [];
159
+ return ensureArray(nestedValue(manifestArtifact.value, "tasks"))
160
+ .map((taskValue) => {
161
+ const task = asJsonRecord(taskValue);
162
+ const packageRef = asText(nestedValue(task, "files", "authoring_package") ??
163
+ nestedValue(task, "files", "authoringPackage"));
164
+ if (!packageRef)
165
+ return null;
166
+ return readAuthoringPackageProofForFullContext({
167
+ packageRef,
168
+ expectedSha256: nestedValue(task, "context", "authoring_package_sha256"),
169
+ source: "patch_collect_task_manifest",
170
+ });
171
+ })
172
+ .filter((proof) => proof !== null);
173
+ }
174
+ function authoringPackageProofsFromCurationGate(mutationManifest) {
175
+ const manifest = asJsonRecord(mutationManifest);
176
+ const evidence = asJsonRecord(manifest.evidence);
177
+ const curationGateArtifact = readJsonArtifactOption(evidence.curation_gate_report);
178
+ if (!curationGateArtifact)
179
+ return [];
180
+ const entities = ensureArray(nestedValue(curationGateArtifact.value, "entities") ??
181
+ nestedValue(curationGateArtifact.value, "processes") ??
182
+ nestedValue(curationGateArtifact.value, "flows") ??
183
+ nestedValue(curationGateArtifact.value, "items"));
184
+ return entities
185
+ .map((entityValue) => {
186
+ const entity = asJsonRecord(entityValue);
187
+ const packageRef = asText(entity.authoring_package ?? entity.authoringPackage);
188
+ if (!packageRef)
189
+ return null;
190
+ return readAuthoringPackageProofForFullContext({
191
+ packageRef,
192
+ expectedSha256: entity?.authoring_package_sha256,
193
+ source: "curation_gate",
194
+ });
195
+ })
196
+ .filter((proof) => proof !== null);
197
+ }
198
+ function fullContextEvidenceArtifactBlocker({ prefix, codePrefix, suffix, message, details = {}, }) {
199
+ return {
200
+ ...prefix,
201
+ code: `${codePrefix}_full_context_${suffix}`,
202
+ message,
203
+ ...details,
204
+ };
205
+ }
206
+ function decisionApplyTasksFromReport(reportValue) {
207
+ const report = asJsonRecord(reportValue);
208
+ const tasks = ensureArray(report.decision_tasks ?? report.decisionTasks);
209
+ if (tasks.length > 0)
210
+ return tasks;
211
+ return report?.decision_task || report?.decisionTask
212
+ ? [report.decision_task ?? report.decisionTask]
213
+ : [];
214
+ }
215
+ function decisionTaskReferencePath(taskValue) {
216
+ const task = asJsonRecord(taskValue);
217
+ return asText(task.path ?? task.task ?? task.decision_task ?? task.decisionTask);
218
+ }
219
+ function readDecisionTaskArtifactForProof(taskValue) {
220
+ const task = asJsonRecord(taskValue);
221
+ const taskRef = decisionTaskReferencePath(task);
222
+ const artifact = readJsonArtifactOption(taskRef);
223
+ if (!artifact) {
224
+ return {
225
+ task_ref: taskRef || null,
226
+ artifact: null,
227
+ sha256: null,
228
+ context_bundle_sha256: null,
229
+ status: null,
230
+ task_kind: null,
231
+ blockers: [
232
+ {
233
+ code: "decision_task_missing",
234
+ message: "Decision apply report references an unreadable AI decision task.",
235
+ decision_task: taskRef || null,
236
+ },
237
+ ],
238
+ };
239
+ }
240
+ const rawText = readText(artifact.path);
241
+ const sha256 = sha256Text(rawText);
242
+ const artifactValue = asJsonRecord(artifact.value);
243
+ const contextBundle = asJsonRecord(artifactValue.context_bundle ?? artifactValue.authoring_context);
244
+ const expectedSha256 = asText(task?.sha256);
245
+ const expectedContextBundleSha256 = asText(task?.context_bundle_sha256 ?? task?.contextBundleSha256);
246
+ const contextBundleSha256 = asText(contextBundle.sha256 ?? contextBundle.context_bundle_sha256);
247
+ const blockers = [];
248
+ if (expectedSha256 && expectedSha256 !== sha256) {
249
+ blockers.push({
250
+ code: "decision_task_hash_mismatch",
251
+ message: "Decision apply report records a decision task sha256 that no longer matches the task file.",
252
+ decision_task: repoRelativePath(artifact.path),
253
+ expected_sha256: expectedSha256,
254
+ actual_sha256: sha256,
255
+ });
256
+ }
257
+ if (expectedContextBundleSha256 &&
258
+ contextBundleSha256 &&
259
+ expectedContextBundleSha256 !== contextBundleSha256) {
260
+ blockers.push({
261
+ code: "decision_task_context_bundle_hash_mismatch",
262
+ message: "Decision apply report records a context_bundle_sha256 that no longer matches the task file.",
263
+ decision_task: repoRelativePath(artifact.path),
264
+ expected_context_bundle_sha256: expectedContextBundleSha256,
265
+ actual_context_bundle_sha256: contextBundleSha256,
266
+ });
267
+ }
268
+ return {
269
+ task_ref: taskRef || null,
270
+ artifact,
271
+ sha256,
272
+ context_bundle_sha256: contextBundleSha256,
273
+ status: asText(artifactValue.status),
274
+ task_kind: asText(artifactValue.task_kind),
275
+ blockers,
276
+ };
277
+ }
278
+ function decisionApplyReportRefs(evidence, reportKey, kind) {
279
+ const values = kind === "identity"
280
+ ? [
281
+ ...ensureArray(evidence.identity_decision_apply_reports),
282
+ ...ensureArray(evidence[reportKey]),
283
+ ]
284
+ : ensureArray(evidence[reportKey]);
285
+ return unique(values.map((value) => asText(value)));
286
+ }
287
+ function buildDecisionApplyProofBlockers({ mutationArtifact, requirement, prefix, codePrefix, kind, expectedCount, }) {
288
+ if (expectedCount <= 0)
289
+ return [];
290
+ const blockers = [];
291
+ const mutationManifest = asJsonRecord(mutationArtifact.value);
292
+ const evidence = asJsonRecord(mutationManifest.evidence);
293
+ const reportKey = kind === "identity"
294
+ ? "identity_decision_apply_report"
295
+ : kind === "location"
296
+ ? "location_decision_apply_report"
297
+ : "classification_decision_apply_report";
298
+ const reportStatusKey = kind === "identity"
299
+ ? "identity_decision_apply_status"
300
+ : kind === "location"
301
+ ? "location_decision_apply_status"
302
+ : "classification_decision_apply_status";
303
+ const expectedTaskKind = kind === "location" ? "location_decision_authoring" : "classification_decision_authoring";
304
+ const expectedTaskStatus = kind === "location"
305
+ ? "ready_for_ai_location_decisions"
306
+ : "ready_for_ai_classification_decisions";
307
+ const reportRefs = decisionApplyReportRefs(evidence, reportKey, kind);
308
+ const reportArtifacts = reportRefs
309
+ .map((reportRef) => readJsonArtifactOption(reportRef))
310
+ .filter((artifact) => artifact !== null);
311
+ const reportArtifact = reportArtifacts[0] ?? null;
312
+ if (!reportArtifact) {
313
+ return [
314
+ fullContextEvidenceArtifactBlocker({
315
+ prefix,
316
+ codePrefix,
317
+ suffix: `${kind}_decision_apply_report_missing`,
318
+ message: "Mutation manifest full-context decision evidence references no readable decision apply report.",
319
+ details: {
320
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
321
+ expected_decision_entries: expectedCount,
322
+ report: evidence[reportKey] ?? null,
323
+ reports: reportRefs,
324
+ },
325
+ }),
326
+ ];
327
+ }
328
+ const report = asJsonRecord(reportArtifact.value);
329
+ for (const candidateReportArtifact of reportArtifacts) {
330
+ const candidateReportStatus = asText(asJsonRecord(candidateReportArtifact.value).status);
331
+ if (candidateReportStatus !== "completed") {
332
+ blockers.push(fullContextEvidenceArtifactBlocker({
333
+ prefix,
334
+ codePrefix,
335
+ suffix: `${kind}_decision_apply_not_completed`,
336
+ message: `Decision apply report status is ${candidateReportStatus || "missing"}.`,
337
+ details: { report: repoRelativePath(candidateReportArtifact.path) },
338
+ }));
339
+ }
340
+ if (asText(evidence[reportStatusKey]) &&
341
+ asText(evidence[reportStatusKey]) !== candidateReportStatus) {
342
+ blockers.push(fullContextEvidenceArtifactBlocker({
343
+ prefix,
344
+ codePrefix,
345
+ suffix: `${kind}_decision_apply_status_mismatch`,
346
+ message: "Mutation manifest recorded decision apply status does not match the current report.",
347
+ details: {
348
+ report: repoRelativePath(candidateReportArtifact.path),
349
+ manifest_status: asText(evidence[reportStatusKey]),
350
+ actual_status: candidateReportStatus || null,
351
+ },
352
+ }));
353
+ }
354
+ }
355
+ const decisionRows = [];
356
+ const decisionFiles = [];
357
+ for (const candidateReportArtifact of reportArtifacts) {
358
+ const candidateReport = asJsonRecord(candidateReportArtifact.value);
359
+ const decisionsRef = candidateReport.decisions_file ?? candidateReport.decisionsFile;
360
+ const decisionsArtifact = readJsonOrJsonlRowsArtifact(decisionsRef);
361
+ if (decisionsArtifact.error) {
362
+ blockers.push(fullContextEvidenceArtifactBlocker({
363
+ prefix,
364
+ codePrefix,
365
+ suffix: `${kind}_decision_file_unreadable`,
366
+ message: "Decision apply report must reference readable AI decision rows for closeout proof.",
367
+ details: {
368
+ report: repoRelativePath(candidateReportArtifact.path),
369
+ decisions_file: decisionsRef ?? null,
370
+ error: decisionsArtifact.error,
371
+ },
372
+ }));
373
+ }
374
+ else {
375
+ decisionRows.push(...decisionsArtifact.rows);
376
+ decisionFiles.push(repoRelativePath(decisionsArtifact.path));
377
+ }
378
+ }
379
+ const decisionsArtifact = { rows: decisionRows };
380
+ if (decisionsArtifact.rows.length < expectedCount) {
381
+ blockers.push(fullContextEvidenceArtifactBlocker({
382
+ prefix,
383
+ codePrefix,
384
+ suffix: `${kind}_decision_count_incomplete`,
385
+ message: "Decision rows referenced by the apply report are fewer than the mutation manifest semantic evidence count.",
386
+ details: {
387
+ report: repoRelativePath(reportArtifact.path),
388
+ reports: reportArtifacts.map((artifact) => repoRelativePath(artifact.path)),
389
+ decisions_files: decisionFiles,
390
+ expected_decision_entries: expectedCount,
391
+ actual_decision_entries: decisionsArtifact.rows.length,
392
+ },
393
+ }));
394
+ }
395
+ const taskProofs = kind === "identity"
396
+ ? []
397
+ : decisionApplyTasksFromReport(report).map((task) => readDecisionTaskArtifactForProof(task));
398
+ if (kind !== "identity" && taskProofs.length === 0) {
399
+ blockers.push(fullContextEvidenceArtifactBlocker({
400
+ prefix,
401
+ codePrefix,
402
+ suffix: `${kind}_decision_task_missing`,
403
+ message: "Decision apply report must bind full-context AI decisions to the decision task context bundle.",
404
+ details: { report: repoRelativePath(reportArtifact.path) },
405
+ }));
406
+ }
407
+ for (const taskProof of taskProofs) {
408
+ for (const blocker of taskProof.blockers) {
409
+ blockers.push(fullContextEvidenceArtifactBlocker({
410
+ prefix,
411
+ codePrefix,
412
+ suffix: `${kind}_${blocker.code}`,
413
+ message: blocker.message,
414
+ details: {
415
+ ...blocker,
416
+ report: repoRelativePath(reportArtifact.path),
417
+ },
418
+ }));
419
+ }
420
+ if (taskProof.artifact && taskProof.task_kind !== expectedTaskKind) {
421
+ blockers.push(fullContextEvidenceArtifactBlocker({
422
+ prefix,
423
+ codePrefix,
424
+ suffix: `${kind}_decision_task_kind_invalid`,
425
+ message: "Decision apply report references a decision task with the wrong task kind.",
426
+ details: {
427
+ report: repoRelativePath(reportArtifact.path),
428
+ decision_task: repoRelativePath(taskProof.artifact.path),
429
+ expected_task_kind: expectedTaskKind,
430
+ actual_task_kind: taskProof.task_kind || null,
431
+ },
432
+ }));
433
+ }
434
+ if (taskProof.artifact && taskProof.status !== expectedTaskStatus) {
435
+ blockers.push(fullContextEvidenceArtifactBlocker({
436
+ prefix,
437
+ codePrefix,
438
+ suffix: `${kind}_decision_task_status_invalid`,
439
+ message: "Decision apply report references a decision task that is no longer ready for AI decisions.",
440
+ details: {
441
+ report: repoRelativePath(reportArtifact.path),
442
+ decision_task: repoRelativePath(taskProof.artifact.path),
443
+ expected_status: expectedTaskStatus,
444
+ actual_status: taskProof.status || null,
445
+ },
446
+ }));
447
+ }
448
+ if (taskProof.artifact && !taskProof.context_bundle_sha256) {
449
+ blockers.push(fullContextEvidenceArtifactBlocker({
450
+ prefix,
451
+ codePrefix,
452
+ suffix: `${kind}_decision_task_context_bundle_missing`,
453
+ message: "Decision task must still carry context_bundle.sha256 for closeout proof.",
454
+ details: {
455
+ report: repoRelativePath(reportArtifact.path),
456
+ decision_task: repoRelativePath(taskProof.artifact.path),
457
+ },
458
+ }));
459
+ }
460
+ }
461
+ const contextBundleHashes = unique(taskProofs.map((proof) => proof.context_bundle_sha256));
462
+ const missingCompletedStatus = decisionsArtifact.rows.filter((decision) => decisionCompletionStatus(decision) !== "completed");
463
+ if (missingCompletedStatus.length > 0) {
464
+ blockers.push(fullContextEvidenceArtifactBlocker({
465
+ prefix,
466
+ codePrefix,
467
+ suffix: `${kind}_decision_status_not_completed`,
468
+ message: "Every AI decision retained as full-context proof must still declare decision_status=completed.",
469
+ details: {
470
+ report: repoRelativePath(reportArtifact.path),
471
+ count: missingCompletedStatus.length,
472
+ },
473
+ }));
474
+ }
475
+ const missingEvidence = decisionsArtifact.rows.filter((decision) => {
476
+ const evidenceValue = asJsonRecord(decision).evidence;
477
+ return !evidenceValue || typeof evidenceValue !== "object";
478
+ });
479
+ if (missingEvidence.length > 0) {
480
+ blockers.push(fullContextEvidenceArtifactBlocker({
481
+ prefix,
482
+ codePrefix,
483
+ suffix: `${kind}_decision_evidence_missing`,
484
+ message: "Every AI decision retained as full-context proof must still include structured evidence.",
485
+ details: {
486
+ report: repoRelativePath(reportArtifact.path),
487
+ count: missingEvidence.length,
488
+ },
489
+ }));
490
+ }
491
+ if (contextBundleHashes.length > 0) {
492
+ const mismatchedContext = decisionsArtifact.rows.filter((decision) => {
493
+ const hash = decisionContextBundleSha256(decision);
494
+ return !hash || !contextBundleHashes.includes(hash);
495
+ });
496
+ if (mismatchedContext.length > 0) {
497
+ blockers.push(fullContextEvidenceArtifactBlocker({
498
+ prefix,
499
+ codePrefix,
500
+ suffix: `${kind}_decision_context_bundle_mismatch`,
501
+ message: "Every AI decision retained as full-context proof must still reference the bound decision task context bundle.",
502
+ details: {
503
+ report: repoRelativePath(reportArtifact.path),
504
+ count: mismatchedContext.length,
505
+ expected_context_bundle_sha256_any_of: contextBundleHashes,
506
+ },
507
+ }));
508
+ }
509
+ }
510
+ const missingContextKinds = [];
511
+ for (const decision of decisionsArtifact.rows) {
512
+ const usedKinds = new Set(classificationDecisionUsedContextKinds(decision));
513
+ for (const requiredKind of requirement?.required_context_kinds ?? []) {
514
+ if (!usedKinds.has(requiredKind)) {
515
+ missingContextKinds.push({ decision, requiredKind });
516
+ }
517
+ }
518
+ }
519
+ if (missingContextKinds.length > 0) {
520
+ blockers.push(fullContextEvidenceArtifactBlocker({
521
+ prefix,
522
+ codePrefix,
523
+ suffix: `${kind}_decision_context_missing`,
524
+ message: "Every AI decision retained as full-context proof must still list all required used_context_kinds.",
525
+ details: {
526
+ report: repoRelativePath(reportArtifact.path),
527
+ count: missingContextKinds.length,
528
+ required_context_kinds: requirement?.required_context_kinds ?? [],
529
+ },
530
+ }));
531
+ }
532
+ return blockers;
533
+ }
534
+ function buildPatchApplyProofBlockers({ mutationArtifact, requirement, prefix, codePrefix, expectedCount, }) {
535
+ if (expectedCount <= 0)
536
+ return [];
537
+ const blockers = [];
538
+ const mutationManifest = asJsonRecord(mutationArtifact.value);
539
+ const evidence = asJsonRecord(mutationManifest.evidence);
540
+ const patchCollectArtifact = readJsonArtifactOption(evidence.patch_collect_report);
541
+ if (!patchCollectArtifact) {
542
+ blockers.push(fullContextEvidenceArtifactBlocker({
543
+ prefix,
544
+ codePrefix,
545
+ suffix: "patch_collect_report_missing",
546
+ message: "Mutation manifest full-context patch evidence references no readable patch collect report.",
547
+ details: {
548
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
549
+ report: evidence.patch_collect_report ?? null,
550
+ },
551
+ }));
552
+ }
553
+ else if (asJsonRecord(patchCollectArtifact.value).status !== "ready_for_patch_apply") {
554
+ blockers.push(fullContextEvidenceArtifactBlocker({
555
+ prefix,
556
+ codePrefix,
557
+ suffix: "patch_collect_not_ready",
558
+ message: `Patch collect report status is ${asJsonRecord(patchCollectArtifact.value).status ?? "missing"}.`,
559
+ details: { report: repoRelativePath(patchCollectArtifact.path) },
560
+ }));
561
+ }
562
+ const authoringPackageProofs = [
563
+ ...authoringPackageProofsFromPatchCollect(patchCollectArtifact),
564
+ ...authoringPackageProofsFromCurationGate(mutationManifest),
565
+ ];
566
+ for (const proof of authoringPackageProofs) {
567
+ for (const blocker of proof.blockers) {
568
+ blockers.push(fullContextEvidenceArtifactBlocker({
569
+ prefix,
570
+ codePrefix,
571
+ suffix: `patch_${blocker.code}`,
572
+ message: blocker.message,
573
+ details: blocker,
574
+ }));
575
+ }
576
+ }
577
+ const patchApplyArtifact = readJsonArtifactOption(evidence.patch_apply_report);
578
+ if (!patchApplyArtifact) {
579
+ blockers.push(fullContextEvidenceArtifactBlocker({
580
+ prefix,
581
+ codePrefix,
582
+ suffix: "patch_apply_report_missing",
583
+ message: "Mutation manifest full-context patch evidence references no readable patch apply report.",
584
+ details: {
585
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
586
+ report: evidence.patch_apply_report ?? null,
587
+ },
588
+ }));
589
+ return blockers;
590
+ }
591
+ const patchApplyReport = asJsonRecord(patchApplyArtifact.value);
592
+ if (patchApplyReport.status !== "completed") {
593
+ blockers.push(fullContextEvidenceArtifactBlocker({
594
+ prefix,
595
+ codePrefix,
596
+ suffix: "patch_apply_not_completed",
597
+ message: `Patch apply report status is ${patchApplyReport.status ?? "missing"}.`,
598
+ details: { report: repoRelativePath(patchApplyArtifact.path) },
599
+ }));
600
+ }
601
+ const patchEvidenceFile = evidence.patch_evidence_file ?? nestedValue(patchApplyReport, "files", "patch_evidence");
602
+ const patchEvidenceArtifact = readJsonOrJsonlRowsArtifact(patchEvidenceFile);
603
+ if (patchEvidenceArtifact.error) {
604
+ blockers.push(fullContextEvidenceArtifactBlocker({
605
+ prefix,
606
+ codePrefix,
607
+ suffix: "patch_evidence_file_unreadable",
608
+ message: "Patch apply report must retain readable AI patch evidence rows for closeout proof.",
609
+ details: {
610
+ report: repoRelativePath(patchApplyArtifact.path),
611
+ patch_evidence_file: patchEvidenceFile ?? null,
612
+ error: patchEvidenceArtifact.error,
613
+ },
614
+ }));
615
+ }
616
+ else if (patchEvidenceArtifact.rows.length < expectedCount) {
617
+ blockers.push(fullContextEvidenceArtifactBlocker({
618
+ prefix,
619
+ codePrefix,
620
+ suffix: "patch_evidence_count_incomplete",
621
+ message: "Patch evidence rows are fewer than the mutation manifest AI patch evidence count.",
622
+ details: {
623
+ report: repoRelativePath(patchApplyArtifact.path),
624
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
625
+ expected_patch_evidence_entries: expectedCount,
626
+ actual_patch_evidence_entries: patchEvidenceArtifact.rows.length,
627
+ },
628
+ }));
629
+ }
630
+ if (!patchEvidenceArtifact.error) {
631
+ const patchEvidenceRows = patchEvidenceArtifact.rows;
632
+ const missingPackageHash = patchEvidenceRows.filter((entry) => !asText(asJsonRecord(entry).authoring_package_sha256));
633
+ if (missingPackageHash.length > 0) {
634
+ blockers.push(fullContextEvidenceArtifactBlocker({
635
+ prefix,
636
+ codePrefix,
637
+ suffix: "patch_package_hash_missing",
638
+ message: "Every retained AI patch evidence row must still include authoring_package_sha256.",
639
+ details: {
640
+ report: repoRelativePath(patchApplyArtifact.path),
641
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
642
+ count: missingPackageHash.length,
643
+ },
644
+ }));
645
+ }
646
+ const knownPackageHashes = new Set(authoringPackageProofs.map((proof) => asText(proof.sha256)).filter(Boolean));
647
+ const unknownPackageHash = patchEvidenceRows.filter((entry) => {
648
+ const hash = asText(asJsonRecord(entry).authoring_package_sha256);
649
+ return hash && !knownPackageHashes.has(hash);
650
+ });
651
+ if (unknownPackageHash.length > 0) {
652
+ blockers.push(fullContextEvidenceArtifactBlocker({
653
+ prefix,
654
+ codePrefix,
655
+ suffix: "patch_package_hash_unknown",
656
+ message: "Every retained AI patch evidence authoring_package_sha256 must match a readable full-context authoring package from patch collect or curation gate evidence.",
657
+ details: {
658
+ report: repoRelativePath(patchApplyArtifact.path),
659
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
660
+ count: unknownPackageHash.length,
661
+ },
662
+ }));
663
+ }
664
+ const missingClosures = patchEvidenceRows.filter((entry) => ensureArray(asJsonRecord(entry).closes_action_items).length === 0);
665
+ if (missingClosures.length > 0) {
666
+ blockers.push(fullContextEvidenceArtifactBlocker({
667
+ prefix,
668
+ codePrefix,
669
+ suffix: "patch_action_closure_missing",
670
+ message: "Every retained AI patch evidence row must still close at least one authoring action item.",
671
+ details: {
672
+ report: repoRelativePath(patchApplyArtifact.path),
673
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
674
+ count: missingClosures.length,
675
+ },
676
+ }));
677
+ }
678
+ const missingEvidence = patchEvidenceRows.filter((entry) => {
679
+ const evidenceValue = asJsonRecord(entry).evidence;
680
+ return !evidenceValue || typeof evidenceValue !== "object";
681
+ });
682
+ if (missingEvidence.length > 0) {
683
+ blockers.push(fullContextEvidenceArtifactBlocker({
684
+ prefix,
685
+ codePrefix,
686
+ suffix: "patch_evidence_missing",
687
+ message: "Every retained AI patch evidence row must still include structured evidence.",
688
+ details: {
689
+ report: repoRelativePath(patchApplyArtifact.path),
690
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
691
+ count: missingEvidence.length,
692
+ },
693
+ }));
694
+ }
695
+ const missingResolution = patchEvidenceRows.filter((entry) => !patchEvidenceResolutionMode(entry));
696
+ if (missingResolution.length > 0) {
697
+ blockers.push(fullContextEvidenceArtifactBlocker({
698
+ prefix,
699
+ codePrefix,
700
+ suffix: "patch_resolution_missing",
701
+ message: "Every retained AI patch evidence row must still include resolution.mode.",
702
+ details: {
703
+ report: repoRelativePath(patchApplyArtifact.path),
704
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
705
+ count: missingResolution.length,
706
+ },
707
+ }));
708
+ }
709
+ const invalidResolutionMode = patchEvidenceRows.filter((entry) => {
710
+ const mode = patchEvidenceResolutionMode(entry);
711
+ return mode && !fullContextPatchResolutionModes.has(mode);
712
+ });
713
+ if (invalidResolutionMode.length > 0) {
714
+ blockers.push(fullContextEvidenceArtifactBlocker({
715
+ prefix,
716
+ codePrefix,
717
+ suffix: "patch_resolution_mode_invalid",
718
+ message: "Retained AI patch evidence contains unsupported resolution.mode values.",
719
+ details: {
720
+ report: repoRelativePath(patchApplyArtifact.path),
721
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
722
+ count: invalidResolutionMode.length,
723
+ },
724
+ }));
725
+ }
726
+ const missingContextKinds = [];
727
+ for (const entry of patchEvidenceRows) {
728
+ const usedKinds = new Set(patchEvidenceResolutionContextKinds(entry));
729
+ for (const requiredKind of requirement?.required_context_kinds ?? []) {
730
+ if (!usedKinds.has(requiredKind)) {
731
+ missingContextKinds.push({ entry, requiredKind });
732
+ }
733
+ }
734
+ }
735
+ if (missingContextKinds.length > 0) {
736
+ blockers.push(fullContextEvidenceArtifactBlocker({
737
+ prefix,
738
+ codePrefix,
739
+ suffix: "patch_resolution_context_missing",
740
+ message: "Retained AI patch evidence resolution.used_context_kinds must still include every required full-context kind.",
741
+ details: {
742
+ report: repoRelativePath(patchApplyArtifact.path),
743
+ patch_evidence_file: repoRelativePath(patchEvidenceArtifact.path),
744
+ count: missingContextKinds.length,
745
+ required_context_kinds: requirement?.required_context_kinds ?? [],
746
+ },
747
+ }));
748
+ }
749
+ }
750
+ return blockers;
751
+ }
752
+ function fullContextEvidenceArtifactBlockers({ mutationArtifact, requirement, prefix, codePrefix, }) {
753
+ const mutationManifest = asJsonRecord(mutationArtifact.value);
754
+ const evidence = asJsonRecord(mutationManifest.evidence);
755
+ if (!evidence.full_context_ai_completion_required) {
756
+ return [];
757
+ }
758
+ const counts = mutationManifest.counts ?? {};
759
+ return [
760
+ ...buildPatchApplyProofBlockers({
761
+ mutationArtifact,
762
+ requirement,
763
+ prefix,
764
+ codePrefix,
765
+ expectedCount: fullContextCount(counts, "ai_patch_evidence_entries"),
766
+ }),
767
+ ...buildDecisionApplyProofBlockers({
768
+ mutationArtifact,
769
+ requirement,
770
+ prefix,
771
+ codePrefix,
772
+ kind: "classification",
773
+ expectedCount: fullContextCount(counts, "ai_classification_decision_entries"),
774
+ }),
775
+ ...buildDecisionApplyProofBlockers({
776
+ mutationArtifact,
777
+ requirement,
778
+ prefix,
779
+ codePrefix,
780
+ kind: "location",
781
+ expectedCount: fullContextCount(counts, "ai_location_decision_entries"),
782
+ }),
783
+ ...buildDecisionApplyProofBlockers({
784
+ mutationArtifact,
785
+ requirement,
786
+ prefix,
787
+ codePrefix,
788
+ kind: "identity",
789
+ expectedCount: fullContextCount(counts, "ai_identity_decision_entries"),
790
+ }),
791
+ ];
792
+ }
793
+ function fullContextProofCheck({ prefix = {}, profileId, datasetType, closeoutCounts = null, mutationArtifact = null, codePrefix = "completion", }) {
794
+ const mutationManifest = mutationArtifact ? asJsonRecord(mutationArtifact.value) : null;
795
+ const mutationEvidence = asJsonRecord(mutationManifest?.evidence);
796
+ const profileRequirement = profileId
797
+ ? profileFullContextRequirement(profileId, datasetType)
798
+ : null;
799
+ const mutationMarkedRequired = mutationEvidence.full_context_ai_completion_required === true;
800
+ if (!profileRequirement && !mutationMarkedRequired) {
801
+ return { required: false, blockers: [] };
802
+ }
803
+ const blockerPrefix = {
804
+ ...prefix,
805
+ profile: profileRequirement?.profile_id ?? (asText(profileId) || null),
806
+ dataset_type: profileRequirement?.dataset_type ?? (asText(datasetType).toLowerCase() || null),
807
+ };
808
+ const semanticEvidenceCount = (countsValue) => {
809
+ const counts = asJsonRecord(countsValue);
810
+ return ((Number(counts.ai_patch_evidence_entries ?? 0) || 0) +
811
+ (Number(counts.ai_classification_decision_entries ?? 0) || 0) +
812
+ (Number(counts.ai_location_decision_entries ?? 0) || 0) +
813
+ (Number(counts.ai_identity_decision_entries ?? 0) || 0) +
814
+ (Number(counts.source_contact_rewrite_semantic_evidence_entries ?? 0) || 0));
815
+ };
816
+ const blockers = [];
817
+ if (closeoutCounts) {
818
+ const closeoutCountRecord = asJsonRecord(closeoutCounts);
819
+ if (closeoutCountRecord.full_context_ai_completion_required !== true) {
820
+ blockers.push({
821
+ ...blockerPrefix,
822
+ code: `${codePrefix}_full_context_scope_missing`,
823
+ message: "This committed scope belongs to a profile or manifest that requires full schema/YAML/context AI completion, but the closeout does not mark the scope as full-context completed.",
824
+ });
825
+ }
826
+ if (semanticEvidenceCount(closeoutCountRecord) <= 0) {
827
+ blockers.push({
828
+ ...blockerPrefix,
829
+ code: `${codePrefix}_full_context_semantic_evidence_missing`,
830
+ message: "Full-context AI completion requires at least one AI patch evidence, AI identity decision, AI classification decision, or AI location decision entry.",
831
+ });
832
+ }
833
+ }
834
+ if (!mutationArtifact) {
835
+ blockers.push({
836
+ ...blockerPrefix,
837
+ code: `${codePrefix}_full_context_mutation_manifest_missing`,
838
+ message: "Full-context completion requires a readable mutation manifest.",
839
+ });
840
+ return { required: true, blockers };
841
+ }
842
+ if (mutationEvidence.full_context_ai_completion_required !== true) {
843
+ blockers.push({
844
+ ...blockerPrefix,
845
+ code: `${codePrefix}_full_context_mutation_requirement_missing`,
846
+ message: "Mutation manifest does not prove that full-context AI completion was required.",
847
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
848
+ });
849
+ }
850
+ if (!mutationEvidence.full_context_ai_completion_proof) {
851
+ blockers.push({
852
+ ...blockerPrefix,
853
+ code: `${codePrefix}_full_context_mutation_proof_missing`,
854
+ message: "Mutation manifest does not carry the full-context AI completion proof snapshot.",
855
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
856
+ });
857
+ }
858
+ if (semanticEvidenceCount(mutationManifest?.counts ?? {}) <= 0) {
859
+ blockers.push({
860
+ ...blockerPrefix,
861
+ code: `${codePrefix}_full_context_mutation_semantic_evidence_missing`,
862
+ message: "Mutation manifest has no AI patch evidence, AI identity decision, AI classification decision, or AI location decision entries for the full-context scope.",
863
+ mutation_manifest: repoRelativePath(mutationArtifact.path),
864
+ });
865
+ }
866
+ blockers.push(...fullContextEvidenceArtifactBlockers({
867
+ mutationArtifact,
868
+ requirement: profileRequirement,
869
+ prefix: blockerPrefix,
870
+ codePrefix,
871
+ }));
872
+ return { required: true, blockers };
873
+ }
874
+ function completionFullContextBlockers({ task, completionReport, }) {
875
+ const blockers = [];
876
+ const completion = asJsonRecord(completionReport);
877
+ const closeouts = ensureArray(completion.closeouts).filter(isJsonRecord);
878
+ const taskProfile = taskProfileId(task);
879
+ const taskType = taskDatasetType(task);
880
+ const taskRequirement = taskProfile
881
+ ? profileFullContextRequirement(taskProfile, taskType)
882
+ : null;
883
+ let requiredCloseoutCount = 0;
884
+ if (taskRequirement && closeouts.length === 0) {
885
+ blockers.push({
886
+ code: "completion_full_context_closeout_missing",
887
+ message: "Task profile requires full schema/YAML/context AI completion, but the completion report has no closeout scope.",
888
+ profile: taskRequirement.profile_id,
889
+ dataset_type: taskRequirement.dataset_type,
890
+ });
891
+ }
892
+ closeouts.forEach((closeout, index) => {
893
+ const profileId = asText(closeout.profile) || taskProfile;
894
+ const datasetType = asText(closeout.dataset_type) || taskType;
895
+ const mutationArtifact = readJsonArtifactOption(closeout.mutation_manifest);
896
+ const fullContextCheck = fullContextProofCheck({
897
+ prefix: {
898
+ closeout_index: index,
899
+ closeout_report: closeout.closeout_report ?? null,
900
+ },
901
+ profileId,
902
+ datasetType,
903
+ closeoutCounts: closeout.counts ?? {},
904
+ mutationArtifact,
905
+ codePrefix: "completion",
906
+ });
907
+ if (!fullContextCheck.required)
908
+ return;
909
+ requiredCloseoutCount += 1;
910
+ blockers.push(...fullContextCheck.blockers.map((blocker) => ({
911
+ ...blocker,
912
+ closeout_index: index,
913
+ closeout_report: closeout.closeout_report ?? null,
914
+ })));
915
+ });
916
+ const reportFullContextScopes = Number(nestedValue(completion, "counts", "full_context_scopes") ?? 0);
917
+ if (requiredCloseoutCount > 0 && reportFullContextScopes < requiredCloseoutCount) {
918
+ blockers.push({
919
+ code: "completion_full_context_scope_count_incomplete",
920
+ message: "Completion report full_context_scopes does not cover every profile-required full-context closeout scope.",
921
+ expected_minimum: requiredCloseoutCount,
922
+ actual: Number.isFinite(reportFullContextScopes) ? reportFullContextScopes : 0,
923
+ });
924
+ }
925
+ return blockers;
926
+ }
927
+ return {
928
+ completionFullContextBlockers,
929
+ fullContextProofCheck,
930
+ profileFullContextRequirement,
931
+ };
932
+ }