@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,817 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { canonicalDescriptionPair, cloneCanonicalDescription, } from "./canonical-description.js";
|
|
4
|
+
import { referenceDescriptionText } from "./reference-description-text.js";
|
|
5
|
+
export function createIdentityReferenceRewriteUtils({ asText, cloneJson, countRowsFile, datasetIdentity, datasetRowsFileStem, ensureArray, fileExists, foundryTraceNamespace, identityPreflightCommands, languageForText, multiLang, normalizedList, nowIso, pathExpression, preferredSourceLanguageText, readJson, readJsonLines, readRowsFile, repoRelativeMaybe, repoRelativePath, resolveRepoPath, supportText, unique, writeJson, writeJsonLines, }) {
|
|
6
|
+
function identityReferenceRewriteIndexPath(options, rowsFile) {
|
|
7
|
+
const explicit = options.identityPreflightIndex ||
|
|
8
|
+
options.identityPreflightRequests ||
|
|
9
|
+
options.identityPreflightRequestsIndex ||
|
|
10
|
+
options.identityPreflightFile;
|
|
11
|
+
if (explicit)
|
|
12
|
+
return resolveRepoPath(explicit);
|
|
13
|
+
if (!rowsFile)
|
|
14
|
+
return null;
|
|
15
|
+
const defaultPath = path.join(path.dirname(path.dirname(rowsFile)), "identity-preflight-requests", "identity-preflight-requests.jsonl");
|
|
16
|
+
return fileExists(defaultPath) ? defaultPath : null;
|
|
17
|
+
}
|
|
18
|
+
function firstCandidateName(candidate) {
|
|
19
|
+
return (preferredSourceLanguageText(candidate?.names) ||
|
|
20
|
+
asText(candidate?.name_en) ||
|
|
21
|
+
asText(candidate?.name));
|
|
22
|
+
}
|
|
23
|
+
function flowGlobalReference({ id, version, shortDescription, }) {
|
|
24
|
+
const description = cloneCanonicalDescription(shortDescription) || id;
|
|
25
|
+
return {
|
|
26
|
+
"@type": "flow data set",
|
|
27
|
+
"@refObjectId": id,
|
|
28
|
+
"@version": version || "00.00.001",
|
|
29
|
+
"@uri": `../flows/${id}.json`,
|
|
30
|
+
"common:shortDescription": typeof description === "string"
|
|
31
|
+
? multiLang(description, languageForText(description))
|
|
32
|
+
: description,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function referenceShortDescription(reference) {
|
|
36
|
+
return referenceDescriptionText(reference, asText);
|
|
37
|
+
}
|
|
38
|
+
function duplicateFlowCandidateFromReport(report) {
|
|
39
|
+
if (asText(report?.kind) !== "flow" ||
|
|
40
|
+
asText(report?.decision) !== "block_duplicate" ||
|
|
41
|
+
asText(report?.confidence) !== "high") {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return (ensureArray(report?.candidates).find((candidate) => {
|
|
45
|
+
const reasons = ensureArray(candidate?.match_reasons).map(asText);
|
|
46
|
+
return (asText(candidate?.decision_hint) === "block_duplicate" ||
|
|
47
|
+
reasons.includes("equivalent_flow_core_fields") ||
|
|
48
|
+
reasons.includes("same_identity_key"));
|
|
49
|
+
}) ?? null);
|
|
50
|
+
}
|
|
51
|
+
function loadIdentityDuplicateFlowMappings(indexPath) {
|
|
52
|
+
const mappings = new Map();
|
|
53
|
+
const rows = indexPath && fileExists(indexPath) ? readJsonLines(indexPath) : [];
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const datasetType = asText(row.dataset_type || row.type);
|
|
56
|
+
if (datasetType !== "flow")
|
|
57
|
+
continue;
|
|
58
|
+
const sourceId = asText(row.dataset_id || row.entity_id || row.id);
|
|
59
|
+
const sourceVersion = asText(row.dataset_version || row.version) || "00.00.001";
|
|
60
|
+
if (!sourceId)
|
|
61
|
+
continue;
|
|
62
|
+
const reportFile = identityPreflightCommands.identityPreflightRunReportFile(row);
|
|
63
|
+
const report = reportFile && fileExists(reportFile) ? readJson(reportFile) : null;
|
|
64
|
+
const candidate = duplicateFlowCandidateFromReport(report);
|
|
65
|
+
const canonicalId = asText(candidate?.id);
|
|
66
|
+
if (!canonicalId)
|
|
67
|
+
continue;
|
|
68
|
+
const confirmedIndexPath = indexPath;
|
|
69
|
+
const confirmedReport = report;
|
|
70
|
+
const confirmedCandidate = candidate;
|
|
71
|
+
const mapping = {
|
|
72
|
+
source: {
|
|
73
|
+
ref_object_id: sourceId,
|
|
74
|
+
version: sourceVersion,
|
|
75
|
+
},
|
|
76
|
+
canonical: {
|
|
77
|
+
table: "flows",
|
|
78
|
+
ref_object_id: canonicalId,
|
|
79
|
+
version: asText(candidate?.version) || "00.00.001",
|
|
80
|
+
short_description: firstCandidateName(candidate) || canonicalId,
|
|
81
|
+
},
|
|
82
|
+
identity_preflight: {
|
|
83
|
+
index_file: repoRelativePath(confirmedIndexPath),
|
|
84
|
+
report_file: repoRelativeMaybe(reportFile),
|
|
85
|
+
decision: confirmedReport.decision,
|
|
86
|
+
status: confirmedReport.status,
|
|
87
|
+
confidence: confirmedReport.confidence ?? null,
|
|
88
|
+
candidate_index: confirmedCandidate.index ?? null,
|
|
89
|
+
candidate_match_score: confirmedCandidate.match_score ?? null,
|
|
90
|
+
candidate_match_reasons: ensureArray(confirmedCandidate.match_reasons),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
mappings.set(`${sourceId}@@${sourceVersion}`, mapping);
|
|
94
|
+
if (!mappings.has(sourceId))
|
|
95
|
+
mappings.set(sourceId, mapping);
|
|
96
|
+
}
|
|
97
|
+
return { rows, mappings };
|
|
98
|
+
}
|
|
99
|
+
function jsonLineFileHasRows(filePath) {
|
|
100
|
+
return Boolean(filePath && fileExists(filePath) && readJsonLines(filePath).length > 0);
|
|
101
|
+
}
|
|
102
|
+
function existingFilePath(filePath) {
|
|
103
|
+
return Boolean(filePath && fileExists(filePath));
|
|
104
|
+
}
|
|
105
|
+
function identityReferenceRewriteInputFiles(options = {}) {
|
|
106
|
+
const files = [];
|
|
107
|
+
const directOptions = [
|
|
108
|
+
options.identityReferenceRewrites,
|
|
109
|
+
options.identityReferenceRewritesFile,
|
|
110
|
+
options.identityFlowReferenceRewrites,
|
|
111
|
+
options.identityFlowReferenceRewritesFile,
|
|
112
|
+
];
|
|
113
|
+
for (const directOption of directOptions) {
|
|
114
|
+
for (const item of normalizedList(directOption)) {
|
|
115
|
+
const filePath = resolveRepoPath(item);
|
|
116
|
+
if (jsonLineFileHasRows(filePath))
|
|
117
|
+
files.push(filePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const reportOptions = unique([
|
|
121
|
+
...normalizedList(options.identityDecisionApplyReport),
|
|
122
|
+
...normalizedList(options.identityDecisionsApplyReport),
|
|
123
|
+
...normalizedList(options.identityDecisionApplyReports),
|
|
124
|
+
...normalizedList(options.identityDecisionsApplyReports),
|
|
125
|
+
]);
|
|
126
|
+
for (const reportOption of reportOptions) {
|
|
127
|
+
const reportFile = resolveRepoPath(reportOption);
|
|
128
|
+
if (!reportFile || !fileExists(reportFile))
|
|
129
|
+
continue;
|
|
130
|
+
const report = readJson(reportFile);
|
|
131
|
+
const reportFiles = report.files;
|
|
132
|
+
const rewriteFile = resolveRepoPath(reportFiles?.identity_reference_rewrites);
|
|
133
|
+
if (jsonLineFileHasRows(rewriteFile))
|
|
134
|
+
files.push(rewriteFile);
|
|
135
|
+
}
|
|
136
|
+
return unique(files);
|
|
137
|
+
}
|
|
138
|
+
function identityUnresolvedReferenceInputFiles(options = {}) {
|
|
139
|
+
const files = [];
|
|
140
|
+
const directOptions = [
|
|
141
|
+
options.identityUnresolvedReferences,
|
|
142
|
+
options.identityUnresolvedReferencesFile,
|
|
143
|
+
options.identityUnresolvedReferenceFile,
|
|
144
|
+
];
|
|
145
|
+
for (const directOption of directOptions) {
|
|
146
|
+
for (const item of normalizedList(directOption)) {
|
|
147
|
+
const filePath = resolveRepoPath(item);
|
|
148
|
+
if (filePath && fileExists(filePath))
|
|
149
|
+
files.push(filePath);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const reportOptions = unique([
|
|
153
|
+
...normalizedList(options.identityDecisionApplyReport),
|
|
154
|
+
...normalizedList(options.identityDecisionsApplyReport),
|
|
155
|
+
...normalizedList(options.identityDecisionApplyReports),
|
|
156
|
+
...normalizedList(options.identityDecisionsApplyReports),
|
|
157
|
+
]);
|
|
158
|
+
for (const reportOption of reportOptions) {
|
|
159
|
+
const reportFile = resolveRepoPath(reportOption);
|
|
160
|
+
if (!reportFile || !fileExists(reportFile))
|
|
161
|
+
continue;
|
|
162
|
+
const report = readJson(reportFile);
|
|
163
|
+
const reportFiles = report.files;
|
|
164
|
+
const unresolvedFile = resolveRepoPath(reportFiles?.identity_unresolved_references);
|
|
165
|
+
if (unresolvedFile && fileExists(unresolvedFile))
|
|
166
|
+
files.push(unresolvedFile);
|
|
167
|
+
}
|
|
168
|
+
return unique(files);
|
|
169
|
+
}
|
|
170
|
+
function loadIdentityReferenceRewriteMappings(rewriteFiles) {
|
|
171
|
+
const mappings = new Map();
|
|
172
|
+
const rows = [];
|
|
173
|
+
for (const rewriteFileValue of ensureArray(rewriteFiles)) {
|
|
174
|
+
const rewriteFile = rewriteFileValue;
|
|
175
|
+
if (!rewriteFile || !fileExists(rewriteFile))
|
|
176
|
+
continue;
|
|
177
|
+
for (const row of readJsonLines(rewriteFile)) {
|
|
178
|
+
rows.push(row);
|
|
179
|
+
const original = (row.original ?? {});
|
|
180
|
+
const canonical = (row.canonical ?? {});
|
|
181
|
+
const sourceId = asText(original.ref_object_id ?? original.refObjectId ?? original.id ?? row?.dataset_id);
|
|
182
|
+
const sourceVersion = asText(original.version ??
|
|
183
|
+
original.ref_version ??
|
|
184
|
+
original["@version"] ??
|
|
185
|
+
row?.dataset_version) || "00.00.001";
|
|
186
|
+
const canonicalId = asText(canonical.ref_object_id ?? canonical.refObjectId ?? canonical.id);
|
|
187
|
+
if (!sourceId || !canonicalId)
|
|
188
|
+
continue;
|
|
189
|
+
const canonicalDescription = canonicalDescriptionPair(canonical.short_description ?? canonical.shortDescription, asText).ledger;
|
|
190
|
+
const mapping = {
|
|
191
|
+
source: {
|
|
192
|
+
ref_object_id: sourceId,
|
|
193
|
+
version: sourceVersion,
|
|
194
|
+
},
|
|
195
|
+
canonical: {
|
|
196
|
+
table: asText(canonical.table) || "flows",
|
|
197
|
+
ref_object_id: canonicalId,
|
|
198
|
+
version: asText(canonical.version ?? canonical.ref_version ?? canonical["@version"]) ||
|
|
199
|
+
"00.00.001",
|
|
200
|
+
short_description: canonicalDescription || canonicalId,
|
|
201
|
+
},
|
|
202
|
+
identity_preflight: row.identity_preflight ?? null,
|
|
203
|
+
identity_decision: row.identity_decision ?? null,
|
|
204
|
+
rewrite_source: {
|
|
205
|
+
file: repoRelativePath(rewriteFile),
|
|
206
|
+
relation: row.relation ?? null,
|
|
207
|
+
action: row.action ?? null,
|
|
208
|
+
reason: row.reason ?? null,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
mappings.set(`${sourceId}@@${sourceVersion}`, mapping);
|
|
212
|
+
if (!mappings.has(sourceId))
|
|
213
|
+
mappings.set(sourceId, mapping);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return { rows, mappings };
|
|
217
|
+
}
|
|
218
|
+
function loadIdentityUnresolvedReferenceMappings(files) {
|
|
219
|
+
const mappings = new Map();
|
|
220
|
+
const rows = [];
|
|
221
|
+
for (const filePathValue of ensureArray(files)) {
|
|
222
|
+
const filePath = filePathValue;
|
|
223
|
+
if (!filePath || !fileExists(filePath))
|
|
224
|
+
continue;
|
|
225
|
+
for (const row of readJsonLines(filePath)) {
|
|
226
|
+
rows.push(row);
|
|
227
|
+
const original = (row.original ?? {});
|
|
228
|
+
const sourceId = asText(original.ref_object_id ?? original.refObjectId ?? original.id ?? row?.dataset_id);
|
|
229
|
+
const sourceVersion = asText(original.version ??
|
|
230
|
+
original.ref_version ??
|
|
231
|
+
original["@version"] ??
|
|
232
|
+
row?.dataset_version) || "00.00.001";
|
|
233
|
+
if (!sourceId)
|
|
234
|
+
continue;
|
|
235
|
+
const mapping = {
|
|
236
|
+
source: {
|
|
237
|
+
ref_object_id: sourceId,
|
|
238
|
+
version: sourceVersion,
|
|
239
|
+
short_description: asText(original.short_description ?? original.shortDescription) || sourceId,
|
|
240
|
+
},
|
|
241
|
+
identity_decision: row.identity_decision ?? null,
|
|
242
|
+
identity_evidence: row.evidence ?? null,
|
|
243
|
+
unresolved_source: {
|
|
244
|
+
file: repoRelativePath(filePath),
|
|
245
|
+
relation: row.relation ?? null,
|
|
246
|
+
action: row.action ?? null,
|
|
247
|
+
reason: row.reason ?? null,
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
mappings.set(`${sourceId}@@${sourceVersion}`, mapping);
|
|
251
|
+
if (!mappings.has(sourceId))
|
|
252
|
+
mappings.set(sourceId, mapping);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return { rows, mappings };
|
|
256
|
+
}
|
|
257
|
+
function processDataSetInformation(row) {
|
|
258
|
+
const rowRecord = row;
|
|
259
|
+
const processDataSet = rowRecord?.processDataSet;
|
|
260
|
+
const processInformation = processDataSet?.processInformation;
|
|
261
|
+
return processInformation?.dataSetInformation ?? null;
|
|
262
|
+
}
|
|
263
|
+
function ensureCommonOther(dataSetInformation) {
|
|
264
|
+
if (!dataSetInformation || typeof dataSetInformation !== "object")
|
|
265
|
+
return null;
|
|
266
|
+
const dataSetInformationRecord = dataSetInformation;
|
|
267
|
+
const current = dataSetInformationRecord["common:other"];
|
|
268
|
+
if (current && typeof current === "object" && !Array.isArray(current)) {
|
|
269
|
+
return current;
|
|
270
|
+
}
|
|
271
|
+
dataSetInformationRecord["common:other"] = {};
|
|
272
|
+
return dataSetInformationRecord["common:other"];
|
|
273
|
+
}
|
|
274
|
+
function appendUnresolvedFlowReferenceTrace(row, traceEntry) {
|
|
275
|
+
const commonOther = ensureCommonOther(processDataSetInformation(row));
|
|
276
|
+
if (!commonOther)
|
|
277
|
+
return false;
|
|
278
|
+
commonOther["@xmlns:tiangongfoundry"] =
|
|
279
|
+
commonOther["@xmlns:tiangongfoundry"] ?? foundryTraceNamespace;
|
|
280
|
+
const key = "tiangongfoundry:unresolvedTrace";
|
|
281
|
+
const current = commonOther[key];
|
|
282
|
+
if (current === undefined) {
|
|
283
|
+
commonOther[key] = [traceEntry];
|
|
284
|
+
}
|
|
285
|
+
else if (Array.isArray(current)) {
|
|
286
|
+
current.push(traceEntry);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
commonOther[key] = [current, traceEntry];
|
|
290
|
+
}
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
function unresolvedFlowTraceReferenceId(trace) {
|
|
294
|
+
const traceRecord = trace;
|
|
295
|
+
const evidence = traceRecord?.evidence;
|
|
296
|
+
const target = evidence?.target;
|
|
297
|
+
const identityDecision = evidence?.identity_decision;
|
|
298
|
+
const identityDecisionEvidence = identityDecision?.evidence;
|
|
299
|
+
const identityDecisionTarget = identityDecisionEvidence?.target;
|
|
300
|
+
return asText(traceRecord?.reference_id ??
|
|
301
|
+
traceRecord?.referenceId ??
|
|
302
|
+
target?.id ??
|
|
303
|
+
target?.["@refObjectId"] ??
|
|
304
|
+
identityDecisionTarget?.id ??
|
|
305
|
+
identityDecisionTarget?.["@refObjectId"]);
|
|
306
|
+
}
|
|
307
|
+
function blockedFlowReferenceBlockerFiles(options = {}) {
|
|
308
|
+
return normalizedList(options.blockedFlowReferenceBlockers ||
|
|
309
|
+
options.blockedFlowReferenceBlockersFile ||
|
|
310
|
+
options.upstreamFlowBlockers ||
|
|
311
|
+
options.upstreamFlowBlockersFile ||
|
|
312
|
+
options.canonicalSupportBlockers ||
|
|
313
|
+
options.canonicalSupportBlockersFile)
|
|
314
|
+
.map(resolveRepoPath)
|
|
315
|
+
.filter(existingFilePath);
|
|
316
|
+
}
|
|
317
|
+
function blockedFlowReferenceBlockersById(options = {}) {
|
|
318
|
+
const byId = new Map();
|
|
319
|
+
for (const filePath of blockedFlowReferenceBlockerFiles(options)) {
|
|
320
|
+
for (const blocker of readJsonLines(filePath)) {
|
|
321
|
+
const datasetType = asText(blocker.dataset_type ?? blocker.datasetType ?? blocker.type);
|
|
322
|
+
const code = asText(blocker.code ?? blocker.blocker_code ?? blocker.blockerCode);
|
|
323
|
+
if (datasetType && datasetType !== "flow")
|
|
324
|
+
continue;
|
|
325
|
+
if (code && code !== "canonical_flow_property_reference_unresolved") {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const id = asText(blocker.dataset_id ?? blocker.datasetId ?? blocker.entity_id ?? blocker.id);
|
|
329
|
+
if (!id)
|
|
330
|
+
continue;
|
|
331
|
+
const existing = byId.get(id) ?? [];
|
|
332
|
+
existing.push({
|
|
333
|
+
...blocker,
|
|
334
|
+
blocker_file: repoRelativePath(filePath),
|
|
335
|
+
});
|
|
336
|
+
byId.set(id, existing);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return byId;
|
|
340
|
+
}
|
|
341
|
+
function externalizeUnresolvedProcessFlowExchanges({ datasetType, rowsFile, outFile, outDir, options = {}, }) {
|
|
342
|
+
const reportFile = path.join(outDir, "unresolved-exchange-externalization-report.json");
|
|
343
|
+
const tracesFile = path.join(outDir, "unresolved-exchanges.jsonl");
|
|
344
|
+
if (datasetType !== "process") {
|
|
345
|
+
const report = {
|
|
346
|
+
schema_version: 1,
|
|
347
|
+
generated_at_utc: nowIso(),
|
|
348
|
+
stage: "unresolved_exchange_externalization",
|
|
349
|
+
status: "not_required",
|
|
350
|
+
input_rows_file: repoRelativePath(rowsFile),
|
|
351
|
+
output_rows_file: repoRelativePath(rowsFile),
|
|
352
|
+
counts: {
|
|
353
|
+
rows: countRowsFile(rowsFile),
|
|
354
|
+
affected_rows: 0,
|
|
355
|
+
externalized_exchanges: 0,
|
|
356
|
+
},
|
|
357
|
+
files: {
|
|
358
|
+
report: repoRelativePath(reportFile),
|
|
359
|
+
output_rows: repoRelativePath(rowsFile),
|
|
360
|
+
traces: null,
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
writeJson(reportFile, report);
|
|
364
|
+
return report;
|
|
365
|
+
}
|
|
366
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
367
|
+
const rows = readRowsFile(rowsFile);
|
|
368
|
+
const externalized = [];
|
|
369
|
+
const blockedFlowReferencesById = blockedFlowReferenceBlockersById(options);
|
|
370
|
+
let affectedRows = 0;
|
|
371
|
+
let elementaryFlowExternalized = 0;
|
|
372
|
+
let blockedDependencyExternalized = 0;
|
|
373
|
+
rows.forEach((row, rowIndex) => {
|
|
374
|
+
const jsonOrdered = row.json_ordered;
|
|
375
|
+
const processDataSet = (row.processDataSet ?? jsonOrdered?.processDataSet);
|
|
376
|
+
const processInformation = processDataSet?.processInformation;
|
|
377
|
+
const dataSetInformation = processInformation?.dataSetInformation ?? null;
|
|
378
|
+
const commonOther = ensureCommonOther(dataSetInformation);
|
|
379
|
+
const commonOtherRecord = commonOther;
|
|
380
|
+
const unresolvedTraces = ensureArray(commonOther?.["tiangongfoundry:unresolvedTrace"]);
|
|
381
|
+
const unresolvedById = new Map();
|
|
382
|
+
for (const traceValue of unresolvedTraces) {
|
|
383
|
+
const trace = traceValue;
|
|
384
|
+
if (trace.action_item_code !== "elementary_flow_identity_manual_review") {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const referenceId = unresolvedFlowTraceReferenceId(trace);
|
|
388
|
+
if (referenceId) {
|
|
389
|
+
unresolvedById.set(referenceId, trace);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (unresolvedById.size === 0 && blockedFlowReferencesById.size === 0) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const exchangesRecord = processDataSet?.exchanges;
|
|
396
|
+
const exchanges = ensureArray(exchangesRecord?.exchange);
|
|
397
|
+
if (exchanges.length === 0)
|
|
398
|
+
return;
|
|
399
|
+
const kept = [];
|
|
400
|
+
let rowExternalized = 0;
|
|
401
|
+
for (const [exchangeIndex, exchangeValue] of exchanges.entries()) {
|
|
402
|
+
const exchange = exchangeValue;
|
|
403
|
+
const reference = exchange?.referenceToFlowDataSet;
|
|
404
|
+
const referenceId = asText(reference?.["@refObjectId"] ?? reference?.refObjectId);
|
|
405
|
+
const unresolvedTrace = referenceId ? unresolvedById.get(referenceId) : null;
|
|
406
|
+
const blockedFlowReferenceBlockers = referenceId
|
|
407
|
+
? (blockedFlowReferencesById.get(referenceId) ?? [])
|
|
408
|
+
: [];
|
|
409
|
+
if (!referenceId || (!unresolvedTrace && blockedFlowReferenceBlockers.length === 0)) {
|
|
410
|
+
kept.push(exchange);
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
commonOtherRecord["@xmlns:tiangongfoundry"] =
|
|
414
|
+
commonOtherRecord["@xmlns:tiangongfoundry"] ?? foundryTraceNamespace;
|
|
415
|
+
const actionItemCode = unresolvedTrace
|
|
416
|
+
? "elementary_flow_exchange_externalized"
|
|
417
|
+
: "blocked_flow_dependency_exchange_externalized";
|
|
418
|
+
const externalizedTrace = {
|
|
419
|
+
status: "externalized_before_remote_write",
|
|
420
|
+
action_item_code: actionItemCode,
|
|
421
|
+
blocked_path: `processDataSet.exchanges.exchange.${exchangeIndex}.referenceToFlowDataSet`,
|
|
422
|
+
reference_id: referenceId,
|
|
423
|
+
reference_version: asText(reference?.["@version"] ?? reference?.version) || null,
|
|
424
|
+
reason: unresolvedTrace
|
|
425
|
+
? "Formal exchange references an unresolved elementary flow identity. Foundry moved the full exchange into common:other trace before remote write planning so the process can remain schema-valid while preserving source evidence for later repair."
|
|
426
|
+
: "Formal exchange references a flow row that cannot be written because its required Flow Property or Unit Group is not backed by a canonical public database support row. Foundry moved the full exchange into common:other trace before remote write planning to avoid a dangling flow reference.",
|
|
427
|
+
unresolved_trace: unresolvedTrace ? cloneJson(unresolvedTrace) : null,
|
|
428
|
+
upstream_flow_blockers: blockedFlowReferenceBlockers.length > 0 ? cloneJson(blockedFlowReferenceBlockers) : [],
|
|
429
|
+
original_exchange: cloneJson(exchange),
|
|
430
|
+
next_action: unresolvedTrace
|
|
431
|
+
? "Resolve this elementary flow against an approved public TianGong flow, then restore a formal process exchange in a later curated repair."
|
|
432
|
+
: "Add the missing public canonical Flow Property or Unit Group support row, rerun flow finalization, then restore this process exchange in a later curated repair.",
|
|
433
|
+
};
|
|
434
|
+
const traceKey = "tiangongfoundry:unresolvedExchangeTrace";
|
|
435
|
+
const current = commonOtherRecord[traceKey];
|
|
436
|
+
if (current === undefined) {
|
|
437
|
+
commonOtherRecord[traceKey] = [externalizedTrace];
|
|
438
|
+
}
|
|
439
|
+
else if (Array.isArray(current)) {
|
|
440
|
+
current.push(externalizedTrace);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
commonOtherRecord[traceKey] = [current, externalizedTrace];
|
|
444
|
+
}
|
|
445
|
+
externalized.push({
|
|
446
|
+
relation: unresolvedTrace
|
|
447
|
+
? "process_exchange_to_unresolved_elementary_flow_trace"
|
|
448
|
+
: "process_exchange_to_blocked_flow_dependency_trace",
|
|
449
|
+
action: "externalize_exchange_before_remote_write",
|
|
450
|
+
dataset_type: "process",
|
|
451
|
+
dataset_id: datasetIdentity(row, "process").id || null,
|
|
452
|
+
dataset_version: datasetIdentity(row, "process").version || null,
|
|
453
|
+
row_index: rowIndex,
|
|
454
|
+
exchange_index: exchangeIndex,
|
|
455
|
+
path: externalizedTrace.blocked_path,
|
|
456
|
+
original: {
|
|
457
|
+
table: "flows",
|
|
458
|
+
ref_object_id: referenceId,
|
|
459
|
+
version: externalizedTrace.reference_version,
|
|
460
|
+
short_description: referenceShortDescription(reference) || null,
|
|
461
|
+
},
|
|
462
|
+
trace: externalizedTrace,
|
|
463
|
+
});
|
|
464
|
+
if (unresolvedTrace) {
|
|
465
|
+
elementaryFlowExternalized += 1;
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
blockedDependencyExternalized += 1;
|
|
469
|
+
}
|
|
470
|
+
rowExternalized += 1;
|
|
471
|
+
}
|
|
472
|
+
if (rowExternalized > 0) {
|
|
473
|
+
affectedRows += 1;
|
|
474
|
+
const processDataSetRecord = processDataSet;
|
|
475
|
+
const nextExchanges = (processDataSetRecord.exchanges ??= {});
|
|
476
|
+
nextExchanges.exchange = kept;
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
writeJsonLines(outFile, rows);
|
|
480
|
+
writeJsonLines(tracesFile, externalized);
|
|
481
|
+
const report = {
|
|
482
|
+
schema_version: 1,
|
|
483
|
+
generated_at_utc: nowIso(),
|
|
484
|
+
stage: "unresolved_exchange_externalization",
|
|
485
|
+
status: "completed",
|
|
486
|
+
input_rows_file: repoRelativePath(rowsFile),
|
|
487
|
+
output_rows_file: repoRelativePath(outFile),
|
|
488
|
+
counts: {
|
|
489
|
+
rows: rows.length,
|
|
490
|
+
affected_rows: affectedRows,
|
|
491
|
+
externalized_exchanges: externalized.length,
|
|
492
|
+
elementary_flow_externalized: elementaryFlowExternalized,
|
|
493
|
+
blocked_flow_dependency_externalized: blockedDependencyExternalized,
|
|
494
|
+
upstream_blocked_flow_references: blockedFlowReferencesById.size,
|
|
495
|
+
},
|
|
496
|
+
files: {
|
|
497
|
+
report: repoRelativePath(reportFile),
|
|
498
|
+
output_rows: repoRelativePath(outFile),
|
|
499
|
+
traces: repoRelativePath(tracesFile),
|
|
500
|
+
blocked_flow_reference_blockers: blockedFlowReferenceBlockerFiles(options).map(repoRelativePath),
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
writeJson(reportFile, report);
|
|
504
|
+
return report;
|
|
505
|
+
}
|
|
506
|
+
function rewriteIdentityDuplicateFlowReferences(value, { mappings, unresolvedMappings, datasetIdentityCache, rowRoot, rowIndex, rewriteRows, unresolvedRows, stats, pathSegments = [], }) {
|
|
507
|
+
if (!value || typeof value !== "object")
|
|
508
|
+
return;
|
|
509
|
+
if (Array.isArray(value)) {
|
|
510
|
+
value.forEach((item, index) => rewriteIdentityDuplicateFlowReferences(item, {
|
|
511
|
+
mappings,
|
|
512
|
+
unresolvedMappings,
|
|
513
|
+
datasetIdentityCache,
|
|
514
|
+
rowRoot,
|
|
515
|
+
rowIndex,
|
|
516
|
+
rewriteRows,
|
|
517
|
+
unresolvedRows,
|
|
518
|
+
stats,
|
|
519
|
+
pathSegments: [...pathSegments, index],
|
|
520
|
+
}));
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const valueRecord = value;
|
|
524
|
+
for (const [key, child] of Object.entries(valueRecord)) {
|
|
525
|
+
const childPath = [...pathSegments, key];
|
|
526
|
+
if (key === "referenceToFlowDataSet" &&
|
|
527
|
+
child &&
|
|
528
|
+
typeof child === "object" &&
|
|
529
|
+
!Array.isArray(child)) {
|
|
530
|
+
const reference = child;
|
|
531
|
+
const originalId = asText(reference["@refObjectId"] ?? reference.refObjectId);
|
|
532
|
+
const originalVersion = asText(reference["@version"] ?? reference.version) || "00.00.001";
|
|
533
|
+
const mapping = mappings.get(`${originalId}@@${originalVersion}`) ?? mappings.get(originalId);
|
|
534
|
+
if (mapping) {
|
|
535
|
+
const canonicalId = mapping.canonical.ref_object_id;
|
|
536
|
+
const canonicalVersion = mapping.canonical.version || "00.00.001";
|
|
537
|
+
const originalShortDescription = referenceShortDescription(child);
|
|
538
|
+
const preservesExistingShortDescription = originalShortDescription &&
|
|
539
|
+
originalId === canonicalId &&
|
|
540
|
+
originalVersion === canonicalVersion;
|
|
541
|
+
const next = flowGlobalReference({
|
|
542
|
+
id: canonicalId,
|
|
543
|
+
version: canonicalVersion,
|
|
544
|
+
shortDescription: preservesExistingShortDescription
|
|
545
|
+
? originalShortDescription
|
|
546
|
+
: mapping.canonical.short_description,
|
|
547
|
+
});
|
|
548
|
+
valueRecord[key] = next;
|
|
549
|
+
stats.rewrites += 1;
|
|
550
|
+
rewriteRows.push({
|
|
551
|
+
relation: mapping.rewrite_source?.relation ?? "flow_reference_to_identity_preflight_duplicate",
|
|
552
|
+
action: mapping.rewrite_source?.action ?? "rewrite_to_identity_preflight_duplicate_reference",
|
|
553
|
+
dataset_type: "process",
|
|
554
|
+
dataset_id: datasetIdentityCache?.id ?? null,
|
|
555
|
+
dataset_version: datasetIdentityCache?.version ?? null,
|
|
556
|
+
row_index: rowIndex,
|
|
557
|
+
path: pathExpression(childPath),
|
|
558
|
+
original: {
|
|
559
|
+
table: "flows",
|
|
560
|
+
ref_object_id: originalId || null,
|
|
561
|
+
version: originalVersion || null,
|
|
562
|
+
short_description: referenceShortDescription(child) || null,
|
|
563
|
+
},
|
|
564
|
+
canonical: {
|
|
565
|
+
table: "flows",
|
|
566
|
+
ref_object_id: next["@refObjectId"],
|
|
567
|
+
version: next["@version"],
|
|
568
|
+
short_description: typeof mapping.canonical.short_description === "string"
|
|
569
|
+
? referenceShortDescription(next) || null
|
|
570
|
+
: cloneCanonicalDescription(next["common:shortDescription"]),
|
|
571
|
+
short_description_source: preservesExistingShortDescription
|
|
572
|
+
? "existing_reference_display_text"
|
|
573
|
+
: "canonical_reference",
|
|
574
|
+
},
|
|
575
|
+
identity_preflight: mapping.identity_preflight,
|
|
576
|
+
identity_decision: mapping.identity_decision ?? null,
|
|
577
|
+
rewrite_source: mapping.rewrite_source ?? null,
|
|
578
|
+
reason: mapping.rewrite_source?.reason ||
|
|
579
|
+
"CLI identity-preflight selected an existing TianGong elementary flow duplicate; Foundry rewrote the process exchange reference before validation and write planning.",
|
|
580
|
+
});
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
const unresolvedMapping = unresolvedMappings?.get(`${originalId}@@${originalVersion}`) ??
|
|
584
|
+
unresolvedMappings?.get(originalId);
|
|
585
|
+
if (unresolvedMapping && rowRoot) {
|
|
586
|
+
const blockedPath = pathExpression(childPath);
|
|
587
|
+
const traceEntry = {
|
|
588
|
+
status: "unresolved_deferred",
|
|
589
|
+
action_item_code: "elementary_flow_identity_manual_review",
|
|
590
|
+
blocked_path: blockedPath,
|
|
591
|
+
reference_id: originalId || null,
|
|
592
|
+
reference_version: originalVersion || null,
|
|
593
|
+
reason: unresolvedMapping.unresolved_source?.reason ||
|
|
594
|
+
"AI identity authoring could not select a sufficient existing TianGong elementary flow reference; Foundry preserved the original process reference with a structured unresolved trace.",
|
|
595
|
+
evidence: {
|
|
596
|
+
source: "dataset-identity-decisions-apply",
|
|
597
|
+
identity_decision: unresolvedMapping.identity_decision,
|
|
598
|
+
unresolved_reference_file: unresolvedMapping.unresolved_source?.file,
|
|
599
|
+
quote_or_trace: unresolvedMapping.source?.short_description || originalId || null,
|
|
600
|
+
remote_search: unresolvedMapping.identity_evidence?.remote_search ?? null,
|
|
601
|
+
target: unresolvedMapping.identity_evidence?.target ?? null,
|
|
602
|
+
top_candidates: unresolvedMapping.identity_evidence?.top_candidates ?? null,
|
|
603
|
+
},
|
|
604
|
+
next_action: "Resolve this elementary flow against an approved public TianGong flow before publishing an upgraded row; do not create a BAFU-owned elementary flow.",
|
|
605
|
+
};
|
|
606
|
+
if (appendUnresolvedFlowReferenceTrace(rowRoot, traceEntry)) {
|
|
607
|
+
stats.unresolved_traces += 1;
|
|
608
|
+
unresolvedRows.push({
|
|
609
|
+
relation: "flow_reference_to_unresolved_elementary_identity",
|
|
610
|
+
action: "preserve_reference_with_unresolved_trace",
|
|
611
|
+
dataset_type: "process",
|
|
612
|
+
dataset_id: datasetIdentityCache?.id ?? null,
|
|
613
|
+
dataset_version: datasetIdentityCache?.version ?? null,
|
|
614
|
+
row_index: rowIndex,
|
|
615
|
+
path: blockedPath,
|
|
616
|
+
original: {
|
|
617
|
+
table: "flows",
|
|
618
|
+
ref_object_id: originalId || null,
|
|
619
|
+
version: originalVersion || null,
|
|
620
|
+
short_description: referenceShortDescription(child) || null,
|
|
621
|
+
},
|
|
622
|
+
identity_decision: unresolvedMapping.identity_decision,
|
|
623
|
+
unresolved_source: unresolvedMapping.unresolved_source,
|
|
624
|
+
trace: traceEntry,
|
|
625
|
+
reason: traceEntry.reason,
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
rewriteIdentityDuplicateFlowReferences(child, {
|
|
632
|
+
mappings,
|
|
633
|
+
unresolvedMappings,
|
|
634
|
+
datasetIdentityCache,
|
|
635
|
+
rowRoot,
|
|
636
|
+
rowIndex,
|
|
637
|
+
rewriteRows,
|
|
638
|
+
unresolvedRows,
|
|
639
|
+
stats,
|
|
640
|
+
pathSegments: childPath,
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function applyIdentityReferenceRewrites({ datasetType, rowsFile, outFile, outDir, options = {}, allowMissingIndex = false, }) {
|
|
645
|
+
const indexPath = identityReferenceRewriteIndexPath(options, rowsFile);
|
|
646
|
+
const explicitRewriteFiles = identityReferenceRewriteInputFiles(options);
|
|
647
|
+
const unresolvedReferenceFiles = identityUnresolvedReferenceInputFiles(options);
|
|
648
|
+
const explicitRewriteMappings = loadIdentityReferenceRewriteMappings(explicitRewriteFiles);
|
|
649
|
+
const unresolvedReferenceMappings = loadIdentityUnresolvedReferenceMappings(unresolvedReferenceFiles);
|
|
650
|
+
const blockers = [];
|
|
651
|
+
if ((!indexPath || !fileExists(indexPath)) &&
|
|
652
|
+
explicitRewriteMappings.mappings.size === 0 &&
|
|
653
|
+
unresolvedReferenceMappings.mappings.size === 0) {
|
|
654
|
+
if (!allowMissingIndex) {
|
|
655
|
+
blockers.push({
|
|
656
|
+
code: "identity_preflight_index_required",
|
|
657
|
+
message: "Identity reference rewrites require a completed identity-preflight index or an identity decision rewrite file.",
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
status: blockers.length > 0 ? "blocked" : "completed_no_index",
|
|
662
|
+
rows_file: repoRelativePath(rowsFile),
|
|
663
|
+
output_rows_file: repoRelativePath(rowsFile),
|
|
664
|
+
identity_preflight_index: indexPath ? repoRelativePath(indexPath) : null,
|
|
665
|
+
identity_reference_rewrites_input: explicitRewriteFiles.map((file) => repoRelativePath(file)),
|
|
666
|
+
identity_unresolved_references_input: unresolvedReferenceFiles.map((file) => repoRelativePath(file)),
|
|
667
|
+
rewrite_rows: [],
|
|
668
|
+
unresolved_reference_rows: [],
|
|
669
|
+
rewrite_file: null,
|
|
670
|
+
unresolved_references_file: null,
|
|
671
|
+
counts: {
|
|
672
|
+
input_rows: countRowsFile(rowsFile),
|
|
673
|
+
output_rows: countRowsFile(rowsFile),
|
|
674
|
+
identity_preflight_rows: 0,
|
|
675
|
+
identity_unresolved_reference_rows: 0,
|
|
676
|
+
duplicate_flow_mappings: 0,
|
|
677
|
+
flow_reference_rewrites: 0,
|
|
678
|
+
flow_reference_unresolved_traces: 0,
|
|
679
|
+
},
|
|
680
|
+
blockers,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
const rows = readRowsFile(rowsFile);
|
|
684
|
+
const { rows: indexRows, mappings } = loadIdentityDuplicateFlowMappings(indexPath);
|
|
685
|
+
for (const [key, mapping] of explicitRewriteMappings.mappings) {
|
|
686
|
+
mappings.set(key, mapping);
|
|
687
|
+
}
|
|
688
|
+
const rewriteRows = [];
|
|
689
|
+
const unresolvedRows = [];
|
|
690
|
+
const referenceRows = [];
|
|
691
|
+
const stats = { rewrites: 0, unresolved_traces: 0, root_unresolved: 0 };
|
|
692
|
+
const rewrittenRows = [];
|
|
693
|
+
rows.forEach((row, rowIndex) => {
|
|
694
|
+
const next = cloneJson(row);
|
|
695
|
+
if (datasetType === "flow") {
|
|
696
|
+
const identity = datasetIdentity(next, "flow");
|
|
697
|
+
const unresolvedMapping = unresolvedReferenceMappings.mappings.get(`${identity.id}@@${identity.version || "00.00.001"}`) ?? unresolvedReferenceMappings.mappings.get(identity.id);
|
|
698
|
+
if (unresolvedMapping) {
|
|
699
|
+
stats.unresolved_traces += 1;
|
|
700
|
+
stats.root_unresolved += 1;
|
|
701
|
+
unresolvedRows.push({
|
|
702
|
+
relation: "root_flow_identity_unresolved",
|
|
703
|
+
action: "defer_flow_row_before_remote_write",
|
|
704
|
+
dataset_type: "flow",
|
|
705
|
+
dataset_id: identity.id ?? null,
|
|
706
|
+
dataset_version: identity.version || "00.00.001",
|
|
707
|
+
row_index: rowIndex,
|
|
708
|
+
path: "/flowDataSet",
|
|
709
|
+
original: {
|
|
710
|
+
table: "flows",
|
|
711
|
+
ref_object_id: identity.id ?? null,
|
|
712
|
+
version: identity.version || "00.00.001",
|
|
713
|
+
short_description: asText(next.flowDataSet?.flowInformation?.dataSetInformation?.name?.baseName?.["#text"]) ||
|
|
714
|
+
supportText(next.flowDataSet?.flowInformation?.dataSetInformation?.name) ||
|
|
715
|
+
identity.id ||
|
|
716
|
+
null,
|
|
717
|
+
},
|
|
718
|
+
identity_decision: unresolvedMapping.identity_decision ?? null,
|
|
719
|
+
unresolved_source: unresolvedMapping.unresolved_source ?? null,
|
|
720
|
+
evidence: unresolvedMapping.identity_evidence ?? null,
|
|
721
|
+
reason: unresolvedMapping.unresolved_source?.reason ||
|
|
722
|
+
"AI identity authoring could not select a sufficient existing TianGong elementary flow reference; Foundry deferred this root flow row before remote write planning.",
|
|
723
|
+
next_action: "Resolve this elementary flow against an approved public TianGong flow before publishing an upgraded row; do not create an account-local elementary flow.",
|
|
724
|
+
});
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const mapping = mappings.get(`${identity.id}@@${identity.version || "00.00.001"}`) ??
|
|
728
|
+
mappings.get(identity.id);
|
|
729
|
+
if (mapping) {
|
|
730
|
+
referenceRows.push(next);
|
|
731
|
+
stats.rewrites += 1;
|
|
732
|
+
rewriteRows.push({
|
|
733
|
+
relation: "flow_identity_preflight_duplicate_reference",
|
|
734
|
+
action: "reuse_identity_preflight_duplicate_reference",
|
|
735
|
+
dataset_type: "flow",
|
|
736
|
+
dataset_id: identity.id ?? null,
|
|
737
|
+
dataset_version: identity.version || "00.00.001",
|
|
738
|
+
row_index: rowIndex,
|
|
739
|
+
path: "/flowDataSet",
|
|
740
|
+
original: {
|
|
741
|
+
table: "flows",
|
|
742
|
+
ref_object_id: identity.id ?? null,
|
|
743
|
+
version: identity.version || "00.00.001",
|
|
744
|
+
short_description: referenceShortDescription(next.flowDataSet?.flowInformation?.dataSetInformation?.name) || null,
|
|
745
|
+
},
|
|
746
|
+
canonical: mapping.canonical,
|
|
747
|
+
identity_preflight: mapping.identity_preflight,
|
|
748
|
+
reason: "CLI identity-preflight selected an existing TianGong flow duplicate; Foundry moved this row to reference reuse instead of planning a BAFU-owned flow write.",
|
|
749
|
+
});
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
if (datasetType === "process") {
|
|
754
|
+
rewriteIdentityDuplicateFlowReferences(next, {
|
|
755
|
+
mappings,
|
|
756
|
+
unresolvedMappings: unresolvedReferenceMappings.mappings,
|
|
757
|
+
datasetIdentityCache: datasetIdentity(next, "process"),
|
|
758
|
+
rowRoot: next,
|
|
759
|
+
rowIndex,
|
|
760
|
+
rewriteRows,
|
|
761
|
+
unresolvedRows,
|
|
762
|
+
stats,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
rewrittenRows.push(next);
|
|
766
|
+
});
|
|
767
|
+
const resolvedOutDir = outDir || path.join(path.dirname(rowsFile), "identity-reference-rewrites");
|
|
768
|
+
const resolvedOutFile = outFile ||
|
|
769
|
+
path.join(resolvedOutDir, `${datasetRowsFileStem(datasetType)}.identity-rewritten.jsonl`);
|
|
770
|
+
const rewriteFile = path.join(resolvedOutDir, "identity-reference-rewrites.jsonl");
|
|
771
|
+
const unresolvedReferencesFile = path.join(resolvedOutDir, "identity-unresolved-references.jsonl");
|
|
772
|
+
const referenceRowsFile = path.join(resolvedOutDir, `${datasetRowsFileStem(datasetType)}.reference-reuse.jsonl`);
|
|
773
|
+
writeJsonLines(resolvedOutFile, rewrittenRows);
|
|
774
|
+
writeJsonLines(rewriteFile, rewriteRows);
|
|
775
|
+
writeJsonLines(unresolvedReferencesFile, unresolvedRows);
|
|
776
|
+
writeJsonLines(referenceRowsFile, referenceRows);
|
|
777
|
+
return {
|
|
778
|
+
status: blockers.length > 0
|
|
779
|
+
? "blocked"
|
|
780
|
+
: rewriteRows.length > 0 || unresolvedRows.length > 0
|
|
781
|
+
? "completed"
|
|
782
|
+
: "completed_no_rewrites",
|
|
783
|
+
rows_file: repoRelativePath(rowsFile),
|
|
784
|
+
output_rows_file: repoRelativePath(resolvedOutFile),
|
|
785
|
+
reference_rows_file: referenceRows.length > 0 ? repoRelativePath(referenceRowsFile) : null,
|
|
786
|
+
identity_preflight_index: indexPath ? repoRelativePath(indexPath) : null,
|
|
787
|
+
identity_reference_rewrites_input: explicitRewriteFiles[0]
|
|
788
|
+
? repoRelativePath(explicitRewriteFiles[0])
|
|
789
|
+
: null,
|
|
790
|
+
identity_reference_rewrites_inputs: explicitRewriteFiles.map((file) => repoRelativePath(file)),
|
|
791
|
+
identity_unresolved_references_input: unresolvedReferenceFiles.map((file) => repoRelativePath(file)),
|
|
792
|
+
rewrite_rows: rewriteRows,
|
|
793
|
+
unresolved_reference_rows: unresolvedRows,
|
|
794
|
+
rewrite_file: repoRelativePath(rewriteFile),
|
|
795
|
+
unresolved_references_file: repoRelativePath(unresolvedReferencesFile),
|
|
796
|
+
counts: {
|
|
797
|
+
input_rows: rows.length,
|
|
798
|
+
output_rows: rewrittenRows.length,
|
|
799
|
+
reference_rows: referenceRows.length,
|
|
800
|
+
identity_preflight_rows: indexRows.length,
|
|
801
|
+
identity_reference_rewrite_rows: explicitRewriteMappings.rows.length,
|
|
802
|
+
identity_unresolved_reference_rows: unresolvedReferenceMappings.rows.length,
|
|
803
|
+
duplicate_flow_mappings: new Set([...mappings.values()].map((mapping) => mapping.source.ref_object_id)).size,
|
|
804
|
+
flow_reference_rewrites: rewriteRows.length,
|
|
805
|
+
flow_reference_unresolved_traces: unresolvedRows.length,
|
|
806
|
+
root_flow_unresolved_rows: stats.root_unresolved,
|
|
807
|
+
},
|
|
808
|
+
blockers,
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
applyIdentityReferenceRewrites,
|
|
813
|
+
externalizeUnresolvedProcessFlowExchanges,
|
|
814
|
+
identityReferenceRewriteIndexPath,
|
|
815
|
+
referenceShortDescription,
|
|
816
|
+
};
|
|
817
|
+
}
|