@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,131 @@
1
+ ---
2
+ title: Foundry Task Authorization Contract
3
+ docType: contract
4
+ scope: repo
5
+ status: active
6
+ authoritative: true
7
+ owner: tiangong-lca-data-foundry
8
+ language: en
9
+ whenToUse:
10
+ - when admitting an account-local support or elementary operation
11
+ - when loading import rules, task permission or historical profile evidence
12
+ whenToUpdate:
13
+ - when task binding, allowed actions, waiver evidence or replay boundaries change
14
+ checkPaths:
15
+ - scripts/lib/task-authorization.ts
16
+ - scripts/lib/foundry-task-authorization.ts
17
+ - scripts/lib/foundry-execution-admission.ts
18
+ - scripts/lib/foundry-package-contract.ts
19
+ - scripts/public-api.ts
20
+ - docs/package-distribution-contract.md
21
+ - scripts/lib/import-curation/internal/profiles-config.ts
22
+ - scripts/lib/import-curation/mutation-manifest.ts
23
+ - scripts/commands/commit-handoff.ts
24
+ - scripts/commands/identity-decisions.ts
25
+ - specs/import-profiles.json
26
+ - specs/schemas/task-authorization.schema.json
27
+ - specs/schemas/authorization-derivation.schema.json
28
+ - specs/schemas/execution-context.schema.json
29
+ - test/unit/task-authorization.test.mts
30
+ - test/unit/task-profile-authority.test.mts
31
+ - test/scenarios/foundry-execution-admission.test.mts
32
+ lastReviewedAt: 2026-09-08
33
+ lastReviewedCommit: 73b74f070dcfa3864474c4061c7cebb6020e43f0
34
+ lastReviewedNote: "Reviewed for Foundry #125: positive dependent-scope fixtures use a logical Date clock to avoid hardware-time expiry. A separate runtime identity regression advances beyond60seconds and requires a new owner receipt. Production freshness, task binding, authorization, execution and no-replay behavior are unchanged."
35
+ related:
36
+ - docs/architecture.md
37
+ - docs/safety-policy.md
38
+ - docs/foundry-task-contracts.md
39
+ ---
40
+
41
+ # Task authorization
42
+
43
+ The persisted host boundary is implemented in `foundry-task-authorization.ts` and `foundry-runtime-identity.ts`. See `foundry-task-contracts.md` for workspace registration, evidence snapshots, active-pointer compare-and-swap and current-identity revalidation. Registration requires independently selected host evidence; merely writing a grant file or copying a success report grants no authority. `foundry-execution-admission.ts` owns the last internal rehydration gate before the existing no-replay owner receives a CommandSpec. The installed W06 package verifies code/assets and exposes the W05 facade, but package integrity, import success or possession of its public API grants no task action.
44
+
45
+ Import profiles describe source formats and domain constraints. They do not identify an account or approve an action. Selecting BAFU, USLCI or Worldsteel, loading a historical profile file, passing a waiver flag, or logging in cannot grant an exception.
46
+
47
+ The task host owns the current workspace/task/actor intent, frozen inputs and fresh CLI identity. It validates a separate `tiangong-foundry.task-authorization.v1` record against those independently assembled facts. `validateTaskAuthorization` returns an immutable, process-local authorization. `profileFor` accepts it only with the same current binding and the digest of the selected rule profile. A serialized report, copied profile object or boolean is never that validated authorization.
48
+
49
+ The runtime host revalidates persisted authorization through its explicit loader; every new process must obtain current identity and the same stored task/input binding. When qualification is present, registration and loading require an identity bound to that exact qualification. The profile API itself has no ambient file search or environment flag granting permission. Native validation and other public preparation remain available without a restricted action grant; only commands that select or hand off restricted scopes declare the authorization boundary.
50
+
51
+ The public facade does not authenticate during workspace initialization or task start. A request revision may retain non-secret account intent, but login/session readiness and task permission remain separate. Local preparation and read-only identity preflight report `permissions.not_required`. Any restricted action must first register its requested actions and approval reference, then rehydrate current qualification, identity and this authorization before exposing a child CommandSpec.
52
+
53
+ The extended public workflow may authenticate for read-only identity preflight after local semantic preparation. Its task account intent and fresh CLI receipt select the read scope. Host authentication is explicit; OAuth configuration is public and headless tokens stay process-only. Query receipts and current-row identity reports are evidence, never an action grant. Preflight does not consume, reset or dispatch a mutation attempt; subsequent permission admission still requires its own current identity and approval checks.
54
+
55
+ ## Required binding and evidence
56
+
57
+ The public facade accepts explicit approval selection through `--authorization-input`, whose descriptor/schema is owned by `public-runtime-contract.md`. Finalization supplies reviewable bindings and current input digests, never an issued grant. Registration uses an internal current-state check under its metadata lock before activation, so an approval for an older finalization cannot replace current state. The existing expected-previous-pointer compare-and-swap remains mandatory.
58
+
59
+ Ready final-row approval rebuilds the existing commit handoff and seals a capsule without dispatching it. Host evidence selections remain independent of grant text, and evidence paths are canonical. Prepared-row approval is continued through current-grant re-finalization and the existing derived-grant helper. Activation uses its returned pointer guard; sealing retains the original approved ancestor. Interrupted post-activation capture verifies the active grant against that original approval before recovering. A registered or sealed report does not relax fresh identity/admission checks or clear consumed attempts.
60
+
61
+ The exact v1 binding contains `workspace_id`, `task_id`, `actor_id`, `project_ref`, `user_id`, `profile_id`, `profile_sha256`, and `input_scope_sha256`. The profile digest is the stable, key-sorted JSON digest of the selected raw rule profile. Input scope is independently frozen by the task host; it must prove current source bytes and downstream lineage, rather than copying the digest from the grant. At a row-consuming permission boundary it is the SHA-256 of that exact input file; commit handoff checks the final-row artifact bytes again. A transformed row file needs a newly bound grant supported by the retained task approval and verified lineage, never silent reuse of the old digest. A binding mismatch invalidates every exception in that grant.
62
+
63
+ The grant is a local approval record, not an authentication credential or server-issued token. It contains no passwords or session contents. The owner CLI verifies current identity; ordinary write policy, schema, context, closure, dry-run, exact final-row hashes, account guards and readback remain separate required checks.
64
+
65
+ Grant issue/expiry timestamps use exact millisecond UTC format. A grant must be current, cannot be issued more than five seconds in the future, and has a maximum 24-hour lifetime. A running host rechecks expiry before using an exception. Continuing an already approved unchanged batch uses retained approval evidence; it must not invent broader scope or treat an expired serialized result as live permission.
66
+
67
+ `remote_state_code` is exactly `0`. Each evidence item has a unique id, kind, reference and content SHA-256. At least one `user-decision` item is required. The host must retain the referenced approval/source documents and verify their bytes when assembling the task context. Source-model evidence alone cannot approve a policy exception. Unknown fields, actions, duplicate actions or malformed evidence are rejected.
68
+
69
+ ## Actions
70
+
71
+ | Action | Permitted exception | Still required |
72
+ | --- | --- | --- |
73
+ | `elementary_flow_create_new` | Select a new elementary identity in the exact task scope | Full-context identity evidence and canonical-first search; a separate write grant before remote handoff |
74
+ | `elementary_flow_write` | Include an elementary row in an owner-draft write plan | All row, account, closure, dry-run and readback gates |
75
+ | `flowproperty_write` | Include the exact Flow Property write scope | Unit evidence, same-owner draft state and reference closure |
76
+ | `unitgroup_write` | Include the exact Unit Group write scope | Unit evidence, same-owner draft state and reference closure |
77
+ | `canonical_support_local_mint` | Admit the task's canonical-gap support mint route | The corresponding FP/UG write action; canonical matches remain reuse-only |
78
+
79
+ A single action never enables another. A mixed support handoff checks the actual final rows, not just the report's declared `support` type. A ready legacy finalize/mutation report cannot bypass this check. Non-generic handoffs require the mutation manifest to record the current `profile_rules_sha256`; used QA exceptions carry `required_qa_waiver_codes` and must still be authorized at handoff. No action grants publication, deletion, foreign-row visibility, review completion, full-context relaxation or replay.
80
+
81
+ ## Derived input and execution admission
82
+
83
+ When a selected derived artifact has identical bytes to the registered input, the loader may reuse that same content-bound grant after proving the registered input's producer lineage to the selected path. It rechecks the active pointer, current identity, binding and expiry after the lineage check. An independent equal-byte copy without an indexed derivation is rejected; grant/registration bytes are not rewritten merely to accommodate a new path.
84
+
85
+ `prepareDerivedFoundryTaskAuthorization` may reuse a current approval only after the indexed receipt/plan graph proves that the selected final rows descend from the approved input. It requires the exact qualified runtime and identity. The successor changes only `input_scope_sha256`; task/account/profile binding, issue and expiry times, actions, QA waivers and evidence remain byte-equivalent in authority. The active pointer must still name the parent before and after preparation, and later activation uses its captured digest as the compare-and-swap base. `authorization-derivation.schema.json` records both content facts and parent/successor digests. It does not activate the successor.
86
+
87
+ The content-addressed `tiangong-foundry.execution-context.v1` document records the current qualification, authorization, approved ancestor, final rows, sorted required actions and QA waivers, and exact CommandSpec digest. Rehydration accepts it only from the task's `evidence/executions/` root, then independently rechecks all current facts. The owner CLI must be entered through the qualified Node/CLI path, use one exact final-row input, keep outputs inside the task root, and select a reviewed owner-draft commit operation. FP/UG actions must match the requested dataset type and account-local flag; elementary create requires the corresponding write action; a canonical support mint requires the matching FP or UG write action. An unrelated command with a valid hash is still rejected.
88
+
89
+ This execution context is not the earlier `foundry-execution-capsule-stage.v1` offline admission document. Neither document changes a consumed attempt. The new gate returns the verified CommandSpec to the existing executor; it does not spawn, retry, clear or relabel a mutation.
90
+
91
+ ## Local preparation and domain rules
92
+
93
+ Preparing candidate JSON, preserving input evidence, deriving public canonical reference proof and normalizing references are local operations. They can run before a task receives restricted write permission. `prepareAccountLocalSupportCandidates` only selects local canonical-gap preparation; it does not authorize a database mint. The retired `allowAccountLocalSupportAndElementary` command option cannot supply task authorization. The Worldsteel adapter's existing `mintUnmatchedFpUgSupport=true` likewise selects a preparation route; final write admission remains action-bound.
94
+
95
+ Both unit-scale blockers remain active during candidate preparation: `canonical_support_amount_scaling_required` for a known positive non-1 factor, and `canonical_support_amount_scale_unresolved` for missing/non-finite/non-positive scale. Local preparation cannot move private rows into the public canonical cache.
96
+
97
+ USLCI's `preserve_referenced_review_sources` domain rule retains a source referenced through `referenceToCompleteReviewReport` as preparation evidence. It does not relax true-source content checks or make that source commit-ready. Public canonical UG/source proofs are derived from the checked cache and source semantics regardless of whether the task can write new support rows.
98
+
99
+ Worldsteel's naming rule classifies only the single trailing `Global` or `EU` plus data-year match, optionally followed by `v<number>`, in a process `baseName`. It applies only to the `latin-author-year` marker. Any additional author/year match, table/figure marker, other name field or other dataset type remains subject to the content policy. Adding another geography requires reviewed source evidence and tests. No whole content-policy rule is waived by a profile.
100
+
101
+ ## QA exceptions
102
+
103
+ The only v1 QA exception is `process_material_balance_deviation` for `process`. The task must provide both user approval and referenced, content-bound `source-model` evidence demonstrating why this exact source scope is an aggregation/formula observation. The source format name or presence of `LCI_RESULT` alone is insufficient. Other QA codes, schema errors, unit-scale errors, missing references and full-context requirements cannot be waived by this contract.
104
+
105
+ ## Disposition of historical fields
106
+
107
+ The evidence source is `specs/import-profiles.json` at `1374961f11d46546acc46398bbdbaa9eb0d2b73e`. It remains retrievable in Git; operators' original `profile-lock.json` files are not rewritten.
108
+
109
+ | Profile / historical field | Classification | Current disposition |
110
+ | --- | --- | --- |
111
+ | Generic format, docs and no-waiver defaults | Distributable rules | Preserve |
112
+ | BAFU full-context/schema/classification/location proof | Distributable rules | Preserve strict requirements |
113
+ | BAFU `authorized_by` 2026-06-15 and five enabled mint/write actions | Account/task approval | Remove from distributed defaults; require a current bound grant |
114
+ | BAFU process material-balance waiver | Source observation plus policy exception | Keep as an evidence-required candidate; no automatic waiver |
115
+ | USLCI D4 2026-06-23 elementary/FP/UG authorization, 1,056-scope and 7/4 counts | Historical delivery and account approval | Retain historical evidence only; counts grant no authority |
116
+ | USLCI D3-QA 2026-06-24 aggregation/formula waiver | Exact task decision | Require current approval and source-model evidence |
117
+ | USLCI referenced review-source retention | Local source-evidence rule | Preserve only the referenced review field; final content gates still apply |
118
+ | Worldsteel R3 2026-06-29 elementary allowance | Historical account/scope approval | No inherited residual-count or mint permission |
119
+ | Worldsteel R5 2026-07-01 unmatched FP/UG support and LANCA 10+10 / 11+11 observations | Historical approval plus retained data evidence | Preserve canonical-cache-miss preparation, ordering and evidence; require exact current actions to write |
120
+ | Worldsteel process material-balance waiver for 33 LCI-result processes | Exact source/task exception | Current approval and source-model proof required |
121
+ | Worldsteel whole `source_locator_in_dataset_name` waiver | Over-broad encoding of a legitimate naming convention | Replace with the field/marker/value rule above |
122
+ | Worldsteel `full_context_ai_completion.scoped_relaxation` 2026-06-30 | Historical task approval | New tasks require strict full-context proof; reading the old field cannot relax it |
123
+ | `waiveQa` / `waiveQaCode` / `waivedQaCode` options | Unbound operator request | Never grant permission without the supported task QA exception |
124
+
125
+ ## Old tasks and replay
126
+
127
+ This contract does not edit old locks, task inputs, checkpoints, sealed attempts or already verified records. Migration must produce a separate reviewed mapping, not relabel historical evidence as new authorization. A fresh grant never resets a consumed attempt or permits a second mutation. Existing no-replay/readback recovery remains authoritative. Real task #95 and its records are outside this refactor's migration scope.
128
+
129
+ Read-only or pending workspace contexts cannot register/derive authorization or admit a business command. After activation, preserved migration scope is checked at execution-capsule creation and before/after admission revalidation. A fresh grant does not reset retained attempt authority. Original profile/account/approval files remain archived evidence, while new permission still needs the independently selected current identity, exact input lineage and reviewed scope.
130
+
131
+ For public prepared FP/UG input, a captured finalization blocked solely by the support permission gate may derive the existing complete support approval through registered input lineage, then rerun local finalization on those exact approved bytes. Missing write/mint actions and unrelated blockers remain pending. This adds no permission, extends no expiry and cannot replay a consumed scope.
@@ -0,0 +1,336 @@
1
+ ---
2
+ title: Historical USLCI Import Runbook
3
+ docType: runbook
4
+ scope: import-profile/uslci-history
5
+ status: historical
6
+ authoritative: false
7
+ owner: tiangong-lca-data-foundry
8
+ language: zh
9
+ whenToUse:
10
+ - when reconstructing the 2026-06 USLCI import execution record and diagnostics
11
+ whenToUpdate:
12
+ - when a current contract changes how this historical runbook should be interpreted
13
+ checkPaths:
14
+ - docs/uslci-import-runbook.md
15
+ - docs/uslci-import-plan.md
16
+ - docs/import-profiles/uslci/**
17
+ - scripts/lib/import-curation/**
18
+ lastReviewedAt: 2026-08-25
19
+ lastReviewedCommit: a2832001e1b67bdc8a1a9eb7707a99187f787a58
20
+ lastReviewedNote: "Reviewed for Issue #67 Wave 22b: the typed USLCI profile wrapper preserves its exact configuration and leaves this retained Python-era runbook historical and non-authoritative."
21
+ related:
22
+ - docs/uslci-import-plan.md
23
+ - docs/import-profiles/uslci/profile.md
24
+ - inputs/source-packages/uslci-database-public.md
25
+ ---
26
+
27
+ # USLCI 导入运行手册(goal 入口文档)
28
+
29
+ > **Rust cutover note:** 本文保留 2026-06 Python `tidas-tools`、PyPI/SDK 版本与旧 CLI wrapper 命令作为历史证据;这些路径不再是可执行入口,也不得用于新任务。当前确定性转换/校验统一使用 `node scripts/foundry.mjs dataset-tidas-import|dataset-tidas-validate` → Rust `tidas` 0.2.x;AI curation、QA、remote handoff 继续使用 Foundry/CLI。
30
+ >
31
+ > **完整方案见 [`docs/uslci-import-plan.md`](uslci-import-plan.md)(自包含、端到端的权威计划)。本文是逐会话的操作日志/快照入口(§6 当前状态、§R 摘要、分诊表)。**
32
+ >
33
+ > 目标读者:接手 USLCI 持续导入的任何一个 agent 会话或人工操作者。读完本文应能:知道当前阶段在哪、用哪条命令继续、遇到 blocker 怎么分诊,而不需要重新逆向工程。最后更新:2026-06-25(**§R 为当前权威计划**:2026-06 ILCD-alignment 发布 tidas-tools 0.0.34 / sdk 0.1.45·0.2.14 / cli 0.0.19 已修 42-bug 审计并收紧 schema → 计划改为 conversion-v7 重转换,手工补丁链 v2..v6 作废)。更新本文时同步更新「§6 当前状态快照」。
34
+
35
+ ---
36
+
37
+ ## 0. 三十秒定位
38
+
39
+ - **Goal**:把 `inputs/National_Renewable_Energy_Laboratory-USLCI_Database_Public` 的 **1,358** 个 process(1,341 USLCI + 17 个被传递引用的 library 电网过程)导入远端 TIDAS 库,gap 0。**收尾口径(对标 BAFU 99.94% close-out)**:每个 process 最终为 _verified_(reuse 既有 canonical **或** created-account-local My Data,readback-verified)或带逐项证据的 _registered-non-importable_。account-local My Data 创建能力使绝大多数原"无 canonical 匹配"项可建可导,非可导入应是极小残留。
40
+ - **质量要求:尽量无损导入**(用户 2026-06-23 明确)。USLCI 数据本身很丰富,这些必须落进 TIDAS 字段、不能只留在 sourceTrace:**881 个 process 的 pedigree 数据质量条目**(+ 逐 exchange pedigree)、**5,651 条 exchange 的不确定性分布(含分布参数)**、**61 个 process 的分配因子**、**852 个 process 的评审记录**。真正无 TIDAS 落点的字段必须逐项列出原因(见 §7.1 数据保真表)。落地见 CAP-20260623-002(tidas-tools 转换器增强 → conversion-v4 commit-canonical)。
41
+ - **Profile**:`uslci`(`specs/import-profiles.json`;约束见 `docs/import-profiles/uslci/`)。Lane:`external-dataset-curated-import`,**禁止新增 USLCI 专用 Foundry 代码路径,直到 pilot 证明必要**。
42
+ - **任务文件**:`tasks/active/external-import-20260612-uslci.md`(已 claim,state Doing;队列内容是本地运行态,不入 git)。
43
+ - **源包事实与 sha256**:`inputs/source-packages/uslci-database-public.md`(这是 source manifest,所有计数和复现命令在那里,本文不重复)。
44
+ - **工作区**:`RUN=.foundry/workspaces/uslci-full-import-<UTC时间戳>`(Phase 1 创建后回填到 §6;下文 `$RUN` 指它)。阶段日志:`$RUN/phase-journal.md`。
45
+ - **所有命令从仓库根目录跑**(`tiangong-lca-data-foundry/`)。
46
+
47
+ ```bash
48
+ cd /Users/davidli/projects/workspace/tiangong-lca-data-foundry
49
+ # Phase 1 起:export RUN=.foundry/workspaces/uslci-full-import-<ts>
50
+ ```
51
+
52
+ ---
53
+
54
+ ## R. 2026-06 ILCD-alignment 发布已落地 → 重转换计划(当前权威计划,取代手工补丁)
55
+
56
+ > 2026-06-25。四个项目发布了 2026-06 ILCD-alignment 修复——**tidas-tools 0.0.34 / tidas-sdk 0.1.45(npm)·0.2.14(PyPI) / @tiangong-lca/cli 0.0.19**——把 42-bug 审计(`_docs/tidas-ilcd-schema-correspondence-audit-2026-06-24.md`)里的转换器伪造 + schema 松弛 + bundle drift 都修了,并收紧 schema 使 `valid-tidas ⟹ valid-ILCD`。**§5 原 Phase 计划中"逐版 conversion-vN 手工补丁"的部分作废**——绝大多数手工修复现已在上游 0.0.34 原生修好。迁移指南:`_docs/tidas-schema-data-migration-2026-06.md`。
57
+
58
+ ### R.1 发布修了什么(与 USLCI 直接相关,取代我方手工链 v2..v6)
59
+
60
+ - ✅ **转换器伪造修复**:elementary 隔间真值(cc3aaaf,取代 CAP-001/v3);product/process classification 不再硬编码 CPC-94900/ISIC-9499 且**写 @name + 多体系**(09d293e);referenceYear 源真值兜底、不写 9999(220d8fc,取代 v6 手工);location 保留 **RoW** 不塌成 GLO、占位可区分(9593505);contact/source/unitgroup classId 4/5/6 常量改为派生;timestamp 确定性。
61
+ - ✅ **无损富字段**:allocation 列表(d35b654);uncertainty 分布参数 + pedigree DQ(0730b70);**Perc 放宽到 eILCD(≤5 位、≤3 小数、允许 >100/负,adcc49b)** → `relativeStandardDeviation95In` >100 现可保留(**我之前把 GSD² 量化到 ≤100 丢弃 >100 的做法已过时,新转换原生保留,是无损提升**)。
62
+ - ✅ **schema 收紧**:GlobalReferenceType @type 8 值枚举、@version/dataSetVersion `NN.NN(.NNN)`、Real 加 `^` 锚、HK/MO/TW/AN/CS location、多体系 classification `anyOf[object,array]`+@name/@classes、subReference、referenceToDigitalFile 数组、lifecyclemodel @version、LCIA review 枚举等(c7dc15f / 0.0.31-0.0.33)。bundle⇄canonical schema 已统一 + zh-lock。
63
+
64
+ ### R.2 发布**没有**覆盖的(仍需我方,全部保留)
65
+
66
+ - ⚠️ **UnitGroup `referenceToReferenceUnit` 选错**(我的 **P1b 新发现,不在 42-bug 审计、不在 0.0.34**):`_unit_group_dataset` 仍硬编码 `"1"`(首单位),USLCI "Units of mass*length" 首单位 lb*mi、真参考 t\*km(cf 1.0) → 参考指针与 meanValue 不一致。修复在 tidas-tools 分支 `fix/unitgroup-reference-unit-selection`(ec95d8a,+2 测试/suite 98)。**行动:PR 上游 → 0.0.35;conversion-v7 必须用含此修复的 tidas-tools 构建**。
67
+ - ⚠️ **foundry runner 改动(编排层,与发布无关,0.0.34 不含,全部保留)**:USLCI runner `dataset-uslci-batch-import-run`、库-contact bootstrap、**P1a 未匹配 FP/UG 作为 account-local support 在依赖 flow 前 mint(已实现+验证:mint scope 0001b273 的 FP/UG 提交 + 6 flows verified)**、P3 不铸孤立、P4 批内去重。foundry 分支 `feat/uslci-runner-and-library-contact-bootstrap`(commits a51ef80/3bf2ed3/a4d672c + 早先)。
68
+
69
+ ### R.3 重转换计划(conversion-v7 = 新 commit-canonical)
70
+
71
+ 1. **采用发布基座**:foundry `npm i @tiangong-lca/cli@0.0.19`(当前 0.0.18);转换引擎 = tidas-tools 0.0.34(submodule 已在 6761cf0)**+ 合并 P1b(ec95d8a)**(或本地装该分支);**从 0.0.34 重新同步 foundry 的 tidas-schema 镜像**(我之前手工放宽 allocation 的那份已被上游取代,勿保留手工版)。
72
+ 2. **重转换全部 2,113 process → conversion-v7**:原生得到正确隔间 / classification(@name+多体系) / referenceYear / location(RoW) / timestamp / allocation / uncertainty(Perc>100 保留) / ILCD-conforming @type·version·Real。**取代 conversion-v2..v6 整条手工链。**
73
+ 3. **用新 schema 重校验 v7**(tidas-tools 0.0.34 / sdk 0.2.14 validator):目标 0 error(同源转换器应通过);存档 baseline 证无新失败。
74
+ 4. **从 v7 重建 canonical 链**:library-index-v7 → decisions-v5(identity key 应稳定;**classification 2,990 决策需复核+重投影/重应用**——新转换写 @name/可能多体系,leaf code 不变但队列键/契约要对齐)→ library-resolution-v9(override ON → 1,358 ready)。
75
+ 5. **重验证导入链**:USLCI runner 在 v7 上重跑 mint scope(0001b273) + reuse scope(e93ae1c1),确认 P1a FP/UG mint + flows + process verify。**先清理 v6 测试写入**(e93ae1c1 + v7-mint 的 flows/FP/UG,account-local linanenv 账号)或 version-bump,避免旧-schema 残留。
76
+ 6. **scale 到 1,358(v7)**,coverage 闭环 gap 0。
77
+
78
+ ### R.4 重转换后复核的残留 blocker
79
+
80
+ - **process 评审报告悬空 source(task #8 / 75ac425f)**:转换器对 review 写 `referenceToCompleteReviewReport → source` 但不建该 source → 闭包失败。0.0.34 的占位/源真值修复**可能改变 review-source 发射**——conversion-v7 后**先复核是否仍在**;若在,按 task #8 处理(转换器建 review-report source,或 curation externalize 悬空引用)。
81
+ - **P2 elementary 复用**:0.0.34 隔间真值映射可能提升复用、降假 mint;v7 后用新隔间复核 reuse-vs-mint,再定 CAS/同义阈值(数据质量,需用户定阈)。
82
+
83
+ ### R.5 注意:已入远端的 BAFU 数据需独立迁移(不属本 plan)
84
+
85
+ BAFU 11,740 行用旧 schema 写入,新 schema 收紧后**可能校验失败**,需按迁移指南 §3/§4 走 walker/SQL(@type 枚举、version 规范、HK/MO/TW、lciamethods bool/枚举/键名、lifecyclemodel @version 等)。这是与 USLCI **并行的独立任务**;USLCI 用 v7(新 schema)直接写,**无需迁移**。
86
+
87
+ ---
88
+
89
+ ## 1. 三条原则(本 goal 的宪法,违反 = 返工)
90
+
91
+ 1. **不影响平行功能**。
92
+ - 绝不读写 BAFU 的运行态:`$RUN_BAFU=.foundry/workspaces/bafu-full-import-20260607T080646Z` 及其全部 decisions/ledger/resolution 目录只许 forensic 参考,不许修改。BAFU 后续 unlock 回合(decisions-v13 路径)可能与本 goal 并行。
93
+ - 不改变任何 `dataset-bafu-*` 命令的行为;共享代码(`scripts/lib`、`scripts/commands/` 中 profile 无关部分)的改动必须 dataset-agnostic 且 `npm test` 全绿 + `node scripts/foundry.mjs doctor` 通过后才能落地。
94
+ - 共享资源注意:`specs/canonical-support/flow-properties-unit-groups.json` 是跨 profile 公共缓存,`dataset-support-cache-refresh` 是增量安全的,但刷新后要确认 BAFU 既有映射未被删改。
95
+ - 单独数据集制备(`source-evidence-dataset-development` lane)与本 goal 无共享运行态,互不阻塞。
96
+ 2. **充分共用既有代码与设施**。
97
+ - 格式转换 owner 是 tidas-tools(`openlca-jsonld` adapter)+ tiangong-lca-cli 包装,Foundry 只编排(`docs/capability-ownership-policy.md`、`specs/workspace-capability-adapters.md` 的 `external-lca-package-conversion`)。转换器缺陷修在 tidas-tools,不在 Foundry 打补丁。
98
+ - 编排走 generic 命令链(§4),决策机制完全复用 BAFU 打磨出的 sha256 绑定 task bundle + deterministic apply 体系。
99
+ 3. **导入过程中持续迭代完善本项目**。
100
+ - 每轮批次暴露的通用缺陷按归属修复:Foundry 编排层 → 本仓库 generic 层(带测试);转换/校验 → tidas-tools(capability-development-request 任务,模板在 `tasks/templates/`);CLI 包装 → tiangong-lca-cli。
101
+ - **确认即修,不绕过**:导入中确认的转换器/校验缺陷(如已确认的单位归一化 a3e1aa9、elementary 隔间硬编码 CAP-20260623-001)在 owning 项目同步修复并带独立验证,**绝不在 foundry 打补丁掩盖**。已确认缺陷与已澄清非缺陷见 §9。
102
+ - pilot 之后预期的两个 Foundry 演进项(届时按 P1 提):把 `dataset-bafu-batch-import-run` 参数化为 profile 驱动的通用批量 runner;把 `dataset-bafu-universe-coverage-report` 推广为 profile 无关的 coverage 报告。
103
+ - 每个会话结束前:回写 §6 快照 + `$RUN/phase-journal.md`;修复以主题 commit 落 foundry main。
104
+
105
+ ## 2. 不变式(继承 BAFU 经验,从第一天就执行)
106
+
107
+ 1. **canonical ledger sources**:成功证据只认 §6 列出的 ledger 目录;coverage 统计用 `dataset-import-ledger-report --ledger-dir` 逐目录汇总并显式列出来源(注意:`--ledger-source-dir` 这个 flag 只存在于 BAFU 专用 runner,generic 链没有,等 §1-3 的通用化演进后才可用)。candidate ≠ authoritative:AI 输出必须带 `authoring_context.context_bundle_sha256` 证据并经 deterministic apply 进库。
108
+ 2. 每个新批次独立 `--out-dir`、独立 report / run-manifest / ledger。
109
+ 3. 所有支持 `--profile` 的命令**显式传 `--profile uslci`**;所有 decisions/resolution 路径显式传参——`dataset-bafu-batch-import-run` 一类命令的默认值指向 BAFU 工件,绝不能依赖默认。
110
+ 4. **远端写入是人工门禁**:任务 frontmatter `allow_remote_commit: false`;翻转它需要用户明确批准账号/写入政策(§5 D4)。在那之前一切到 dry-run / queue verify 为止。
111
+ 5. **单位归一化硬门禁**:✅ 已满足(2026-06-12 关闭,tidas-tools a3e1aa9 + 独立校验器全对,见 §7-2)。规则保留:若未来重新转换(新 tidas-tools 版本/源包变更),必须重跑 `$RUN/unit-normalization-verify/verify.py` 全对后才可恢复 commit。
112
+ 6. 高并行跑 CLI 时 `npm install --no-save @tiangong-lca/cli@latest && export TIANGONG_LCA_CLI_BIN=$PWD/node_modules/.bin/tiangong-lca`(npx 并发风暴会假性 blocked;BAFU 实测教训)。
113
+ 7. 源包目录(含 `libraries/`)是冻结输入:任何变更必须同步更新 `inputs/source-packages/uslci-database-public.md` 的 sha256/日期。
114
+
115
+ ## 3. 目录地图
116
+
117
+ | 路径 | 是什么 |
118
+ | --- | --- |
119
+ | `inputs/National_Renewable_Energy_Laboratory-USLCI_Database_Public/` | 冻结源包(openLCA JSON-LD v2)+ `libraries/` 补充数据(见 source manifest) |
120
+ | `inputs/source-packages/uslci-database-public.md` | source manifest:计数、sha256、闭合验证事实、复现命令 |
121
+ | `docs/import-profiles/uslci/` | profile.md(政策与 open decisions)、constraints.md(gate 约束) |
122
+ | `$RUN/conversion-vN/` | tidas-tools 转换输出(tidas/ + process-bundles/ + conversion-report.json),Phase 1 产生 |
123
+ | `$RUN/library-index/` | `dataset-library-index-build` 输出(entity index + scope projection) |
124
+ | `$RUN/decisions-vN-*/` | identity / classification / location / canonical-support 决策 JSONL(sha 绑定 bundle 证据同目录) |
125
+ | `$RUN/library-resolution-vN/` | `dataset-library-decisions-apply` 输出:ready-scopes + blocked-scope-ledger |
126
+ | `$RUN/batch-import-vN-*/` | 批次工作台与 import-ledger |
127
+ | `$RUN/phase-journal.md` | 阶段日志(每会话追加) |
128
+
129
+ ## 4. 流水线总览
130
+
131
+ ```
132
+ inputs(合并源包) → tidas-tools 转换(CLI 包装入口,见 §5 Phase 1)
133
+ → dataset-library-index-build ($RUN/library-index)
134
+ → [决策回合] identity-preflight / classification / location / canonical-support ($RUN/decisions-vN)
135
+ → dataset-library-decisions-apply ($RUN/library-resolution-vN)
136
+ → generic 提交链(per scope):tiangong-lca dataset curation-queue build/next/verify
137
+ + dataset-curation-gate / dataset-curation-cleanup
138
+ + dataset-post-authoring-finalize → dataset-mutation-manifest
139
+ → dataset-commit-handoff-plan → remote write → readback → dataset-post-write-closeout
140
+ (批量执行器:dataset-process-scope-run;不要用 dataset-bafu-batch-import-run)
141
+ → dataset-import-ledger-report / coverage 统计 → 回写 §6
142
+ ```
143
+
144
+ 命令清单:`node scripts/foundry.mjs --help`;逐命令参数 `node scripts/foundry.mjs <cmd> --help`。决策回合的方法论直接参照 `docs/bafu-import-runbook.md` §4(机制完全相同,只是 profile/路径换成 uslci)。
145
+
146
+ ## 5. 阶段计划
147
+
148
+ ### Phase 0 — 补充数据与可转换性验证 ✅(2026-06-12 本会话完成)
149
+
150
+ - library zip 下载冻结 + meta 解压进 `libraries/`;UUID 零冲突、引用闭合 0 缺失、传递 provider 闭包 = 17 个 library 过程——全部验证通过(证据与命令:source manifest)。
151
+ - 合并包根目录全量冒烟转换(tidas-tools 0.0.29 checkout):0 错误、TIDAS 校验 0 issue、2,112 bundles、`unresolved_references` 0。CLI 包装入口(@tiangong-lca/cli 0.0.16)端到端验证通过。输出在 /tmp(一次性,Phase 1 正式重跑进 $RUN)。
152
+
153
+ ### Phase 1 — 入场与正式转换
154
+
155
+ 1. claim 任务(inbox → active),`mkdir -p .foundry/workspaces/uslci-full-import-<ts>`,回填 §6 的 $RUN,开 phase-journal。
156
+ 2. 正式转换(文档入口,@tiangong-lca/cli ≥0.0.16;注意包装裸调 `python3`,必须 `--python` 指向带 tidas-tools 依赖的解释器):
157
+ ```bash
158
+ npm install --no-save @tiangong-lca/cli@latest
159
+ ./node_modules/.bin/tiangong-lca dataset import-lca convert \
160
+ --input "inputs/National_Renewable_Energy_Laboratory-USLCI_Database_Public" \
161
+ --output-dir "$RUN/conversion-v1" \
162
+ --from-format openlca-jsonld --target tidas --validation-jobs 0 \
163
+ --python /Users/davidli/projects/workspace/tidas-tools/.venv/bin/python \
164
+ --tidas-tools-dir /Users/davidli/projects/workspace/tidas-tools --json
165
+ ```
166
+ 备选(包装不可用时等价):`cd tidas-tools && PYTHONPATH=src .venv/bin/python -m tidas_tools.import_lca.cli --input … --output-dir … --from-format openlca-jsonld --target tidas --validation-jobs 0`。预期 ≈2-4 分钟、1.9 GB。出场标准:conversion-report 0 error;TIDAS validation ok;bundle index `unresolved_references == 0`;数字与 source manifest 冒烟一致。
167
+ 3. `dataset-library-index-build` 指向 `$RUN/conversion-v1/process-bundles` 建库存索引。
168
+ 4. **范围决策 D1(默认推荐已给)**:universe = 1,341 USLCI + 17 provider 过程 = 1,358;其余 754 个 library 过程不在本 goal 范围(未来可另立 goal)。在 phase-journal 记录 universe 清单文件。
169
+
170
+ ### Phase 2 / identity ✅(2026-06-12/13 完成)
171
+
172
+ 单位归一化(tidas-tools a3e1aa9)+ identity evaluator openLCA-compartment 修复(foundry 9136031)已闭环:conversion-v2 9,478 处换算、独立校验器 78,757/78,757 全对;elementary identity reuse 2,988/3,919(0 假阳性)。详见 §6 与 phase-journal。
173
+
174
+ > **战略升级(2026-06-23,基于 foundry main 新能力重制)**:BAFU 已 **GOAL COMPLETE(11,740/11,747 verified = 99.94%,仅 7 个 mega-scope 残留)**。它不是靠"大量 non-importable"收尾,而是用 **account-local "My Data" 创建**把原本无 canonical 匹配的 elementary/FP/UG **建成自有数据(state_code=0)**后导入。这条路径现在是 **profile 数据驱动的通用能力**(commit 8f28e91),USLCI 加一段 profile 配置即可启用,**无需任何 foundry 代码改动**。因此原 §6 把"931 manual + 139 FP/UG"当永久非可导入尾巴的框架作废,改为下面的**双杠杆**。
175
+
176
+ **双杠杆解锁模型**(合在一起 → 2,112 个 scope 全部 ready):
177
+
178
+ - **杠杆 1 = classification 授权**(Phase 3A,唯一硬必须的 AI 工作;override 不触及它):3,750 条 leaf 分类决策。
179
+ - **杠杆 2 = account-local My Data override**(Phase 3-PRE,一次性 profile 配置 + 人工授权):自动清除 elementary identity(931)+ FP/UG(7+4)三类 blocker,把残余建为 My Data。
180
+
181
+ ### Phase 3-PRE — 状态同步 + 授权 override(profile 数据改动 + 人工门禁)
182
+
183
+ 1. **同步 §6**(已在本文件完成):live 链 = conversion-v2 + library-index-v2 + decisions-v3(identity 2,988 + canonical-support 20)+ library-resolution-v4 + identity-from-preflight-v3;测试基线 `npm test` **206/206** + doctor 绿。
184
+ 2. **人工门禁 D4-elementary(阻塞本 Phase)**:override 反转了"reference-only / elementary 只许 reuse"的既定治理,**必须用户显式授权**才能开。逐字记录 `authorized_by`(对标 BAFU 2026-06-15 override)。可逆:`enabled=false` 即还原。
185
+ 3. 在 `specs/import-profiles.json` 的 **uslci** 条目加 `allow_account_local_support_and_elementary` block(照抄 bafu 形状:`enabled:true` + `authorized_by` + `scope:[elementary_flow_write, elementary_flow_create_new, flowproperty_write, unitgroup_write, canonical_support_local_mint]` + note)。**纯数据改动,零 gate 代码改动**。跑 `npm test`/doctor 必须保持绿(建议加一条 uslci-on 的 dataset-agnostic 断言到 `bafu-mydata-override.test.mjs`)。
186
+ 4. 写 `docs/import-profiles/uslci/constraints.md`(当前 constraints 是"无 waiver"占位)+ 更新 profile.md,**显式授权** override 并带审计字段(否则治理文档与 JSON 冲突)。topic commit 落 foundry main。
187
+ 5. **不变量**:override **不放松** 单位尺度门禁 `canonical_support_amount_scaling_required`;conversion-v2 的单位归一化(§7-2)是安全网,My Data 行保留源单位故自洽。
188
+
189
+ ### Phase 3A — classification 授权(process 2,112 + flow-product 1,638 = 3,750,杠杆 1)✅ 链已验证
190
+
191
+ 走**完全 generic、profile 中立**的链(`classification-decisions.ts` 零 bafu 引用)。**pilot(15 process + 85 flow-product)已端到端打通**:6 scope 仅凭 classification 即 ready、pilot-15 classification blocker 归零。**经验证的精确配方 + 坑**(细节见 `$RUN/phase-journal.md`):
192
+
193
+ 1. **context pack**(USLCI 此前无,必须生成;process/flow 各一次,profile 值是 `ai-import` 不是 uslci): `tiangong-lca dataset context-pack --type <process|flow> --profile ai-import --out-dir <SR>/context/<type> --json`。
194
+ 2. **队列**:`dataset-bundle-sample-rows --profile uslci --bundles-dir $RUN/conversion-v3/process-bundles [--sample-size N] --out-dir <SR>` → `classification-authoring-queue.jsonl`(含两类)+ `rows/*.jsonl`。⚠️ `authoring-plan-v1` 模板和 resolution blocked-ledger **都不能替代**队列(缺 `classification_workflow.commands.input_rows`)。
195
+ 3. **按 category_type 拆队列 + 按 dataset_id 去重**(一个 flow 被 k 个 process 引用就出现 k 次;apply 拒绝重复队列行/重复决策)。
196
+ 4. **task-build 按类型、对 per-type 去重队列**:`dataset-classification-decision-task-build --profile uslci --classification-queue <per-type-deduped-queue> --rows-file <SR>/rows/<processes|flows>.jsonl --schema-file/--yaml-file/--ruleset-file <SR>/context/<type>/outputs/* --classification-schema tidas_<processes|flows_product>_category.json --location-schema … --category-type <process|flow-product> --chunk-label … --shared-context-cache-dir <一个目录> --out-dir …`。⚠️ task 记录的 `task_queue` = 该队列文件 → 后续 project/apply **必须用同一队列文件**(否则 `classification_decision_task_queue_mismatch`);改队列即换 sha → 决策须从新模板**重新加盖** `authoring_context`。
197
+ 5. **AI 授权合同(按语义分类)**:process → ISIC 4 位 leaf(`tidas_processes_category.json`);flow-product → CPC level-4(5 位)leaf(`tidas_flows_product_category.json`)。**NAICS 弱提示通常为空**(被剥离)→ 纯按含义分类。每行需 `code`+`selected_code` + `decision_status:completed` + basis + confidence + `used_context_kinds[schema,methodology_yaml,ruleset,classification_schema]` + `evidence{}` + 保留 `authoring_context.context_bundle_sha256`。**按 dataset_id 去重决策**。**绝不无 sha-bundle 证据授权**(BAFU appended-rows 事故教训)。
198
+ 6. **project 按类型**(单 `--decision-task`,**不可重复**,传两个会抛错):`dataset-library-classification-decisions-project --profile uslci --classification-queue <per-type-queue> --library-decisions <authored> --decision-task <per-type-task> --out-dir …`(强制 leaf-only,拒 `library_classification_decision_not_leaf`)。出场 errors 0 / manual_review 0。
199
+ 7. **apply 按类型** → `decisions/<type>-classification-decisions.jsonl`。
200
+ 8. 合并两类的 `decisions/*-classification-decisions.jsonl` 为 decisions-vN 目录的 `classification-decisions.jsonl` → `dataset-library-decisions-apply` → resolution。
201
+
202
+ - **不要**用 `dataset-bafu-leaf-classification-*`(ecoinvent 名称→code 硬编码,不吃 USLCI 名)。
203
+ - **全量放大**:对全部 2,112 scope 跑 bundle-sample(不加 --sample-size)→ 拆+去重 → ~90-100 行/shard 分片 task-build → 并行 AI 授权代理(每 shard 一个,对标 BAFU)→ project+apply → decisions-v4 → resolution-v5。预期 ~1,056 scope 仅凭 classification 即 ready,其余需杠杆 2。
204
+
205
+ ### Phase 3B — elementary:remap-first, mint-last(931 deps / 986 scopes,杠杆 2 之一)
206
+
207
+ 931 manual **主要是匹配问题不是创建负担**:reason 分布 no_candidate 698 / multiple_plausible 220 / create_new_forbidden 12 / score_too_low 1。
208
+
209
+ 1. **先 re-judge(remap-first)**:220 multiple_plausible 多是同一 canonical flow 的子隔间重复(AI/确定性挑对子隔间 → reuse);698 里大量是同 CAS/同名仅因 `category_or_compartment_conflict` 被拒(隔间感知 re-judge 可救回为 reuse)。对标 BAFU `fullpool-rejudge.py`(全候选池 ~80,要求同隔间 sourceClassification + 名称等价 + 维度匹配)。设 `BAFU_IDENTITY_PREFLIGHT_RESULT_CACHE` 加速 3,919 条重判。**隔间权威源永远是 `sourceTrace.payload` 的 openLCA 路径,绝不用转换器写死的 elementaryFlowCategorization**(§7-3)。
210
+ 2. 救回的写成 reuse_existing_reference(需 canonical ref_object_id/version)入 decisions-v4;re-apply 重测残余。
211
+ 3. **mint-last**:真正零候选残余(12 个 create_new_forbidden:Coal bituminous/sub-bituminous、Oil shale、Shale gas、Phosphate ore、Ulexite、Lutetium ore、Gangue、Saponifiable oils/fats、Total oil and grease less TPH、Unused primary solar、PM>10um + re-judge 后仍无物理等价的)→ 在 `--profile uslci`(override 已开)下写 **create_new** identity 决策(无需 canonical 目标,需 status=completed + basis + 结构化 evidence FEDEFL UUID/CAS/隔间 + used_context_kinds)。commit 时经 elementary save-draft 路径建为 My Data(state_code=0,保留源单位)。
212
+ - ✅ **mint 前置已满足(§7-6 / §9 / CAP-20260623-001 Done)**:隔间硬编码 bug 已修(tidas-tools cc3aaaf),**conversion-v3** 隔间正确(4,872 elementary 0 错配)+ 单位校验全过。mint 路径用 conversion-v3(重建 library-index-v3 等下游链时切到 v3;identity 决策键于 dataset_id/version,v2→v3 不变,decisions-v3 可沿用)。
213
+ 4. re-apply → resolution-v5:确认 `elementary_flow_requires_existing_database_match` 归 0。
214
+
215
+ - **决策合同没有新值**:identity 仍只接受 `reuse_existing_reference | create_new | block_unresolved`;override 只是不再 block elementary 的 create_new。
216
+
217
+ ### Phase 3C — FP/UG:mint-or-non-importable(7 FP + 4 UG / 139 scopes,杠杆 2 之二)
218
+
219
+ 7 个本地特殊 FP(Taxes/Jobs/Wages/Producer price/Market value/Duration/Person transport)+ 4 UG(Currencies×2/time/person\*length)确认无 canonical 等价 → override 下其 blocker(`canonical_flow_property/unit_group_reference_unresolved`)**自动清除**,源 FP/UG ref 保留源单位建为 My Data。
220
+
221
+ - **污染陷阱(BAFU 26912eb 教训)**:**绝不**把这些 account-local My Data UUID 写进共享的 `specs/canonical-support/flow-properties-unit-groups.json` 的 `flow_property_mappings`(会污染其他账户的全局 canonical-support 解析,有 support-cache 测试守着)。共享映射留 pending,仅按 scope 就地 mint。
222
+ - commit 经 `dataset save-draft --type flowproperty|unitgroup --allow-account-local-support --commit`(commit-handoff 路径)。`dataset-support-cache-refresh` 后核对 BAFU 既有映射未被删改(原则 1)。
223
+
224
+ ### Phase 4 — Pilot 批次 + 关闭 D2/D3/D4 人工门禁(首个 commit)
225
+
226
+ 1. 从 resolution-v5 ready-scopes 选 20-50 个干净 scope(无 allocation/amountFormula/单位不一致,不依赖 17 library provider)。
227
+ 2. **generic runner**(**不用** `dataset-bafu-batch-import-run`,它 ledger-source-dir 硬编码 bafu):
228
+ ```bash
229
+ npm install --no-save @tiangong-lca/cli@latest
230
+ export TIANGONG_LCA_CLI_BIN=$PWD/node_modules/.bin/tiangong-lca # 否则 npx@latest 卡死
231
+ node scripts/foundry.mjs dataset-process-scope-run \
232
+ --process-bundles-dir "$RUN/conversion-v2/process-bundles" \
233
+ --library-resolution "$RUN/library-resolution-v5/library-resolution.json" \
234
+ --scope-file <ready-scopes.jsonl> --profile uslci --parallel 5 --dry-run
235
+ ```
236
+ 走完整 generic 链:curation-gate → curation-cleanup → post-authoring-finalize → mutation-manifest → commit-handoff-plan → (dry-run)。
237
+ 3. 凭 pilot 证据关闭:**D2** source 署名(NREL contact/database fallback + bin/ 8 附件取舍);**D3** QA warning-vs-blocker(25 LCI_RESULT / 61 allocationFactors / 1,425 amountFormula / 本地 FP-UG);**D4** 账号/state-code/写入(**用户批准后**才翻 `allow_remote_commit:true`)。落地到 profile.md/constraints.md/import-profiles.json waivers。
238
+ 4. 首批 `--commit` + readback verify + `dataset-post-write-closeout`;建立第一个 canonical ledger source 登记 §6。
239
+
240
+ ### Phase 5 — 批量推进 + coverage 闭环(gap 0)
241
+
242
+ - 回合:缺口分析 → decisions-vN(全量超集)→ resolution-vN → 批次 vN(独立 out-dir)→ `dataset-import-ledger-report` / `dataset-import-completion-report` → 重测。My Data 行 readback-verified 后**计入 verified**(BAFU 第三态)。每轮 mint 后预期**复合解锁**(多依赖,少量 mint 解锁大量下游)。
243
+ - 非可导入登记文件(逐项 reason+evidence+disposition,对标 BAFU `non-importable-scopes-v2.jsonl`)。override 下 USLCI 预期 **gap 0 无需上游补充**(不同于 BAFU 的 TiO₂/Ulexite 需建 468 上游 flow)。
244
+ - **收尾口径(对标 BAFU close-out)**:verified(reuse + created-account-local,readback-verified)+ registered-non-importable = 1,358,gap 0;blocked/failed_retryable/human_review/retry/pending 全 0;npm test + doctor 绿。
245
+ - **最终交付物 = USLCI trace/进展工作簿**:fork `reports/bafu-import/build-bafu-trace-xlsx.py`(BAFU 路径硬编码,非 drop-in)到 `reports/uslci-import/`,改 USLCI 路径/标签,或从 ledger/completion report 构建。7 sheet:说明 / 导入进展 Summary / 待人工校验 / Process Trace / Flow Trace / 转换映射 / Support Identities。goal 关闭,`npm run task:complete` 归档。
246
+
247
+ ## 6. 当前状态快照(每会话结束前更新)
248
+
249
+ - **🔑 当前权威计划 = §R(2026-06 ILCD-alignment 重转换)**。2026-06-25:发布 tidas-tools 0.0.34 / sdk 0.1.45·0.2.14 / cli 0.0.19 把 42-bug 审计的转换器伪造 + schema 松弛全修了并收紧 schema。**下一步 = 按 §R.3 做 conversion-v7**(采用 0.0.34 基座 + 合并 P1b ec95d8a + cli 0.0.19 → 重转换 2,113 process → 新 schema 重校验 → 从 v7 重建 canonical 链 → 重验证导入链 → scale)。conversion-v2..v6 的手工补丁链作废(已被上游原生取代)。
250
+ - **已验证但基于旧 schema(v6)的成果,重转换后复用/复核**:
251
+ - **阶段**:Phase 4 进行中 — **首个真实远端 commit 已成功并全链验证**(2026-06-24,旧 schema v6 数据;v7 重转换后需复核/清理这些测试写入)。USLCI runner(`dataset-uslci-batch-import-run`,复用 BAFU 引擎 + uslci 配置)已落地,BAFU 零回归(npm test 206/206)。
252
+ - ✅ **reuse-only scope `e93ae1c1` 已真实写入远端**(`process get` 实测:state_code=0 My Data、version 00.01.004、modified 2026-06-24T03:55:33;账号 linanenv@126.com → user_id 5c784552…)。全链 stage 全 exit 0:flow.support.commit → post_write_verify → closeout → finalize_after_support → flow.commit → post_write_verify;process 同。**D2 实测干净**:committed 报告 NREL×22 / FOEN×0 / openLCA×0 / GreenDelta×0。证据 `$RUN/batch-import-v2/scopes/e93ae1c1…/scope-run-report.json`。
253
+ - ✅ **根因修复(已落 foundry,gated 不碰 BAFU)**:库 contact 从未 bootstrap 到远端 → flow pre-finalize 的 reference-closure 卡死。修法见 §9 路由表「库 contact + FP/UG/elementary My Data support 提交」一行。
254
+ - ✅ **P1a 已实现+验证(2026-06-24)**:未匹配 FP/UG 作为 account-local support 在依赖 flow 前 mint。mint scope 0001b273 实测:UG 838aaa21 + FP 838aaa20 + contact 提交(verified_support_identities 3)、6 dependency flows verified。过滤器实测正确(838aaa20 US-单位 mass×distance → mint;93a60a56 Mass canonical UUID → reuse)。foundry commits a51ef80/3bf2ed3/a4d672c。**该 scope 的 process 仍 block 于独立的评审报告悬空 source(task #8 / 75ac425f),与 P1a 无关**。
255
+ - **⚠️ 上述均基于旧 schema(conversion-v6)**。按 §R:v7 重转换后这些验证需在新 schema 上重跑;旧 schema 测试写入需清理或 version-bump。P1b(UnitGroup 参考单位)仍需合并上游再进 v7。
256
+ - **$RUN**:`.foundry/workspaces/uslci-full-import-20260612T093202Z`(task:external-import-20260612-uslci,active/Doing;`$RUN/phase-journal.md` 有 NEXT SESSION ENTRY POINT)。
257
+ - **canonical 链(盘上)**:**`conversion-v6` = commit-canonical**(v5 + 稀疏过程修复:referenceYear creationDate 兜底、dataSources 块始终输出;tidas-tools 220d8fc。74 个 9999 referenceYear + 9 个缺 dataSources 在源头清零)(隔间修复 + 无损保真:不确定性/pedigree/**分配** 全落字段);`library-index-v4` + `decisions-v4`(identity 2,988 + support 20 + classification 2,990)+ **`library-resolution-v6-override`(override ON → ready 1,358)**。注意:v4/v5 仅 classification 不触及的字段变化,dataset_id 键不变;commit 前用 conversion-v5 重建 library-index(mint 写库用 v5 的字段)。
258
+ - **universe**:1,358(`$RUN/universe-v1/`;排除 754 个 out-of-scope library 过程)。
259
+ - **classification ✅ 全量 + D4 override ✅ 已授权**:35 shard 授权 2,990(0 非法 code)→ project/apply 35/35。`--profile uslci` 的 override ON 后 **resolution-v6 = 1,358/1,358 in-universe ready**(elementary 无匹配 + 7 FP + 4 UG 将在 commit 时 mint 为 My Data);剩 754 全是 out-of-universe library 过程不导入。
260
+ - **D3 分配无损 ✅**(走 A):TIDAS schema 放宽为分配列表 + 转换器写列表 → conversion-v5 56 process 落字段;详见 §7.1。
261
+ - **新能力**:account-local My Data override **uslci 已开 enabled:true**(specs/import-profiles.json,user 2026-06-23 D4-elementary 授权,可逆);constraints.md 已记授权与保留门禁。
262
+ - **BAFU 参照**:GOAL COMPLETE 11,740/11,747 verified(99.94%);最终交付物 `reports/bafu-import/build-bafu-trace-xlsx.py`(7-sheet 工作簿)是 USLCI 收尾模板。
263
+ - **canonical ledger sources**:无(首个在 Phase 4 产生)。**`allow_remote_commit:false`(D4 账号/写入政策批准前不写远端)**。
264
+ - **测试基线**:foundry `npm test` **206/206** + doctor 绿;tidas-tools **95 passed**(2026-06-23)。
265
+
266
+ ## 7. 已知问题与 blocker 分诊
267
+
268
+ | # | 问题 | 影响 | 处置 |
269
+ | --- | --- | --- | --- |
270
+ | 1 | ~~tiangong-lca-cli ≤0.0.14 向 tidas-tools ≥0.0.28 传已移除的 `--process-bundles` flag,文档入口直接失败~~ **已解决**:cli 0.0.16(commit 98104c9,2026-06-11)已适配,2026-06-12 端到端验证通过 | 无(历史) | 留意两点:包装默认裸调 `python3`,要传 `--python <venv解释器>`;`npm install --no-save @tiangong-lca/cli@latest` 保持 ≥0.0.16 |
271
+ | 2 | ~~转换器不做单位换算,数值错最高 1000×~~ **已解决**:tidas-tools a3e1aa9(2026-06-12)在 openlca adapter 加归一化 pass;conversion-v2 修正 9,478 条(unresolved 0),独立校验器 78,757/78,757 全对 | 无(历史) | 留意:474 条 amountFormula 公式本身未重缩放(仅存 trace,QA 在 pilot 定性);84 条 ref_unit_name_mismatch 为源数据 refUnit 文本怪癖,数值已验证正确 |
272
+ | 3 | ~~FEDEFL elementary 匹配率未知~~ **已量化**:reuse 2,988/3,919(76%)。残余 931 不再是死路——override 下可 remap-first/mint-last(Phase 3B) | 不再是永久尾巴 | ⚠️ **隔间权威源 = `sourceTrace.payload` 的 openLCA 路径,绝不用转换器写死的 elementaryFlowCategorization**;re-judge 需适配 FEDEFL trace 形状(generic + 测试),否则隔间污染产生错误决策 |
273
+ | 3b | **My Data override 未在 uslci profile 启用** | 931 elementary + 7 FP + 4 UG 仍 blocked | Phase 3-PRE 加 `allow_account_local_support_and_elementary` block(待 D4-elementary 用户授权);纯 profile 数据,零 gate 代码改动 |
274
+ | 4 | ~~数据保真缺口~~ **已全部落地**(CAP-20260623-002 → conversion-v5):不确定性 5,129+522、process pedigree 1,652、**分配 56 process(D3 走 A:schema 放宽为列表 + 转换器)** 全落 TIDAS 字段;reviews 保留 | 无(历史) | 残留仅逐 exchange pedigree(D1)等无 ILCD slot 项,详见 §7.1 |
275
+ | 5 | bin/ 8 个 source 附件(PDF/JPG)转换时丢弃 | 来源证据不全 | D2 一并定(附件→TIDAS digital file 或 trace 记录) |
276
+ | 6 | ~~转换器对所有 elementary flow 硬编码隔间 `Emissions to air, unspecified`~~ **已修复**:tidas-tools `cc3aaaf` 加 `_elementary_categorization` 映射真实 FEDEFL 隔间;**conversion-v3** 实测 4,872 个 elementary **0 隔间错配**、TIDAS 校验 0、单位归一化仍 78,757/78,757 全对(CAP-20260623-001 → Done) | 无(历史) | mint 用 **conversion-v3**(非 v2);35 个 economic/non-FEDEFL 回退默认(可接受残留) |
277
+ | 7 | 1,425 条 amountFormula 公式仅存 trace(**注**:25 个 LCI_RESULT 是带 `typeOfDataSet="LCI result"` 的正常 TIDAS **process**,非 trace-only,见 §8) | QA 定性未定 | pilot 时定 warning vs blocker(D3) |
278
+ | 8 | 纯英文源 vs TIDAS zh/en 双语治理 | curation gate 可能 block | Phase 3-5 定 transcreation 批量路径 |
279
+ | 9 | 12 个 currency、399 个 location 实体、categories.json 不转换为 TIDAS 实体 | 无(currency 零引用;location 仅供代码解析;类目以各实体 `category` 字段为准) | 已定性,无需处理 |
280
+
281
+ ### 7.1 数据保真 / lossless fidelity(§0 无损要求的逐项账)✅ 已落地(conversion-v4)
282
+
283
+ CAP-20260623-002(tidas-tools commit `0730b70`)已把可无损映射的富字段落进 TIDAS 字段。**conversion-v4** 实测(conversion-report `rich_field_fidelity_summary`):
284
+
285
+ | 富字段 | 量 | conversion-v4 结果 | TIDAS 目标字段 |
286
+ | --- | --- | --- | --- |
287
+ | 评审记录 reviews | 852 process(v4 有 687 带真实评审类型) | ✅ **保留**(回归守护通过) | `validation.review` |
288
+ | 不确定性分布 | 5,651 exchange | ✅ **全部落字段**:5,129 log-normal geomSd→`relativeStandardDeviation95In`(=GSD²,0 个 >100 残留)+ 522 triangle/uniform min/max | `relativeStandardDeviation95In`、`min/maxAmount` |
289
+ | pedigree 数据质量(process 级) | 1,652 process | ✅ **全部落字段**:dqEntry + dqSystem 指标名→ILCD `dataQualityIndicators`(1=best→Very good…5→Very poor) | `validation.review.common:dataQualityIndicators` |
290
+ | 分配因子 allocationFactors | 61 process | ✅ **已无损落字段**(D3 走 A):56 个多功能过程的 per-exchange allocation **列表**(每 exchange 多 co-product,分数和=100%);方法另在 `LCIMethodApproaches` | exchange `allocations`(列表) |
291
+
292
+ **D3 分配解法(已落地,2026-06-23)**:原以为是 ILCD 模型限制,实为 **TIDAS JSON schema 把 eILCD 的分配列表收窄成了单对象**。eILCD `ILCD_ProcessDataSet.xsd` 明确 `allocation maxOccurs="unbounded"`。修法 = **放宽 TIDAS process schema `allocations.allocation` 为 anyOf [object, array]**(source-of-truth = `tidas-tools/src/tidas_tools/tidas/schemas/tidas_processes.json` + schemas_zh + lock;**push 后经 GitHub `dispatch-tidas-sdk-sync.yml` 自动同步 tidas-sdk**,勿手改其副本;CLI assets 手动镜像已同步)+ 转换器 `_apply_exchange_allocations` 写列表(稀疏 0 项省略,非零和=100%)。**lifecyclemodel(models) 模型不适用**(零 allocation 字段,仅表达系统链接)。conversion-v5:56 process 写入、a591c53f 722 exchange 分数全和=100%、TIDAS 校验 0、单位 78,757/78,757、隔间 0 错配。
293
+
294
+ **已知有据残留**(无 TIDAS 忠实落点,完整数据留 sourceTrace,fidelity summary 计数):
295
+
296
+ - **D1 逐-exchange flow pedigree**(28,572):ILCD 无 per-exchange DQ slot → trace。
297
+ - **U1 三角分布 mode** / **U2 GSD²>100**(USLCI 实际 0 个)/ **D2 dqSystem 身份** / **D3 exchange 派生类型**(openLCA 无原生值,默认 Unknown derivation):均 trace/默认。
298
+
299
+ **口径**:**最终 commit 用 conversion-v4**(=v3 隔间修复 + 本保真增强)。classification(基于 conversion-v3)不触及这些字段,已 pilot 验证可并行;mint/commit 前切 conversion-v4 重建下游链(identity 决策键不变可沿用)。TIDAS 校验 0、单位归一化 78,757/78,757、隔间 0 错配——v4 全部保持。
300
+
301
+ ## 8. 与 BAFU 的差异速查
302
+
303
+ | 维度 | BAFU | USLCI |
304
+ | --- | --- | --- |
305
+ | 源格式 | ecoSpold1 →(预转换)TIDAS 入库 inputs | openLCA JSON-LD 原始包入库 inputs,转换在 Phase 1 现场跑 |
306
+ | 引用闭合 | 包内自洽 | 依赖外部 library(已合并冻结,Phase 0 闭合) |
307
+ | 单位 | 天然同单位 | 12.2% exchange 需换算(§7-2) |
308
+ | 名称形态 | 德文压缩名,需大量 name-split 规则 | 分号结构化英文名,预期无 name-split 回合 |
309
+ | 支持数据 | 合成 contact/source 居多 | 70 真实 actor + 557 真实 source,质量更好 |
310
+ | elementary 体系 | ecoinvent 隔间(trace 恢复) | FEDEFL 隔间(openLcaCompartmentClassification 已适配,9136031) |
311
+ | 批量 runner | dataset-bafu-batch-import-run(bafu 硬编码) | **generic `dataset-process-scope-run`**(threads profileFor,accepts --dry-run/--commit) |
312
+ | My Data override | enabled:true(2026-06-15) | 待 Phase 3-PRE 启用(D4-elementary 用户授权) |
313
+ | coverage/trace 生成器 | `build-bafu-trace-xlsx.py`(路径硬编码) | fork 到 `reports/uslci-import/`(非 drop-in) |
314
+ | 导入单位 | process(unit process) | **同样是 process**(不是 LCA model,见下方说明) |
315
+ | LCI_RESULT/聚合结果 | 几乎无 | 257 个 LCI_RESULT(USLCI 主包 25 + electricity library 232)→ TIDAS process `typeOfDataSet="LCI result"`;D3 定是否导入/标注 |
316
+ | 收尾态 | verified(reuse+MyData) + 7 残留 = 99.94% | 目标同口径:verified + 少量 registered-non-importable = 1,358 |
317
+
318
+ ### 8.1 导入单位澄清:USLCI 全部导入为 process,不是 LCA model(已核验)
319
+
320
+ > 常见误解:USLCI 是连通数据库,是否会有大量数据导入为 LCA models / lifecyclemodels?**不会。**
321
+
322
+ - **两种 openLCA processType 都映射成 TIDAS process**(`tidas_json.py:_process_type` 985-993):`UNIT_PROCESS → typeOfDataSet "Unit process, single operation"`;`LCI_RESULT → "LCI result"`。`typeOfDataSet` 是 ILCD/TIDAS **process 数据集内部**的枚举字段——这四种全是 process,**没有一个变成 lifecyclemodel**。实测 LCI_RESULT(如 "Steel; hot rolled coil")转出确为 `processDataSet` 带 `typeOfDataSet=LCI result`。
323
+ - **conversion-v2 产出 = 2,112 process + 1 lifecyclemodel**。那 1 个 lifecyclemodel 是转换器从全包 defaultProvider 图**派生的候选产物**,不是导入单位。
324
+ - **导入 scope universe 是纯 process**:`scope-projection.jsonl` = `{process: 2112}`,0 个 lifecyclemodel scope。本 goal 的 1,358 in-scope 全是 process。
325
+ - **链接性的去向**:4,474 条带 defaultProvider 的 exchange 形成的产品系统图,作为 trace/链接保留在各 process 内 + 1 个候选 lifecyclemodel,**不会**展开成 2,112 个 lifecyclemodel。若未来要"产品系统/生命周期模型"视图,是导入后基于已入库 process 另建的下游工作,不在本 process 导入 goal 内。
326
+
327
+ ## 9. 需路由的缺陷 / 能力缺口(按归属)
328
+
329
+ > **原则(写入 §1-3 的延伸)**:导入过程中确认的转换/校验缺陷,按归属在 owning 项目同步修复(converter/校验 → tidas-tools;CLI 包装 → tiangong-lca-cli),**绝不在 foundry 打补丁绕过**。确认即开 capability-development-request 任务(模板 `tasks/templates/`),带独立验证 + 全测试,对标已闭环的单位归一化(a3e1aa9)与本会话的 CAP-20260623-001。
330
+
331
+ - **tidas-tools(待修,CAP-20260623-002,commit 前置)**:富字段无损保真——pedigree DQ(881 process + 逐 exchange)、不确定性分布参数(5,651 exchange,log-normal 的 geomSd 等)、分配因子(61 process)现仅进 sourceTrace,须落 TIDAS 字段(`dataQualityIndicators`/`dataDerivationTypeStatus`、`relativeStandardDeviation95In`/min-max、`allocations`,schema 已支持)。修后重转换 **conversion-v4**(commit-canonical)+ 确定性保真扫描。reviews(852)已保留,作回归守护。详见 §7.1。
332
+ - **tidas-tools(✅ 已修复 BUG,CAP-20260623-001 → Done)**:`_flow_classification()` 原对**所有** elementary flow 硬编码 `Emissions to air, unspecified`,无视真实隔间(water 1,966 / soil 703 / **resource 360** 全写成"空气排放",resource 连类目大类都错)。**修复 = tidas-tools commit `cc3aaaf`**:加 `_elementary_categorization` 把 FEDEFL `/` 路径映射进 TIDAS `common:elementaryFlowCategorization` 正确叶子(catId 按 `tidas_flows_elementary_category.json`),dataset-agnostic(ecoSpold 单 token/无路径回退默认,**BAFU 零回归**),+1 测试套件 92 passed。**conversion-v3** 实测:4,872 elementary **0 隔间错配**(原 ~3,072 错)、TIDAS 校验 0、单位归一化 78,757/78,757 全对。**mint 必须用 conversion-v3**(reused flow 用 canonical 分类不受此限)。
333
+ - **tidas-tools(已澄清,非 bug)**:flowType 映射**忠实无误判**。`_flow_type`(`tidas_json.py:1398`)直接读 openLCA 显式 `flowType` 字段,**不用 input/outputGroup**;盘上 6,624 flow 源 flowType→TIDAS typeOfDataSet **0 错配**。"按 input/outputGroup 把 technosphere 误判为 elementary"是 **ecoSpold1 特有担忧,对 openLCA/USLCI 不成立**,无需改动。
334
+ - **tidas-tools(已闭环,作为不变量)**:单位归一化(a3e1aa9)。override **不放松** `canonical_support_amount_scaling_required`——若 USLCI 重新转换(新 tidas-tools/源,**含上面的 conversion-v3**),必须重跑 `$RUN/unit-normalization-verify/verify.py` 全过才恢复 commit。
335
+ - **foundry-generic(可能需要,带测试 + dataset-agnostic)**:FEDEFL trace 形状的全候选池确定性 re-judge(对标 BAFU `fullpool-rejudge.py`)。`openLcaCompartmentClassification`(9136031)已覆盖隔间恢复;先查 USLCI 实际 `sourceTrace.payload` 结构确认是配置-only 还是需代码改动。
336
+ - **foundry-generic(新 line-item)**:无 profile 中立的 coverage/trace 生成器与 batch runner。`dataset-bafu-batch-import-run` / `dataset-bafu-universe-coverage-report` / `build-bafu-trace-xlsx.py` 均 bafu 硬编码。Phase 5 fork trace 生成器;若吞吐不足再把 batch runner 参数化为 profile 驱动(P1,连带 mega-scope 基础设施一并通用化)。