@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,593 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { loadTidasSchema } from "./context-inputs.js";
|
|
3
|
+
import { asText, ensureArray, resolveRepoPath } from "./runtime-io.js";
|
|
4
|
+
import { evidenceEntries, evidenceSourceKeys, evidenceTraceKeys, firstNonEmptyEvidenceValue, hasNonEmptyTraceEvidence, } from "./workflow-authoring-tasks.js";
|
|
5
|
+
import { isAnnualSupplyTarget } from "./workflow-queue-context.js";
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function asOperation(value) {
|
|
10
|
+
return isRecord(value) ? value : {};
|
|
11
|
+
}
|
|
12
|
+
function asTask(value) {
|
|
13
|
+
return isRecord(value) ? value : {};
|
|
14
|
+
}
|
|
15
|
+
function asActionItem(value) {
|
|
16
|
+
return isRecord(value) ? value : {};
|
|
17
|
+
}
|
|
18
|
+
// part-04.mjs
|
|
19
|
+
export function hasStructuredTraceEvidence(value) {
|
|
20
|
+
return evidenceEntries(value)
|
|
21
|
+
.filter((entry) => entry && typeof entry === "object" && !Array.isArray(entry))
|
|
22
|
+
.some((entry) => firstNonEmptyEvidenceValue(entry, evidenceSourceKeys) &&
|
|
23
|
+
firstNonEmptyEvidenceValue(entry, evidenceTraceKeys));
|
|
24
|
+
}
|
|
25
|
+
export function objectTraceEntries(value, traceKey) {
|
|
26
|
+
const entries = [];
|
|
27
|
+
const visit = (node) => {
|
|
28
|
+
if (!node || typeof node !== "object")
|
|
29
|
+
return;
|
|
30
|
+
if (Array.isArray(node)) {
|
|
31
|
+
node.forEach(visit);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const record = node;
|
|
35
|
+
if (Object.hasOwn(record, traceKey)) {
|
|
36
|
+
entries.push(...ensureArray(record[traceKey]));
|
|
37
|
+
}
|
|
38
|
+
const commonOther = record["common:other"];
|
|
39
|
+
if (commonOther && typeof commonOther === "object" && !Array.isArray(commonOther)) {
|
|
40
|
+
const commonOtherRecord = commonOther;
|
|
41
|
+
if (Object.hasOwn(commonOtherRecord, traceKey)) {
|
|
42
|
+
entries.push(...ensureArray(commonOtherRecord[traceKey]));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const child of Object.values(record))
|
|
46
|
+
visit(child);
|
|
47
|
+
};
|
|
48
|
+
visit(value);
|
|
49
|
+
return entries;
|
|
50
|
+
}
|
|
51
|
+
export function operationTraceEntries(operation, traceKey) {
|
|
52
|
+
const typedOperation = asOperation(operation);
|
|
53
|
+
const pointer = asText(typedOperation.path);
|
|
54
|
+
const value = typedOperation.value;
|
|
55
|
+
if (pointer.includes(`/${traceKey}`))
|
|
56
|
+
return ensureArray(value);
|
|
57
|
+
if (pointer.includes("/common:other"))
|
|
58
|
+
return objectTraceEntries(value, traceKey);
|
|
59
|
+
return objectTraceEntries(value, traceKey);
|
|
60
|
+
}
|
|
61
|
+
export function validateDeferredCommonOtherTrace({ operation, actionItems, }) {
|
|
62
|
+
const traceEntries = operationTraceEntries(operation, "tiangongfoundry:unresolvedTrace");
|
|
63
|
+
const closureCodes = new Set(operationClosureCodes(operation));
|
|
64
|
+
const actionCodes = new Set(ensureArray(actionItems)
|
|
65
|
+
.map((item) => {
|
|
66
|
+
const typedItem = asActionItem(item);
|
|
67
|
+
return asText(typedItem.code ?? typedItem.rule_id ?? typedItem.ruleId);
|
|
68
|
+
})
|
|
69
|
+
.filter(Boolean));
|
|
70
|
+
const acceptedCodes = closureCodes.size > 0 ? closureCodes : actionCodes;
|
|
71
|
+
const blockers = [];
|
|
72
|
+
if (traceEntries.length === 0) {
|
|
73
|
+
blockers.push({
|
|
74
|
+
code: "patch_deferred_trace_missing",
|
|
75
|
+
message: "resolution.mode=deferred_to_common_other must add tiangongfoundry:unresolvedTrace under common:other.",
|
|
76
|
+
});
|
|
77
|
+
return blockers;
|
|
78
|
+
}
|
|
79
|
+
const closureCodesOnly = new Set([...closureCodes].filter(Boolean));
|
|
80
|
+
const tracedActionCodes = new Set(traceEntries
|
|
81
|
+
.map((entry) => {
|
|
82
|
+
const record = isRecord(entry) ? entry : {};
|
|
83
|
+
return asText(record.action_item_code ?? record.actionItemCode ?? record.code);
|
|
84
|
+
})
|
|
85
|
+
.filter(Boolean));
|
|
86
|
+
for (const closureCode of closureCodesOnly) {
|
|
87
|
+
if (!tracedActionCodes.has(closureCode)) {
|
|
88
|
+
blockers.push({
|
|
89
|
+
code: "patch_deferred_trace_action_item_untraced",
|
|
90
|
+
message: "Each action item closed by a deferred_to_common_other operation must have a matching tiangongfoundry:unresolvedTrace.action_item_code entry.",
|
|
91
|
+
action_item_code: closureCode,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
traceEntries.forEach((entry, index) => {
|
|
96
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
97
|
+
blockers.push({
|
|
98
|
+
code: "patch_deferred_trace_invalid",
|
|
99
|
+
message: "tiangongfoundry:unresolvedTrace entries must be JSON objects.",
|
|
100
|
+
trace_index: index,
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const typedEntry = entry;
|
|
105
|
+
const status = asText(typedEntry.status ?? typedEntry.decision_status ?? typedEntry.decisionStatus);
|
|
106
|
+
const actionCode = asText(typedEntry.action_item_code ?? typedEntry.actionItemCode ?? typedEntry.code);
|
|
107
|
+
const blockedPath = asText(typedEntry.blocked_path ??
|
|
108
|
+
typedEntry.blockedPath ??
|
|
109
|
+
typedEntry.field_path ??
|
|
110
|
+
typedEntry.fieldPath ??
|
|
111
|
+
typedEntry.path);
|
|
112
|
+
const reason = asText(typedEntry.reason ?? typedEntry.deferred_reason ?? typedEntry.deferredReason);
|
|
113
|
+
const nextAction = asText(typedEntry.next_action ??
|
|
114
|
+
typedEntry.nextAction ??
|
|
115
|
+
typedEntry.follow_up ??
|
|
116
|
+
typedEntry.followUp);
|
|
117
|
+
if (!["unresolved_deferred", "deferred_to_common_other", "needs_followup"].includes(status)) {
|
|
118
|
+
blockers.push({
|
|
119
|
+
code: "patch_deferred_trace_status_invalid",
|
|
120
|
+
message: "tiangongfoundry:unresolvedTrace.status must be unresolved_deferred, deferred_to_common_other, or needs_followup.",
|
|
121
|
+
trace_index: index,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (!actionCode || (acceptedCodes.size > 0 && !acceptedCodes.has(actionCode))) {
|
|
125
|
+
blockers.push({
|
|
126
|
+
code: "patch_deferred_trace_action_item_missing",
|
|
127
|
+
message: "tiangongfoundry:unresolvedTrace must identify the deferred action item code closed by this operation.",
|
|
128
|
+
trace_index: index,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (!blockedPath) {
|
|
132
|
+
blockers.push({
|
|
133
|
+
code: "patch_deferred_trace_path_missing",
|
|
134
|
+
message: "tiangongfoundry:unresolvedTrace must record the blocked field/path.",
|
|
135
|
+
trace_index: index,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (!reason) {
|
|
139
|
+
blockers.push({
|
|
140
|
+
code: "patch_deferred_trace_reason_missing",
|
|
141
|
+
message: "tiangongfoundry:unresolvedTrace must record why the value could not be safely inferred.",
|
|
142
|
+
trace_index: index,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const evidence = typedEntry.evidence ?? typedEntry.source_evidence ?? typedEntry.sourceEvidence;
|
|
146
|
+
if (!hasNonEmptyTraceEvidence(evidence)) {
|
|
147
|
+
blockers.push({
|
|
148
|
+
code: "patch_deferred_trace_evidence_missing",
|
|
149
|
+
message: "tiangongfoundry:unresolvedTrace must preserve source/context evidence for later database-side repair.",
|
|
150
|
+
trace_index: index,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else if (!hasStructuredTraceEvidence(evidence)) {
|
|
154
|
+
blockers.push({
|
|
155
|
+
code: "patch_deferred_trace_evidence_incomplete",
|
|
156
|
+
message: "tiangongfoundry:unresolvedTrace evidence must include both a source/context identifier and a quote, trace, field path, citation, or equivalent pointer.",
|
|
157
|
+
trace_index: index,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (!nextAction) {
|
|
161
|
+
blockers.push({
|
|
162
|
+
code: "patch_deferred_trace_next_action_missing",
|
|
163
|
+
message: "tiangongfoundry:unresolvedTrace must record a concrete next_action/follow_up.",
|
|
164
|
+
trace_index: index,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return blockers;
|
|
169
|
+
}
|
|
170
|
+
export function validateSourceExchangeCompletenessTrace(operation) {
|
|
171
|
+
const traceEntries = operationTraceEntries(operation, "tiangongfoundry:sourceExchangeCompleteness");
|
|
172
|
+
const blockers = [];
|
|
173
|
+
if (traceEntries.length === 0) {
|
|
174
|
+
blockers.push({
|
|
175
|
+
code: "patch_source_exchange_trace_missing",
|
|
176
|
+
message: "resolution.mode=source_trace_verified must add tiangongfoundry:sourceExchangeCompleteness under common:other.",
|
|
177
|
+
});
|
|
178
|
+
return blockers;
|
|
179
|
+
}
|
|
180
|
+
traceEntries.forEach((entry, index) => {
|
|
181
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
182
|
+
blockers.push({
|
|
183
|
+
code: "patch_source_exchange_trace_invalid",
|
|
184
|
+
message: "tiangongfoundry:sourceExchangeCompleteness entries must be JSON objects.",
|
|
185
|
+
trace_index: index,
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const typedEntry = entry;
|
|
190
|
+
const status = asText(typedEntry.status ?? typedEntry.decision_status ?? typedEntry.decisionStatus);
|
|
191
|
+
if (!["source_only_output_exchange_verified", "accepted_source_only_output", "verified"].includes(status)) {
|
|
192
|
+
blockers.push({
|
|
193
|
+
code: "patch_source_exchange_trace_status_invalid",
|
|
194
|
+
message: "tiangongfoundry:sourceExchangeCompleteness.status must prove source-only-output verification.",
|
|
195
|
+
trace_index: index,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const evidence = typedEntry.evidence ??
|
|
199
|
+
typedEntry.source_evidence ??
|
|
200
|
+
typedEntry.sourceEvidence ??
|
|
201
|
+
typedEntry.trace;
|
|
202
|
+
if (!hasNonEmptyTraceEvidence(evidence)) {
|
|
203
|
+
blockers.push({
|
|
204
|
+
code: "patch_source_exchange_trace_evidence_missing",
|
|
205
|
+
message: "tiangongfoundry:sourceExchangeCompleteness must include source trace evidence used for verification.",
|
|
206
|
+
trace_index: index,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
else if (!hasStructuredTraceEvidence(evidence)) {
|
|
210
|
+
blockers.push({
|
|
211
|
+
code: "patch_source_exchange_trace_evidence_incomplete",
|
|
212
|
+
message: "tiangongfoundry:sourceExchangeCompleteness evidence must include both a source/context identifier and a quote, trace, field path, citation, or equivalent pointer.",
|
|
213
|
+
trace_index: index,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return blockers;
|
|
218
|
+
}
|
|
219
|
+
export function operationClosureCodes(operation) {
|
|
220
|
+
return operationClosureKeys(operation)
|
|
221
|
+
.map((key) => key.split("\u0000")[0])
|
|
222
|
+
.filter(Boolean);
|
|
223
|
+
}
|
|
224
|
+
export function containsAiTemplatePlaceholder(value) {
|
|
225
|
+
if (typeof value === "string") {
|
|
226
|
+
return /__AI_FILL_[A-Z0-9_]*__|\/__AI_FILL_JSON_POINTER__/u.test(value);
|
|
227
|
+
}
|
|
228
|
+
if (Array.isArray(value))
|
|
229
|
+
return value.some((item) => containsAiTemplatePlaceholder(item));
|
|
230
|
+
if (value && typeof value === "object") {
|
|
231
|
+
return Object.values(value).some((item) => containsAiTemplatePlaceholder(item));
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
export function operationClosureKeys(operation) {
|
|
236
|
+
const typedOperation = asOperation(operation);
|
|
237
|
+
const raw = typedOperation.closes ??
|
|
238
|
+
typedOperation.closes_action_items ??
|
|
239
|
+
typedOperation.closesActionItems ??
|
|
240
|
+
typedOperation.action_items ??
|
|
241
|
+
typedOperation.actionItems;
|
|
242
|
+
return ensureArray(raw)
|
|
243
|
+
.map((item) => {
|
|
244
|
+
if (typeof item === "string")
|
|
245
|
+
return `${item}\u0000`;
|
|
246
|
+
const record = isRecord(item) ? item : {};
|
|
247
|
+
const code = asText(record.code ??
|
|
248
|
+
record.action_item_code ??
|
|
249
|
+
record.actionItemCode ??
|
|
250
|
+
record.rule_id ??
|
|
251
|
+
record.ruleId);
|
|
252
|
+
const itemPath = asText(record.path ?? record.json_path ?? record.jsonPath);
|
|
253
|
+
return code ? `${code}\u0000${itemPath}` : "";
|
|
254
|
+
})
|
|
255
|
+
.filter(Boolean);
|
|
256
|
+
}
|
|
257
|
+
export function operationClosesAnnualSupplyTarget(operation) {
|
|
258
|
+
return operationClosureKeys(operation).some((key) => {
|
|
259
|
+
const [code, itemPath] = key.split("\u0000");
|
|
260
|
+
return isAnnualSupplyTarget(code, itemPath);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
export function categoryEntries(repoRoot, schemaFile) {
|
|
264
|
+
const schema = loadTidasSchema(repoRoot, schemaFile);
|
|
265
|
+
const entries = ensureArray(schema.oneOf)
|
|
266
|
+
.map((entry) => {
|
|
267
|
+
const properties = isRecord(entry) && isRecord(entry.properties) ? entry.properties : {};
|
|
268
|
+
const levelProperty = isRecord(properties["@level"]) ? properties["@level"] : {};
|
|
269
|
+
const classProperty = isRecord(properties["@classId"]) ? properties["@classId"] : {};
|
|
270
|
+
const categoryProperty = isRecord(properties["@catId"]) ? properties["@catId"] : {};
|
|
271
|
+
const codeProperty = isRecord(properties["@code"]) ? properties["@code"] : {};
|
|
272
|
+
const textProperty = isRecord(properties["#text"]) ? properties["#text"] : {};
|
|
273
|
+
const levelText = asText(levelProperty.const);
|
|
274
|
+
const code = asText(classProperty.const ?? categoryProperty.const ?? codeProperty.const);
|
|
275
|
+
const text = asText(textProperty.const);
|
|
276
|
+
const level = levelText === "" ? Number.NaN : Number(levelText);
|
|
277
|
+
return Number.isInteger(level) && code && text ? { level, code, text } : null;
|
|
278
|
+
})
|
|
279
|
+
.filter((entry) => entry !== null);
|
|
280
|
+
const byCode = new Map(entries.map((entry) => [entry.code, entry]));
|
|
281
|
+
const parentByCode = new Map();
|
|
282
|
+
const lastPerLevel = new Map();
|
|
283
|
+
for (const entry of entries) {
|
|
284
|
+
if (entry.level === 0) {
|
|
285
|
+
parentByCode.set(entry.code, null);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
let parent = null;
|
|
289
|
+
for (let level = entry.level - 1; level >= 0; level -= 1) {
|
|
290
|
+
parent = lastPerLevel.get(level) ?? null;
|
|
291
|
+
if (parent)
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
parentByCode.set(entry.code, parent);
|
|
295
|
+
}
|
|
296
|
+
lastPerLevel.set(entry.level, entry);
|
|
297
|
+
}
|
|
298
|
+
return { byCode, parentByCode };
|
|
299
|
+
}
|
|
300
|
+
export function categoryPathForCode(repoRoot, schemaFile, code) {
|
|
301
|
+
const { byCode, parentByCode } = categoryEntries(repoRoot, schemaFile);
|
|
302
|
+
const entry = byCode.get(asText(code));
|
|
303
|
+
if (!entry)
|
|
304
|
+
return [];
|
|
305
|
+
const pathEntries = [entry];
|
|
306
|
+
let current = entry;
|
|
307
|
+
while (true) {
|
|
308
|
+
const parent = parentByCode.get(current.code);
|
|
309
|
+
if (!parent)
|
|
310
|
+
break;
|
|
311
|
+
pathEntries.push(parent);
|
|
312
|
+
current = parent;
|
|
313
|
+
}
|
|
314
|
+
return pathEntries.reverse();
|
|
315
|
+
}
|
|
316
|
+
export function processCategoryPathForCode(repoRoot, code) {
|
|
317
|
+
return categoryPathForCode(repoRoot, "tidas_processes_category.json", code);
|
|
318
|
+
}
|
|
319
|
+
export function classCode(value) {
|
|
320
|
+
const record = isRecord(value) ? value : {};
|
|
321
|
+
return asText(record["@classId"] ??
|
|
322
|
+
record.classId ??
|
|
323
|
+
record.class_id ??
|
|
324
|
+
record["@catId"] ??
|
|
325
|
+
record.catId ??
|
|
326
|
+
record.cat_id);
|
|
327
|
+
}
|
|
328
|
+
export function classText(value) {
|
|
329
|
+
const record = isRecord(value) ? value : {};
|
|
330
|
+
return asText(record["#text"] ?? record.text ?? record.label ?? record.name);
|
|
331
|
+
}
|
|
332
|
+
export function classLevel(value) {
|
|
333
|
+
const record = isRecord(value) ? value : {};
|
|
334
|
+
const text = asText(record["@level"] ?? record.level);
|
|
335
|
+
return text === "" ? null : Number(text);
|
|
336
|
+
}
|
|
337
|
+
export function classificationItemsFromOperation(operation) {
|
|
338
|
+
const value = asOperation(operation).value;
|
|
339
|
+
if (Array.isArray(value))
|
|
340
|
+
return value;
|
|
341
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
342
|
+
return [];
|
|
343
|
+
const record = value;
|
|
344
|
+
const commonClass = record["common:class"];
|
|
345
|
+
if (Array.isArray(commonClass))
|
|
346
|
+
return commonClass;
|
|
347
|
+
if (commonClass && typeof commonClass === "object")
|
|
348
|
+
return [commonClass];
|
|
349
|
+
const commonCategory = record["common:category"];
|
|
350
|
+
if (Array.isArray(commonCategory))
|
|
351
|
+
return commonCategory;
|
|
352
|
+
if (commonCategory && typeof commonCategory === "object")
|
|
353
|
+
return [commonCategory];
|
|
354
|
+
const wrappedClassification = record["common:classification"];
|
|
355
|
+
if (wrappedClassification &&
|
|
356
|
+
typeof wrappedClassification === "object" &&
|
|
357
|
+
!Array.isArray(wrappedClassification)) {
|
|
358
|
+
const wrappedClass = wrappedClassification["common:class"];
|
|
359
|
+
if (Array.isArray(wrappedClass))
|
|
360
|
+
return wrappedClass;
|
|
361
|
+
if (wrappedClass && typeof wrappedClass === "object")
|
|
362
|
+
return [wrappedClass];
|
|
363
|
+
}
|
|
364
|
+
const wrappedElementary = record["common:elementaryFlowCategorization"];
|
|
365
|
+
if (wrappedElementary &&
|
|
366
|
+
typeof wrappedElementary === "object" &&
|
|
367
|
+
!Array.isArray(wrappedElementary)) {
|
|
368
|
+
const wrappedCategory = wrappedElementary["common:category"];
|
|
369
|
+
if (Array.isArray(wrappedCategory))
|
|
370
|
+
return wrappedCategory;
|
|
371
|
+
if (wrappedCategory && typeof wrappedCategory === "object")
|
|
372
|
+
return [wrappedCategory];
|
|
373
|
+
}
|
|
374
|
+
const classes = record.classes ?? record.classification_classes;
|
|
375
|
+
if (Array.isArray(classes))
|
|
376
|
+
return classes;
|
|
377
|
+
const categories = record.categories ?? record.category;
|
|
378
|
+
if (Array.isArray(categories))
|
|
379
|
+
return categories;
|
|
380
|
+
return [];
|
|
381
|
+
}
|
|
382
|
+
export function validateClassificationDecisionOperation({ repoRoot, operation, schemaFile, codeAttribute, datasetLabel, itemLabel, }) {
|
|
383
|
+
const items = classificationItemsFromOperation(operation);
|
|
384
|
+
if (items.length === 0) {
|
|
385
|
+
return [
|
|
386
|
+
{
|
|
387
|
+
code: "patch_classification_decision_value_missing",
|
|
388
|
+
message: `${datasetLabel} classification_decision operations must write ${itemLabel} from the bundled TIDAS category schema.`,
|
|
389
|
+
},
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
const rawCodes = items.map(classCode).filter(Boolean);
|
|
393
|
+
const leafCode = rawCodes.at(-1);
|
|
394
|
+
const canonical = categoryPathForCode(repoRoot, schemaFile, leafCode);
|
|
395
|
+
if (!leafCode || canonical.length === 0) {
|
|
396
|
+
return [
|
|
397
|
+
{
|
|
398
|
+
code: "patch_classification_decision_code_invalid",
|
|
399
|
+
message: `${datasetLabel} classification_decision leaf code is not present in ${schemaFile}.`,
|
|
400
|
+
leaf_code: leafCode || null,
|
|
401
|
+
},
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
const canonicalPrefix = canonical.slice(0, rawCodes.length);
|
|
405
|
+
const canonicalCodes = canonicalPrefix.map((entry) => entry.code);
|
|
406
|
+
if (rawCodes.join("/") !== canonicalCodes.join("/")) {
|
|
407
|
+
return [
|
|
408
|
+
{
|
|
409
|
+
code: "patch_classification_decision_path_invalid",
|
|
410
|
+
message: `${datasetLabel} classification_decision path does not match the canonical TIDAS category path.`,
|
|
411
|
+
expected_codes: canonical.map((entry) => entry.code),
|
|
412
|
+
actual_codes: rawCodes,
|
|
413
|
+
},
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
const invalidEntries = items
|
|
417
|
+
.map((item, index) => {
|
|
418
|
+
const expected = canonicalPrefix[index];
|
|
419
|
+
if (!expected)
|
|
420
|
+
return null;
|
|
421
|
+
const level = classLevel(item);
|
|
422
|
+
const text = classText(item);
|
|
423
|
+
const problems = [];
|
|
424
|
+
if (level !== null && level !== expected.level)
|
|
425
|
+
problems.push("level");
|
|
426
|
+
if (text && text !== expected.text)
|
|
427
|
+
problems.push("text");
|
|
428
|
+
const itemCode = asText(isRecord(item) ? item[codeAttribute] : undefined);
|
|
429
|
+
if (itemCode && itemCode !== expected.code)
|
|
430
|
+
problems.push(codeAttribute);
|
|
431
|
+
return problems.length > 0
|
|
432
|
+
? {
|
|
433
|
+
index,
|
|
434
|
+
code: expected.code,
|
|
435
|
+
expected_level: expected.level,
|
|
436
|
+
actual_level: level,
|
|
437
|
+
expected_text: expected.text,
|
|
438
|
+
actual_text: text || null,
|
|
439
|
+
expected_code_attribute: codeAttribute,
|
|
440
|
+
actual_code: itemCode || null,
|
|
441
|
+
problems,
|
|
442
|
+
}
|
|
443
|
+
: null;
|
|
444
|
+
})
|
|
445
|
+
.filter(Boolean);
|
|
446
|
+
return invalidEntries.length > 0
|
|
447
|
+
? [
|
|
448
|
+
{
|
|
449
|
+
code: "patch_classification_decision_entry_invalid",
|
|
450
|
+
message: `${datasetLabel} classification_decision entries must use canonical @level/${codeAttribute}/#text values from ${schemaFile}.`,
|
|
451
|
+
invalid_entries: invalidEntries,
|
|
452
|
+
},
|
|
453
|
+
]
|
|
454
|
+
: [];
|
|
455
|
+
}
|
|
456
|
+
export function validateProcessClassificationDecisionOperation({ repoRoot, task, operation, }) {
|
|
457
|
+
const typedTask = asTask(task);
|
|
458
|
+
const entity = isRecord(typedTask.entity) ? typedTask.entity : {};
|
|
459
|
+
if (asText(entity.dataset_type) !== "process")
|
|
460
|
+
return [];
|
|
461
|
+
return validateClassificationDecisionOperation({
|
|
462
|
+
repoRoot,
|
|
463
|
+
operation,
|
|
464
|
+
schemaFile: "tidas_processes_category.json",
|
|
465
|
+
codeAttribute: "@classId",
|
|
466
|
+
datasetLabel: "Process",
|
|
467
|
+
itemLabel: "common:classification.common:class",
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
export function validateFlowClassificationDecisionOperation({ repoRoot, task, operation, }) {
|
|
471
|
+
const typedTask = asTask(task);
|
|
472
|
+
const entity = isRecord(typedTask.entity) ? typedTask.entity : {};
|
|
473
|
+
if (asText(entity.dataset_type) !== "flow")
|
|
474
|
+
return [];
|
|
475
|
+
const actionPaths = ensureArray(typedTask.action_items)
|
|
476
|
+
.map((item) => asText(asActionItem(item).path))
|
|
477
|
+
.filter(Boolean);
|
|
478
|
+
const operationPath = asText(asOperation(operation).path);
|
|
479
|
+
const isElementary = operationPath.includes("elementaryFlowCategorization") ||
|
|
480
|
+
actionPaths.some((itemPath) => itemPath.includes("elementaryFlowCategorization"));
|
|
481
|
+
return validateClassificationDecisionOperation({
|
|
482
|
+
repoRoot,
|
|
483
|
+
operation,
|
|
484
|
+
schemaFile: isElementary
|
|
485
|
+
? "tidas_flows_elementary_category.json"
|
|
486
|
+
: "tidas_flows_product_category.json",
|
|
487
|
+
codeAttribute: isElementary ? "@catId" : "@classId",
|
|
488
|
+
datasetLabel: isElementary ? "Elementary flow" : "Product/waste flow",
|
|
489
|
+
itemLabel: isElementary
|
|
490
|
+
? "common:elementaryFlowCategorization.common:category"
|
|
491
|
+
: "common:classification.common:class",
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
export function locationCodeMapForPatch(repoRoot) {
|
|
495
|
+
const schema = loadTidasSchema(repoRoot, "tidas_locations_category.json");
|
|
496
|
+
return new Map(ensureArray(schema.oneOf)
|
|
497
|
+
.map((entry) => {
|
|
498
|
+
const record = isRecord(entry) ? entry : {};
|
|
499
|
+
return [asText(record.const), asText(record.description)];
|
|
500
|
+
})
|
|
501
|
+
.filter(([code]) => Boolean(code)));
|
|
502
|
+
}
|
|
503
|
+
export function locationCodeFromOperation(operation) {
|
|
504
|
+
const value = asOperation(operation).value;
|
|
505
|
+
if (typeof value === "string")
|
|
506
|
+
return value.trim();
|
|
507
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
508
|
+
const record = value;
|
|
509
|
+
return asText(record.code ??
|
|
510
|
+
record.location ??
|
|
511
|
+
record["@location"] ??
|
|
512
|
+
record["@subLocation"] ??
|
|
513
|
+
record["#text"] ??
|
|
514
|
+
record.impactLocation ??
|
|
515
|
+
record.interventionLocation ??
|
|
516
|
+
record.intervensionSubLocation ??
|
|
517
|
+
record.locationOfSupply);
|
|
518
|
+
}
|
|
519
|
+
return "";
|
|
520
|
+
}
|
|
521
|
+
export function operationTargetsLocationCode(operation) {
|
|
522
|
+
const typedOperation = asOperation(operation);
|
|
523
|
+
const pointer = asText(typedOperation.path);
|
|
524
|
+
if (pointer.includes("/name/"))
|
|
525
|
+
return false;
|
|
526
|
+
const pointerSegments = pointer
|
|
527
|
+
.split("/")
|
|
528
|
+
.filter(Boolean)
|
|
529
|
+
.map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
530
|
+
const codeFields = new Set([
|
|
531
|
+
"location",
|
|
532
|
+
"subLocation",
|
|
533
|
+
"locationOfSupply",
|
|
534
|
+
"locationOfOperationSupplyOrProduction",
|
|
535
|
+
"impactLocation",
|
|
536
|
+
"interventionLocation",
|
|
537
|
+
"intervensionSubLocation",
|
|
538
|
+
]);
|
|
539
|
+
if (pointerSegments.some((segment) => codeFields.has(segment)))
|
|
540
|
+
return true;
|
|
541
|
+
const value = typedOperation.value;
|
|
542
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
543
|
+
return false;
|
|
544
|
+
return [...codeFields].some((field) => Object.hasOwn(value, field));
|
|
545
|
+
}
|
|
546
|
+
export function validateLocationDecisionOperation({ repoRoot, operation, }) {
|
|
547
|
+
const code = locationCodeFromOperation(operation);
|
|
548
|
+
if (!code) {
|
|
549
|
+
return [
|
|
550
|
+
{
|
|
551
|
+
code: "patch_location_decision_value_missing",
|
|
552
|
+
message: "location_decision operations must write a location code from tidas_locations_category.json.",
|
|
553
|
+
},
|
|
554
|
+
];
|
|
555
|
+
}
|
|
556
|
+
if (!locationCodeMapForPatch(repoRoot).has(code)) {
|
|
557
|
+
return [
|
|
558
|
+
{
|
|
559
|
+
code: "patch_location_decision_code_invalid",
|
|
560
|
+
message: "location_decision code is not present in tidas_locations_category.json.",
|
|
561
|
+
location_code: code,
|
|
562
|
+
},
|
|
563
|
+
];
|
|
564
|
+
}
|
|
565
|
+
return [];
|
|
566
|
+
}
|
|
567
|
+
export function taskActionItemKeys(task) {
|
|
568
|
+
return ensureArray(asTask(task).action_items)
|
|
569
|
+
.map((item) => {
|
|
570
|
+
const typedItem = asActionItem(item);
|
|
571
|
+
const code = asText(typedItem.code ?? typedItem.rule_id ?? typedItem.ruleId);
|
|
572
|
+
const itemPath = asText(typedItem.path);
|
|
573
|
+
return code ? `${code}\u0000${itemPath}` : "";
|
|
574
|
+
})
|
|
575
|
+
.filter(Boolean);
|
|
576
|
+
}
|
|
577
|
+
export function taskActionItemsForOperation(task, operation) {
|
|
578
|
+
const closures = operationClosureKeys(operation).map((key) => {
|
|
579
|
+
const [code, itemPath] = key.split("\u0000");
|
|
580
|
+
return { code, path: itemPath || null };
|
|
581
|
+
});
|
|
582
|
+
return ensureArray(asTask(task).action_items).filter((item) => {
|
|
583
|
+
const typedItem = asActionItem(item);
|
|
584
|
+
const code = asText(typedItem.code ?? typedItem.rule_id ?? typedItem.ruleId);
|
|
585
|
+
const itemPath = asText(typedItem.path) || null;
|
|
586
|
+
return closures.some((closure) => closure.code === code && (!closure.path || !itemPath || closure.path === itemPath));
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
export function taskAuthoringPackageName(repoRoot, task) {
|
|
590
|
+
const files = asTask(task).files;
|
|
591
|
+
const resolved = resolveRepoPath(repoRoot, isRecord(files) ? asText(files.authoring_package) : "");
|
|
592
|
+
return resolved ? path.basename(resolved) : "";
|
|
593
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface JsonRecord {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
}
|
|
4
|
+
export interface QueueTask extends JsonRecord {
|
|
5
|
+
schema_version?: number;
|
|
6
|
+
task_id?: string;
|
|
7
|
+
entity_type?: string;
|
|
8
|
+
entity_id?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
lock_key?: string;
|
|
11
|
+
depends_on?: unknown;
|
|
12
|
+
input_rows_file?: string | null;
|
|
13
|
+
closure_file?: string | null;
|
|
14
|
+
run_plan_file?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface CurationQueueContext {
|
|
17
|
+
queueDir: string;
|
|
18
|
+
manifestPath: string;
|
|
19
|
+
manifest: JsonRecord;
|
|
20
|
+
tasks: QueueTask[];
|
|
21
|
+
tasksById: Map<string, QueueTask>;
|
|
22
|
+
}
|
|
23
|
+
export interface AuthoringQueueContext {
|
|
24
|
+
kind: string;
|
|
25
|
+
path: string;
|
|
26
|
+
rows: JsonRecord[];
|
|
27
|
+
rowsByIdentity: Map<string, JsonRecord>;
|
|
28
|
+
}
|
|
29
|
+
interface DatasetIdentity {
|
|
30
|
+
id: string;
|
|
31
|
+
version: string;
|
|
32
|
+
}
|
|
33
|
+
interface CurationQueueOptions {
|
|
34
|
+
queueDir?: string;
|
|
35
|
+
curationQueueDir?: string;
|
|
36
|
+
}
|
|
37
|
+
interface IdentityPreflightOptions {
|
|
38
|
+
identityPreflightIndex?: string;
|
|
39
|
+
identityPreflightRequests?: string;
|
|
40
|
+
identityPreflightRequestsIndex?: string;
|
|
41
|
+
identityPreflightFile?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const annualSupplyFieldPath = "processDataSet.modellingAndValidation.dataSourcesTreatmentAndRepresentativeness.annualSupplyOrProductionVolume";
|
|
44
|
+
export declare function isAnnualSupplyTarget(code: unknown, itemPath: unknown): boolean;
|
|
45
|
+
export declare function isAnnualSupplySchemaIssue(issue: unknown): boolean;
|
|
46
|
+
export declare function schemaIssueInstruction(issue: unknown): string | null;
|
|
47
|
+
export declare function schemaIssueCurationAction(issue: unknown): JsonRecord;
|
|
48
|
+
export declare function readCurationQueueContext(repoRoot: string, options: CurationQueueOptions): CurationQueueContext | null;
|
|
49
|
+
export declare function queueFilePath(repoRoot: string, queueContext: CurationQueueContext, fileRef: string | null | undefined): string | null;
|
|
50
|
+
export declare function queueFileRelativePath(repoRoot: string, queueContext: CurationQueueContext, fileRef: string | null | undefined): string | null;
|
|
51
|
+
export declare function summarizeQueueTask(repoRoot: string, queueContext: CurationQueueContext, task: QueueTask | null | undefined): JsonRecord | null;
|
|
52
|
+
export declare function readQueueTaskRows(repoRoot: string, queueContext: CurationQueueContext, task: QueueTask | null | undefined): unknown[];
|
|
53
|
+
export declare function findQueueTask(queueContext: CurationQueueContext | null, datasetType: string, identity: DatasetIdentity): QueueTask | null;
|
|
54
|
+
export declare function buildQueueAuthoringContext(repoRoot: string, queueContext: CurationQueueContext | null, datasetType: string, identity: DatasetIdentity): JsonRecord | null;
|
|
55
|
+
export declare function readAuthoringQueueContext(repoRoot: string, optionValue: string | null | undefined, kind: string): AuthoringQueueContext | null;
|
|
56
|
+
export declare function authoringQueueRowsForIdentity(queueContext: AuthoringQueueContext | null, identity: DatasetIdentity): JsonRecord[];
|
|
57
|
+
export declare function identityPreflightIndexPath(repoRoot: string, options: IdentityPreflightOptions, rowsFile: string | null | undefined): string | null;
|
|
58
|
+
export {};
|