@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,24 @@
1
+ interface JsonRecord {
2
+ [key: string]: unknown;
3
+ }
4
+ export interface FlowDryRunArtifactMaps {
5
+ success: Map<string, JsonRecord>;
6
+ failures: Map<string, JsonRecord>;
7
+ }
8
+ export interface ProgressDryRunArtifactMaps {
9
+ prepared: Map<string, JsonRecord>;
10
+ failures: Map<string, JsonRecord>;
11
+ }
12
+ interface RemoteVerifyBlockerOptions {
13
+ plannedRootKeys?: Set<string>;
14
+ plannedRootIds?: Set<string>;
15
+ }
16
+ export declare function mapSchemaRows(schemaReport: unknown): Map<string, JsonRecord>;
17
+ export declare function mapCurationEntities(curationGateReport: unknown): Map<string, JsonRecord>;
18
+ export declare function normalizeDryRunOperation(operation: unknown): unknown;
19
+ export declare function readFlowDryRunArtifacts(repoRoot: string, dryRunReport: unknown): FlowDryRunArtifactMaps;
20
+ export declare function readProcessDryRunArtifacts(repoRoot: string, dryRunReport: unknown): ProgressDryRunArtifactMaps;
21
+ export declare function readLifecyclemodelDryRunArtifacts(repoRoot: string, dryRunReport: unknown): ProgressDryRunArtifactMaps;
22
+ export declare function readDatasetSaveDraftDryRunArtifacts(repoRoot: string, dryRunReport: unknown): ProgressDryRunArtifactMaps;
23
+ export declare function remoteVerifyBlockerKeys(remoteVerifyReport: unknown, options?: RemoteVerifyBlockerOptions): Set<string>;
24
+ export {};
@@ -0,0 +1,191 @@
1
+ import { curationEntityId, datasetIdentity, identityKey } from "./dataset-payload.js";
2
+ import { asText, ensureArray, resolveRepoPath } from "./runtime-io.js";
3
+ import { readJsonLines, readRowsIfExists } from "./workflow-patch-collect.js";
4
+ function referenceKey({ table, id, version }) {
5
+ return [asText(table), asText(id), asText(version)].join("\u0000");
6
+ }
7
+ export function mapSchemaRows(schemaReport) {
8
+ const report = schemaReport;
9
+ const map = new Map();
10
+ for (const row of ensureArray(report?.rows)) {
11
+ const record = row;
12
+ const id = asText(record?.id ?? record?.dataset_id);
13
+ const version = asText(record?.version) || "00.00.001";
14
+ if (!id)
15
+ continue;
16
+ map.set(`${id}@@${version}`, record);
17
+ if (!map.has(id))
18
+ map.set(id, record);
19
+ }
20
+ return map;
21
+ }
22
+ export function mapCurationEntities(curationGateReport) {
23
+ const report = curationGateReport;
24
+ const map = new Map();
25
+ for (const entity of ensureArray(report?.entities ?? report?.processes)) {
26
+ const record = entity;
27
+ const id = curationEntityId(entity);
28
+ const version = asText(record?.version) || "00.00.001";
29
+ if (!id)
30
+ continue;
31
+ map.set(`${id}@@${version}`, record);
32
+ if (!map.has(id))
33
+ map.set(id, record);
34
+ }
35
+ return map;
36
+ }
37
+ export function normalizeDryRunOperation(operation) {
38
+ switch (operation) {
39
+ case "would_update_existing":
40
+ return "update_existing";
41
+ case "would_insert":
42
+ return "insert";
43
+ case "would_skip":
44
+ return "skip";
45
+ default:
46
+ return operation || null;
47
+ }
48
+ }
49
+ export function readFlowDryRunArtifacts(repoRoot, dryRunReport) {
50
+ const report = dryRunReport;
51
+ const files = report?.files;
52
+ const successFile = resolveRepoPath(repoRoot, files?.success_list);
53
+ const failureFile = resolveRepoPath(repoRoot, files?.remote_failed);
54
+ const success = new Map();
55
+ const failures = new Map();
56
+ for (const row of readRowsIfExists(successFile)) {
57
+ const record = row;
58
+ const id = asText(record?.id);
59
+ const version = asText(record?.version) || "00.00.001";
60
+ if (id)
61
+ success.set(`${id}@@${version}`, record);
62
+ }
63
+ for (const row of readJsonLines(failureFile)) {
64
+ const record = row;
65
+ const payload = record?.json_ordered ?? record?.jsonOrdered ?? record?.json ?? record?.payload ?? row;
66
+ const identity = datasetIdentity(payload, 0, "flow");
67
+ failures.set(identityKey(identity), record);
68
+ }
69
+ return { success, failures };
70
+ }
71
+ export function readProcessDryRunArtifacts(repoRoot, dryRunReport) {
72
+ const report = dryRunReport;
73
+ const files = report?.files;
74
+ const progressFile = resolveRepoPath(repoRoot, files?.progress_jsonl);
75
+ const failuresFile = resolveRepoPath(repoRoot, files?.failures_jsonl);
76
+ const prepared = new Map();
77
+ const failures = new Map();
78
+ for (const row of readJsonLines(progressFile)) {
79
+ const record = row;
80
+ const id = asText(record?.id);
81
+ const version = asText(record?.version) || "00.00.001";
82
+ if (!id)
83
+ continue;
84
+ if (record?.status === "prepared") {
85
+ prepared.set(`${id}@@${version}`, record);
86
+ }
87
+ else {
88
+ failures.set(`${id}@@${version}`, record);
89
+ }
90
+ }
91
+ for (const row of readJsonLines(failuresFile)) {
92
+ const record = row;
93
+ const id = asText(record?.id);
94
+ const version = asText(record?.version) || "00.00.001";
95
+ if (id)
96
+ failures.set(`${id}@@${version}`, record);
97
+ }
98
+ return { prepared, failures };
99
+ }
100
+ export function readLifecyclemodelDryRunArtifacts(repoRoot, dryRunReport) {
101
+ const report = dryRunReport;
102
+ const files = report?.files;
103
+ const progressFile = resolveRepoPath(repoRoot, files?.progress_jsonl);
104
+ const failuresFile = resolveRepoPath(repoRoot, files?.failures_jsonl);
105
+ const prepared = new Map();
106
+ const failures = new Map();
107
+ for (const row of readJsonLines(progressFile)) {
108
+ const record = row;
109
+ const id = asText(record?.id);
110
+ const version = asText(record?.version) || "00.00.001";
111
+ if (!id)
112
+ continue;
113
+ if (record?.status === "prepared") {
114
+ prepared.set(`${id}@@${version}`, record);
115
+ }
116
+ else {
117
+ failures.set(`${id}@@${version}`, record);
118
+ }
119
+ }
120
+ for (const row of readJsonLines(failuresFile)) {
121
+ const record = row;
122
+ const id = asText(record?.id);
123
+ const version = asText(record?.version) || "00.00.001";
124
+ if (id)
125
+ failures.set(`${id}@@${version}`, record);
126
+ }
127
+ return { prepared, failures };
128
+ }
129
+ export function readDatasetSaveDraftDryRunArtifacts(repoRoot, dryRunReport) {
130
+ const report = dryRunReport;
131
+ const files = report?.files;
132
+ const progressFile = resolveRepoPath(repoRoot, files?.progress_jsonl);
133
+ const failuresFile = resolveRepoPath(repoRoot, files?.failures_jsonl);
134
+ const prepared = new Map();
135
+ const failures = new Map();
136
+ for (const row of readJsonLines(progressFile)) {
137
+ const record = row;
138
+ const id = asText(record?.id);
139
+ const version = asText(record?.version) || "00.00.001";
140
+ if (!id)
141
+ continue;
142
+ if (record?.status === "prepared") {
143
+ prepared.set(`${id}@@${version}`, record);
144
+ }
145
+ else {
146
+ failures.set(`${id}@@${version}`, record);
147
+ }
148
+ }
149
+ for (const row of readJsonLines(failuresFile)) {
150
+ const record = row;
151
+ const id = asText(record?.id);
152
+ const version = asText(record?.version) || "00.00.001";
153
+ if (id)
154
+ failures.set(`${id}@@${version}`, record);
155
+ }
156
+ return { prepared, failures };
157
+ }
158
+ export function remoteVerifyBlockerKeys(remoteVerifyReport, options = {}) {
159
+ const report = remoteVerifyReport;
160
+ const plannedRootKeys = options.plannedRootKeys ?? new Set();
161
+ const plannedRootIds = options.plannedRootIds ?? new Set();
162
+ const keys = new Set();
163
+ for (const blocker of ensureArray(report?.blockers)) {
164
+ const record = blocker;
165
+ const role = asText(record?.role);
166
+ const table = asText(record?.table);
167
+ const version = asText(record?.version ??
168
+ record?.dataset_version ??
169
+ record?.reference_version ??
170
+ record?.ref_version);
171
+ for (const key of [
172
+ record?.root_id,
173
+ record?.dataset_id,
174
+ record?.id,
175
+ record?.refObjectId,
176
+ record?.ref_object_id,
177
+ record?.reference_id,
178
+ ]) {
179
+ const value = asText(key);
180
+ if (role === "reference" &&
181
+ value &&
182
+ ((table && plannedRootKeys.has(referenceKey({ table, id: value, version }))) ||
183
+ plannedRootIds.has(value))) {
184
+ continue;
185
+ }
186
+ if (value)
187
+ keys.add(value);
188
+ }
189
+ }
190
+ return keys;
191
+ }
@@ -0,0 +1,80 @@
1
+ interface JsonRecord {
2
+ [key: string]: unknown;
3
+ }
4
+ interface ArtifactFiles extends JsonRecord {
5
+ input?: unknown;
6
+ input_rows?: unknown;
7
+ source_rows?: unknown;
8
+ selected_rows_input?: unknown;
9
+ cleaned_rows?: unknown;
10
+ patched_rows?: unknown;
11
+ batch_patch?: unknown;
12
+ }
13
+ interface ArtifactValue extends JsonRecord {
14
+ input_path?: unknown;
15
+ inputPath?: unknown;
16
+ input_file?: unknown;
17
+ inputFile?: unknown;
18
+ rows_file?: unknown;
19
+ rowsFile?: unknown;
20
+ source_rows_file?: unknown;
21
+ sourceRowsFile?: unknown;
22
+ source_path?: unknown;
23
+ sourcePath?: unknown;
24
+ status?: string;
25
+ qa_report?: string;
26
+ schema_report?: unknown;
27
+ cleaned_rows_file?: unknown;
28
+ out_path?: unknown;
29
+ patch_path?: unknown;
30
+ files?: ArtifactFiles | null;
31
+ }
32
+ interface ArtifactEnvelope {
33
+ path?: string;
34
+ value?: ArtifactValue | null;
35
+ }
36
+ interface EvidenceScopeBlockerOptions {
37
+ code: unknown;
38
+ stage: unknown;
39
+ message: unknown;
40
+ expected: unknown;
41
+ actual: unknown;
42
+ artifact: string | null | undefined;
43
+ repoRoot: string;
44
+ }
45
+ interface PatchApplyContext {
46
+ evidenceRows: unknown[];
47
+ }
48
+ interface TransformContextLike {
49
+ status?: unknown;
50
+ inputRowsFile?: string | null;
51
+ outputRowsFile?: string | null;
52
+ inputRows?: string[];
53
+ outputRows?: string[];
54
+ inputPayloadSha256ByIdentity?: Map<string, string>;
55
+ outputPayloadSha256ByIdentity?: Map<string, string>;
56
+ }
57
+ interface BuildEvidenceScopeOptions {
58
+ repoRoot: string;
59
+ rowsFile: unknown;
60
+ schemaReportArtifact?: ArtifactEnvelope | null;
61
+ curationGateArtifact?: ArtifactEnvelope | null;
62
+ dryRunReportArtifact?: ArtifactEnvelope | null;
63
+ cleanupArtifact?: ArtifactEnvelope | null;
64
+ patchApplyArtifact?: ArtifactEnvelope | null;
65
+ patchApplyContext?: PatchApplyContext | null;
66
+ patchCollectArtifact?: ArtifactEnvelope | null;
67
+ requirePatchCollectReport?: unknown;
68
+ requireCurationGate?: boolean;
69
+ remoteVerifyArtifact?: ArtifactEnvelope | null;
70
+ identityDecisionApplyContext?: TransformContextLike | null;
71
+ identityReferenceRewriteContext?: TransformContextLike | null;
72
+ unresolvedExchangeExternalizationContext?: TransformContextLike | null;
73
+ sourceContactRewriteContext?: TransformContextLike | null;
74
+ canonicalSupportRewriteContext?: TransformContextLike | null;
75
+ cleanupContext?: TransformContextLike | null;
76
+ }
77
+ export declare function evidenceScopeBlocker({ code, stage, message, expected, actual, artifact, repoRoot, }: EvidenceScopeBlockerOptions): JsonRecord;
78
+ export declare function dryRunReportRowsFile(report: unknown): unknown;
79
+ export declare function buildEvidenceScopeBlockers({ repoRoot, rowsFile, schemaReportArtifact, curationGateArtifact, dryRunReportArtifact, cleanupArtifact, patchApplyArtifact, patchApplyContext, patchCollectArtifact, requirePatchCollectReport, requireCurationGate, remoteVerifyArtifact, identityDecisionApplyContext, identityReferenceRewriteContext, unresolvedExchangeExternalizationContext, sourceContactRewriteContext: _sourceContactRewriteContext, canonicalSupportRewriteContext, cleanupContext: _cleanupContext, }: BuildEvidenceScopeOptions): JsonRecord[];
80
+ export {};
@@ -0,0 +1,359 @@
1
+ import path from "node:path";
2
+ import { fileExists, readJson, repoRelativeArtifactPath, repoRelativePath, resolveRepoPath, sameArtifactPath, } from "./runtime-io.js";
3
+ import { deterministicRowsFileTransformEntries, patchApplyOutputChainsThroughIdentityRewrite, patchApplyOutputChainsThroughIdentityRewriteAndUnresolvedExchangeExternalization, patchApplyOutputChainsThroughUnresolvedExchangeExternalization, rowsFileReachableThroughTransformChain, } from "./workflow-row-transform-context.js";
4
+ export function evidenceScopeBlocker({ code, stage, message, expected, actual, artifact, repoRoot, }) {
5
+ return {
6
+ code,
7
+ stage,
8
+ message,
9
+ expected: repoRelativeArtifactPath(repoRoot, expected),
10
+ actual: repoRelativeArtifactPath(repoRoot, actual),
11
+ artifact: artifact ? repoRelativePath(repoRoot, artifact) : null,
12
+ };
13
+ }
14
+ export function dryRunReportRowsFile(report) {
15
+ const record = report;
16
+ const files = record?.files;
17
+ return (record?.input_path ??
18
+ record?.inputPath ??
19
+ record?.input_file ??
20
+ record?.inputFile ??
21
+ record?.rows_file ??
22
+ record?.rowsFile ??
23
+ record?.source_rows_file ??
24
+ record?.sourceRowsFile ??
25
+ record?.source_path ??
26
+ record?.sourcePath ??
27
+ files?.input ??
28
+ files?.input_rows ??
29
+ files?.source_rows ??
30
+ files?.selected_rows_input);
31
+ }
32
+ export function buildEvidenceScopeBlockers({ repoRoot, rowsFile, schemaReportArtifact, curationGateArtifact, dryRunReportArtifact, cleanupArtifact, patchApplyArtifact, patchApplyContext, patchCollectArtifact, requirePatchCollectReport, requireCurationGate = true, remoteVerifyArtifact, identityDecisionApplyContext, identityReferenceRewriteContext, unresolvedExchangeExternalizationContext, sourceContactRewriteContext: _sourceContactRewriteContext, canonicalSupportRewriteContext, cleanupContext: _cleanupContext, }) {
33
+ const blockers = [];
34
+ const finalRowsFile = path.resolve(rowsFile);
35
+ const schemaInput = schemaReportArtifact?.value?.input_path;
36
+ if (!schemaInput) {
37
+ blockers.push(evidenceScopeBlocker({
38
+ code: "schema_report_input_missing",
39
+ stage: "schema",
40
+ message: "Schema validation report must record input_path for exact rows-file scope verification.",
41
+ expected: finalRowsFile,
42
+ actual: null,
43
+ artifact: schemaReportArtifact?.path,
44
+ repoRoot,
45
+ }));
46
+ }
47
+ else if (!sameArtifactPath(repoRoot, schemaInput, finalRowsFile)) {
48
+ blockers.push(evidenceScopeBlocker({
49
+ code: "schema_report_rows_mismatch",
50
+ stage: "schema",
51
+ message: "Schema validation report input_path does not match the mutation manifest rows file.",
52
+ expected: finalRowsFile,
53
+ actual: schemaInput,
54
+ artifact: schemaReportArtifact?.path,
55
+ repoRoot,
56
+ }));
57
+ }
58
+ if (!curationGateArtifact && requireCurationGate) {
59
+ blockers.push({
60
+ code: "curation_gate_report_required",
61
+ stage: "foundry_curation",
62
+ message: "dataset-mutation-manifest requires a post-authoring dataset-curation-gate report for the exact write rows.",
63
+ });
64
+ }
65
+ else if (curationGateArtifact) {
66
+ const curationRowsFile = curationGateArtifact.value?.rows_file;
67
+ if (!curationRowsFile) {
68
+ blockers.push(evidenceScopeBlocker({
69
+ code: "curation_gate_rows_missing",
70
+ stage: "foundry_curation",
71
+ message: "Curation gate report must record rows_file for exact rows-file scope verification.",
72
+ expected: finalRowsFile,
73
+ actual: null,
74
+ artifact: curationGateArtifact.path,
75
+ repoRoot,
76
+ }));
77
+ }
78
+ else if (!sameArtifactPath(repoRoot, curationRowsFile, finalRowsFile)) {
79
+ blockers.push(evidenceScopeBlocker({
80
+ code: "curation_gate_rows_mismatch",
81
+ stage: "foundry_curation",
82
+ message: "Curation gate report rows_file does not match the mutation manifest rows file.",
83
+ expected: finalRowsFile,
84
+ actual: curationRowsFile,
85
+ artifact: curationGateArtifact.path,
86
+ repoRoot,
87
+ }));
88
+ }
89
+ if (!["ready", "ready_with_profile_waivers"].includes(curationGateArtifact.value?.status)) {
90
+ blockers.push({
91
+ code: "curation_gate_report_not_ready",
92
+ stage: "foundry_curation",
93
+ message: `Curation gate report status is ${curationGateArtifact.value?.status ?? "missing"}.`,
94
+ artifact: repoRelativePath(repoRoot, curationGateArtifact.path),
95
+ });
96
+ }
97
+ if (!curationGateArtifact.value?.qa_report) {
98
+ blockers.push({
99
+ code: "curation_gate_qa_report_missing",
100
+ stage: "foundry_curation",
101
+ message: "Curation gate report must record the deterministic QA report used for final prewrite curation.",
102
+ artifact: repoRelativePath(repoRoot, curationGateArtifact.path),
103
+ });
104
+ }
105
+ else {
106
+ const qaReportPath = resolveRepoPath(repoRoot, curationGateArtifact.value.qa_report);
107
+ if (!fileExists(qaReportPath)) {
108
+ blockers.push({
109
+ code: "curation_gate_qa_report_not_readable",
110
+ stage: "foundry_curation",
111
+ message: "Curation gate qa_report file is not readable.",
112
+ artifact: repoRelativePath(repoRoot, curationGateArtifact.path),
113
+ qa_report: repoRelativeArtifactPath(repoRoot, curationGateArtifact.value.qa_report),
114
+ });
115
+ }
116
+ else {
117
+ try {
118
+ const qaReport = readJson(qaReportPath);
119
+ const qaRowsFile = qaReport.rows_file ?? qaReport.input_path ?? qaReport.inputPath;
120
+ if (!qaRowsFile) {
121
+ blockers.push({
122
+ code: "curation_gate_qa_rows_missing",
123
+ stage: "foundry_curation",
124
+ message: "Final deterministic QA report must record rows_file or input_path for exact rows-file scope verification.",
125
+ artifact: repoRelativePath(repoRoot, curationGateArtifact.path),
126
+ qa_report: repoRelativePath(repoRoot, qaReportPath),
127
+ });
128
+ }
129
+ else if (!sameArtifactPath(repoRoot, qaRowsFile, finalRowsFile)) {
130
+ blockers.push(evidenceScopeBlocker({
131
+ code: "curation_gate_qa_rows_mismatch",
132
+ stage: "foundry_curation",
133
+ message: "Final deterministic QA report rows_file/input_path does not match the mutation manifest rows file.",
134
+ expected: finalRowsFile,
135
+ actual: qaRowsFile,
136
+ artifact: qaReportPath,
137
+ repoRoot,
138
+ }));
139
+ }
140
+ }
141
+ catch (error) {
142
+ blockers.push({
143
+ code: "curation_gate_qa_report_invalid",
144
+ stage: "foundry_curation",
145
+ message: error instanceof Error ? error.message : String(error),
146
+ artifact: repoRelativePath(repoRoot, curationGateArtifact.path),
147
+ qa_report: repoRelativePath(repoRoot, qaReportPath),
148
+ });
149
+ }
150
+ }
151
+ }
152
+ if (curationGateArtifact.value?.schema_report &&
153
+ schemaReportArtifact?.path &&
154
+ !sameArtifactPath(repoRoot, curationGateArtifact.value.schema_report, schemaReportArtifact.path)) {
155
+ blockers.push(evidenceScopeBlocker({
156
+ code: "curation_gate_schema_report_mismatch",
157
+ stage: "foundry_curation",
158
+ message: "Curation gate schema_report does not match the schema report passed to mutation manifest.",
159
+ expected: schemaReportArtifact.path,
160
+ actual: curationGateArtifact.value.schema_report,
161
+ artifact: curationGateArtifact.path,
162
+ repoRoot,
163
+ }));
164
+ }
165
+ }
166
+ if (cleanupArtifact) {
167
+ const cleanedRowsFile = cleanupArtifact.value?.cleaned_rows_file ?? cleanupArtifact.value?.files?.cleaned_rows;
168
+ if (!cleanedRowsFile) {
169
+ blockers.push(evidenceScopeBlocker({
170
+ code: "cleanup_cleaned_rows_missing",
171
+ stage: "prewrite_cleanup",
172
+ message: "Cleanup report must record cleaned_rows_file/files.cleaned_rows for exact rows-file scope verification.",
173
+ expected: finalRowsFile,
174
+ actual: null,
175
+ artifact: cleanupArtifact.path,
176
+ repoRoot,
177
+ }));
178
+ }
179
+ else if (!sameArtifactPath(repoRoot, cleanedRowsFile, finalRowsFile)) {
180
+ blockers.push(evidenceScopeBlocker({
181
+ code: "cleanup_cleaned_rows_mismatch",
182
+ stage: "prewrite_cleanup",
183
+ message: "Cleanup cleaned_rows_file does not match the mutation manifest rows file.",
184
+ expected: finalRowsFile,
185
+ actual: cleanedRowsFile,
186
+ artifact: cleanupArtifact.path,
187
+ repoRoot,
188
+ }));
189
+ }
190
+ }
191
+ if (patchApplyArtifact) {
192
+ const patchOut = patchApplyArtifact.value?.out_path ?? patchApplyArtifact.value?.files?.patched_rows;
193
+ const cleanupInput = cleanupArtifact?.value?.rows_file;
194
+ if (!patchOut) {
195
+ blockers.push(evidenceScopeBlocker({
196
+ code: "patch_apply_output_missing",
197
+ stage: "ai_patch_apply",
198
+ message: "Patch apply report must record out_path/files.patched_rows for exact scope verification.",
199
+ expected: cleanupInput || finalRowsFile,
200
+ actual: null,
201
+ artifact: patchApplyArtifact.path,
202
+ repoRoot,
203
+ }));
204
+ }
205
+ else if (cleanupArtifact &&
206
+ !sameArtifactPath(repoRoot, patchOut, cleanupInput) &&
207
+ !patchApplyOutputChainsThroughIdentityRewrite({
208
+ repoRoot,
209
+ patchOut,
210
+ cleanupInput,
211
+ identityReferenceRewriteContext,
212
+ }) &&
213
+ !patchApplyOutputChainsThroughUnresolvedExchangeExternalization({
214
+ repoRoot,
215
+ patchOut,
216
+ cleanupInput,
217
+ unresolvedExchangeExternalizationContext,
218
+ }) &&
219
+ !patchApplyOutputChainsThroughIdentityRewriteAndUnresolvedExchangeExternalization({
220
+ repoRoot,
221
+ patchOut,
222
+ cleanupInput,
223
+ identityReferenceRewriteContext,
224
+ unresolvedExchangeExternalizationContext,
225
+ }) &&
226
+ !rowsFileReachableThroughTransformChain({
227
+ repoRoot,
228
+ startFiles: [patchOut],
229
+ expectedRowsFile: cleanupInput,
230
+ transforms: deterministicRowsFileTransformEntries({
231
+ patchApplyContext: null,
232
+ identityDecisionApplyContext,
233
+ identityReferenceRewriteContext,
234
+ unresolvedExchangeExternalizationContext,
235
+ canonicalSupportRewriteContext,
236
+ }),
237
+ })) {
238
+ blockers.push(evidenceScopeBlocker({
239
+ code: "patch_apply_cleanup_input_mismatch",
240
+ stage: "ai_patch_apply",
241
+ message: "Patch apply output must match the cleanup input rows file, or feed a completed deterministic rewrite chain whose output is the cleanup input.",
242
+ expected: cleanupInput,
243
+ actual: patchOut,
244
+ artifact: patchApplyArtifact.path,
245
+ repoRoot,
246
+ }));
247
+ }
248
+ else if (!cleanupArtifact && !sameArtifactPath(repoRoot, patchOut, finalRowsFile)) {
249
+ blockers.push(evidenceScopeBlocker({
250
+ code: "patch_apply_rows_mismatch",
251
+ stage: "ai_patch_apply",
252
+ message: "Patch apply output does not match the mutation manifest rows file.",
253
+ expected: finalRowsFile,
254
+ actual: patchOut,
255
+ artifact: patchApplyArtifact.path,
256
+ repoRoot,
257
+ }));
258
+ }
259
+ if ((patchApplyContext?.evidenceRows.length ?? 0) === 0) {
260
+ blockers.push({
261
+ code: "patch_evidence_required",
262
+ stage: "ai_patch_apply",
263
+ message: "AI-authored patch apply report was provided, but no patch evidence rows were found.",
264
+ patch_apply_report: repoRelativePath(repoRoot, patchApplyArtifact.path),
265
+ });
266
+ }
267
+ }
268
+ if (requirePatchCollectReport && patchApplyArtifact && !patchCollectArtifact) {
269
+ blockers.push({
270
+ code: "patch_collect_report_required",
271
+ stage: "ai_patch_collect",
272
+ message: "Foundry AI authoring task patch apply requires --patch-collect-report from dataset-authoring-patch-collect.",
273
+ });
274
+ }
275
+ if (patchCollectArtifact) {
276
+ if (patchCollectArtifact.value?.status !== "ready_for_patch_apply") {
277
+ blockers.push({
278
+ code: "patch_collect_not_ready",
279
+ stage: "ai_patch_collect",
280
+ message: `dataset-authoring-patch-collect status is ${patchCollectArtifact.value?.status ?? "missing"}.`,
281
+ artifact: repoRelativePath(repoRoot, patchCollectArtifact.path),
282
+ });
283
+ }
284
+ const batchPatch = patchCollectArtifact.value?.files?.batch_patch;
285
+ const appliedPatch = patchApplyArtifact?.value?.patch_path;
286
+ if (patchApplyArtifact &&
287
+ batchPatch &&
288
+ appliedPatch &&
289
+ !sameArtifactPath(repoRoot, batchPatch, appliedPatch)) {
290
+ blockers.push(evidenceScopeBlocker({
291
+ code: "patch_collect_apply_patch_mismatch",
292
+ stage: "ai_patch_collect",
293
+ message: "Collected batch patch file does not match the patch file applied by dataset-patch-apply.",
294
+ expected: batchPatch,
295
+ actual: appliedPatch,
296
+ artifact: patchCollectArtifact.path,
297
+ repoRoot,
298
+ }));
299
+ }
300
+ }
301
+ if (!dryRunReportArtifact) {
302
+ blockers.push({
303
+ code: "dry_run_report_required",
304
+ stage: "dry_run",
305
+ message: "dataset-mutation-manifest requires a dry-run report before remote write planning. Upstream prewrite gates may intentionally skip dry-run and keep the manifest blocked.",
306
+ });
307
+ }
308
+ else {
309
+ const dryRunInput = dryRunReportRowsFile(dryRunReportArtifact.value);
310
+ if (!dryRunInput) {
311
+ blockers.push(evidenceScopeBlocker({
312
+ code: "dry_run_report_input_missing",
313
+ stage: "dry_run",
314
+ message: "Dry-run report must record input_path/input_file/rows_file for exact rows-file scope verification.",
315
+ expected: finalRowsFile,
316
+ actual: null,
317
+ artifact: dryRunReportArtifact.path,
318
+ repoRoot,
319
+ }));
320
+ }
321
+ else if (!sameArtifactPath(repoRoot, dryRunInput, finalRowsFile)) {
322
+ blockers.push(evidenceScopeBlocker({
323
+ code: "dry_run_report_rows_mismatch",
324
+ stage: "dry_run",
325
+ message: "Dry-run report input path does not match the mutation manifest rows file.",
326
+ expected: finalRowsFile,
327
+ actual: dryRunInput,
328
+ artifact: dryRunReportArtifact.path,
329
+ repoRoot,
330
+ }));
331
+ }
332
+ }
333
+ if (remoteVerifyArtifact) {
334
+ const remoteInput = remoteVerifyArtifact.value?.input_path;
335
+ if (!remoteInput) {
336
+ blockers.push(evidenceScopeBlocker({
337
+ code: "remote_verify_input_missing",
338
+ stage: "remote_verify",
339
+ message: "Remote verification report must record input_path for exact rows-file scope verification.",
340
+ expected: finalRowsFile,
341
+ actual: null,
342
+ artifact: remoteVerifyArtifact.path,
343
+ repoRoot,
344
+ }));
345
+ }
346
+ else if (!sameArtifactPath(repoRoot, remoteInput, finalRowsFile)) {
347
+ blockers.push(evidenceScopeBlocker({
348
+ code: "remote_verify_rows_mismatch",
349
+ stage: "remote_verify",
350
+ message: "Remote verification report input_path does not match the mutation manifest rows file.",
351
+ expected: finalRowsFile,
352
+ actual: remoteInput,
353
+ artifact: remoteVerifyArtifact.path,
354
+ repoRoot,
355
+ }));
356
+ }
357
+ }
358
+ return blockers;
359
+ }