@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,225 @@
|
|
|
1
|
+
import { parseCapsule, FOUNDRY_EXECUTION_CAPSULE_SCHEMA, } from "./foundry-execution-context-format.js";
|
|
2
|
+
export { FOUNDRY_EXECUTION_CAPSULE_SCHEMA, } from "./foundry-execution-context-format.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertFoundryCommandSpecArtifactsCurrent, commandSpecOptionValue, parseFoundryCommandSpec, } from "@tiangong-lca/cli/command-spec";
|
|
6
|
+
import { assertFoundryRuntimeContext, assertFoundryWorkspaceActive, captureFoundryInput, FoundryContextError, readFoundryInput, resolveFoundryInputPath, resolveFoundryOutput, writeFoundryArtifact, } from "./foundry-runtime-context.js";
|
|
7
|
+
import { assertVerifiedFoundryIdentity, } from "./foundry-runtime-identity.js";
|
|
8
|
+
import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.js";
|
|
9
|
+
import { foundryRuntimeCommandPolicy } from "./foundry-runtime-command-policy.js";
|
|
10
|
+
import { loadFoundryTaskAuthorization } from "./foundry-task-authorization.js";
|
|
11
|
+
import { assertFoundryTaskInputLineage } from "./foundry-task-store.js";
|
|
12
|
+
import { taskAuthorizationAllows, taskAuthorizationWaivesQa, } from "./task-authorization.js";
|
|
13
|
+
import { bytes, digest } from "./foundry-task-io.js";
|
|
14
|
+
import { resolveInstalledTiangongLcaCliPackage } from "./foundry-runtime-utils.js";
|
|
15
|
+
import { assertFoundryMigrationNoReplay } from "./foundry-migration-replay.js";
|
|
16
|
+
const admissions = new WeakSet();
|
|
17
|
+
function fail(code, message) {
|
|
18
|
+
throw new FoundryContextError(code, message);
|
|
19
|
+
}
|
|
20
|
+
function selected(context, file) {
|
|
21
|
+
const resolved = resolveFoundryInputPath(context, file);
|
|
22
|
+
const fact = context.inputs.find((item) => item.path === resolved);
|
|
23
|
+
if (!fact)
|
|
24
|
+
fail("execution_input_unselected", "Execution input was not selected by the host.");
|
|
25
|
+
const current = captureFoundryInput(fact.path);
|
|
26
|
+
if (current.bytes !== fact.bytes || current.sha256 !== fact.sha256)
|
|
27
|
+
fail("execution_input_changed", "Execution input changed after host selection.");
|
|
28
|
+
return fact;
|
|
29
|
+
}
|
|
30
|
+
function sameFact(left, right) {
|
|
31
|
+
return left.path === right.path && left.bytes === right.bytes && left.sha256 === right.sha256;
|
|
32
|
+
}
|
|
33
|
+
function resolveSpecArtifact(context, value) {
|
|
34
|
+
const candidate = path.isAbsolute(value)
|
|
35
|
+
? path.resolve(value)
|
|
36
|
+
: path.resolve(context.workspaceRoot, value);
|
|
37
|
+
if (!fs.existsSync(candidate))
|
|
38
|
+
return candidate;
|
|
39
|
+
return fs.realpathSync(candidate);
|
|
40
|
+
}
|
|
41
|
+
function commandSpec(context, value, finalRows, actions) {
|
|
42
|
+
const spec = assertFoundryCommandSpecArtifactsCurrent(value, (artifactPath) => resolveSpecArtifact(context, artifactPath));
|
|
43
|
+
if (spec.binding.artifacts.length !== 1 || spec.binding.artifacts[0]?.role !== "final_rows")
|
|
44
|
+
fail("execution_final_rows_unbound", "Restricted execution requires one exact final_rows artifact binding.");
|
|
45
|
+
const artifact = spec.binding.artifacts[0];
|
|
46
|
+
if (resolveSpecArtifact(context, artifact.path) !== finalRows.path ||
|
|
47
|
+
artifact.bytes !== finalRows.bytes ||
|
|
48
|
+
artifact.sha256 !== finalRows.sha256)
|
|
49
|
+
fail("execution_final_rows_unbound", "CommandSpec does not bind the selected final-row bytes.");
|
|
50
|
+
const cli = resolveInstalledTiangongLcaCliPackage();
|
|
51
|
+
let selectedCli = null;
|
|
52
|
+
try {
|
|
53
|
+
selectedCli = spec.argv[0] ? fs.realpathSync(spec.argv[0]) : null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
/* A missing or non-resolvable argv[0] has no execution authority. */
|
|
57
|
+
}
|
|
58
|
+
if (path.resolve(spec.executable) !== path.resolve(process.execPath) ||
|
|
59
|
+
selectedCli !== fs.realpathSync(cli.binPath))
|
|
60
|
+
fail("execution_cli_unqualified", "Restricted execution must enter the exact installed owner CLI through Node.");
|
|
61
|
+
const input = commandSpecOptionValue(spec, "--input") ?? commandSpecOptionValue(spec, "--input-file");
|
|
62
|
+
if (!input || resolveFoundryInputPath(context, input) !== finalRows.path)
|
|
63
|
+
fail("execution_final_rows_unbound", "The owner CLI input argument must select the exact final-row artifact.");
|
|
64
|
+
const outDir = commandSpecOptionValue(spec, "--out-dir");
|
|
65
|
+
if (!outDir)
|
|
66
|
+
fail("execution_output_unbound", "Restricted execution requires a task output root.");
|
|
67
|
+
resolveFoundryOutput(context, outDir);
|
|
68
|
+
if (!spec.argv.includes("--commit") || !spec.argv.includes("--json"))
|
|
69
|
+
fail("execution_command_unadmitted", "Restricted execution requires the owner CLI commit and machine-result flags.");
|
|
70
|
+
const [group, operation] = spec.argv.slice(1, 3);
|
|
71
|
+
const datasetType = commandSpecOptionValue(spec, "--type");
|
|
72
|
+
const isDatasetSave = group === "dataset" &&
|
|
73
|
+
operation === "save-draft" &&
|
|
74
|
+
datasetType !== null &&
|
|
75
|
+
["auto", "contact", "source", "unitgroup", "flowproperty"].includes(datasetType);
|
|
76
|
+
const isProcessSave = group === "process" && operation === "save-draft" && !datasetType;
|
|
77
|
+
const isLifecycleSave = group === "lifecyclemodel" && operation === "save-draft" && !datasetType;
|
|
78
|
+
const isFlowPublish = group === "flow" && operation === "publish-version" && !datasetType;
|
|
79
|
+
if (!isDatasetSave && !isProcessSave && !isLifecycleSave && !isFlowPublish)
|
|
80
|
+
fail("execution_command_unadmitted", "CommandSpec is not one of the reviewed owner-draft write operations.");
|
|
81
|
+
const has = (action) => actions.includes(action);
|
|
82
|
+
if ((datasetType === "unitgroup" && !has("unitgroup_write")) ||
|
|
83
|
+
(datasetType === "flowproperty" && !has("flowproperty_write")) ||
|
|
84
|
+
(has("unitgroup_write") && !["unitgroup", "auto"].includes(datasetType ?? "")) ||
|
|
85
|
+
(has("flowproperty_write") && !["flowproperty", "auto"].includes(datasetType ?? "")) ||
|
|
86
|
+
((has("elementary_flow_write") || has("elementary_flow_create_new")) && !isFlowPublish) ||
|
|
87
|
+
(has("elementary_flow_create_new") && !has("elementary_flow_write")) ||
|
|
88
|
+
(has("canonical_support_local_mint") && !has("unitgroup_write") && !has("flowproperty_write")))
|
|
89
|
+
fail("execution_action_command_mismatch", "Authorized exception actions do not match the selected owner CLI write operation.");
|
|
90
|
+
if ((has("unitgroup_write") || has("flowproperty_write")) &&
|
|
91
|
+
!spec.argv.includes("--allow-account-local-support"))
|
|
92
|
+
fail("execution_action_command_mismatch", "Account-local support writes require the reviewed owner CLI override flag.");
|
|
93
|
+
const targetUserId = commandSpecOptionValue(spec, "--target-user-id");
|
|
94
|
+
if (targetUserId && targetUserId !== context.accountIntent?.userId)
|
|
95
|
+
fail("execution_account_mismatch", "CommandSpec target user does not match the freshly verified task account intent.");
|
|
96
|
+
readFoundryInput(context, finalRows.path);
|
|
97
|
+
return spec;
|
|
98
|
+
}
|
|
99
|
+
async function verifyAdmission(context, qualification, identity, capsule, specValue) {
|
|
100
|
+
assertFoundryRuntimeContext(context);
|
|
101
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
102
|
+
assertVerifiedFoundryIdentity(context, identity, qualification);
|
|
103
|
+
if (capsule.workspace_id !== context.workspaceId ||
|
|
104
|
+
capsule.task_id !== context.taskId ||
|
|
105
|
+
capsule.actor_id !== context.actorId ||
|
|
106
|
+
capsule.qualification_sha256 !== qualification.qualification_sha256)
|
|
107
|
+
fail("execution_context_mismatch", "Execution capsule does not match current workspace, task, actor and runtime.");
|
|
108
|
+
const policy = foundryRuntimeCommandPolicy(capsule.command);
|
|
109
|
+
if (!["task-stage", "native-runtime-stage"].includes(policy.disposition) ||
|
|
110
|
+
policy.authorization !== "required-before-restricted-action")
|
|
111
|
+
fail("execution_command_unadmitted", "Selected command is not a qualified task stage.");
|
|
112
|
+
const approved = selected(context, capsule.approved_input.path);
|
|
113
|
+
const finalRows = selected(context, capsule.final_rows.path);
|
|
114
|
+
assertFoundryMigrationNoReplay(context, finalRows.path);
|
|
115
|
+
if (!sameFact(approved, capsule.approved_input) || !sameFact(finalRows, capsule.final_rows))
|
|
116
|
+
fail("execution_input_changed", "Capsule input facts differ from current host selection.");
|
|
117
|
+
if (!sameFact(approved, finalRows))
|
|
118
|
+
await assertFoundryTaskInputLineage(context, approved.path, finalRows.path);
|
|
119
|
+
const authorization = await loadFoundryTaskAuthorization(context, identity, finalRows.path, qualification);
|
|
120
|
+
if (authorization.authorization_sha256 !== capsule.authorization_sha256 ||
|
|
121
|
+
capsule.required_actions.some((action) => !taskAuthorizationAllows(authorization, action)))
|
|
122
|
+
fail("execution_action_unauthorized", "Current task authorization does not permit the required final-row action.");
|
|
123
|
+
for (const code of capsule.required_qa_waivers) {
|
|
124
|
+
if (!taskAuthorizationWaivesQa(authorization, "process", code))
|
|
125
|
+
fail("execution_qa_waiver_required", "Current final rows require a QA waiver not present in current authorization.");
|
|
126
|
+
}
|
|
127
|
+
const spec = commandSpec(context, specValue, finalRows, capsule.required_actions);
|
|
128
|
+
if (spec.sha256 !== capsule.command_spec_sha256)
|
|
129
|
+
fail("execution_command_changed", "CommandSpec differs from the reviewed execution capsule.");
|
|
130
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
131
|
+
assertVerifiedFoundryIdentity(context, identity, qualification);
|
|
132
|
+
const refreshed = await loadFoundryTaskAuthorization(context, identity, finalRows.path, qualification);
|
|
133
|
+
if (refreshed.authorization_sha256 !== authorization.authorization_sha256 ||
|
|
134
|
+
capsule.required_actions.some((action) => !taskAuthorizationAllows(refreshed, action)))
|
|
135
|
+
fail("execution_authorization_changed", "Authorization changed during final admission checks.");
|
|
136
|
+
assertFoundryMigrationNoReplay(context, finalRows.path);
|
|
137
|
+
return { spec, authorization: refreshed };
|
|
138
|
+
}
|
|
139
|
+
export async function createFoundryExecutionCapsule(context, qualification, identity, options) {
|
|
140
|
+
assertFoundryWorkspaceActive(context);
|
|
141
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
142
|
+
assertVerifiedFoundryIdentity(context, identity, qualification);
|
|
143
|
+
const approved = selected(context, options.approvedInputFile);
|
|
144
|
+
const finalRows = selected(context, options.finalRowsFile);
|
|
145
|
+
assertFoundryMigrationNoReplay(context, finalRows.path);
|
|
146
|
+
const authorization = await loadFoundryTaskAuthorization(context, identity, finalRows.path, qualification);
|
|
147
|
+
const spec = parseFoundryCommandSpec(options.commandSpec);
|
|
148
|
+
const capsule = parseCapsule({
|
|
149
|
+
schema: FOUNDRY_EXECUTION_CAPSULE_SCHEMA,
|
|
150
|
+
workspace_id: context.workspaceId,
|
|
151
|
+
task_id: context.taskId,
|
|
152
|
+
actor_id: context.actorId,
|
|
153
|
+
command: options.command,
|
|
154
|
+
qualification_sha256: qualification.qualification_sha256,
|
|
155
|
+
authorization_sha256: authorization.authorization_sha256,
|
|
156
|
+
approved_input: approved,
|
|
157
|
+
final_rows: finalRows,
|
|
158
|
+
required_actions: [...(options.requiredActions ?? [])].sort(),
|
|
159
|
+
required_qa_waivers: [...(options.requiredQaWaivers ?? [])].sort(),
|
|
160
|
+
command_spec_sha256: spec.sha256,
|
|
161
|
+
});
|
|
162
|
+
await verifyAdmission(context, qualification, identity, capsule, options.commandSpec);
|
|
163
|
+
const content = bytes(capsule);
|
|
164
|
+
const relative = `evidence/executions/${digest(content)}.json`;
|
|
165
|
+
writeFoundryArtifact(context, relative, content);
|
|
166
|
+
return Object.freeze({
|
|
167
|
+
capsule,
|
|
168
|
+
capsule_file: path.join(context.taskRoot, relative),
|
|
169
|
+
capsule_sha256: digest(content),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
export async function rehydrateFoundryExecutionAdmission(context, qualification, identity, options) {
|
|
173
|
+
assertFoundryWorkspaceActive(context);
|
|
174
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
175
|
+
assertVerifiedFoundryIdentity(context, identity, qualification);
|
|
176
|
+
const root = context.taskRoot;
|
|
177
|
+
if (!root)
|
|
178
|
+
fail("task_context_required", "Execution admission requires one task context.");
|
|
179
|
+
let file;
|
|
180
|
+
try {
|
|
181
|
+
file = fs.realpathSync(options.capsuleFile);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
fail("execution_capsule_invalid", "Execution capsule must be a current regular file.");
|
|
185
|
+
}
|
|
186
|
+
const executionRoot = path.join(root, "evidence", "executions");
|
|
187
|
+
const relative = path.relative(executionRoot, file);
|
|
188
|
+
if (path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`))
|
|
189
|
+
fail("execution_capsule_outside_task", "Execution capsule must remain in its task execution-evidence root.");
|
|
190
|
+
const fact = captureFoundryInput(file);
|
|
191
|
+
if (fact.bytes > 1024 * 1024)
|
|
192
|
+
fail("execution_capsule_invalid", "Execution capsule exceeds its byte limit.");
|
|
193
|
+
const content = fs.readFileSync(file);
|
|
194
|
+
if (content.length !== fact.bytes ||
|
|
195
|
+
digest(content) !== fact.sha256 ||
|
|
196
|
+
path.basename(file) !== `${fact.sha256}.json`)
|
|
197
|
+
fail("execution_capsule_changed", "Execution capsule bytes or content address changed.");
|
|
198
|
+
let parsed;
|
|
199
|
+
try {
|
|
200
|
+
parsed = JSON.parse(content.toString("utf8"));
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
fail("execution_capsule_invalid", "Execution capsule is not complete JSON.");
|
|
204
|
+
}
|
|
205
|
+
const capsule = parseCapsule(parsed);
|
|
206
|
+
const verified = await verifyAdmission(context, qualification, identity, capsule, options.commandSpec);
|
|
207
|
+
const admission = Object.freeze({
|
|
208
|
+
capsule,
|
|
209
|
+
capsule_file: file,
|
|
210
|
+
command_spec: verified.spec,
|
|
211
|
+
authorization: verified.authorization,
|
|
212
|
+
});
|
|
213
|
+
admissions.add(admission);
|
|
214
|
+
return admission;
|
|
215
|
+
}
|
|
216
|
+
/** Re-run every external fact immediately before handing the spec to the existing no-replay owner. */
|
|
217
|
+
export async function assertFoundryExecutionAdmission(context, qualification, identity, admission) {
|
|
218
|
+
if (!admission || !admissions.has(admission))
|
|
219
|
+
fail("execution_admission_unverified", "Serialized execution admission cannot authorize a child process.");
|
|
220
|
+
const verified = await rehydrateFoundryExecutionAdmission(context, qualification, identity, {
|
|
221
|
+
capsuleFile: admission.capsule_file,
|
|
222
|
+
commandSpec: admission.command_spec,
|
|
223
|
+
});
|
|
224
|
+
return verified.command_spec;
|
|
225
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ExecutionAttemptState = {
|
|
2
|
+
dispatch_state?: string;
|
|
3
|
+
readback_state?: string;
|
|
4
|
+
};
|
|
5
|
+
export type ExecutionAttemptDisposition = {
|
|
6
|
+
disposition: "UNATTEMPTED" | "SUCCEEDED_EXACT_READBACK" | "SUCCEEDED_RECOVERED_EXACT_READBACK" | "UNKNOWN_DO_NOT_REPLAY";
|
|
7
|
+
attempt_consumed: boolean;
|
|
8
|
+
replay_allowed: boolean;
|
|
9
|
+
terminal: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function modelExecutionAttemptDisposition(state: ExecutionAttemptState): ExecutionAttemptDisposition;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ATTEMPT_DISPATCH_STATES = new Set([
|
|
2
|
+
"NOT_DISPATCHED",
|
|
3
|
+
"DISPATCH_CONFIRMED",
|
|
4
|
+
"DISPATCH_UNKNOWN",
|
|
5
|
+
]);
|
|
6
|
+
export function modelExecutionAttemptDisposition(state) {
|
|
7
|
+
const dispatchState = state?.dispatch_state;
|
|
8
|
+
const desiredExact = state?.readback_state === "EXACT_DESIRED";
|
|
9
|
+
if (dispatchState === "NOT_DISPATCHED") {
|
|
10
|
+
return {
|
|
11
|
+
disposition: "UNATTEMPTED",
|
|
12
|
+
attempt_consumed: false,
|
|
13
|
+
replay_allowed: true,
|
|
14
|
+
terminal: false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (ATTEMPT_DISPATCH_STATES.has(dispatchState ?? "") && desiredExact) {
|
|
18
|
+
return {
|
|
19
|
+
disposition: dispatchState === "DISPATCH_UNKNOWN"
|
|
20
|
+
? "SUCCEEDED_RECOVERED_EXACT_READBACK"
|
|
21
|
+
: "SUCCEEDED_EXACT_READBACK",
|
|
22
|
+
attempt_consumed: true,
|
|
23
|
+
replay_allowed: false,
|
|
24
|
+
terminal: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
disposition: "UNKNOWN_DO_NOT_REPLAY",
|
|
29
|
+
attempt_consumed: dispatchState !== "NOT_DISPATCHED",
|
|
30
|
+
replay_allowed: false,
|
|
31
|
+
terminal: false,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FoundryInputFact } from "./foundry-runtime-context-types.ts";
|
|
2
|
+
import { type TaskAuthorizationAction } from "./task-authorization.ts";
|
|
3
|
+
export declare const FOUNDRY_EXECUTION_CAPSULE_SCHEMA: "tiangong-foundry.execution-context.v1";
|
|
4
|
+
export interface ExecutionCapsule {
|
|
5
|
+
schema: typeof FOUNDRY_EXECUTION_CAPSULE_SCHEMA;
|
|
6
|
+
workspace_id: string;
|
|
7
|
+
task_id: string;
|
|
8
|
+
actor_id: string;
|
|
9
|
+
command: string;
|
|
10
|
+
qualification_sha256: string;
|
|
11
|
+
authorization_sha256: string;
|
|
12
|
+
approved_input: FoundryInputFact;
|
|
13
|
+
final_rows: FoundryInputFact;
|
|
14
|
+
required_actions: TaskAuthorizationAction[];
|
|
15
|
+
required_qa_waivers: string[];
|
|
16
|
+
command_spec_sha256: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseCapsule(value: unknown): Readonly<ExecutionCapsule>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { exact, object, shaPattern } from "./foundry-task-io.js";
|
|
3
|
+
import { FoundryContextError } from "./foundry-runtime-error.js";
|
|
4
|
+
import { taskAuthorizationActions } from "./task-authorization.js";
|
|
5
|
+
function fail(code, message) {
|
|
6
|
+
throw new FoundryContextError(code, message);
|
|
7
|
+
}
|
|
8
|
+
const qaWaiverCode = "process_material_balance_deviation";
|
|
9
|
+
export const FOUNDRY_EXECUTION_CAPSULE_SCHEMA = "tiangong-foundry.execution-context.v1";
|
|
10
|
+
function requiredQa(value) {
|
|
11
|
+
if (value.length > 1 ||
|
|
12
|
+
new Set(value).size !== value.length ||
|
|
13
|
+
value.some((code) => code !== qaWaiverCode))
|
|
14
|
+
fail("execution_qa_waiver_invalid", "Only the evidence-bound process material-balance waiver can enter execution admission.");
|
|
15
|
+
return Object.freeze([...value]);
|
|
16
|
+
}
|
|
17
|
+
function requiredActions(value) {
|
|
18
|
+
if (value.length > taskAuthorizationActions.length ||
|
|
19
|
+
new Set(value).size !== value.length ||
|
|
20
|
+
value.some((action) => typeof action !== "string" ||
|
|
21
|
+
!taskAuthorizationActions.includes(action)) ||
|
|
22
|
+
[...value].sort().some((action, index) => action !== value[index]))
|
|
23
|
+
fail("execution_action_invalid", "Execution actions must be a unique, sorted subset of the task authorization contract.");
|
|
24
|
+
return Object.freeze([...value]);
|
|
25
|
+
}
|
|
26
|
+
function parseFact(value, label) {
|
|
27
|
+
const fact = object(value);
|
|
28
|
+
exact(fact, ["path", "bytes", "sha256"]);
|
|
29
|
+
if (typeof fact.path !== "string" ||
|
|
30
|
+
!path.isAbsolute(fact.path) ||
|
|
31
|
+
typeof fact.bytes !== "number" ||
|
|
32
|
+
!Number.isSafeInteger(fact.bytes) ||
|
|
33
|
+
fact.bytes < 0 ||
|
|
34
|
+
typeof fact.sha256 !== "string" ||
|
|
35
|
+
!shaPattern.test(fact.sha256))
|
|
36
|
+
fail("execution_capsule_invalid", `${label} content fact is malformed.`);
|
|
37
|
+
return Object.freeze({ path: fact.path, bytes: fact.bytes, sha256: fact.sha256 });
|
|
38
|
+
}
|
|
39
|
+
export function parseCapsule(value) {
|
|
40
|
+
const item = object(value);
|
|
41
|
+
exact(item, [
|
|
42
|
+
"schema",
|
|
43
|
+
"workspace_id",
|
|
44
|
+
"task_id",
|
|
45
|
+
"actor_id",
|
|
46
|
+
"command",
|
|
47
|
+
"qualification_sha256",
|
|
48
|
+
"authorization_sha256",
|
|
49
|
+
"approved_input",
|
|
50
|
+
"final_rows",
|
|
51
|
+
"required_actions",
|
|
52
|
+
"required_qa_waivers",
|
|
53
|
+
"command_spec_sha256",
|
|
54
|
+
]);
|
|
55
|
+
if (item.schema !== FOUNDRY_EXECUTION_CAPSULE_SCHEMA ||
|
|
56
|
+
typeof item.workspace_id !== "string" ||
|
|
57
|
+
typeof item.task_id !== "string" ||
|
|
58
|
+
typeof item.actor_id !== "string" ||
|
|
59
|
+
typeof item.command !== "string" ||
|
|
60
|
+
typeof item.qualification_sha256 !== "string" ||
|
|
61
|
+
!shaPattern.test(item.qualification_sha256) ||
|
|
62
|
+
typeof item.authorization_sha256 !== "string" ||
|
|
63
|
+
!shaPattern.test(item.authorization_sha256) ||
|
|
64
|
+
!Array.isArray(item.required_actions) ||
|
|
65
|
+
typeof item.command_spec_sha256 !== "string" ||
|
|
66
|
+
!shaPattern.test(item.command_spec_sha256) ||
|
|
67
|
+
!Array.isArray(item.required_qa_waivers))
|
|
68
|
+
fail("execution_capsule_invalid", "Execution capsule has an unsupported shape.");
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
schema: FOUNDRY_EXECUTION_CAPSULE_SCHEMA,
|
|
71
|
+
workspace_id: item.workspace_id,
|
|
72
|
+
task_id: item.task_id,
|
|
73
|
+
actor_id: item.actor_id,
|
|
74
|
+
command: item.command,
|
|
75
|
+
qualification_sha256: item.qualification_sha256,
|
|
76
|
+
authorization_sha256: item.authorization_sha256,
|
|
77
|
+
approved_input: parseFact(item.approved_input, "Approved input"),
|
|
78
|
+
final_rows: parseFact(item.final_rows, "Final rows"),
|
|
79
|
+
required_actions: [...requiredActions(item.required_actions)],
|
|
80
|
+
required_qa_waivers: [...requiredQa(item.required_qa_waivers)],
|
|
81
|
+
command_spec_sha256: item.command_spec_sha256,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type FoundryInputFact, type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import { type FoundryTaskStartSpec } from "./foundry-task-start-spec.ts";
|
|
3
|
+
export declare const FOUNDRY_FACADE_REQUEST_INDEX_SCHEMA: "tiangong-foundry.facade-request-index.v1";
|
|
4
|
+
export declare const FOUNDRY_FACADE_TASK_POINTER_SCHEMA: "tiangong-foundry.facade-task-pointer.v1";
|
|
5
|
+
export interface FoundryFacadeTaskRecord {
|
|
6
|
+
readonly request_sha256: string;
|
|
7
|
+
readonly revision: number;
|
|
8
|
+
readonly task_id: string;
|
|
9
|
+
readonly predecessor_task_id: string | null;
|
|
10
|
+
readonly fingerprint_sha256: string;
|
|
11
|
+
readonly spec_source: Readonly<FoundryInputFact>;
|
|
12
|
+
readonly spec: FoundryTaskStartSpec;
|
|
13
|
+
readonly inputs: readonly Readonly<FoundryInputFact>[];
|
|
14
|
+
readonly created_at_utc: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function registerFoundryFacadeTask(context: FoundryRuntimeContext, options: {
|
|
17
|
+
specSource: FoundryInputFact;
|
|
18
|
+
spec: FoundryTaskStartSpec;
|
|
19
|
+
inputs: readonly FoundryInputFact[];
|
|
20
|
+
createOrLoad: (taskId: string) => {
|
|
21
|
+
created_at_utc: string;
|
|
22
|
+
inputs_sha256: string;
|
|
23
|
+
};
|
|
24
|
+
}): Promise<FoundryFacadeTaskRecord>;
|
|
25
|
+
export declare function loadFoundryFacadeTaskRecord(context: FoundryRuntimeContext, taskId: string, actorId: string): FoundryFacadeTaskRecord;
|