@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,552 @@
|
|
|
1
|
+
import { contextFileDetails } from "./context-inputs.js";
|
|
2
|
+
import { datasetIdentity, detectDatasetType, identityFreshnessIdentityKey, } from "./dataset-payload.js";
|
|
3
|
+
import { sha256Json, sha256Text } from "./hash-utils.js";
|
|
4
|
+
import { asText, ensureArray, fileExists, readJson, readRows, readText, repoRelativeArtifactPath, repoRelativePath, resolveRepoPath, } from "./runtime-io.js";
|
|
5
|
+
function contextFileArray(value) {
|
|
6
|
+
return ensureArray(value);
|
|
7
|
+
}
|
|
8
|
+
export function curationGateContextHasKind(curationGateArtifact, kind) {
|
|
9
|
+
const details = contextFileArray(curationGateArtifact?.value?.context?.contract_context_file_details);
|
|
10
|
+
if (details.some((file) => asText(file?.kind) === kind))
|
|
11
|
+
return true;
|
|
12
|
+
const contextPaths = ensureArray(curationGateArtifact?.value?.context?.contract_context_files);
|
|
13
|
+
const expectedFileByKind = {
|
|
14
|
+
schema: "schema.json",
|
|
15
|
+
methodology_yaml: "methodology.yaml",
|
|
16
|
+
ruleset: "runtime-ruleset.json",
|
|
17
|
+
};
|
|
18
|
+
const expected = expectedFileByKind[kind];
|
|
19
|
+
return Boolean(expected &&
|
|
20
|
+
contextPaths.some((filePath) => String(filePath ?? "")
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.includes(expected)));
|
|
23
|
+
}
|
|
24
|
+
export function curationGateContextHasPattern(curationGateArtifact, pattern) {
|
|
25
|
+
const details = contextFileArray(curationGateArtifact?.value?.context?.contract_context_file_details);
|
|
26
|
+
if (details.some((file) => String(file?.path ?? "")
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.includes(pattern.toLowerCase()))) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const contextPaths = ensureArray(curationGateArtifact?.value?.context?.contract_context_files);
|
|
32
|
+
return contextPaths.some((filePath) => String(filePath ?? "")
|
|
33
|
+
.toLowerCase()
|
|
34
|
+
.includes(pattern.toLowerCase()));
|
|
35
|
+
}
|
|
36
|
+
export function evidenceResolution(entry) {
|
|
37
|
+
const typedEntry = entry;
|
|
38
|
+
return typedEntry?.resolution &&
|
|
39
|
+
typeof typedEntry.resolution === "object" &&
|
|
40
|
+
!Array.isArray(typedEntry.resolution)
|
|
41
|
+
? typedEntry.resolution
|
|
42
|
+
: null;
|
|
43
|
+
}
|
|
44
|
+
export function evidenceResolutionMode(entry) {
|
|
45
|
+
return asText(evidenceResolution(entry)?.mode);
|
|
46
|
+
}
|
|
47
|
+
export function evidenceResolutionContextKinds(entry) {
|
|
48
|
+
return ensureArray(evidenceResolution(entry)?.used_context_kinds ?? evidenceResolution(entry)?.usedContextKinds)
|
|
49
|
+
.map((kind) => asText(kind))
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
}
|
|
52
|
+
export function contextFileHasNonEmptyText(file) {
|
|
53
|
+
return Buffer.byteLength(String(file?.text ?? ""), "utf8") > 0;
|
|
54
|
+
}
|
|
55
|
+
export function contextFilesHaveKind(files, kind) {
|
|
56
|
+
return contextFileArray(files).some((file) => asText(file?.kind) === kind && contextFileHasNonEmptyText(file));
|
|
57
|
+
}
|
|
58
|
+
export function contextFilesHavePattern(files, pattern) {
|
|
59
|
+
const needle = String(pattern).toLowerCase();
|
|
60
|
+
return contextFileArray(files).some((file) => String(file?.path ?? "")
|
|
61
|
+
.toLowerCase()
|
|
62
|
+
.includes(needle) && contextFileHasNonEmptyText(file));
|
|
63
|
+
}
|
|
64
|
+
export function readAuthoringPackageProof(repoRoot, packageRef, expectedSha256 = null, source = null) {
|
|
65
|
+
const packagePath = resolveRepoPath(repoRoot, packageRef);
|
|
66
|
+
const proof = {
|
|
67
|
+
source,
|
|
68
|
+
path: packageRef ? repoRelativeArtifactPath(repoRoot, packageRef) : null,
|
|
69
|
+
exists: false,
|
|
70
|
+
sha256: null,
|
|
71
|
+
expected_sha256: asText(expectedSha256) || null,
|
|
72
|
+
payload: null,
|
|
73
|
+
contract_context_files: [],
|
|
74
|
+
contract_context_file_details: [],
|
|
75
|
+
blockers: [],
|
|
76
|
+
};
|
|
77
|
+
if (!packageRef || !packagePath || !fileExists(packagePath)) {
|
|
78
|
+
proof.blockers.push({
|
|
79
|
+
code: "full_context_authoring_package_missing",
|
|
80
|
+
stage: "full_context_ai_completion",
|
|
81
|
+
message: "Full-context AI completion evidence references an unreadable authoring package.",
|
|
82
|
+
authoring_package: proof.path,
|
|
83
|
+
source,
|
|
84
|
+
});
|
|
85
|
+
return proof;
|
|
86
|
+
}
|
|
87
|
+
proof.exists = true;
|
|
88
|
+
proof.path = repoRelativePath(repoRoot, packagePath);
|
|
89
|
+
let rawText = "";
|
|
90
|
+
try {
|
|
91
|
+
rawText = readText(packagePath);
|
|
92
|
+
proof.sha256 = sha256Text(rawText);
|
|
93
|
+
proof.payload = JSON.parse(rawText);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
proof.blockers.push({
|
|
97
|
+
code: "full_context_authoring_package_invalid",
|
|
98
|
+
stage: "full_context_ai_completion",
|
|
99
|
+
message: error instanceof Error ? error.message : String(error),
|
|
100
|
+
authoring_package: proof.path,
|
|
101
|
+
source,
|
|
102
|
+
});
|
|
103
|
+
return proof;
|
|
104
|
+
}
|
|
105
|
+
if (!proof.payload || typeof proof.payload !== "object" || Array.isArray(proof.payload)) {
|
|
106
|
+
proof.blockers.push({
|
|
107
|
+
code: "full_context_authoring_package_invalid",
|
|
108
|
+
stage: "full_context_ai_completion",
|
|
109
|
+
message: "Authoring package must be a JSON object.",
|
|
110
|
+
authoring_package: proof.path,
|
|
111
|
+
source,
|
|
112
|
+
});
|
|
113
|
+
return proof;
|
|
114
|
+
}
|
|
115
|
+
proof.contract_context_files = contextFileArray(proof.payload.contract_context_files);
|
|
116
|
+
proof.contract_context_file_details = contextFileDetails(proof.contract_context_files);
|
|
117
|
+
if (proof.expected_sha256 && proof.sha256 && proof.expected_sha256 !== proof.sha256) {
|
|
118
|
+
proof.blockers.push({
|
|
119
|
+
code: "full_context_authoring_package_hash_mismatch",
|
|
120
|
+
stage: "full_context_ai_completion",
|
|
121
|
+
message: "Recorded authoring_package_sha256 does not match the current authoring package content.",
|
|
122
|
+
authoring_package: proof.path,
|
|
123
|
+
expected_sha256: proof.expected_sha256,
|
|
124
|
+
actual_sha256: proof.sha256,
|
|
125
|
+
source,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return proof;
|
|
129
|
+
}
|
|
130
|
+
export function authoringPackageProofsFromCurationGate(repoRoot, curationGateArtifact) {
|
|
131
|
+
const entities = ensureArray(curationGateArtifact?.value?.entities ??
|
|
132
|
+
curationGateArtifact?.value?.processes ??
|
|
133
|
+
curationGateArtifact?.value?.flows ??
|
|
134
|
+
curationGateArtifact?.value?.items);
|
|
135
|
+
return entities
|
|
136
|
+
.map((entity) => {
|
|
137
|
+
const packageRef = asText(entity?.authoring_package ?? entity?.authoringPackage);
|
|
138
|
+
if (!packageRef)
|
|
139
|
+
return null;
|
|
140
|
+
return readAuthoringPackageProof(repoRoot, packageRef, entity?.authoring_package_sha256, "curation_gate");
|
|
141
|
+
})
|
|
142
|
+
.filter(Boolean);
|
|
143
|
+
}
|
|
144
|
+
// part-09.mjs
|
|
145
|
+
export function authoringPackageProofsFromPatchCollect(repoRoot, patchCollectArtifact) {
|
|
146
|
+
const manifestRef = patchCollectArtifact?.value?.task_manifest;
|
|
147
|
+
const manifestPath = resolveRepoPath(repoRoot, manifestRef);
|
|
148
|
+
if (!manifestRef || !manifestPath || !fileExists(manifestPath))
|
|
149
|
+
return [];
|
|
150
|
+
let manifest;
|
|
151
|
+
try {
|
|
152
|
+
manifest = readJson(manifestPath);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
return ensureArray(manifest.tasks)
|
|
158
|
+
.map((task) => {
|
|
159
|
+
const packageRef = asText(task?.files?.authoring_package ?? task?.files?.authoringPackage);
|
|
160
|
+
if (!packageRef)
|
|
161
|
+
return null;
|
|
162
|
+
return readAuthoringPackageProof(repoRoot, packageRef, task?.context?.authoring_package_sha256, "patch_collect_task_manifest");
|
|
163
|
+
})
|
|
164
|
+
.filter(Boolean);
|
|
165
|
+
}
|
|
166
|
+
export function fullContextPackageProofBlockers({ requirement, proof, }) {
|
|
167
|
+
const blockers = [...proof.blockers];
|
|
168
|
+
if (blockers.length > 0 || !proof.payload)
|
|
169
|
+
return blockers;
|
|
170
|
+
for (const kind of requirement.requiredContextKinds) {
|
|
171
|
+
if (!contextFilesHaveKind(proof.contract_context_files, kind)) {
|
|
172
|
+
blockers.push({
|
|
173
|
+
code: "full_context_authoring_package_context_kind_missing",
|
|
174
|
+
stage: "full_context_ai_completion",
|
|
175
|
+
message: `Authoring package does not contain full non-empty context text for '${kind}'.`,
|
|
176
|
+
required_kind: kind,
|
|
177
|
+
authoring_package: proof.path,
|
|
178
|
+
source: proof.source,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const pattern of requirement.requiredContextFilePatterns) {
|
|
183
|
+
if (!contextFilesHavePattern(proof.contract_context_files, pattern)) {
|
|
184
|
+
blockers.push({
|
|
185
|
+
code: "full_context_authoring_package_context_file_missing",
|
|
186
|
+
stage: "full_context_ai_completion",
|
|
187
|
+
message: `Authoring package does not contain full non-empty context text for a file matching '${pattern}'.`,
|
|
188
|
+
required_file_pattern: pattern,
|
|
189
|
+
authoring_package: proof.path,
|
|
190
|
+
source: proof.source,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (ensureArray(proof.payload.missing_context_files).length > 0) {
|
|
195
|
+
blockers.push({
|
|
196
|
+
code: "full_context_authoring_package_missing_context_files",
|
|
197
|
+
stage: "full_context_ai_completion",
|
|
198
|
+
message: "Authoring package records missing context files and cannot prove full-context AI completion.",
|
|
199
|
+
authoring_package: proof.path,
|
|
200
|
+
missing_context_files: ensureArray(proof.payload.missing_context_files),
|
|
201
|
+
source: proof.source,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return blockers;
|
|
205
|
+
}
|
|
206
|
+
export function normalizeClassificationDecisionRows(value) {
|
|
207
|
+
const record = value;
|
|
208
|
+
if (Array.isArray(value))
|
|
209
|
+
return value.filter(Boolean);
|
|
210
|
+
if (Array.isArray(record?.decisions))
|
|
211
|
+
return record.decisions.filter(Boolean);
|
|
212
|
+
if (Array.isArray(record?.rows))
|
|
213
|
+
return record.rows.filter(Boolean);
|
|
214
|
+
return value && typeof value === "object" ? [value] : [];
|
|
215
|
+
}
|
|
216
|
+
export function readDecisionTaskProof(repoRoot, taskRef, expectedSha256 = null, expectedContextBundleSha256 = null, source = null) {
|
|
217
|
+
const taskPath = resolveRepoPath(repoRoot, taskRef);
|
|
218
|
+
const proof = {
|
|
219
|
+
source,
|
|
220
|
+
path: taskRef ? repoRelativeArtifactPath(repoRoot, taskRef) : null,
|
|
221
|
+
exists: false,
|
|
222
|
+
sha256: null,
|
|
223
|
+
expected_sha256: asText(expectedSha256) || null,
|
|
224
|
+
expected_context_bundle_sha256: asText(expectedContextBundleSha256) || null,
|
|
225
|
+
payload: null,
|
|
226
|
+
status: null,
|
|
227
|
+
task_kind: null,
|
|
228
|
+
context_bundle_sha256: null,
|
|
229
|
+
contract_context_files: [],
|
|
230
|
+
contract_context_file_details: [],
|
|
231
|
+
missing_context_files: [],
|
|
232
|
+
shared_context_bundle: null,
|
|
233
|
+
blockers: [],
|
|
234
|
+
};
|
|
235
|
+
if (!taskRef || !taskPath || !fileExists(taskPath)) {
|
|
236
|
+
proof.blockers.push({
|
|
237
|
+
code: "full_context_decision_task_missing",
|
|
238
|
+
stage: "full_context_ai_completion",
|
|
239
|
+
message: "Full-context decision evidence references an unreadable AI decision task.",
|
|
240
|
+
decision_task: proof.path,
|
|
241
|
+
source,
|
|
242
|
+
});
|
|
243
|
+
return proof;
|
|
244
|
+
}
|
|
245
|
+
proof.exists = true;
|
|
246
|
+
proof.path = repoRelativePath(repoRoot, taskPath);
|
|
247
|
+
let rawText = "";
|
|
248
|
+
try {
|
|
249
|
+
rawText = readText(taskPath);
|
|
250
|
+
proof.sha256 = sha256Text(rawText);
|
|
251
|
+
proof.payload = JSON.parse(rawText);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
proof.blockers.push({
|
|
255
|
+
code: "full_context_decision_task_invalid",
|
|
256
|
+
stage: "full_context_ai_completion",
|
|
257
|
+
message: error instanceof Error ? error.message : String(error),
|
|
258
|
+
decision_task: proof.path,
|
|
259
|
+
source,
|
|
260
|
+
});
|
|
261
|
+
return proof;
|
|
262
|
+
}
|
|
263
|
+
if (!proof.payload || typeof proof.payload !== "object" || Array.isArray(proof.payload)) {
|
|
264
|
+
proof.blockers.push({
|
|
265
|
+
code: "full_context_decision_task_invalid",
|
|
266
|
+
stage: "full_context_ai_completion",
|
|
267
|
+
message: "Decision task must be a JSON object.",
|
|
268
|
+
decision_task: proof.path,
|
|
269
|
+
source,
|
|
270
|
+
});
|
|
271
|
+
return proof;
|
|
272
|
+
}
|
|
273
|
+
const contextBundle = (proof.payload.context_bundle ??
|
|
274
|
+
proof.payload.authoring_context ??
|
|
275
|
+
{});
|
|
276
|
+
proof.status = asText(proof.payload.status);
|
|
277
|
+
proof.task_kind = asText(proof.payload.task_kind);
|
|
278
|
+
proof.context_bundle_sha256 = asText(contextBundle.sha256 ?? contextBundle.context_bundle_sha256);
|
|
279
|
+
proof.shared_context_bundle = readDecisionTaskSharedContextBundleProof(repoRoot, proof.payload, proof.path);
|
|
280
|
+
proof.blockers.push(...proof.shared_context_bundle.blockers);
|
|
281
|
+
proof.contract_context_files = [
|
|
282
|
+
...contextFileArray(proof.payload.contract_context_files),
|
|
283
|
+
...proof.shared_context_bundle.files,
|
|
284
|
+
];
|
|
285
|
+
proof.contract_context_file_details = contextFileDetails(proof.contract_context_files);
|
|
286
|
+
proof.missing_context_files = ensureArray(proof.payload.missing_context_files);
|
|
287
|
+
if (proof.expected_sha256 && proof.expected_sha256 !== proof.sha256) {
|
|
288
|
+
proof.blockers.push({
|
|
289
|
+
code: "full_context_decision_task_hash_mismatch",
|
|
290
|
+
stage: "full_context_ai_completion",
|
|
291
|
+
message: "Recorded decision task sha256 does not match the current decision task content.",
|
|
292
|
+
decision_task: proof.path,
|
|
293
|
+
expected_sha256: proof.expected_sha256,
|
|
294
|
+
actual_sha256: proof.sha256,
|
|
295
|
+
source,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (proof.expected_context_bundle_sha256 &&
|
|
299
|
+
proof.context_bundle_sha256 &&
|
|
300
|
+
proof.expected_context_bundle_sha256 !== proof.context_bundle_sha256) {
|
|
301
|
+
proof.blockers.push({
|
|
302
|
+
code: "full_context_decision_task_context_hash_mismatch",
|
|
303
|
+
stage: "full_context_ai_completion",
|
|
304
|
+
message: "Recorded decision task context bundle hash does not match the decision task.",
|
|
305
|
+
decision_task: proof.path,
|
|
306
|
+
expected_context_bundle_sha256: proof.expected_context_bundle_sha256,
|
|
307
|
+
actual_context_bundle_sha256: proof.context_bundle_sha256,
|
|
308
|
+
source,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return proof;
|
|
312
|
+
}
|
|
313
|
+
export function decisionTaskProofFromApplyReport(repoRoot, report, source) {
|
|
314
|
+
const task = (report?.decision_task ?? report?.decisionTask);
|
|
315
|
+
const taskRef = asText(task?.path ?? task?.task ?? task?.decision_task ?? task?.decisionTask);
|
|
316
|
+
if (!taskRef)
|
|
317
|
+
return null;
|
|
318
|
+
return readDecisionTaskProof(repoRoot, taskRef, task?.sha256, task?.context_bundle_sha256 ?? task?.contextBundleSha256, source);
|
|
319
|
+
}
|
|
320
|
+
export function readDecisionTaskSharedContextBundleProof(repoRoot, payload, taskPath) {
|
|
321
|
+
const contextBundle = (payload?.context_bundle ?? payload?.authoring_context ?? {});
|
|
322
|
+
const sharedContext = (payload?.shared_context_bundle ??
|
|
323
|
+
contextBundle.shared_context_bundle ??
|
|
324
|
+
{});
|
|
325
|
+
const payloadFiles = payload?.files;
|
|
326
|
+
const sharedPath = asText(sharedContext?.path ?? payloadFiles?.shared_context_bundle);
|
|
327
|
+
const expectedSha256 = asText(sharedContext?.sha256 ?? contextBundle?.shared_context_bundle_sha256);
|
|
328
|
+
const proof = {
|
|
329
|
+
path: sharedPath ? repoRelativeArtifactPath(repoRoot, sharedPath) : null,
|
|
330
|
+
sha256: null,
|
|
331
|
+
expected_sha256: expectedSha256 || null,
|
|
332
|
+
files: [],
|
|
333
|
+
blockers: [],
|
|
334
|
+
};
|
|
335
|
+
if (!sharedPath)
|
|
336
|
+
return proof;
|
|
337
|
+
const bundlePath = resolveRepoPath(repoRoot, sharedPath);
|
|
338
|
+
if (!bundlePath || !fileExists(bundlePath)) {
|
|
339
|
+
proof.blockers.push({
|
|
340
|
+
code: "full_context_decision_task_shared_context_bundle_missing",
|
|
341
|
+
stage: "full_context_ai_completion",
|
|
342
|
+
message: "Decision task references an unreadable shared full-context bundle.",
|
|
343
|
+
decision_task: taskPath,
|
|
344
|
+
shared_context_bundle: proof.path,
|
|
345
|
+
});
|
|
346
|
+
return proof;
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
const bundle = readJson(bundlePath);
|
|
350
|
+
proof.sha256 = asText(bundle?.sha256);
|
|
351
|
+
proof.files = contextFileArray(bundle?.files);
|
|
352
|
+
if (expectedSha256 && proof.sha256 !== expectedSha256) {
|
|
353
|
+
proof.blockers.push({
|
|
354
|
+
code: "full_context_decision_task_shared_context_bundle_hash_mismatch",
|
|
355
|
+
stage: "full_context_ai_completion",
|
|
356
|
+
message: "Decision task shared context bundle sha256 no longer matches the task reference.",
|
|
357
|
+
decision_task: taskPath,
|
|
358
|
+
shared_context_bundle: proof.path,
|
|
359
|
+
expected_sha256: expectedSha256,
|
|
360
|
+
actual_sha256: proof.sha256 || null,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
proof.blockers.push({
|
|
366
|
+
code: "full_context_decision_task_shared_context_bundle_invalid",
|
|
367
|
+
stage: "full_context_ai_completion",
|
|
368
|
+
message: error instanceof Error ? error.message : String(error),
|
|
369
|
+
decision_task: taskPath,
|
|
370
|
+
shared_context_bundle: proof.path,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return proof;
|
|
374
|
+
}
|
|
375
|
+
export function decisionTaskProofsFromApplyReport(repoRoot, report, source) {
|
|
376
|
+
const tasks = ensureArray(report?.decision_tasks ?? report?.decisionTasks);
|
|
377
|
+
if (tasks.length === 0) {
|
|
378
|
+
const single = decisionTaskProofFromApplyReport(repoRoot, report, source);
|
|
379
|
+
return single ? [single] : [];
|
|
380
|
+
}
|
|
381
|
+
return tasks
|
|
382
|
+
.map((task) => {
|
|
383
|
+
const taskRef = asText(task?.path ?? task?.task ?? task?.decision_task ?? task?.decisionTask);
|
|
384
|
+
if (!taskRef)
|
|
385
|
+
return null;
|
|
386
|
+
return readDecisionTaskProof(repoRoot, taskRef, task?.sha256, task?.context_bundle_sha256 ?? task?.contextBundleSha256, source);
|
|
387
|
+
})
|
|
388
|
+
.filter(Boolean);
|
|
389
|
+
}
|
|
390
|
+
export function payloadSha256ByIdentityForRows(repoRoot, rowFiles, fallbackDatasetType = null) {
|
|
391
|
+
const map = new Map();
|
|
392
|
+
for (const rowFile of ensureArray(rowFiles)) {
|
|
393
|
+
const resolved = resolveRepoPath(repoRoot, rowFile);
|
|
394
|
+
if (!resolved || !fileExists(resolved))
|
|
395
|
+
continue;
|
|
396
|
+
readRows(resolved).forEach((row, index) => {
|
|
397
|
+
const datasetType = detectDatasetType(row, fallbackDatasetType);
|
|
398
|
+
if (!datasetType)
|
|
399
|
+
return;
|
|
400
|
+
const identity = datasetIdentity(row, index, datasetType);
|
|
401
|
+
const key = identityFreshnessIdentityKey({ datasetType, identity });
|
|
402
|
+
if (key)
|
|
403
|
+
map.set(key, sha256Json(identity.payload));
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
return map;
|
|
407
|
+
}
|
|
408
|
+
export function fullContextDecisionTaskProofBlockers({ requirement, proof, label, }) {
|
|
409
|
+
if (!proof) {
|
|
410
|
+
return [
|
|
411
|
+
{
|
|
412
|
+
code: `full_context_ai_${label}_decision_task_required`,
|
|
413
|
+
stage: "full_context_ai_completion",
|
|
414
|
+
message: "Decision apply report must bind to the AI decision task that carried the full schema/YAML/context bundle.",
|
|
415
|
+
},
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
const blockers = [...proof.blockers];
|
|
419
|
+
if (blockers.length > 0 || !proof.payload)
|
|
420
|
+
return blockers;
|
|
421
|
+
const expectedTaskKind = label === "location" ? "location_decision_authoring" : "classification_decision_authoring";
|
|
422
|
+
const expectedStatus = label === "location"
|
|
423
|
+
? "ready_for_ai_location_decisions"
|
|
424
|
+
: "ready_for_ai_classification_decisions";
|
|
425
|
+
if (proof.task_kind !== expectedTaskKind) {
|
|
426
|
+
blockers.push({
|
|
427
|
+
code: `full_context_ai_${label}_decision_task_kind_invalid`,
|
|
428
|
+
stage: "full_context_ai_completion",
|
|
429
|
+
message: "Decision apply report must reference the matching full-context AI decision task kind.",
|
|
430
|
+
decision_task: proof.path,
|
|
431
|
+
expected_task_kind: expectedTaskKind,
|
|
432
|
+
actual_task_kind: proof.task_kind || null,
|
|
433
|
+
source: proof.source,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (proof.status !== expectedStatus) {
|
|
437
|
+
blockers.push({
|
|
438
|
+
code: `full_context_ai_${label}_decision_task_status_invalid`,
|
|
439
|
+
stage: "full_context_ai_completion",
|
|
440
|
+
message: "Decision apply report must reference a ready full-context AI decision task.",
|
|
441
|
+
decision_task: proof.path,
|
|
442
|
+
expected_status: expectedStatus,
|
|
443
|
+
actual_status: proof.status || null,
|
|
444
|
+
source: proof.source,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
for (const kind of requirement.requiredContextKinds) {
|
|
448
|
+
if (!contextFilesHaveKind(proof.contract_context_files, kind)) {
|
|
449
|
+
blockers.push({
|
|
450
|
+
code: `full_context_ai_${label}_decision_task_context_kind_missing`,
|
|
451
|
+
stage: "full_context_ai_completion",
|
|
452
|
+
message: `Decision task does not contain full non-empty context text for '${kind}'.`,
|
|
453
|
+
required_kind: kind,
|
|
454
|
+
decision_task: proof.path,
|
|
455
|
+
source: proof.source,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
for (const pattern of decisionTaskRequiredContextFilePatterns({
|
|
460
|
+
requirement,
|
|
461
|
+
proof,
|
|
462
|
+
label,
|
|
463
|
+
})) {
|
|
464
|
+
if (!contextFilesHavePattern(proof.contract_context_files, pattern)) {
|
|
465
|
+
blockers.push({
|
|
466
|
+
code: `full_context_ai_${label}_decision_task_context_file_missing`,
|
|
467
|
+
stage: "full_context_ai_completion",
|
|
468
|
+
message: `Decision task does not contain full non-empty context text for a file matching '${pattern}'.`,
|
|
469
|
+
required_file_pattern: pattern,
|
|
470
|
+
decision_task: proof.path,
|
|
471
|
+
source: proof.source,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (proof.missing_context_files.length > 0) {
|
|
476
|
+
blockers.push({
|
|
477
|
+
code: `full_context_ai_${label}_decision_task_missing_context_files`,
|
|
478
|
+
stage: "full_context_ai_completion",
|
|
479
|
+
message: "Decision task records missing context files and cannot prove full-context AI completion.",
|
|
480
|
+
decision_task: proof.path,
|
|
481
|
+
missing_context_files: proof.missing_context_files,
|
|
482
|
+
source: proof.source,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
if (!proof.context_bundle_sha256) {
|
|
486
|
+
blockers.push({
|
|
487
|
+
code: `full_context_ai_${label}_decision_task_context_hash_missing`,
|
|
488
|
+
stage: "full_context_ai_completion",
|
|
489
|
+
message: "Decision task must include context_bundle.sha256 so decisions can be tied to the exact context bundle.",
|
|
490
|
+
decision_task: proof.path,
|
|
491
|
+
source: proof.source,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return blockers;
|
|
495
|
+
}
|
|
496
|
+
export function decisionTaskRequiredContextFilePatterns({ requirement, proof, label, }) {
|
|
497
|
+
const profilePatterns = ensureArray(requirement.requiredContextFilePatterns);
|
|
498
|
+
if (label === "location") {
|
|
499
|
+
return profilePatterns.filter((pattern) => [
|
|
500
|
+
"schema.json",
|
|
501
|
+
"methodology.yaml",
|
|
502
|
+
"runtime-ruleset.json",
|
|
503
|
+
"tidas_locations_category.json",
|
|
504
|
+
].includes(String(pattern).toLowerCase()));
|
|
505
|
+
}
|
|
506
|
+
if (label !== "classification")
|
|
507
|
+
return profilePatterns;
|
|
508
|
+
const schemaTypeToFile = {
|
|
509
|
+
contact: "tidas_contacts_category.json",
|
|
510
|
+
contacts: "tidas_contacts_category.json",
|
|
511
|
+
flowproperty: "tidas_flowproperties_category.json",
|
|
512
|
+
flowproperties: "tidas_flowproperties_category.json",
|
|
513
|
+
"flow-elementary": "tidas_flows_elementary_category.json",
|
|
514
|
+
elementary: "tidas_flows_elementary_category.json",
|
|
515
|
+
"flow-product": "tidas_flows_product_category.json",
|
|
516
|
+
flow: "tidas_flows_product_category.json",
|
|
517
|
+
lciamethod: "tidas_lciamethods_category.json",
|
|
518
|
+
lciamethods: "tidas_lciamethods_category.json",
|
|
519
|
+
process: "tidas_processes_category.json",
|
|
520
|
+
processes: "tidas_processes_category.json",
|
|
521
|
+
source: "tidas_sources_category.json",
|
|
522
|
+
sources: "tidas_sources_category.json",
|
|
523
|
+
unitgroup: "tidas_unitgroups_category.json",
|
|
524
|
+
unitgroups: "tidas_unitgroups_category.json",
|
|
525
|
+
};
|
|
526
|
+
const payload = proof?.payload ?? {};
|
|
527
|
+
const schemaTypes = [
|
|
528
|
+
...ensureArray(payload.schema_types ?? payload.schemaTypes),
|
|
529
|
+
...ensureArray(payload.row_types ?? payload.rowTypes),
|
|
530
|
+
]
|
|
531
|
+
.map((value) => asText(value).toLowerCase())
|
|
532
|
+
.filter(Boolean);
|
|
533
|
+
const required = new Set([
|
|
534
|
+
"schema.json",
|
|
535
|
+
"methodology.yaml",
|
|
536
|
+
"runtime-ruleset.json",
|
|
537
|
+
"tidas_locations_category.json",
|
|
538
|
+
]);
|
|
539
|
+
for (const schemaType of schemaTypes) {
|
|
540
|
+
const fileName = schemaTypeToFile[schemaType];
|
|
541
|
+
if (fileName)
|
|
542
|
+
required.add(fileName);
|
|
543
|
+
}
|
|
544
|
+
if (schemaTypes.length === 0) {
|
|
545
|
+
for (const pattern of profilePatterns) {
|
|
546
|
+
if (contextFilesHavePattern(proof?.contract_context_files, pattern)) {
|
|
547
|
+
required.add(String(pattern).toLowerCase());
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return profilePatterns.filter((pattern) => required.has(String(pattern).toLowerCase()));
|
|
552
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
export function sha256Text(value) {
|
|
3
|
+
return crypto
|
|
4
|
+
.createHash("sha256")
|
|
5
|
+
.update(String(value ?? ""))
|
|
6
|
+
.digest("hex");
|
|
7
|
+
}
|
|
8
|
+
export function sha256Json(value) {
|
|
9
|
+
return crypto.createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { fullContextAiCompletionRequirement } from "./context-inputs.ts";
|
|
2
|
+
export { identityKey, mapRowsByIdentity } from "./dataset-payload.ts";
|
|
3
|
+
export { datasetTypeFromOptions, datasetTypePlural, supportDatasetTypes } from "./dataset-types.ts";
|
|
4
|
+
export { profileFor } from "./profiles-config.ts";
|
|
5
|
+
export { asText, ensureArray, fileExists, jsonLines, nowIso, readRows, repoRelativePath, resolveRepoPath, writeJson, writeJsonLines, writeText, } from "./runtime-io.ts";
|
|
6
|
+
export { readClassificationDecisionApplyContext } from "./workflow-decision-apply-context.ts";
|
|
7
|
+
export { decisionApplyContextRelevantToRowsFile, decisionTaskContextBundleHashesFromContext, readLocationDecisionApplyContext, } from "./workflow-decision-full-context.ts";
|
|
8
|
+
export { mapCurationEntities, mapSchemaRows, readDatasetSaveDraftDryRunArtifacts, readFlowDryRunArtifacts, readLifecyclemodelDryRunArtifacts, readProcessDryRunArtifacts, remoteVerifyBlockerKeys, } from "./workflow-dry-run-context.ts";
|
|
9
|
+
export { buildEvidenceScopeBlockers, evidenceScopeBlocker } from "./workflow-evidence-scope.ts";
|
|
10
|
+
export { identityDecisionUnresolvedReferenceKeys, readIdentityDecisionApplyContexts, readIdentityReferenceRewriteContext, } from "./workflow-identity-decision-context.ts";
|
|
11
|
+
export { identityDecisionApplyReportOptionValues, readFileArtifactIfOption, readJsonArtifactsIfOption, readJsonIfOption, readRowsIfExists, } from "./workflow-patch-collect.ts";
|
|
12
|
+
export { readPatchApplyContext, readPolicySnapshots } from "./workflow-patch-evidence-context.ts";
|
|
13
|
+
export { buildFullContextAiCompletionBlockers, buildReferenceClosureBlockers, buildReferenceReuseItems, buildWriteCandidateItem, decisionCounts, identityReferenceRewriteProofKeys, operationCounts, plannedRootReferenceIds, plannedRootReferenceKeys, referenceKey, sourceContactRewriteSemanticEvidenceCount, } from "./workflow-reference-closure.ts";
|
|
14
|
+
export { readCanonicalSupportRewriteContext, readCleanupTransformContext, readSourceContactRewriteContext, readUnresolvedExchangeExternalizationContext, } from "./workflow-row-transform-context.ts";
|
|
15
|
+
export { publicCanonicalSourceReferenceKeys, readSourceReferenceRewriteContext, sourceContactSupportCanonicalUnitGroupProofKeys, sourceContactSupportTrueSourceProofKeys, sourceReferenceRewriteProofKeys, } from "./workflow-source-reference-context.ts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { fullContextAiCompletionRequirement } from "./context-inputs.js";
|
|
2
|
+
export { identityKey, mapRowsByIdentity } from "./dataset-payload.js";
|
|
3
|
+
export { datasetTypeFromOptions, datasetTypePlural, supportDatasetTypes } from "./dataset-types.js";
|
|
4
|
+
export { profileFor } from "./profiles-config.js";
|
|
5
|
+
export { asText, ensureArray, fileExists, jsonLines, nowIso, readRows, repoRelativePath, resolveRepoPath, writeJson, writeJsonLines, writeText, } from "./runtime-io.js";
|
|
6
|
+
export { readClassificationDecisionApplyContext } from "./workflow-decision-apply-context.js";
|
|
7
|
+
export { decisionApplyContextRelevantToRowsFile, decisionTaskContextBundleHashesFromContext, readLocationDecisionApplyContext, } from "./workflow-decision-full-context.js";
|
|
8
|
+
export { mapCurationEntities, mapSchemaRows, readDatasetSaveDraftDryRunArtifacts, readFlowDryRunArtifacts, readLifecyclemodelDryRunArtifacts, readProcessDryRunArtifacts, remoteVerifyBlockerKeys, } from "./workflow-dry-run-context.js";
|
|
9
|
+
export { buildEvidenceScopeBlockers, evidenceScopeBlocker } from "./workflow-evidence-scope.js";
|
|
10
|
+
export { identityDecisionUnresolvedReferenceKeys, readIdentityDecisionApplyContexts, readIdentityReferenceRewriteContext, } from "./workflow-identity-decision-context.js";
|
|
11
|
+
export { identityDecisionApplyReportOptionValues, readFileArtifactIfOption, readJsonArtifactsIfOption, readJsonIfOption, readRowsIfExists, } from "./workflow-patch-collect.js";
|
|
12
|
+
export { readPatchApplyContext, readPolicySnapshots } from "./workflow-patch-evidence-context.js";
|
|
13
|
+
export { buildFullContextAiCompletionBlockers, buildReferenceClosureBlockers, buildReferenceReuseItems, buildWriteCandidateItem, decisionCounts, identityReferenceRewriteProofKeys, operationCounts, plannedRootReferenceIds, plannedRootReferenceKeys, referenceKey, sourceContactRewriteSemanticEvidenceCount, } from "./workflow-reference-closure.js";
|
|
14
|
+
export { readCanonicalSupportRewriteContext, readCleanupTransformContext, readSourceContactRewriteContext, readUnresolvedExchangeExternalizationContext, } from "./workflow-row-transform-context.js";
|
|
15
|
+
export { publicCanonicalSourceReferenceKeys, readSourceReferenceRewriteContext, sourceContactSupportCanonicalUnitGroupProofKeys, sourceContactSupportTrueSourceProofKeys, sourceReferenceRewriteProofKeys, } from "./workflow-source-reference-context.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { datasetIdentity } from "./dataset-payload.ts";
|
|
2
|
+
export declare const annualSupplyMissingDataSentinelText = "9999 missing-data-sentinel/year";
|
|
3
|
+
export declare const foundryTraceNamespace = "https://tiangong-lca.dev/foundry/import-curation/1";
|
|
4
|
+
interface JsonRecord {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface SourceRowEntry {
|
|
8
|
+
row: unknown;
|
|
9
|
+
index: number;
|
|
10
|
+
identity: ReturnType<typeof datasetIdentity>;
|
|
11
|
+
}
|
|
12
|
+
export type SourceRowsByIdentity = Map<string, SourceRowEntry>;
|
|
13
|
+
interface SourceExchangeProofOptions {
|
|
14
|
+
rowIndex?: number | null;
|
|
15
|
+
sourceRowsByKey?: SourceRowsByIdentity | null;
|
|
16
|
+
sourceRowsFile?: string | null;
|
|
17
|
+
rowsFile?: string | null;
|
|
18
|
+
proofRows?: JsonRecord[];
|
|
19
|
+
}
|
|
20
|
+
export declare function normalizeUtcDateTimeString(value: unknown): string | null;
|
|
21
|
+
export declare function normalizeDateTimeMetadata(value: unknown): number;
|
|
22
|
+
export declare function applyAnnualSupplyMissingDataSentinel(row: unknown, datasetType: string): boolean;
|
|
23
|
+
export declare function applyDeterministicSourceExchangeCompletenessProofs(row: unknown, datasetType: string, { rowIndex, sourceRowsByKey, sourceRowsFile, rowsFile, proofRows, }?: SourceExchangeProofOptions): boolean;
|
|
24
|
+
export declare function buildSourceRowsByIdentity(sourceRows: unknown[]): SourceRowsByIdentity;
|
|
25
|
+
export declare function externalizeImportTraceMetadata(value: unknown): {
|
|
26
|
+
removed: number;
|
|
27
|
+
summaries: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function ensureFoundryTraceNamespaces(value: unknown): number;
|
|
30
|
+
export declare function sanitizeFoundryTraceEvidenceLocators(value: unknown): number;
|
|
31
|
+
export {};
|