@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,117 @@
1
+ import { type AuthIdentityReceipt as CliAuthIdentityReceipt } from "@tiangong-lca/cli/auth-identity-receipt";
2
+ type JsonRecord = Record<string, unknown>;
3
+ export type AuthIdentityReceipt = CliAuthIdentityReceipt;
4
+ export type CliIdentity = {
5
+ packageName: string;
6
+ packageVersion: string;
7
+ packageIntegrity: string | null;
8
+ };
9
+ export type IdentityPreflightBindingInput = {
10
+ datasetType: string;
11
+ datasetId: string;
12
+ datasetVersion: string;
13
+ targetSha256: string;
14
+ requestText: string;
15
+ semanticArgv: string[];
16
+ cli: CliIdentity;
17
+ authReceipt: AuthIdentityReceipt | null;
18
+ relevantInputHashes: Record<string, string>;
19
+ };
20
+ export type IdentityPreflightBinding = {
21
+ schema: "tiangong-foundry.identity-preflight-binding.v1";
22
+ dataset: {
23
+ type: string;
24
+ id: string;
25
+ version: string;
26
+ target_sha256: string;
27
+ };
28
+ request: {
29
+ bytes_sha256: string;
30
+ canonical_sha256: string;
31
+ };
32
+ command: {
33
+ semantic_argv: string[];
34
+ argv_sha256: string;
35
+ };
36
+ cli: {
37
+ package_name: string;
38
+ package_version: string;
39
+ package_integrity: string | null;
40
+ };
41
+ account: {
42
+ project_ref: string;
43
+ user_id: string;
44
+ } | null;
45
+ relevant_input_hashes: Record<string, string>;
46
+ binding_sha256: string;
47
+ inputs: IdentityPreflightBindingInput;
48
+ };
49
+ export type IdentityPreflightBindingEvidence = Omit<IdentityPreflightBinding, "inputs">;
50
+ export type ExecutionManifest = {
51
+ schema: "tiangong-foundry.identity-preflight-execution.v1";
52
+ binding_sha256: string;
53
+ binding: IdentityPreflightBindingEvidence;
54
+ producer_auth: {
55
+ project_ref: string;
56
+ user_id: string;
57
+ receipt_scope_sha256: string;
58
+ captured_at_utc: string;
59
+ };
60
+ report: {
61
+ bytes_sha256: string;
62
+ canonical_sha256: string;
63
+ status: string;
64
+ decision: string | null;
65
+ };
66
+ completed_at_utc: string;
67
+ manifest_sha256: string;
68
+ };
69
+ type ValidationFailure = {
70
+ ok: false;
71
+ code: string;
72
+ message: string;
73
+ };
74
+ type ValidationSuccess = {
75
+ ok: true;
76
+ report: JsonRecord;
77
+ manifest: ExecutionManifest;
78
+ };
79
+ export declare function stableJson(value: unknown): string;
80
+ export declare function sha256Text(value: string): string;
81
+ export declare function sha256Json(value: unknown): string;
82
+ export declare function parseFreshIntentBoundAuthReceipt(value: unknown, options: {
83
+ nowMs: number;
84
+ maxAgeMs: number;
85
+ expectedProjectRef: string;
86
+ expectedUserId: string;
87
+ sessionMode?: "oauth" | "headless";
88
+ }): AuthIdentityReceipt;
89
+ export declare function createIdentityPreflightBinding(input: IdentityPreflightBindingInput): IdentityPreflightBinding;
90
+ export declare function validateIdentityPreflightExecution(input: {
91
+ binding: IdentityPreflightBinding;
92
+ exitCode: number;
93
+ stdoutText: string;
94
+ diskReportText: string | null;
95
+ startedAtMs: number;
96
+ diskReportMtimeMs: number | null;
97
+ completedAtUtc: string;
98
+ }): ValidationFailure | ValidationSuccess;
99
+ export declare function validateBoundExecutionManifest(value: unknown, binding: IdentityPreflightBinding, reportText: string | null): {
100
+ ok: boolean;
101
+ code?: string;
102
+ };
103
+ export declare function validateIdentityPreflightEvidence(value: unknown, input: {
104
+ requestText: string | null;
105
+ reportText: string | null;
106
+ datasetType: string;
107
+ datasetId: string;
108
+ datasetVersion: string;
109
+ targetSha256: string;
110
+ expectedProjectRef?: string | null;
111
+ expectedUserId?: string | null;
112
+ }): {
113
+ ok: boolean;
114
+ code?: string;
115
+ binding?: IdentityPreflightBindingEvidence;
116
+ };
117
+ export {};
@@ -0,0 +1,341 @@
1
+ import { createHash } from "node:crypto";
2
+ import { parseAuthIdentityReceipt, } from "@tiangong-lca/cli/auth-identity-receipt";
3
+ const SHA256_PATTERN = /^[0-9a-f]{64}$/u;
4
+ const ALLOWED_REPORT_STATUSES = new Set(["passed", "blocked", "needs_review"]);
5
+ function isRecord(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+ function stableJsonValue(value) {
9
+ if (Array.isArray(value))
10
+ return value.map(stableJsonValue);
11
+ if (!isRecord(value))
12
+ return value;
13
+ return Object.fromEntries(Object.keys(value)
14
+ .sort()
15
+ .map((key) => [key, stableJsonValue(value[key])]));
16
+ }
17
+ export function stableJson(value) {
18
+ return JSON.stringify(stableJsonValue(value));
19
+ }
20
+ export function sha256Text(value) {
21
+ return createHash("sha256").update(value).digest("hex");
22
+ }
23
+ export function sha256Json(value) {
24
+ return sha256Text(stableJson(value));
25
+ }
26
+ function exactRecord(value, label) {
27
+ if (!isRecord(value))
28
+ throw new Error(`${label} must be an object.`);
29
+ return value;
30
+ }
31
+ export function parseFreshIntentBoundAuthReceipt(value, options) {
32
+ if (!Number.isFinite(options.nowMs) ||
33
+ !Number.isFinite(options.maxAgeMs) ||
34
+ options.maxAgeMs <= 0) {
35
+ throw new Error("Auth receipt freshness options are invalid.");
36
+ }
37
+ const receipt = parseAuthIdentityReceipt(value);
38
+ const capturedAtMs = Date.parse(receipt.captured_at_utc);
39
+ const ageMs = options.nowMs - capturedAtMs;
40
+ if (!Number.isFinite(capturedAtMs) || ageMs < -5_000 || ageMs > options.maxAgeMs) {
41
+ throw new Error("Auth identity receipt is stale or future-dated.");
42
+ }
43
+ if (receipt.assertions.mode !== "intent-bound" ||
44
+ !receipt.assertions.passed ||
45
+ receipt.assertions.expected_project_ref !== options.expectedProjectRef ||
46
+ receipt.assertions.expected_user_id !== options.expectedUserId ||
47
+ receipt.project.project_ref !== options.expectedProjectRef ||
48
+ receipt.identity.user_id !== options.expectedUserId) {
49
+ throw new Error("Auth identity receipt is not bound to the expected project and user.");
50
+ }
51
+ if (options.sessionMode === "headless") {
52
+ if (receipt.session.source !== "access_token" ||
53
+ receipt.session.cache_mode !== "disabled" ||
54
+ (receipt.session.expires_at_utc !== null &&
55
+ Date.parse(receipt.session.expires_at_utc) <= options.nowMs)) {
56
+ throw new Error("Headless identity requires the CLI process-only access-token contract.");
57
+ }
58
+ return receipt;
59
+ }
60
+ if (!["memory", "cache", "refresh", "oauth_login"].includes(receipt.session.source) ||
61
+ receipt.session.cache_mode === "disabled" ||
62
+ receipt.session.expires_at_utc === null ||
63
+ Date.parse(receipt.session.expires_at_utc) <= options.nowMs) {
64
+ throw new Error("Auth identity receipt requires a current OAuth session and fresh server verification.");
65
+ }
66
+ return receipt;
67
+ }
68
+ function validatedHash(value, label) {
69
+ if (!SHA256_PATTERN.test(value))
70
+ throw new Error(`${label} must be a lowercase SHA-256.`);
71
+ return value;
72
+ }
73
+ function validatedToken(value, label) {
74
+ const token = String(value).trim();
75
+ if (!token)
76
+ throw new Error(`${label} is required.`);
77
+ return token;
78
+ }
79
+ export function createIdentityPreflightBinding(input) {
80
+ const request = exactRecord(JSON.parse(input.requestText), "Identity-preflight request");
81
+ const semanticArgv = input.semanticArgv.map((value) => validatedToken(value, "argv token"));
82
+ if (semanticArgv.length === 0)
83
+ throw new Error("Identity-preflight semantic argv is required.");
84
+ const relevantInputHashes = Object.fromEntries(Object.entries(input.relevantInputHashes)
85
+ .sort(([left], [right]) => left.localeCompare(right))
86
+ .map(([key, hash]) => [validatedToken(key, "input hash key"), validatedHash(hash, key)]));
87
+ const scope = {
88
+ schema: "tiangong-foundry.identity-preflight-binding.v1",
89
+ dataset: {
90
+ type: validatedToken(input.datasetType, "dataset type"),
91
+ id: validatedToken(input.datasetId, "dataset id"),
92
+ version: validatedToken(input.datasetVersion, "dataset version"),
93
+ target_sha256: validatedHash(input.targetSha256, "target_sha256"),
94
+ },
95
+ request: {
96
+ bytes_sha256: sha256Text(input.requestText),
97
+ canonical_sha256: sha256Json(request),
98
+ },
99
+ command: {
100
+ semantic_argv: semanticArgv,
101
+ argv_sha256: sha256Json(semanticArgv),
102
+ },
103
+ cli: {
104
+ package_name: validatedToken(input.cli.packageName, "CLI package name"),
105
+ package_version: validatedToken(input.cli.packageVersion, "CLI package version"),
106
+ package_integrity: input.cli.packageIntegrity
107
+ ? validatedToken(input.cli.packageIntegrity, "CLI package integrity")
108
+ : null,
109
+ },
110
+ account: input.authReceipt
111
+ ? {
112
+ project_ref: input.authReceipt.project.project_ref,
113
+ user_id: input.authReceipt.identity.user_id,
114
+ }
115
+ : null,
116
+ relevant_input_hashes: relevantInputHashes,
117
+ };
118
+ return {
119
+ ...scope,
120
+ binding_sha256: sha256Json(scope),
121
+ inputs: {
122
+ ...input,
123
+ semanticArgv,
124
+ relevantInputHashes,
125
+ },
126
+ };
127
+ }
128
+ function bindingEvidence(binding) {
129
+ const { inputs: _inputs, ...evidence } = binding;
130
+ return evidence;
131
+ }
132
+ function failure(code, message) {
133
+ return { ok: false, code, message };
134
+ }
135
+ function parseReport(text, code) {
136
+ if (text === null || !String(text).trim())
137
+ return failure(code, "Identity report is missing.");
138
+ try {
139
+ const value = JSON.parse(String(text).trim());
140
+ return isRecord(value) ? value : failure(code, "Identity report must be a JSON object.");
141
+ }
142
+ catch {
143
+ return failure(code, "Identity report is not exact JSON.");
144
+ }
145
+ }
146
+ function isFailure(value) {
147
+ return value.ok === false && typeof value.code === "string" && typeof value.message === "string";
148
+ }
149
+ export function validateIdentityPreflightExecution(input) {
150
+ if (input.exitCode !== 0) {
151
+ return failure("identity_preflight_cli_exit_nonzero", "Identity-preflight CLI exited nonzero.");
152
+ }
153
+ const stdoutReport = parseReport(input.stdoutText, "identity_preflight_stdout_missing_or_non_json");
154
+ if (isFailure(stdoutReport))
155
+ return stdoutReport;
156
+ const diskReport = parseReport(input.diskReportText, "identity_preflight_disk_report_missing_or_non_json");
157
+ if (isFailure(diskReport))
158
+ return diskReport;
159
+ if (input.diskReportMtimeMs === null || input.diskReportMtimeMs < input.startedAtMs) {
160
+ return failure("identity_preflight_disk_report_stale", "Identity-preflight disk report is stale.");
161
+ }
162
+ if (stableJson(stdoutReport) !== stableJson(diskReport)) {
163
+ return failure("identity_preflight_stdout_disk_mismatch", "Identity-preflight stdout and disk reports differ.");
164
+ }
165
+ if (Object.hasOwn(diskReport, "ok") && diskReport.ok !== true) {
166
+ return failure("identity_preflight_report_not_ok", "Identity-preflight report has ok != true.");
167
+ }
168
+ const status = typeof diskReport.status === "string" ? diskReport.status : "";
169
+ if (!ALLOWED_REPORT_STATUSES.has(status)) {
170
+ return failure("identity_preflight_report_status_invalid", `Identity-preflight report status ${status || "missing"} is not accepted.`);
171
+ }
172
+ const authReceipt = input.binding.inputs.authReceipt;
173
+ if (!authReceipt || !input.binding.account) {
174
+ return failure("identity_preflight_auth_receipt_missing", "Identity-preflight execution requires account receipt evidence.");
175
+ }
176
+ const manifestScope = {
177
+ schema: "tiangong-foundry.identity-preflight-execution.v1",
178
+ binding_sha256: input.binding.binding_sha256,
179
+ binding: bindingEvidence(input.binding),
180
+ producer_auth: {
181
+ project_ref: authReceipt.project.project_ref,
182
+ user_id: authReceipt.identity.user_id,
183
+ receipt_scope_sha256: validatedHash(authReceipt.receipt_scope_sha256, "receipt_scope_sha256"),
184
+ captured_at_utc: authReceipt.captured_at_utc,
185
+ },
186
+ report: {
187
+ bytes_sha256: sha256Text(input.diskReportText ?? ""),
188
+ canonical_sha256: sha256Json(diskReport),
189
+ status,
190
+ decision: typeof diskReport.decision === "string" ? diskReport.decision : null,
191
+ },
192
+ completed_at_utc: input.completedAtUtc,
193
+ };
194
+ return {
195
+ ok: true,
196
+ report: diskReport,
197
+ manifest: { ...manifestScope, manifest_sha256: sha256Json(manifestScope) },
198
+ };
199
+ }
200
+ export function validateBoundExecutionManifest(value, binding, reportText) {
201
+ if (!isRecord(value) || value.schema !== "tiangong-foundry.identity-preflight-execution.v1") {
202
+ return { ok: false, code: "identity_preflight_manifest_invalid" };
203
+ }
204
+ const report = isRecord(value.report) ? value.report : null;
205
+ const manifestScope = {
206
+ schema: value.schema,
207
+ binding_sha256: value.binding_sha256,
208
+ binding: value.binding,
209
+ producer_auth: value.producer_auth,
210
+ report: value.report,
211
+ completed_at_utc: value.completed_at_utc,
212
+ };
213
+ if (value.binding_sha256 !== binding.binding_sha256 ||
214
+ stableJson(value.binding) !== stableJson(bindingEvidence(binding)) ||
215
+ typeof value.manifest_sha256 !== "string" ||
216
+ value.manifest_sha256 !== sha256Json(manifestScope) ||
217
+ !report ||
218
+ reportText === null ||
219
+ report.bytes_sha256 !== sha256Text(reportText)) {
220
+ return { ok: false, code: "identity_preflight_manifest_binding_mismatch" };
221
+ }
222
+ if (!isRecord(value.producer_auth) ||
223
+ value.producer_auth.project_ref !== binding.account?.project_ref ||
224
+ value.producer_auth.user_id !== binding.account?.user_id ||
225
+ typeof value.producer_auth.receipt_scope_sha256 !== "string" ||
226
+ !SHA256_PATTERN.test(value.producer_auth.receipt_scope_sha256) ||
227
+ typeof value.producer_auth.captured_at_utc !== "string" ||
228
+ !Number.isFinite(Date.parse(value.producer_auth.captured_at_utc))) {
229
+ return { ok: false, code: "identity_preflight_manifest_account_mismatch" };
230
+ }
231
+ try {
232
+ if (report.canonical_sha256 !== sha256Json(JSON.parse(reportText))) {
233
+ return { ok: false, code: "identity_preflight_manifest_report_mismatch" };
234
+ }
235
+ }
236
+ catch {
237
+ return { ok: false, code: "identity_preflight_manifest_report_invalid" };
238
+ }
239
+ return { ok: true };
240
+ }
241
+ export function validateIdentityPreflightEvidence(value, input) {
242
+ if (!isRecord(value) || value.schema !== "tiangong-foundry.identity-preflight-execution.v1") {
243
+ return { ok: false, code: "identity_preflight_manifest_invalid" };
244
+ }
245
+ if (!isRecord(value.binding) || !isRecord(value.producer_auth) || !isRecord(value.report)) {
246
+ return { ok: false, code: "identity_preflight_manifest_invalid" };
247
+ }
248
+ const binding = value.binding;
249
+ if (binding.schema !== "tiangong-foundry.identity-preflight-binding.v1" ||
250
+ !isRecord(binding.dataset) ||
251
+ !isRecord(binding.request) ||
252
+ !isRecord(binding.command) ||
253
+ !isRecord(binding.cli) ||
254
+ !isRecord(binding.account) ||
255
+ !isRecord(binding.relevant_input_hashes) ||
256
+ typeof binding.binding_sha256 !== "string") {
257
+ return { ok: false, code: "identity_preflight_manifest_binding_invalid" };
258
+ }
259
+ if (typeof binding.account.project_ref !== "string" ||
260
+ !binding.account.project_ref ||
261
+ typeof binding.account.user_id !== "string" ||
262
+ !binding.account.user_id ||
263
+ value.producer_auth.project_ref !== binding.account.project_ref ||
264
+ value.producer_auth.user_id !== binding.account.user_id ||
265
+ typeof value.producer_auth.receipt_scope_sha256 !== "string" ||
266
+ !SHA256_PATTERN.test(value.producer_auth.receipt_scope_sha256) ||
267
+ typeof value.producer_auth.captured_at_utc !== "string" ||
268
+ !Number.isFinite(Date.parse(value.producer_auth.captured_at_utc))) {
269
+ return { ok: false, code: "identity_preflight_manifest_account_invalid" };
270
+ }
271
+ const bindingScope = {
272
+ schema: binding.schema,
273
+ dataset: binding.dataset,
274
+ request: binding.request,
275
+ command: binding.command,
276
+ cli: binding.cli,
277
+ account: binding.account,
278
+ relevant_input_hashes: binding.relevant_input_hashes,
279
+ };
280
+ if (binding.binding_sha256 !== sha256Json(bindingScope) ||
281
+ value.binding_sha256 !== binding.binding_sha256) {
282
+ return { ok: false, code: "identity_preflight_manifest_binding_mismatch" };
283
+ }
284
+ if (binding.dataset.type !== input.datasetType ||
285
+ binding.dataset.id !== input.datasetId ||
286
+ binding.dataset.version !== input.datasetVersion ||
287
+ binding.dataset.target_sha256 !== input.targetSha256) {
288
+ return { ok: false, code: "identity_preflight_manifest_dataset_mismatch" };
289
+ }
290
+ if (input.requestText === null || input.reportText === null) {
291
+ return { ok: false, code: "identity_preflight_manifest_artifact_missing" };
292
+ }
293
+ let request;
294
+ let reportValue;
295
+ try {
296
+ const parsedRequest = JSON.parse(input.requestText);
297
+ const parsedReport = JSON.parse(input.reportText);
298
+ if (!isRecord(parsedRequest) || !isRecord(parsedReport))
299
+ throw new Error("not an object");
300
+ request = parsedRequest;
301
+ reportValue = parsedReport;
302
+ }
303
+ catch {
304
+ return { ok: false, code: "identity_preflight_manifest_artifact_invalid" };
305
+ }
306
+ if (binding.request.bytes_sha256 !== sha256Text(input.requestText) ||
307
+ binding.request.canonical_sha256 !== sha256Json(request) ||
308
+ sha256Text(JSON.stringify(request.target)) !== input.targetSha256) {
309
+ return { ok: false, code: "identity_preflight_manifest_request_mismatch" };
310
+ }
311
+ const report = value.report;
312
+ if (report.bytes_sha256 !== sha256Text(input.reportText) ||
313
+ report.canonical_sha256 !== sha256Json(reportValue) ||
314
+ report.status !== reportValue.status ||
315
+ report.decision !== (typeof reportValue.decision === "string" ? reportValue.decision : null) ||
316
+ !ALLOWED_REPORT_STATUSES.has(String(report.status ?? "")) ||
317
+ (Object.hasOwn(reportValue, "ok") && reportValue.ok !== true)) {
318
+ return { ok: false, code: "identity_preflight_manifest_report_mismatch" };
319
+ }
320
+ const manifestScope = {
321
+ schema: value.schema,
322
+ binding_sha256: value.binding_sha256,
323
+ binding: value.binding,
324
+ producer_auth: value.producer_auth,
325
+ report: value.report,
326
+ completed_at_utc: value.completed_at_utc,
327
+ };
328
+ if (typeof value.manifest_sha256 !== "string" ||
329
+ value.manifest_sha256 !== sha256Json(manifestScope) ||
330
+ typeof value.completed_at_utc !== "string" ||
331
+ !Number.isFinite(Date.parse(value.completed_at_utc))) {
332
+ return { ok: false, code: "identity_preflight_manifest_integrity_invalid" };
333
+ }
334
+ if (input.expectedProjectRef || input.expectedUserId) {
335
+ if ((input.expectedProjectRef && binding.account.project_ref !== input.expectedProjectRef) ||
336
+ (input.expectedUserId && binding.account.user_id !== input.expectedUserId)) {
337
+ return { ok: false, code: "identity_preflight_manifest_account_mismatch" };
338
+ }
339
+ }
340
+ return { ok: true, binding: binding };
341
+ }
@@ -0,0 +1,147 @@
1
+ type UnknownRecord = Record<string, unknown>;
2
+ type PathSegment = string | number;
3
+ type DatasetIdentity = {
4
+ id: string | null;
5
+ version: string | null;
6
+ };
7
+ type IdentityRewriteOptions = Record<string, unknown>;
8
+ type IdentityPreflightCommands = {
9
+ identityPreflightRunReportFile: (row: UnknownRecord) => string | null;
10
+ };
11
+ type IdentityReferenceRewriteDependencies = {
12
+ asText: (value: unknown) => string;
13
+ cloneJson: <T>(value: T) => T;
14
+ countRowsFile: (filePath: string | null | undefined) => number;
15
+ datasetIdentity: (payload: unknown, type: string) => DatasetIdentity;
16
+ datasetRowsFileStem: (datasetType: unknown) => string;
17
+ ensureArray: (value: unknown) => unknown[];
18
+ fileExists: (filePath: string | null | undefined) => boolean;
19
+ foundryTraceNamespace: string;
20
+ identityPreflightCommands: IdentityPreflightCommands;
21
+ languageForText: (text: unknown, fallback?: unknown) => string;
22
+ multiLang: (text: unknown, language?: unknown) => UnknownRecord;
23
+ normalizedList: (value: unknown) => string[];
24
+ nowIso: () => string;
25
+ pathExpression: (parts: PathSegment[]) => string;
26
+ preferredSourceLanguageText: (values: unknown) => string;
27
+ readJson: (filePath: string) => UnknownRecord;
28
+ readJsonLines: (filePath: string) => UnknownRecord[];
29
+ readRowsFile: (filePath: string | null | undefined) => UnknownRecord[];
30
+ repoRelativeMaybe: (filePath: string | null | undefined) => string | null;
31
+ repoRelativePath: (filePath: string) => string;
32
+ resolveRepoPath: (filePath: unknown) => string | null;
33
+ supportText: (value: unknown) => string;
34
+ unique: <T>(values: T[]) => T[];
35
+ writeJson: (filePath: string, value: unknown) => void;
36
+ writeJsonLines: (filePath: string, rows: unknown[]) => void;
37
+ };
38
+ export declare function createIdentityReferenceRewriteUtils({ asText, cloneJson, countRowsFile, datasetIdentity, datasetRowsFileStem, ensureArray, fileExists, foundryTraceNamespace, identityPreflightCommands, languageForText, multiLang, normalizedList, nowIso, pathExpression, preferredSourceLanguageText, readJson, readJsonLines, readRowsFile, repoRelativeMaybe, repoRelativePath, resolveRepoPath, supportText, unique, writeJson, writeJsonLines, }: IdentityReferenceRewriteDependencies): {
39
+ applyIdentityReferenceRewrites: ({ datasetType, rowsFile, outFile, outDir, options, allowMissingIndex, }: {
40
+ datasetType: string;
41
+ rowsFile: string;
42
+ outFile?: string | null;
43
+ outDir?: string | null;
44
+ options?: IdentityRewriteOptions;
45
+ allowMissingIndex?: boolean;
46
+ }) => {
47
+ status: string;
48
+ rows_file: string;
49
+ output_rows_file: string;
50
+ identity_preflight_index: string | null;
51
+ identity_reference_rewrites_input: string[];
52
+ identity_unresolved_references_input: string[];
53
+ rewrite_rows: never[];
54
+ unresolved_reference_rows: never[];
55
+ rewrite_file: null;
56
+ unresolved_references_file: null;
57
+ counts: {
58
+ input_rows: number;
59
+ output_rows: number;
60
+ identity_preflight_rows: number;
61
+ identity_unresolved_reference_rows: number;
62
+ duplicate_flow_mappings: number;
63
+ flow_reference_rewrites: number;
64
+ flow_reference_unresolved_traces: number;
65
+ reference_rows?: undefined;
66
+ identity_reference_rewrite_rows?: undefined;
67
+ root_flow_unresolved_rows?: undefined;
68
+ };
69
+ blockers: UnknownRecord[];
70
+ reference_rows_file?: undefined;
71
+ identity_reference_rewrites_inputs?: undefined;
72
+ } | {
73
+ status: string;
74
+ rows_file: string;
75
+ output_rows_file: string;
76
+ reference_rows_file: string | null;
77
+ identity_preflight_index: string | null;
78
+ identity_reference_rewrites_input: string | null;
79
+ identity_reference_rewrites_inputs: string[];
80
+ identity_unresolved_references_input: string[];
81
+ rewrite_rows: UnknownRecord[];
82
+ unresolved_reference_rows: UnknownRecord[];
83
+ rewrite_file: string;
84
+ unresolved_references_file: string;
85
+ counts: {
86
+ input_rows: number;
87
+ output_rows: number;
88
+ reference_rows: number;
89
+ identity_preflight_rows: number;
90
+ identity_reference_rewrite_rows: number;
91
+ identity_unresolved_reference_rows: number;
92
+ duplicate_flow_mappings: number;
93
+ flow_reference_rewrites: number;
94
+ flow_reference_unresolved_traces: number;
95
+ root_flow_unresolved_rows: number;
96
+ };
97
+ blockers: UnknownRecord[];
98
+ };
99
+ externalizeUnresolvedProcessFlowExchanges: ({ datasetType, rowsFile, outFile, outDir, options, }: {
100
+ datasetType: string;
101
+ rowsFile: string;
102
+ outFile: string;
103
+ outDir: string;
104
+ options?: IdentityRewriteOptions;
105
+ }) => {
106
+ schema_version: number;
107
+ generated_at_utc: string;
108
+ stage: string;
109
+ status: string;
110
+ input_rows_file: string;
111
+ output_rows_file: string;
112
+ counts: {
113
+ rows: number;
114
+ affected_rows: number;
115
+ externalized_exchanges: number;
116
+ };
117
+ files: {
118
+ report: string;
119
+ output_rows: string;
120
+ traces: null;
121
+ };
122
+ } | {
123
+ schema_version: number;
124
+ generated_at_utc: string;
125
+ stage: string;
126
+ status: string;
127
+ input_rows_file: string;
128
+ output_rows_file: string;
129
+ counts: {
130
+ rows: number;
131
+ affected_rows: number;
132
+ externalized_exchanges: number;
133
+ elementary_flow_externalized: number;
134
+ blocked_flow_dependency_externalized: number;
135
+ upstream_blocked_flow_references: number;
136
+ };
137
+ files: {
138
+ report: string;
139
+ output_rows: string;
140
+ traces: string;
141
+ blocked_flow_reference_blockers: string[];
142
+ };
143
+ };
144
+ identityReferenceRewriteIndexPath: (options: IdentityRewriteOptions, rowsFile: string | null | undefined) => string | null;
145
+ referenceShortDescription: (reference: unknown) => string;
146
+ };
147
+ export {};