@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.
- package/LICENSE +21 -0
- package/README.md +532 -0
- package/docs/architecture.md +450 -0
- package/docs/foundry-task-contracts.md +147 -0
- package/docs/import-profiles/bafu/constraints.md +343 -0
- package/docs/import-profiles/bafu/leaf-process-classification-authoring.md +153 -0
- package/docs/import-profiles/bafu/profile.md +183 -0
- package/docs/import-profiles/uslci/constraints.md +29 -0
- package/docs/import-profiles/uslci/profile.md +43 -0
- package/docs/import-profiles/worldsteel/constraints.md +77 -0
- package/docs/import-profiles/worldsteel/import-coverage.md +93 -0
- package/docs/import-profiles/worldsteel/import-plan.md +375 -0
- package/docs/import-profiles/worldsteel/profile.md +78 -0
- package/docs/package-distribution-contract.md +287 -0
- package/docs/public-runtime-contract.md +218 -0
- package/docs/runtime-context-contract.md +138 -0
- package/docs/safety-policy.md +164 -0
- package/docs/task-authorization-contract.md +131 -0
- package/docs/uslci-import-runbook.md +336 -0
- package/docs/workspace-migration-contract.md +127 -0
- package/package-dist/assets/foundry-package-descriptor.json +1661 -0
- package/package-dist/scripts/foundry-facade.d.ts +78 -0
- package/package-dist/scripts/foundry-facade.js +1317 -0
- package/package-dist/scripts/foundry-runtime.d.ts +180 -0
- package/package-dist/scripts/foundry-runtime.js +190 -0
- package/package-dist/scripts/lib/batch-orchestration/scope-attempt-ledger.d.ts +27 -0
- package/package-dist/scripts/lib/batch-orchestration/scope-attempt-ledger.js +85 -0
- package/package-dist/scripts/lib/batch-orchestration/scope-resume-contract.d.ts +38 -0
- package/package-dist/scripts/lib/batch-orchestration/scope-resume-contract.js +90 -0
- package/package-dist/scripts/lib/bundle-row-types.d.ts +44 -0
- package/package-dist/scripts/lib/bundle-row-types.js +46 -0
- package/package-dist/scripts/lib/bundle-sample-utils.d.ts +183 -0
- package/package-dist/scripts/lib/bundle-sample-utils.js +526 -0
- package/package-dist/scripts/lib/bundle-source-context.d.ts +31 -0
- package/package-dist/scripts/lib/bundle-source-context.js +142 -0
- package/package-dist/scripts/lib/canonical-description.d.ts +12 -0
- package/package-dist/scripts/lib/canonical-description.js +72 -0
- package/package-dist/scripts/lib/canonical-support-rewrites.d.ts +127 -0
- package/package-dist/scripts/lib/canonical-support-rewrites.js +527 -0
- package/package-dist/scripts/lib/decision-owners/classification.d.ts +245 -0
- package/package-dist/scripts/lib/decision-owners/classification.js +754 -0
- package/package-dist/scripts/lib/decision-owners/identity-preflight.d.ts +333 -0
- package/package-dist/scripts/lib/decision-owners/identity-preflight.js +1353 -0
- package/package-dist/scripts/lib/decision-owners/identity-task.d.ts +130 -0
- package/package-dist/scripts/lib/decision-owners/identity-task.js +494 -0
- package/package-dist/scripts/lib/decision-owners/identity.d.ts +74 -0
- package/package-dist/scripts/lib/decision-owners/identity.js +443 -0
- package/package-dist/scripts/lib/decision-owners/location.d.ts +239 -0
- package/package-dist/scripts/lib/decision-owners/location.js +704 -0
- package/package-dist/scripts/lib/decision-task-utils.d.ts +484 -0
- package/package-dist/scripts/lib/decision-task-utils.js +735 -0
- package/package-dist/scripts/lib/finalize-owners/cli-wrappers.d.ts +52 -0
- package/package-dist/scripts/lib/finalize-owners/cli-wrappers.js +146 -0
- package/package-dist/scripts/lib/finalize-owners/commit-handoff.d.ts +79 -0
- package/package-dist/scripts/lib/finalize-owners/commit-handoff.js +515 -0
- package/package-dist/scripts/lib/finalize-owners/post-authoring.d.ts +234 -0
- package/package-dist/scripts/lib/finalize-owners/post-authoring.js +1720 -0
- package/package-dist/scripts/lib/finalize-owners/post-write-closeout.d.ts +140 -0
- package/package-dist/scripts/lib/finalize-owners/post-write-closeout.js +656 -0
- package/package-dist/scripts/lib/foundry-args.d.ts +7 -0
- package/package-dist/scripts/lib/foundry-args.js +38 -0
- package/package-dist/scripts/lib/foundry-authentication-environment.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-authentication-environment.js +55 -0
- package/package-dist/scripts/lib/foundry-authorization-input.d.ts +31 -0
- package/package-dist/scripts/lib/foundry-authorization-input.js +151 -0
- package/package-dist/scripts/lib/foundry-command-metadata.d.ts +32 -0
- package/package-dist/scripts/lib/foundry-command-metadata.js +1012 -0
- package/package-dist/scripts/lib/foundry-command-registry.d.ts +34 -0
- package/package-dist/scripts/lib/foundry-command-registry.js +241 -0
- package/package-dist/scripts/lib/foundry-command-spec.d.ts +1 -0
- package/package-dist/scripts/lib/foundry-command-spec.js +1 -0
- package/package-dist/scripts/lib/foundry-decision-owners.d.ts +17 -0
- package/package-dist/scripts/lib/foundry-decision-owners.js +68 -0
- package/package-dist/scripts/lib/foundry-decision-routing.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-decision-routing.js +38 -0
- package/package-dist/scripts/lib/foundry-execution-admission.d.ts +33 -0
- package/package-dist/scripts/lib/foundry-execution-admission.js +225 -0
- package/package-dist/scripts/lib/foundry-execution-attempt.d.ts +11 -0
- package/package-dist/scripts/lib/foundry-execution-attempt.js +33 -0
- package/package-dist/scripts/lib/foundry-execution-context-format.d.ts +18 -0
- package/package-dist/scripts/lib/foundry-execution-context-format.js +83 -0
- package/package-dist/scripts/lib/foundry-facade-store.d.ts +25 -0
- package/package-dist/scripts/lib/foundry-facade-store.js +449 -0
- package/package-dist/scripts/lib/foundry-finalize-owners.d.ts +21 -0
- package/package-dist/scripts/lib/foundry-finalize-owners.js +203 -0
- package/package-dist/scripts/lib/foundry-identity-owners.d.ts +13 -0
- package/package-dist/scripts/lib/foundry-identity-owners.js +58 -0
- package/package-dist/scripts/lib/foundry-managed-host.d.ts +7 -0
- package/package-dist/scripts/lib/foundry-managed-host.js +173 -0
- package/package-dist/scripts/lib/foundry-migration-adoption-plan.d.ts +39 -0
- package/package-dist/scripts/lib/foundry-migration-adoption-plan.js +467 -0
- package/package-dist/scripts/lib/foundry-migration-adoption.d.ts +31 -0
- package/package-dist/scripts/lib/foundry-migration-adoption.js +187 -0
- package/package-dist/scripts/lib/foundry-migration-authority.d.ts +42 -0
- package/package-dist/scripts/lib/foundry-migration-authority.js +280 -0
- package/package-dist/scripts/lib/foundry-migration-inventory.d.ts +31 -0
- package/package-dist/scripts/lib/foundry-migration-inventory.js +148 -0
- package/package-dist/scripts/lib/foundry-migration-plan.d.ts +48 -0
- package/package-dist/scripts/lib/foundry-migration-plan.js +234 -0
- package/package-dist/scripts/lib/foundry-migration-replay.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-migration-replay.js +134 -0
- package/package-dist/scripts/lib/foundry-migration-stage.d.ts +15 -0
- package/package-dist/scripts/lib/foundry-migration-stage.js +152 -0
- package/package-dist/scripts/lib/foundry-migration-transfer-io.d.ts +13 -0
- package/package-dist/scripts/lib/foundry-migration-transfer-io.js +226 -0
- package/package-dist/scripts/lib/foundry-migration-transfer.d.ts +36 -0
- package/package-dist/scripts/lib/foundry-migration-transfer.js +350 -0
- package/package-dist/scripts/lib/foundry-operation-result.d.ts +71 -0
- package/package-dist/scripts/lib/foundry-operation-result.js +264 -0
- package/package-dist/scripts/lib/foundry-owner-execution-store.d.ts +319 -0
- package/package-dist/scripts/lib/foundry-owner-execution-store.js +293 -0
- package/package-dist/scripts/lib/foundry-owner-readback.d.ts +22 -0
- package/package-dist/scripts/lib/foundry-owner-readback.js +189 -0
- package/package-dist/scripts/lib/foundry-owner-trace-acceptance.d.ts +15 -0
- package/package-dist/scripts/lib/foundry-owner-trace-acceptance.js +68 -0
- package/package-dist/scripts/lib/foundry-package-contract.d.ts +56 -0
- package/package-dist/scripts/lib/foundry-package-contract.js +392 -0
- package/package-dist/scripts/lib/foundry-private-path.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-private-path.js +20 -0
- package/package-dist/scripts/lib/foundry-runtime-cache.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-runtime-cache.js +25 -0
- package/package-dist/scripts/lib/foundry-runtime-command-policy.d.ts +20 -0
- package/package-dist/scripts/lib/foundry-runtime-command-policy.js +173 -0
- package/package-dist/scripts/lib/foundry-runtime-context-types.d.ts +59 -0
- package/package-dist/scripts/lib/foundry-runtime-context-types.js +1 -0
- package/package-dist/scripts/lib/foundry-runtime-context.d.ts +27 -0
- package/package-dist/scripts/lib/foundry-runtime-context.js +668 -0
- package/package-dist/scripts/lib/foundry-runtime-environment.d.ts +9 -0
- package/package-dist/scripts/lib/foundry-runtime-environment.js +90 -0
- package/package-dist/scripts/lib/foundry-runtime-error.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-runtime-error.js +8 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.d.ts +18 -0
- package/package-dist/scripts/lib/foundry-runtime-identity.js +127 -0
- package/package-dist/scripts/lib/foundry-runtime-paths.d.ts +16 -0
- package/package-dist/scripts/lib/foundry-runtime-paths.js +159 -0
- package/package-dist/scripts/lib/foundry-runtime-qualification.d.ts +66 -0
- package/package-dist/scripts/lib/foundry-runtime-qualification.js +223 -0
- package/package-dist/scripts/lib/foundry-runtime-selection-record.d.ts +16 -0
- package/package-dist/scripts/lib/foundry-runtime-selection-record.js +32 -0
- package/package-dist/scripts/lib/foundry-runtime-selection.d.ts +14 -0
- package/package-dist/scripts/lib/foundry-runtime-selection.js +123 -0
- package/package-dist/scripts/lib/foundry-runtime-utils.d.ts +178 -0
- package/package-dist/scripts/lib/foundry-runtime-utils.js +603 -0
- package/package-dist/scripts/lib/foundry-semantic-input.d.ts +30 -0
- package/package-dist/scripts/lib/foundry-semantic-input.js +132 -0
- package/package-dist/scripts/lib/foundry-task-authorization.d.ts +68 -0
- package/package-dist/scripts/lib/foundry-task-authorization.js +350 -0
- package/package-dist/scripts/lib/foundry-task-io.d.ts +18 -0
- package/package-dist/scripts/lib/foundry-task-io.js +92 -0
- package/package-dist/scripts/lib/foundry-task-registration.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-task-registration.js +384 -0
- package/package-dist/scripts/lib/foundry-task-start-spec.d.ts +34 -0
- package/package-dist/scripts/lib/foundry-task-start-spec.js +161 -0
- package/package-dist/scripts/lib/foundry-task-store.d.ts +18 -0
- package/package-dist/scripts/lib/foundry-task-store.js +466 -0
- package/package-dist/scripts/lib/foundry-task-types.d.ts +99 -0
- package/package-dist/scripts/lib/foundry-task-types.js +1 -0
- package/package-dist/scripts/lib/foundry-workflow-approval-continuation.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-workflow-approval-continuation.js +136 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-workflow-assessment.js +231 -0
- package/package-dist/scripts/lib/foundry-workflow-authorization.d.ts +22 -0
- package/package-dist/scripts/lib/foundry-workflow-authorization.js +174 -0
- package/package-dist/scripts/lib/foundry-workflow-context.d.ts +3 -0
- package/package-dist/scripts/lib/foundry-workflow-context.js +99 -0
- package/package-dist/scripts/lib/foundry-workflow-decisions.d.ts +18 -0
- package/package-dist/scripts/lib/foundry-workflow-decisions.js +123 -0
- package/package-dist/scripts/lib/foundry-workflow-execution.d.ts +8 -0
- package/package-dist/scripts/lib/foundry-workflow-execution.js +248 -0
- package/package-dist/scripts/lib/foundry-workflow-finalize.d.ts +13 -0
- package/package-dist/scripts/lib/foundry-workflow-finalize.js +264 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-apply.d.ts +14 -0
- package/package-dist/scripts/lib/foundry-workflow-identity-apply.js +159 -0
- package/package-dist/scripts/lib/foundry-workflow-identity.d.ts +6 -0
- package/package-dist/scripts/lib/foundry-workflow-identity.js +153 -0
- package/package-dist/scripts/lib/foundry-workflow-import.d.ts +4 -0
- package/package-dist/scripts/lib/foundry-workflow-import.js +70 -0
- package/package-dist/scripts/lib/foundry-workflow-io.d.ts +11 -0
- package/package-dist/scripts/lib/foundry-workflow-io.js +77 -0
- package/package-dist/scripts/lib/foundry-workflow-reference-verify.d.ts +41 -0
- package/package-dist/scripts/lib/foundry-workflow-reference-verify.js +266 -0
- package/package-dist/scripts/lib/foundry-workflow-rows.d.ts +2 -0
- package/package-dist/scripts/lib/foundry-workflow-rows.js +47 -0
- package/package-dist/scripts/lib/foundry-workflow-semantic.d.ts +5 -0
- package/package-dist/scripts/lib/foundry-workflow-semantic.js +367 -0
- package/package-dist/scripts/lib/foundry-workflow-state.d.ts +37 -0
- package/package-dist/scripts/lib/foundry-workflow-state.js +158 -0
- package/package-dist/scripts/lib/full-context-proof.d.ts +51 -0
- package/package-dist/scripts/lib/full-context-proof.js +932 -0
- package/package-dist/scripts/lib/identity-preflight-artifacts.d.ts +184 -0
- package/package-dist/scripts/lib/identity-preflight-artifacts.js +573 -0
- package/package-dist/scripts/lib/identity-preflight-proof.d.ts +117 -0
- package/package-dist/scripts/lib/identity-preflight-proof.js +341 -0
- package/package-dist/scripts/lib/identity-reference-rewrite-utils.d.ts +147 -0
- package/package-dist/scripts/lib/identity-reference-rewrite-utils.js +817 -0
- package/package-dist/scripts/lib/import-curation/authoring-packages.d.ts +28 -0
- package/package-dist/scripts/lib/import-curation/authoring-packages.js +92 -0
- package/package-dist/scripts/lib/import-curation/curation-cleanup.d.ts +32 -0
- package/package-dist/scripts/lib/import-curation/curation-cleanup.js +203 -0
- package/package-dist/scripts/lib/import-curation/curation-gate.d.ts +47 -0
- package/package-dist/scripts/lib/import-curation/curation-gate.js +528 -0
- package/package-dist/scripts/lib/import-curation/internal/artifact-inputs.d.ts +24 -0
- package/package-dist/scripts/lib/import-curation/internal/artifact-inputs.js +152 -0
- package/package-dist/scripts/lib/import-curation/internal/authoring-patch-workflow.d.ts +3 -0
- package/package-dist/scripts/lib/import-curation/internal/authoring-patch-workflow.js +3 -0
- package/package-dist/scripts/lib/import-curation/internal/authoring-task-workflow.d.ts +1 -0
- package/package-dist/scripts/lib/import-curation/internal/authoring-task-workflow.js +1 -0
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.d.ts +56 -0
- package/package-dist/scripts/lib/import-curation/internal/context-inputs.js +206 -0
- package/package-dist/scripts/lib/import-curation/internal/curation-gate-workflow.d.ts +14 -0
- package/package-dist/scripts/lib/import-curation/internal/curation-gate-workflow.js +14 -0
- package/package-dist/scripts/lib/import-curation/internal/dataset-payload.d.ts +70 -0
- package/package-dist/scripts/lib/import-curation/internal/dataset-payload.js +141 -0
- package/package-dist/scripts/lib/import-curation/internal/dataset-types.d.ts +25 -0
- package/package-dist/scripts/lib/import-curation/internal/dataset-types.js +45 -0
- package/package-dist/scripts/lib/import-curation/internal/full-context-proof.d.ts +129 -0
- package/package-dist/scripts/lib/import-curation/internal/full-context-proof.js +552 -0
- package/package-dist/scripts/lib/import-curation/internal/hash-utils.d.ts +2 -0
- package/package-dist/scripts/lib/import-curation/internal/hash-utils.js +10 -0
- package/package-dist/scripts/lib/import-curation/internal/mutation-manifest-workflow.d.ts +15 -0
- package/package-dist/scripts/lib/import-curation/internal/mutation-manifest-workflow.js +15 -0
- package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.d.ts +31 -0
- package/package-dist/scripts/lib/import-curation/internal/prewrite-cleanup.js +467 -0
- package/package-dist/scripts/lib/import-curation/internal/profiles-config.d.ts +47 -0
- package/package-dist/scripts/lib/import-curation/internal/profiles-config.js +88 -0
- package/package-dist/scripts/lib/import-curation/internal/runtime-io.d.ts +23 -0
- package/package-dist/scripts/lib/import-curation/internal/runtime-io.js +132 -0
- package/package-dist/scripts/lib/import-curation/internal/trace-summary.d.ts +53 -0
- package/package-dist/scripts/lib/import-curation/internal/trace-summary.js +114 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-authoring-tasks.d.ts +141 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-authoring-tasks.js +854 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-decision-apply-context.d.ts +20 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-decision-apply-context.js +46 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-decision-full-context.d.ts +110 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-decision-full-context.js +782 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-dry-run-context.d.ts +24 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-dry-run-context.js +191 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-evidence-scope.d.ts +80 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-evidence-scope.js +359 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-decision-context.d.ts +146 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-decision-context.js +381 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.d.ts +223 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-identity-preflight.js +1079 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-collect.d.ts +41 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-collect.js +412 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence-context.d.ts +117 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence-context.js +278 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence.d.ts +59 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-patch-evidence.js +593 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-queue-context.d.ts +58 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-queue-context.js +263 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.d.ts +177 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-reference-closure.js +812 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-row-transform-context.d.ts +159 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-row-transform-context.js +466 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-semantic-actions.d.ts +152 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-semantic-actions.js +1377 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-source-reference-context.d.ts +38 -0
- package/package-dist/scripts/lib/import-curation/internal/workflow-source-reference-context.js +116 -0
- package/package-dist/scripts/lib/import-curation/mutation-manifest.d.ts +51 -0
- package/package-dist/scripts/lib/import-curation/mutation-manifest.js +542 -0
- package/package-dist/scripts/lib/import-curation/patch-collect.d.ts +18 -0
- package/package-dist/scripts/lib/import-curation/patch-collect.js +172 -0
- package/package-dist/scripts/lib/import-curation/profiles.d.ts +1 -0
- package/package-dist/scripts/lib/import-curation/profiles.js +1 -0
- package/package-dist/scripts/lib/import-curation/trace-summary.d.ts +1 -0
- package/package-dist/scripts/lib/import-curation/trace-summary.js +1 -0
- package/package-dist/scripts/lib/oauth-session-reference.d.ts +1 -0
- package/package-dist/scripts/lib/oauth-session-reference.js +20 -0
- package/package-dist/scripts/lib/post-authoring-finalize-utils.d.ts +95 -0
- package/package-dist/scripts/lib/post-authoring-finalize-utils.js +548 -0
- package/package-dist/scripts/lib/post-write-root-proof.d.ts +44 -0
- package/package-dist/scripts/lib/post-write-root-proof.js +169 -0
- package/package-dist/scripts/lib/reference-description-text.d.ts +2 -0
- package/package-dist/scripts/lib/reference-description-text.js +12 -0
- package/package-dist/scripts/lib/remote-verification-accepted-diff.d.ts +42 -0
- package/package-dist/scripts/lib/remote-verification-accepted-diff.js +424 -0
- package/package-dist/scripts/lib/same-identity-commit-recovery.d.ts +8 -0
- package/package-dist/scripts/lib/same-identity-commit-recovery.js +52 -0
- package/package-dist/scripts/lib/source-semantics.d.ts +255 -0
- package/package-dist/scripts/lib/source-semantics.js +888 -0
- package/package-dist/scripts/lib/stage-contract.d.ts +36 -0
- package/package-dist/scripts/lib/stage-contract.js +25 -0
- package/package-dist/scripts/lib/task-authorization.d.ts +84 -0
- package/package-dist/scripts/lib/task-authorization.js +210 -0
- package/package-dist/scripts/lib/tidas-adapter.d.ts +113 -0
- package/package-dist/scripts/lib/tidas-adapter.js +525 -0
- package/package-dist/scripts/lib/tidas-language-utils.d.ts +8 -0
- package/package-dist/scripts/lib/tidas-language-utils.js +206 -0
- package/package-dist/scripts/lib/tidas-row-utils.d.ts +70 -0
- package/package-dist/scripts/lib/tidas-row-utils.js +225 -0
- package/package-dist/scripts/lib/trace-coverage.d.ts +53 -0
- package/package-dist/scripts/lib/trace-coverage.js +178 -0
- package/package-dist/scripts/package-entry.d.ts +2 -0
- package/package-dist/scripts/package-entry.js +4 -0
- package/package-dist/scripts/public-api.d.ts +80 -0
- package/package-dist/scripts/public-api.js +28 -0
- package/package-dist/scripts/runtime-entry.d.ts +23 -0
- package/package-dist/scripts/runtime-entry.js +424 -0
- package/package.json +93 -0
- package/specs/canonical-support/flow-properties-unit-groups.json +2692 -0
- package/specs/import-profiles.json +118 -0
- package/specs/prewrite-content-policy.json +105 -0
- package/specs/schemas/authorization-derivation.schema.json +34 -0
- package/specs/schemas/execution-context.schema.json +68 -0
- package/specs/schemas/foundry-authorization-input.schema.json +120 -0
- package/specs/schemas/foundry-facade-request-index.schema.json +78 -0
- package/specs/schemas/foundry-managed-runtime.schema.json +122 -0
- package/specs/schemas/foundry-migration-activation.schema.json +213 -0
- package/specs/schemas/foundry-migration-adoption-plan.schema.json +548 -0
- package/specs/schemas/foundry-migration-transfer-receipt.schema.json +93 -0
- package/specs/schemas/foundry-operation-result.schema.json +147 -0
- package/specs/schemas/foundry-package-descriptor.schema.json +134 -0
- package/specs/schemas/foundry-runtime-selection.schema.json +59 -0
- package/specs/schemas/foundry-semantic-input.schema.json +36 -0
- package/specs/schemas/foundry-task-start.schema.json +123 -0
- package/specs/schemas/foundry-workspace-migration-pending.schema.json +17 -0
- package/specs/schemas/foundry-workspace-migration-plan.schema.json +59 -0
- package/specs/schemas/foundry-workspace-migration-transfer-plan.schema.json +357 -0
- package/specs/schemas/foundry-workspace-v2.schema.json +70 -0
- package/specs/schemas/runtime-qualification.schema.json +63 -0
- package/specs/schemas/task-authorization.schema.json +154 -0
- package/specs/schemas/tidas-runtime-expectation.schema.json +54 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createFileArtifactFact, createFoundryCommandSpec } from "./foundry-command-spec.js";
|
|
4
|
+
function isUnknownRecord(value) {
|
|
5
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
6
|
+
}
|
|
7
|
+
export function createIdentityPreflightArtifactUtils({ asText, bundleClassificationPath, cleanEcoSpoldNameText, collectSourceTracePayloads, datasetIdentity, ensureArray, fileExists, flowNameParts, flowTypeOfDataSet, isConvertedDefaultClassification, jsonSha256, normalizedList, processAuthoringContextFromTrace, processSourceClassificationSummary, readJson, readJsonLines, repoRelativeMaybe, repoRelativePath, resolveRepoPath, safeFileToken, sha256Text, shellQuote, sourceTraceLocationCode, textValue, writeJson, writeJsonLines, }) {
|
|
8
|
+
function normalizedLookupKey(key) {
|
|
9
|
+
return String(key ?? "")
|
|
10
|
+
.split(":")
|
|
11
|
+
.pop()
|
|
12
|
+
.replace(/[^A-Za-z0-9]+/gu, "")
|
|
13
|
+
.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function collectValuesByNormalizedKey(value, wantedKeys, output = []) {
|
|
16
|
+
if (!value || typeof value !== "object")
|
|
17
|
+
return output;
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
for (const item of value)
|
|
20
|
+
collectValuesByNormalizedKey(item, wantedKeys, output);
|
|
21
|
+
return output;
|
|
22
|
+
}
|
|
23
|
+
for (const [key, child] of Object.entries(value)) {
|
|
24
|
+
if (wantedKeys.has(normalizedLookupKey(key)))
|
|
25
|
+
output.push(child);
|
|
26
|
+
collectValuesByNormalizedKey(child, wantedKeys, output);
|
|
27
|
+
}
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
function collectTextsFromValue(value, output = []) {
|
|
31
|
+
const direct = textValue(value);
|
|
32
|
+
if (direct) {
|
|
33
|
+
output.push(direct);
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
for (const item of value)
|
|
38
|
+
collectTextsFromValue(item, output);
|
|
39
|
+
return output;
|
|
40
|
+
}
|
|
41
|
+
if (value && typeof value === "object") {
|
|
42
|
+
for (const [key, child] of Object.entries(value)) {
|
|
43
|
+
if (key.startsWith("@"))
|
|
44
|
+
continue;
|
|
45
|
+
collectTextsFromValue(child, output);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return output;
|
|
49
|
+
}
|
|
50
|
+
function isSearchNoiseText(value) {
|
|
51
|
+
const text = asText(value).normalize("NFKC").replace(/\s+/gu, " ").trim();
|
|
52
|
+
if (!text)
|
|
53
|
+
return true;
|
|
54
|
+
if (/^(?:<null>|not specified|not declared|not known|unspecified|n\/a|none|null)$/iu.test(text)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (/^not specified by the .* source\.?$/iu.test(text))
|
|
58
|
+
return true;
|
|
59
|
+
if (/^dataValidForEntirePeriod\s*=\s*true$/iu.test(text))
|
|
60
|
+
return true;
|
|
61
|
+
if (/^ilcd format$/iu.test(text))
|
|
62
|
+
return true;
|
|
63
|
+
if (/^ilcd data network\s*-\s*entry-level$/iu.test(text))
|
|
64
|
+
return true;
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
function sanitizeSearchText(value) {
|
|
68
|
+
return cleanEcoSpoldNameText(value)
|
|
69
|
+
.replace(/\bGeography:\s*(?:Unspecified|Not specified|Not known)\b\.?/giu, "")
|
|
70
|
+
.replace(/<null>/giu, "")
|
|
71
|
+
.replace(/\bnot known\b/giu, "")
|
|
72
|
+
.replace(/\s*\/\s*;?\s*$/u, "")
|
|
73
|
+
.replace(/\s*;\s*$/u, "")
|
|
74
|
+
.replace(/\s{2,}/gu, " ")
|
|
75
|
+
.trim();
|
|
76
|
+
}
|
|
77
|
+
function normalizeSearchText(value) {
|
|
78
|
+
return asText(value)
|
|
79
|
+
.normalize("NFKC")
|
|
80
|
+
.toLowerCase()
|
|
81
|
+
.replace(/[^\p{Letter}\p{Number}]+/gu, " ")
|
|
82
|
+
.replace(/\s+/gu, " ")
|
|
83
|
+
.trim();
|
|
84
|
+
}
|
|
85
|
+
function uniqueSearchTexts(values, limit = 6) {
|
|
86
|
+
const byKey = new Map();
|
|
87
|
+
for (const value of values.flat()) {
|
|
88
|
+
for (const text of collectTextsFromValue(value)) {
|
|
89
|
+
const cleaned = sanitizeSearchText(text);
|
|
90
|
+
if (isSearchNoiseText(cleaned))
|
|
91
|
+
continue;
|
|
92
|
+
const normalized = normalizeSearchText(cleaned);
|
|
93
|
+
if (normalized && !byKey.has(normalized))
|
|
94
|
+
byKey.set(normalized, cleaned);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return [...byKey.values()].slice(0, limit);
|
|
98
|
+
}
|
|
99
|
+
function truncateSearchText(value, maxChars = 240) {
|
|
100
|
+
const text = asText(value).replace(/\s+/gu, " ").trim();
|
|
101
|
+
if (!text || text.length <= maxChars)
|
|
102
|
+
return text;
|
|
103
|
+
return `${text.slice(0, Math.max(0, maxChars - 1)).trim()}…`;
|
|
104
|
+
}
|
|
105
|
+
function appendSearchBriefLine(lines, label, values, limit = 6, maxChars = 240) {
|
|
106
|
+
const texts = uniqueSearchTexts(ensureArray(values), limit).map((text) => truncateSearchText(text, maxChars));
|
|
107
|
+
if (texts.length > 0)
|
|
108
|
+
lines.push(`${label}: ${texts.join("; ")}`);
|
|
109
|
+
}
|
|
110
|
+
function bundleClassificationPathForSearch(payload, type) {
|
|
111
|
+
const classificationPath = bundleClassificationPath(payload, type);
|
|
112
|
+
return isConvertedDefaultClassification(classificationPath) ? "" : classificationPath;
|
|
113
|
+
}
|
|
114
|
+
function sourceClassificationTextsForSearch(sourceClassification) {
|
|
115
|
+
return [
|
|
116
|
+
sourceClassification.category,
|
|
117
|
+
sourceClassification.subCategory,
|
|
118
|
+
sourceClassification.localCategory,
|
|
119
|
+
sourceClassification.localSubCategory,
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
function processNameParts(payload) {
|
|
123
|
+
const name = payload?.processDataSet?.processInformation?.dataSetInformation?.name ?? {};
|
|
124
|
+
return {
|
|
125
|
+
base_name: asText(name.baseName?.["#text"] ?? name.baseName),
|
|
126
|
+
treatment_standards_routes: asText(name.treatmentStandardsRoutes?.["#text"] ?? name.treatmentStandardsRoutes),
|
|
127
|
+
mix_and_location_types: asText(name.mixAndLocationTypes?.["#text"] ?? name.mixAndLocationTypes),
|
|
128
|
+
functional_unit_flow_properties: asText(name.functionalUnitFlowProperties?.["#text"] ?? name.functionalUnitFlowProperties),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function valuesByKeys(payload, keys, limit = 6) {
|
|
132
|
+
const wanted = new Set(keys.map(normalizedLookupKey));
|
|
133
|
+
return uniqueSearchTexts(collectValuesByNormalizedKey(payload, wanted), limit);
|
|
134
|
+
}
|
|
135
|
+
function isLikelyLocationCodeText(value) {
|
|
136
|
+
const text = asText(value).trim();
|
|
137
|
+
if (!text || /\s/u.test(text) || text.length > 24)
|
|
138
|
+
return false;
|
|
139
|
+
return /^[A-Za-z]{2,5}(?:-[A-Za-z0-9]{1,8})*$/u.test(text);
|
|
140
|
+
}
|
|
141
|
+
function locationCodeSearchTexts(values, limit = 4) {
|
|
142
|
+
return uniqueSearchTexts(values, limit).filter(isLikelyLocationCodeText);
|
|
143
|
+
}
|
|
144
|
+
function processGeographySearchTexts(payload, sourceTraces = []) {
|
|
145
|
+
const location = payload?.processDataSet?.processInformation?.geography?.locationOfOperationSupplyOrProduction;
|
|
146
|
+
return locationCodeSearchTexts([
|
|
147
|
+
location?.["@location"],
|
|
148
|
+
location?.location,
|
|
149
|
+
sourceTraceLocationCode(sourceTraces),
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
function elementaryFlowCategoryPath(payload) {
|
|
153
|
+
const categories = payload?.flowDataSet?.flowInformation?.dataSetInformation?.classificationInformation?.["common:elementaryFlowCategorization"]?.["common:category"];
|
|
154
|
+
return ensureArray(categories)
|
|
155
|
+
.map((entry) => textValue(entry))
|
|
156
|
+
.filter(Boolean)
|
|
157
|
+
.join(" > ");
|
|
158
|
+
}
|
|
159
|
+
function elementaryFlowCategoryPathForSearch(payload, sourceClassification) {
|
|
160
|
+
const categoryPath = elementaryFlowCategoryPath(payload);
|
|
161
|
+
if (!categoryPath)
|
|
162
|
+
return "";
|
|
163
|
+
const sourceText = sourceClassificationTextsForSearch(sourceClassification)
|
|
164
|
+
.join(" ")
|
|
165
|
+
.toLowerCase();
|
|
166
|
+
if (sourceText &&
|
|
167
|
+
/(?:resources?|land)/iu.test(sourceText) &&
|
|
168
|
+
/emissions?\s*>\s*emissions?\s+to\s+air/iu.test(categoryPath)) {
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
171
|
+
return categoryPath;
|
|
172
|
+
}
|
|
173
|
+
function elementaryFlowCompartmentAliasesForSearch(payload, sourceClassification) {
|
|
174
|
+
const categoryText = uniqueSearchTexts([
|
|
175
|
+
elementaryFlowCategoryPath(payload),
|
|
176
|
+
...sourceClassificationTextsForSearch(sourceClassification),
|
|
177
|
+
], 12)
|
|
178
|
+
.join(" ")
|
|
179
|
+
.toLowerCase();
|
|
180
|
+
if (!categoryText)
|
|
181
|
+
return [];
|
|
182
|
+
const aliases = [];
|
|
183
|
+
const isAir = /emissions?\s+to\s+air|air emissions?/iu.test(categoryText);
|
|
184
|
+
if (isAir &&
|
|
185
|
+
(/\blow\.?\s*pop\.?\b/iu.test(categoryText) ||
|
|
186
|
+
/low\s+population/iu.test(categoryText) ||
|
|
187
|
+
/non[-\s]?urban/iu.test(categoryText) ||
|
|
188
|
+
/high\s+stacks?/iu.test(categoryText))) {
|
|
189
|
+
aliases.push("Emissions to non-urban air or from high stacks", "non-urban air or from high stacks", "low population air emissions");
|
|
190
|
+
}
|
|
191
|
+
if (isAir &&
|
|
192
|
+
(/\bhigh\.?\s*pop\.?\b/iu.test(categoryText) ||
|
|
193
|
+
/high\s+population/iu.test(categoryText) ||
|
|
194
|
+
/urban\s+air\s+close\s+to\s+ground/iu.test(categoryText))) {
|
|
195
|
+
aliases.push("Emissions to urban air close to ground", "urban air close to ground", "high population air emissions");
|
|
196
|
+
}
|
|
197
|
+
if (isAir && /unspecified/iu.test(categoryText)) {
|
|
198
|
+
aliases.push("Emissions to air, unspecified");
|
|
199
|
+
}
|
|
200
|
+
if (/fresh\s+water/iu.test(categoryText)) {
|
|
201
|
+
aliases.push("Emissions to fresh water");
|
|
202
|
+
}
|
|
203
|
+
if (/sea\s+water|ocean/iu.test(categoryText)) {
|
|
204
|
+
aliases.push("Emissions to sea water");
|
|
205
|
+
}
|
|
206
|
+
if (/water/iu.test(categoryText) && /unspecified/iu.test(categoryText)) {
|
|
207
|
+
aliases.push("Emissions to water, unspecified");
|
|
208
|
+
}
|
|
209
|
+
if (/non[-\s]?agricultural\s+soil/iu.test(categoryText)) {
|
|
210
|
+
aliases.push("Emissions to non-agricultural soil");
|
|
211
|
+
}
|
|
212
|
+
else if (/agricultural\s+soil/iu.test(categoryText)) {
|
|
213
|
+
aliases.push("Emissions to agricultural soil");
|
|
214
|
+
}
|
|
215
|
+
else if (/soil/iu.test(categoryText) && /unspecified/iu.test(categoryText)) {
|
|
216
|
+
aliases.push("Emissions to soil, unspecified");
|
|
217
|
+
}
|
|
218
|
+
return uniqueSearchTexts(aliases, 8);
|
|
219
|
+
}
|
|
220
|
+
function flowReferencePropertyTexts(payload) {
|
|
221
|
+
const flowProperties = ensureArray(payload?.flowDataSet?.flowProperties?.flowProperty);
|
|
222
|
+
return uniqueSearchTexts(flowProperties.map((property) => property?.referenceToFlowPropertyDataSet?.["common:shortDescription"] ??
|
|
223
|
+
property?.referenceToFlowPropertyDataSet), 4);
|
|
224
|
+
}
|
|
225
|
+
function referenceDescriptionTexts(payload, keyNames, limit = 8, { includeIds = true } = {}) {
|
|
226
|
+
const wanted = new Set(keyNames.map(normalizedLookupKey));
|
|
227
|
+
return uniqueSearchTexts(collectValuesByNormalizedKey(payload, wanted).map((reference) => {
|
|
228
|
+
if (isUnknownRecord(reference)) {
|
|
229
|
+
const descriptions = [reference["common:shortDescription"], reference.shortDescription];
|
|
230
|
+
const descriptionTexts = uniqueSearchTexts(descriptions, 4);
|
|
231
|
+
if (descriptionTexts.length > 0 || !includeIds) {
|
|
232
|
+
return descriptionTexts;
|
|
233
|
+
}
|
|
234
|
+
return reference["@refObjectId"];
|
|
235
|
+
}
|
|
236
|
+
return reference;
|
|
237
|
+
}), limit);
|
|
238
|
+
}
|
|
239
|
+
function processReferenceFlowSearchTexts(payload, limit = 4) {
|
|
240
|
+
const processDataSet = payload?.processDataSet ?? {};
|
|
241
|
+
const referenceInternalIds = uniqueSearchTexts(ensureArray(processDataSet?.processInformation?.quantitativeReference?.referenceToReferenceFlow), 4);
|
|
242
|
+
const internalIdSet = new Set(referenceInternalIds.map((id) => normalizeSearchText(id)));
|
|
243
|
+
const exchanges = ensureArray(processDataSet?.exchanges?.exchange).filter((exchange) => exchange && typeof exchange === "object");
|
|
244
|
+
const referenceExchanges = internalIdSet.size > 0
|
|
245
|
+
? exchanges.filter((exchange) => internalIdSet.has(normalizeSearchText(exchange?.["@dataSetInternalID"])))
|
|
246
|
+
: [];
|
|
247
|
+
const selected = referenceExchanges.length > 0 ? referenceExchanges : exchanges.slice(0, 1);
|
|
248
|
+
return uniqueSearchTexts(selected.flatMap((exchange) => {
|
|
249
|
+
const reference = exchange?.referenceToFlowDataSet ?? {};
|
|
250
|
+
const descriptions = [reference?.["common:shortDescription"], reference?.shortDescription];
|
|
251
|
+
const descriptionTexts = uniqueSearchTexts(descriptions, limit);
|
|
252
|
+
return descriptionTexts.length > 0 ? descriptionTexts : [reference?.["@refObjectId"]];
|
|
253
|
+
}), limit);
|
|
254
|
+
}
|
|
255
|
+
function processExchangeSearchSignature(payload, limit = 12) {
|
|
256
|
+
const exchanges = ensureArray(payload?.processDataSet?.exchanges?.exchange);
|
|
257
|
+
return uniqueSearchTexts(exchanges.map((exchange) => {
|
|
258
|
+
const reference = exchange?.referenceToFlowDataSet ?? {};
|
|
259
|
+
const referenceText = textValue(reference?.["common:shortDescription"]) ||
|
|
260
|
+
textValue(reference?.shortDescription) ||
|
|
261
|
+
textValue(reference?.["@refObjectId"]) ||
|
|
262
|
+
textValue(reference);
|
|
263
|
+
const direction = textValue(exchange?.exchangeDirection ?? exchange?.inputGroup ?? exchange?.outputGroup);
|
|
264
|
+
const amount = textValue(exchange?.meanAmount ??
|
|
265
|
+
exchange?.resultingAmount ??
|
|
266
|
+
exchange?.amount ??
|
|
267
|
+
exchange?.meanValue);
|
|
268
|
+
return [direction, referenceText, amount].filter(Boolean).join(" ");
|
|
269
|
+
}), limit);
|
|
270
|
+
}
|
|
271
|
+
function compactSearchBrief(lines) {
|
|
272
|
+
return lines
|
|
273
|
+
.map((line) => line.replace(/\s+/gu, " ").trim())
|
|
274
|
+
.filter(Boolean)
|
|
275
|
+
.join("\n")
|
|
276
|
+
.slice(0, 1800)
|
|
277
|
+
.trim();
|
|
278
|
+
}
|
|
279
|
+
function identityPreflightHybridSearchOptions() {
|
|
280
|
+
return {
|
|
281
|
+
match_threshold: 0.15,
|
|
282
|
+
lexical_weight: 0.8,
|
|
283
|
+
semantic_weight: 0.2,
|
|
284
|
+
rrf_k: 30,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function flowHybridSearchBrief(payload, sourceTraces = []) {
|
|
288
|
+
const authoringContext = processAuthoringContextFromTrace(sourceTraces);
|
|
289
|
+
const sourceClassification = processSourceClassificationSummary(sourceTraces);
|
|
290
|
+
const nameParts = flowNameParts(payload);
|
|
291
|
+
const lines = [];
|
|
292
|
+
appendSearchBriefLine(lines, "flow name", [
|
|
293
|
+
nameParts.base_name,
|
|
294
|
+
nameParts.treatment_standards_routes,
|
|
295
|
+
nameParts.mix_and_location_types,
|
|
296
|
+
nameParts.functional_unit_flow_properties,
|
|
297
|
+
], 4, 180);
|
|
298
|
+
appendSearchBriefLine(lines, "flow type", flowTypeOfDataSet(payload), 1);
|
|
299
|
+
appendSearchBriefLine(lines, "CAS", valuesByKeys(payload, ["CASNumber", "cas"]));
|
|
300
|
+
appendSearchBriefLine(lines, "reference property", flowReferencePropertyTexts(payload));
|
|
301
|
+
appendSearchBriefLine(lines, "reference unit", authoringContext.source_unit, 1);
|
|
302
|
+
appendSearchBriefLine(lines, "category or compartment", [
|
|
303
|
+
bundleClassificationPathForSearch(payload, "flow"),
|
|
304
|
+
elementaryFlowCategoryPathForSearch(payload, sourceClassification),
|
|
305
|
+
...sourceClassificationTextsForSearch(sourceClassification),
|
|
306
|
+
]);
|
|
307
|
+
appendSearchBriefLine(lines, "compartment aliases", elementaryFlowCompartmentAliasesForSearch(payload, sourceClassification));
|
|
308
|
+
appendSearchBriefLine(lines, "target classification candidate", bundleClassificationPathForSearch(payload, "flow"));
|
|
309
|
+
appendSearchBriefLine(lines, "source classification or compartment", sourceClassificationTextsForSearch(sourceClassification));
|
|
310
|
+
appendSearchBriefLine(lines, "geography or market", [
|
|
311
|
+
...valuesByKeys(payload, ["geography", "location", "market", "mixAndLocationTypes"]),
|
|
312
|
+
authoringContext.source_location,
|
|
313
|
+
]);
|
|
314
|
+
appendSearchBriefLine(lines, "source location", authoringContext.source_location);
|
|
315
|
+
return compactSearchBrief(lines);
|
|
316
|
+
}
|
|
317
|
+
function processHybridSearchBrief(payload, sourceTraces = []) {
|
|
318
|
+
const authoringContext = processAuthoringContextFromTrace(sourceTraces);
|
|
319
|
+
const nameParts = processNameParts(payload);
|
|
320
|
+
const lines = [];
|
|
321
|
+
appendSearchBriefLine(lines, "process name", [
|
|
322
|
+
nameParts.base_name,
|
|
323
|
+
nameParts.treatment_standards_routes,
|
|
324
|
+
nameParts.mix_and_location_types,
|
|
325
|
+
nameParts.functional_unit_flow_properties,
|
|
326
|
+
authoringContext.source_name,
|
|
327
|
+
authoringContext.source_local_name,
|
|
328
|
+
], 4, 220);
|
|
329
|
+
appendSearchBriefLine(lines, "reference flow", processReferenceFlowSearchTexts(payload, 4));
|
|
330
|
+
appendSearchBriefLine(lines, "quantitative reference", valuesByKeys(payload, ["functionalUnitOrOther"]));
|
|
331
|
+
appendSearchBriefLine(lines, "geography", processGeographySearchTexts(payload, sourceTraces));
|
|
332
|
+
appendSearchBriefLine(lines, "time", valuesByKeys(payload, ["time", "referenceYear", "timePeriod"]));
|
|
333
|
+
appendSearchBriefLine(lines, "classification or sector", [
|
|
334
|
+
bundleClassificationPathForSearch(payload, "process"),
|
|
335
|
+
...sourceClassificationTextsForSearch(processSourceClassificationSummary(sourceTraces)),
|
|
336
|
+
]);
|
|
337
|
+
appendSearchBriefLine(lines, "target classification candidate", bundleClassificationPathForSearch(payload, "process"));
|
|
338
|
+
appendSearchBriefLine(lines, "source classification or sector", sourceClassificationTextsForSearch(processSourceClassificationSummary(sourceTraces)));
|
|
339
|
+
appendSearchBriefLine(lines, "technology route", [
|
|
340
|
+
...valuesByKeys(payload, [
|
|
341
|
+
"technologyDescriptionAndIncludedProcesses",
|
|
342
|
+
"treatmentStandardsRoutes",
|
|
343
|
+
]),
|
|
344
|
+
authoringContext.technology,
|
|
345
|
+
], 2, 320);
|
|
346
|
+
appendSearchBriefLine(lines, "system boundary", [authoringContext.included_processes], 2, 220);
|
|
347
|
+
appendSearchBriefLine(lines, "exchange flow refs", referenceDescriptionTexts(payload, ["referenceToFlowDataSet"], 6, {
|
|
348
|
+
includeIds: false,
|
|
349
|
+
}), 6, 160);
|
|
350
|
+
appendSearchBriefLine(lines, "exchange signature", processExchangeSearchSignature(payload, 6), 6, 160);
|
|
351
|
+
return compactSearchBrief(lines);
|
|
352
|
+
}
|
|
353
|
+
function identityPreflightRemoteSearchRequest(type, payload, sourceTraces = []) {
|
|
354
|
+
const query = type === "process"
|
|
355
|
+
? processHybridSearchBrief(payload, sourceTraces)
|
|
356
|
+
: flowHybridSearchBrief(payload, sourceTraces);
|
|
357
|
+
const isElementaryFlow = type === "flow" && /^elementary flow$/iu.test(flowTypeOfDataSet(payload));
|
|
358
|
+
const filter = type === "flow" && flowTypeOfDataSet(payload)
|
|
359
|
+
? { flowType: flowTypeOfDataSet(payload) }
|
|
360
|
+
: null;
|
|
361
|
+
const profileHints = identityPreflightProfileHints(type, payload, sourceTraces);
|
|
362
|
+
return {
|
|
363
|
+
enabled: true,
|
|
364
|
+
query,
|
|
365
|
+
...(Object.keys(profileHints).length > 0 ? { profile_hints: profileHints } : {}),
|
|
366
|
+
data_source: "tg",
|
|
367
|
+
limit: isElementaryFlow ? 80 : 20,
|
|
368
|
+
...identityPreflightHybridSearchOptions(),
|
|
369
|
+
...(filter ? { filter } : {}),
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function edgeSearchRequestPreview(type, remoteSearch) {
|
|
373
|
+
return {
|
|
374
|
+
endpoint: type === "process" ? "process_hybrid_search" : "flow_hybrid_search",
|
|
375
|
+
body: {
|
|
376
|
+
query: remoteSearch.query,
|
|
377
|
+
...(remoteSearch.filter ? { filter: remoteSearch.filter } : {}),
|
|
378
|
+
match_count: remoteSearch.limit,
|
|
379
|
+
page_size: remoteSearch.limit,
|
|
380
|
+
data_source: remoteSearch.data_source,
|
|
381
|
+
...identityPreflightHybridSearchOptions(),
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function identityPreflightProfileHints(type, payload, sourceTraces = []) {
|
|
386
|
+
const authoringContext = processAuthoringContextFromTrace(sourceTraces);
|
|
387
|
+
const sourceClassification = processSourceClassificationSummary(sourceTraces);
|
|
388
|
+
if (type === "flow") {
|
|
389
|
+
const sourceCategories = uniqueSearchTexts(sourceClassificationTextsForSearch(sourceClassification), 8);
|
|
390
|
+
const hints = {
|
|
391
|
+
type_of_dataset: flowTypeOfDataSet(payload),
|
|
392
|
+
flow_property: flowReferencePropertyTexts(payload),
|
|
393
|
+
reference_unit: authoringContext.source_unit,
|
|
394
|
+
categories: sourceCategories,
|
|
395
|
+
geography: authoringContext.source_location,
|
|
396
|
+
};
|
|
397
|
+
return Object.fromEntries(Object.entries(hints).filter(([, value]) => Array.isArray(value) ? value.length > 0 : Boolean(asText(value))));
|
|
398
|
+
}
|
|
399
|
+
const hints = {
|
|
400
|
+
reference_flow_names: processReferenceFlowSearchTexts(payload, 4),
|
|
401
|
+
quantitative_reference: valuesByKeys(payload, ["functionalUnitOrOther"], 2),
|
|
402
|
+
geography: authoringContext.source_location,
|
|
403
|
+
technology_route: authoringContext.technology,
|
|
404
|
+
system_boundary: authoringContext.included_processes,
|
|
405
|
+
categories: uniqueSearchTexts(sourceClassificationTextsForSearch(sourceClassification), 8),
|
|
406
|
+
};
|
|
407
|
+
return Object.fromEntries(Object.entries(hints).filter(([, value]) => Array.isArray(value) ? value.length > 0 : Boolean(asText(value))));
|
|
408
|
+
}
|
|
409
|
+
function readSourceTracesFromFile(sourceFile) {
|
|
410
|
+
if (!sourceFile || !fileExists(sourceFile))
|
|
411
|
+
return [];
|
|
412
|
+
return collectSourceTracePayloads(readJson(sourceFile));
|
|
413
|
+
}
|
|
414
|
+
function buildIdentityPreflightArtifacts({ rowsByType, sourceByType, outDir, cliBin, }) {
|
|
415
|
+
const cliPrefix = Array.isArray(cliBin) ? cliBin : [cliBin];
|
|
416
|
+
const requestsRoot = path.join(outDir, "identity-preflight-requests");
|
|
417
|
+
const indexRows = [];
|
|
418
|
+
const byIdentity = new Map();
|
|
419
|
+
for (const type of ["flow", "process"]) {
|
|
420
|
+
const plural = type === "flow" ? "flows" : "processes";
|
|
421
|
+
const requestDir = path.join(requestsRoot, plural);
|
|
422
|
+
for (const [key, payload] of rowsByType[type].entries()) {
|
|
423
|
+
const identity = datasetIdentity(payload, type);
|
|
424
|
+
if (!identity.id || !identity.version)
|
|
425
|
+
continue;
|
|
426
|
+
const sourceFile = sourceByType[type].get(key);
|
|
427
|
+
const sourceTraces = readSourceTracesFromFile(sourceFile);
|
|
428
|
+
const remoteSearch = identityPreflightRemoteSearchRequest(type, payload, sourceTraces);
|
|
429
|
+
const request = {
|
|
430
|
+
schema_version: 1,
|
|
431
|
+
target: payload,
|
|
432
|
+
remote_candidate_search: remoteSearch,
|
|
433
|
+
};
|
|
434
|
+
const requestPath = path.join(requestDir, `${safeFileToken(identity.id, "missing")}.json`);
|
|
435
|
+
writeJson(requestPath, request);
|
|
436
|
+
const outputDir = path.join(outDir, "identity-preflight", plural, safeFileToken(identity.id, "missing"));
|
|
437
|
+
const expectedReportFile = path.join(outputDir, "outputs", "identity-decision.json");
|
|
438
|
+
const expectedCandidatesFile = path.join(outputDir, "outputs", "identity-candidates.jsonl");
|
|
439
|
+
const expectedCandidateSourcesFile = path.join(outputDir, "outputs", "identity-candidate-sources.json");
|
|
440
|
+
const commandTokens = [
|
|
441
|
+
...cliPrefix,
|
|
442
|
+
type,
|
|
443
|
+
"identity-preflight",
|
|
444
|
+
"--input",
|
|
445
|
+
requestPath,
|
|
446
|
+
"--out-dir",
|
|
447
|
+
outputDir,
|
|
448
|
+
"--json",
|
|
449
|
+
];
|
|
450
|
+
const command = commandTokens.map(shellQuote).join(" ");
|
|
451
|
+
const requestText = fs.readFileSync(requestPath, "utf8");
|
|
452
|
+
const indexRow = {
|
|
453
|
+
dataset_type: type,
|
|
454
|
+
dataset_id: identity.id,
|
|
455
|
+
dataset_version: identity.version,
|
|
456
|
+
target_sha256: jsonSha256(payload),
|
|
457
|
+
request_bytes_sha256: sha256Text(requestText),
|
|
458
|
+
request_json_sha256: jsonSha256(request),
|
|
459
|
+
source_file: repoRelativeMaybe(sourceFile),
|
|
460
|
+
request_file: repoRelativePath(requestPath),
|
|
461
|
+
output_dir: repoRelativePath(outputDir),
|
|
462
|
+
expected_report_file: repoRelativePath(expectedReportFile),
|
|
463
|
+
expected_candidates_file: repoRelativePath(expectedCandidatesFile),
|
|
464
|
+
expected_candidate_sources_file: repoRelativePath(expectedCandidateSourcesFile),
|
|
465
|
+
command,
|
|
466
|
+
command_spec: createFoundryCommandSpec({
|
|
467
|
+
executable: commandTokens[0],
|
|
468
|
+
argv: commandTokens.slice(1),
|
|
469
|
+
binding: {
|
|
470
|
+
artifacts: [
|
|
471
|
+
createFileArtifactFact({
|
|
472
|
+
role: "identity_preflight_request",
|
|
473
|
+
path: repoRelativePath(requestPath),
|
|
474
|
+
filePath: requestPath,
|
|
475
|
+
}),
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
}),
|
|
479
|
+
remote_search: {
|
|
480
|
+
data_source: remoteSearch.data_source,
|
|
481
|
+
limit: remoteSearch.limit,
|
|
482
|
+
filter: remoteSearch.filter ?? null,
|
|
483
|
+
query: remoteSearch.query,
|
|
484
|
+
edge_request: edgeSearchRequestPreview(type, remoteSearch),
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
indexRows.push(indexRow);
|
|
488
|
+
byIdentity.set(`${type}:${identity.id}:${identity.version}`, indexRow);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const indexPath = path.join(requestsRoot, "identity-preflight-requests.jsonl");
|
|
492
|
+
writeJsonLines(indexPath, indexRows);
|
|
493
|
+
return {
|
|
494
|
+
root: requestsRoot,
|
|
495
|
+
indexPath,
|
|
496
|
+
rows: indexRows,
|
|
497
|
+
byIdentity,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function identityPreflightSourceIndexPaths(options) {
|
|
501
|
+
return normalizedList(options.sourceIndex ||
|
|
502
|
+
options.sourceIndexes ||
|
|
503
|
+
options.sourceContextIndex ||
|
|
504
|
+
options.sourceContextIndexes).map(resolveRepoPath);
|
|
505
|
+
}
|
|
506
|
+
function identityPreflightSourceIndexKey(row) {
|
|
507
|
+
return [
|
|
508
|
+
asText(row?.dataset_type || row?.type),
|
|
509
|
+
asText(row?.dataset_id || row?.entity_id || row?.id),
|
|
510
|
+
asText(row?.dataset_version || row?.version) || "00.00.001",
|
|
511
|
+
].join(":");
|
|
512
|
+
}
|
|
513
|
+
function loadIdentityPreflightSourceFileMap(indexPaths) {
|
|
514
|
+
const sourceFilesByIdentity = new Map();
|
|
515
|
+
const blockers = [];
|
|
516
|
+
let rowCount = 0;
|
|
517
|
+
for (const indexPath of indexPaths) {
|
|
518
|
+
if (!indexPath || !fileExists(indexPath)) {
|
|
519
|
+
blockers.push({
|
|
520
|
+
code: "identity_preflight_source_index_missing",
|
|
521
|
+
message: "--source-index must point to a readable identity-preflight index.",
|
|
522
|
+
source_index: repoRelativeMaybe(indexPath),
|
|
523
|
+
});
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
for (const row of readJsonLines(indexPath)) {
|
|
527
|
+
rowCount += 1;
|
|
528
|
+
const key = identityPreflightSourceIndexKey(row);
|
|
529
|
+
if (!key.startsWith("flow:") && !key.startsWith("process:"))
|
|
530
|
+
continue;
|
|
531
|
+
const sourceFile = asText(row.source_file || row.sourceFile);
|
|
532
|
+
if (!sourceFile)
|
|
533
|
+
continue;
|
|
534
|
+
const resolvedSourceFile = resolveRepoPath(sourceFile);
|
|
535
|
+
if (!fileExists(resolvedSourceFile)) {
|
|
536
|
+
blockers.push({
|
|
537
|
+
code: "identity_preflight_source_context_file_missing",
|
|
538
|
+
message: "A matching source-index row points to a source_file that no longer exists.",
|
|
539
|
+
source_index: repoRelativePath(indexPath),
|
|
540
|
+
source_file: repoRelativeMaybe(resolvedSourceFile),
|
|
541
|
+
dataset_key: key,
|
|
542
|
+
});
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (!sourceFilesByIdentity.has(key)) {
|
|
546
|
+
sourceFilesByIdentity.set(key, resolvedSourceFile);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
sourceFilesByIdentity,
|
|
552
|
+
rowCount,
|
|
553
|
+
blockers,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function attachIdentityPreflightRows(queueRows, identityArtifacts) {
|
|
557
|
+
for (const row of queueRows) {
|
|
558
|
+
const match = identityArtifacts.byIdentity.get(`${row.dataset_type}:${row.dataset_id}:${row.dataset_version}`);
|
|
559
|
+
if (!match)
|
|
560
|
+
continue;
|
|
561
|
+
row.identity_preflight_request_file = match.request_file;
|
|
562
|
+
row.identity_preflight_command = match.command;
|
|
563
|
+
row.remote_search = match.remote_search;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
attachIdentityPreflightRows,
|
|
568
|
+
buildIdentityPreflightArtifacts,
|
|
569
|
+
identityPreflightSourceIndexPaths,
|
|
570
|
+
isLikelyLocationCodeText,
|
|
571
|
+
loadIdentityPreflightSourceFileMap,
|
|
572
|
+
};
|
|
573
|
+
}
|