@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,424 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { transferRead } from "./lib/foundry-migration-transfer-io.js";
|
|
4
|
+
import { migrationCredentialPath } from "./lib/foundry-migration-inventory.js";
|
|
5
|
+
import { createFoundryFacade } from "./foundry-facade.js";
|
|
6
|
+
import { createFoundryRuntime } from "./foundry-runtime.js";
|
|
7
|
+
import { parseArgs } from "./lib/foundry-args.js";
|
|
8
|
+
import { assertFoundryCacheRootSeparated } from "./lib/foundry-runtime-cache.js";
|
|
9
|
+
import { captureFoundryInput, createFoundryRuntimeContext, FoundryContextError, } from "./lib/foundry-runtime-context.js";
|
|
10
|
+
import { exitCodeForCommand } from "./lib/foundry-command-registry.js";
|
|
11
|
+
import { createFoundryOperationResult, exitCodeForFoundryOperationResult, } from "./lib/foundry-operation-result.js";
|
|
12
|
+
function option(value, name) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
if (typeof value !== "string" || !value.trim())
|
|
16
|
+
throw new FoundryContextError("argument_invalid", `${name} requires one nonempty value.`);
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function doctorAccountIntent(args) {
|
|
20
|
+
const projectRef = option(args.expectedProjectRef, "--expected-project-ref");
|
|
21
|
+
const userId = option(args.expectedUserId, "--expected-user-id");
|
|
22
|
+
const sessionReference = option(args.sessionReference, "--session-reference");
|
|
23
|
+
if (!projectRef && !userId && !sessionReference)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (!projectRef || !userId)
|
|
26
|
+
throw new FoundryContextError("argument_account_intent_incomplete", "Account diagnostics require both expected project and user identifiers.");
|
|
27
|
+
return { projectRef, userId, ...(sessionReference ? { sessionReference } : {}) };
|
|
28
|
+
}
|
|
29
|
+
function publicCommand(argv) {
|
|
30
|
+
const [group, action, ...rest] = argv.slice(2);
|
|
31
|
+
if (group === "doctor")
|
|
32
|
+
return { operation: "doctor", args: parseArgs([action, ...rest].filter(Boolean)) };
|
|
33
|
+
if (group === "workspace" && action === "init")
|
|
34
|
+
return { operation: "workspace.init", args: parseArgs(rest) };
|
|
35
|
+
if (group === "workspace" && action === "migrate")
|
|
36
|
+
return { operation: "workspace.migrate", args: parseArgs(rest) };
|
|
37
|
+
if (group === "task" && ["start", "status", "resume"].includes(action))
|
|
38
|
+
return { operation: `task.${action}`, args: parseArgs(rest) };
|
|
39
|
+
if (group === "workspace" || group === "task")
|
|
40
|
+
return { operation: "unknown", args: parseArgs([action, ...rest].filter(Boolean)) };
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function invalidResult(operation, taskId, code, message) {
|
|
44
|
+
return createFoundryOperationResult({
|
|
45
|
+
operation,
|
|
46
|
+
status: "needs_input",
|
|
47
|
+
taskId,
|
|
48
|
+
artifacts: [],
|
|
49
|
+
blockers: [{ code, message, scope: taskId }],
|
|
50
|
+
nextActions: [],
|
|
51
|
+
runtimeIdentity: null,
|
|
52
|
+
permissions: { state: "not_required", requested_actions: [], approval_reference: null },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function interruptedResult(operation, taskId) {
|
|
56
|
+
return createFoundryOperationResult({
|
|
57
|
+
operation,
|
|
58
|
+
status: "failed",
|
|
59
|
+
taskId,
|
|
60
|
+
artifacts: [],
|
|
61
|
+
blockers: [
|
|
62
|
+
{
|
|
63
|
+
code: "operation_interrupted",
|
|
64
|
+
message: "Operation was interrupted; retained evidence must be inspected before resume.",
|
|
65
|
+
scope: taskId,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
nextActions: [],
|
|
69
|
+
runtimeIdentity: null,
|
|
70
|
+
permissions: { state: "not_required", requested_actions: [], approval_reference: null },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function failedResult(operation, taskId, code, message, status = "failed") {
|
|
74
|
+
return createFoundryOperationResult({
|
|
75
|
+
operation,
|
|
76
|
+
status,
|
|
77
|
+
taskId,
|
|
78
|
+
artifacts: [],
|
|
79
|
+
blockers: [{ code, message, scope: taskId }],
|
|
80
|
+
nextActions: [],
|
|
81
|
+
runtimeIdentity: null,
|
|
82
|
+
permissions: { state: "not_required", requested_actions: [], approval_reference: null },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function runPublicCommand(parsed, host) {
|
|
86
|
+
const taskId = option(parsed.args.task, "--task") ?? null;
|
|
87
|
+
if (host.signal?.aborted)
|
|
88
|
+
return interruptedResult(parsed.operation, taskId);
|
|
89
|
+
if (parsed.args.json !== true)
|
|
90
|
+
return invalidResult(parsed.operation, taskId, "argument_json_required", "Public Foundry operations require --json.");
|
|
91
|
+
if (parsed.operation === "unknown")
|
|
92
|
+
return invalidResult(parsed.operation, taskId, "unknown_public_operation", "Unknown Foundry workspace or task operation.");
|
|
93
|
+
if (parsed.args._.length)
|
|
94
|
+
return invalidResult(parsed.operation, taskId, "argument_positional_unsupported", "Public Foundry operations do not accept extra positional arguments.");
|
|
95
|
+
const allowed = new Set([
|
|
96
|
+
"_",
|
|
97
|
+
"json",
|
|
98
|
+
"workspace",
|
|
99
|
+
...(parsed.operation === "doctor"
|
|
100
|
+
? ["expectedProjectRef", "expectedUserId", "sessionReference"]
|
|
101
|
+
: parsed.operation === "workspace.migrate"
|
|
102
|
+
? [
|
|
103
|
+
"dryRun",
|
|
104
|
+
"to",
|
|
105
|
+
"actor",
|
|
106
|
+
"request",
|
|
107
|
+
"stageManifest",
|
|
108
|
+
"input",
|
|
109
|
+
"stage",
|
|
110
|
+
"audit",
|
|
111
|
+
"plan",
|
|
112
|
+
"adoptionDryRun",
|
|
113
|
+
"apply",
|
|
114
|
+
"adoptionPlan",
|
|
115
|
+
"taskSpec",
|
|
116
|
+
"runtimeUse",
|
|
117
|
+
"access",
|
|
118
|
+
]
|
|
119
|
+
: parsed.operation === "task.start"
|
|
120
|
+
? ["spec"]
|
|
121
|
+
: parsed.operation === "task.resume"
|
|
122
|
+
? ["task", "actor", "semanticInput", "authorizationInput"]
|
|
123
|
+
: parsed.operation === "task.status"
|
|
124
|
+
? ["task", "actor"]
|
|
125
|
+
: []),
|
|
126
|
+
]);
|
|
127
|
+
const unknownOption = Object.keys(parsed.args).find((key) => !allowed.has(key));
|
|
128
|
+
if (unknownOption)
|
|
129
|
+
return invalidResult(parsed.operation, taskId, "argument_option_unsupported", `Public Foundry operation does not accept --${unknownOption}.`);
|
|
130
|
+
const workspace = option(parsed.args.workspace, "--workspace");
|
|
131
|
+
if (!workspace)
|
|
132
|
+
return invalidResult(parsed.operation, taskId, "argument_workspace_required", "Public Foundry operations require an explicit --workspace.");
|
|
133
|
+
if (host.runtimeManager?.cacheDir !== undefined)
|
|
134
|
+
assertFoundryCacheRootSeparated(host.runtimeManager.cacheDir, path.resolve(workspace));
|
|
135
|
+
const facade = createFoundryFacade({
|
|
136
|
+
moduleUrl: import.meta.url,
|
|
137
|
+
workspace,
|
|
138
|
+
cacheBase: host.cacheBase,
|
|
139
|
+
runtimeSelection: host.runtimeSelection,
|
|
140
|
+
authentication: host.authentication,
|
|
141
|
+
workspaceAccess: host.workspaceAccess,
|
|
142
|
+
runtimeManager: host.runtimeManager,
|
|
143
|
+
accountIntent: parsed.operation === "doctor"
|
|
144
|
+
? (doctorAccountIntent(parsed.args) ?? host.accountIntent)
|
|
145
|
+
: host.accountIntent,
|
|
146
|
+
signal: host.signal,
|
|
147
|
+
});
|
|
148
|
+
let result;
|
|
149
|
+
if (parsed.operation === "workspace.init")
|
|
150
|
+
result = facade.initialize();
|
|
151
|
+
else if (parsed.operation === "doctor")
|
|
152
|
+
result = facade.doctor();
|
|
153
|
+
else if (parsed.operation === "workspace.migrate") {
|
|
154
|
+
if (parsed.args.runtimeUse === true) {
|
|
155
|
+
const permitted = new Set([
|
|
156
|
+
"_",
|
|
157
|
+
"json",
|
|
158
|
+
"workspace",
|
|
159
|
+
"runtimeUse",
|
|
160
|
+
"access",
|
|
161
|
+
"actor",
|
|
162
|
+
"request",
|
|
163
|
+
]);
|
|
164
|
+
if (Object.keys(parsed.args).some((key) => !permitted.has(key)))
|
|
165
|
+
return invalidResult(parsed.operation, null, "argument_runtime_selection_invalid", "Runtime selection cannot be combined with migration file operations.");
|
|
166
|
+
const actorId = option(parsed.args.actor, "--actor"), requestId = option(parsed.args.request, "--request"), access = option(parsed.args.access, "--access") ?? "read";
|
|
167
|
+
if (!actorId || !requestId || !["read", "write"].includes(access) || !host.runtimeTarget)
|
|
168
|
+
return invalidResult(parsed.operation, null, "argument_runtime_selection_required", "Runtime selection requires actor/request intent and an independently trusted target manifest from the host.");
|
|
169
|
+
return facade.runtimeUse({
|
|
170
|
+
manifest: host.runtimeTarget,
|
|
171
|
+
actorId,
|
|
172
|
+
requestId,
|
|
173
|
+
access: access,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (parsed.args.access !== undefined)
|
|
177
|
+
return invalidResult(parsed.operation, null, "argument_runtime_selection_invalid", "Access mode belongs to explicit runtime selection.");
|
|
178
|
+
if ([
|
|
179
|
+
parsed.args.dryRun,
|
|
180
|
+
parsed.args.stage,
|
|
181
|
+
parsed.args.audit,
|
|
182
|
+
parsed.args.adoptionDryRun,
|
|
183
|
+
parsed.args.apply,
|
|
184
|
+
].filter((value) => value === true).length !== 1)
|
|
185
|
+
return invalidResult(parsed.operation, null, "argument_dry_run_required", "Select exactly one migration mode: --dry-run, --stage, --adoption-dry-run, --apply or --audit.");
|
|
186
|
+
const destination = option(parsed.args.to, "--to");
|
|
187
|
+
const actorId = option(parsed.args.actor, "--actor");
|
|
188
|
+
const requestId = option(parsed.args.request, "--request");
|
|
189
|
+
const stageValue = parsed.args.stageManifest;
|
|
190
|
+
const inputValue = parsed.args.input;
|
|
191
|
+
const externalInputs = inputValue === undefined
|
|
192
|
+
? []
|
|
193
|
+
: (Array.isArray(inputValue) ? inputValue : [inputValue]).map((value) => path.resolve(option(value, "--input")));
|
|
194
|
+
const stageManifests = stageValue === undefined
|
|
195
|
+
? []
|
|
196
|
+
: (Array.isArray(stageValue) ? stageValue : [stageValue]).map((value) => option(value, "--stage-manifest"));
|
|
197
|
+
if ((destination && (!actorId || !requestId)) ||
|
|
198
|
+
(!destination &&
|
|
199
|
+
(actorId ||
|
|
200
|
+
requestId ||
|
|
201
|
+
stageManifests.length ||
|
|
202
|
+
externalInputs.length ||
|
|
203
|
+
parsed.args.stage ||
|
|
204
|
+
parsed.args.audit ||
|
|
205
|
+
parsed.args.plan ||
|
|
206
|
+
parsed.args.adoptionDryRun ||
|
|
207
|
+
parsed.args.apply ||
|
|
208
|
+
parsed.args.adoptionPlan ||
|
|
209
|
+
parsed.args.taskSpec)))
|
|
210
|
+
return invalidResult(parsed.operation, null, "argument_migration_intent_required", "Transfer planning requires --to, --actor and --request together.");
|
|
211
|
+
if (parsed.args.stage === true ||
|
|
212
|
+
parsed.args.audit === true ||
|
|
213
|
+
parsed.args.adoptionDryRun === true ||
|
|
214
|
+
parsed.args.apply === true) {
|
|
215
|
+
const planFile = option(parsed.args.plan, "--plan");
|
|
216
|
+
if (!planFile || !destination || !actorId || !requestId)
|
|
217
|
+
return invalidResult(parsed.operation, null, "argument_migration_plan_required", "Staging and audit require a saved --plan and explicit transfer intent.");
|
|
218
|
+
if (migrationCredentialPath(planFile))
|
|
219
|
+
return invalidResult(parsed.operation, null, "argument_migration_plan_invalid", "A private file cannot be used as a migration plan.");
|
|
220
|
+
const plan = JSON.parse(transferRead(path.resolve(planFile), 8 * 1024 * 1024).toString("utf8"));
|
|
221
|
+
if (parsed.args.adoptionDryRun === true || parsed.args.apply === true) {
|
|
222
|
+
const raw = parsed.args.taskSpec;
|
|
223
|
+
const tasks = (raw === undefined ? [] : Array.isArray(raw) ? raw : [raw]).map((value) => {
|
|
224
|
+
const selected = option(value, "--task-spec");
|
|
225
|
+
const separator = selected.indexOf("=");
|
|
226
|
+
if (separator < 1 || separator === selected.length - 1)
|
|
227
|
+
throw new FoundryContextError("argument_task_spec_invalid", "Select --task-spec source-task=absolute-spec-file.");
|
|
228
|
+
return {
|
|
229
|
+
sourceTask: selected.slice(0, separator),
|
|
230
|
+
specFile: path.resolve(selected.slice(separator + 1)),
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
const adoptionFile = option(parsed.args.adoptionPlan, "--adoption-plan");
|
|
234
|
+
if ((parsed.args.apply === true && !adoptionFile) ||
|
|
235
|
+
(parsed.args.adoptionDryRun === true && adoptionFile))
|
|
236
|
+
throw new FoundryContextError("argument_adoption_plan_required", "Apply requires a saved adoption plan; adoption dry-run reconstructs it.");
|
|
237
|
+
if (adoptionFile && migrationCredentialPath(adoptionFile))
|
|
238
|
+
throw new FoundryContextError("argument_migration_plan_invalid", "Private storage cannot be used as an adoption plan.");
|
|
239
|
+
const adoptionPlan = adoptionFile
|
|
240
|
+
? JSON.parse(transferRead(path.resolve(adoptionFile), 8 * 1024 * 1024).toString("utf8"))
|
|
241
|
+
: undefined;
|
|
242
|
+
result = await facade.migrationAdoption({
|
|
243
|
+
destination,
|
|
244
|
+
actorId,
|
|
245
|
+
requestId,
|
|
246
|
+
stageManifests,
|
|
247
|
+
externalInputs,
|
|
248
|
+
plan,
|
|
249
|
+
tasks,
|
|
250
|
+
adoptionPlan,
|
|
251
|
+
apply: parsed.args.apply === true,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
if (parsed.args.taskSpec !== undefined || parsed.args.adoptionPlan !== undefined)
|
|
256
|
+
throw new FoundryContextError("argument_migration_plan_invalid", "Task specifications belong to explicit adoption preview/application.");
|
|
257
|
+
result = await facade.migrationTransfer({
|
|
258
|
+
destination,
|
|
259
|
+
actorId,
|
|
260
|
+
requestId,
|
|
261
|
+
stageManifests,
|
|
262
|
+
externalInputs,
|
|
263
|
+
plan,
|
|
264
|
+
audit: parsed.args.audit === true,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
if (parsed.args.plan !== undefined ||
|
|
270
|
+
parsed.args.taskSpec !== undefined ||
|
|
271
|
+
parsed.args.adoptionPlan !== undefined)
|
|
272
|
+
return invalidResult(parsed.operation, null, "argument_migration_plan_invalid", "Dry-run reconstructs a new plan; saved plans are used by stage or audit.");
|
|
273
|
+
result = facade.migrationDryRun(destination
|
|
274
|
+
? {
|
|
275
|
+
destination,
|
|
276
|
+
actorId: actorId,
|
|
277
|
+
requestId: requestId,
|
|
278
|
+
stageManifests,
|
|
279
|
+
externalInputs,
|
|
280
|
+
}
|
|
281
|
+
: undefined);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else if (parsed.operation === "task.start") {
|
|
285
|
+
const specFile = option(parsed.args.spec, "--spec");
|
|
286
|
+
if (!specFile)
|
|
287
|
+
return invalidResult(parsed.operation, null, "argument_spec_required", "Task start requires one explicit --spec file.");
|
|
288
|
+
result = await facade.start({ specFile });
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const actorId = option(parsed.args.actor, "--actor");
|
|
292
|
+
if (!taskId || !actorId)
|
|
293
|
+
return invalidResult(parsed.operation, taskId, "argument_task_actor_required", "Task status and resume require exact --task and --actor values.");
|
|
294
|
+
result =
|
|
295
|
+
parsed.operation === "task.status"
|
|
296
|
+
? await facade.status({ taskId, actorId })
|
|
297
|
+
: await facade.resume({
|
|
298
|
+
taskId,
|
|
299
|
+
actorId,
|
|
300
|
+
semanticInputFile: option(parsed.args.semanticInput, "--semantic-input") ?? undefined,
|
|
301
|
+
authorizationInputFile: option(parsed.args.authorizationInput, "--authorization-input") ?? undefined,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
async function runLegacyWorkspaceRuntimeCommand(argv) {
|
|
307
|
+
try {
|
|
308
|
+
const [command = "help", ...rest] = argv.slice(2);
|
|
309
|
+
if (!["init", "profiles-list", "dataset-curation-cleanup"].includes(command)) {
|
|
310
|
+
throw new FoundryContextError("runtime_command_unavailable", "This command has not been admitted to the explicit workspace runtime.");
|
|
311
|
+
}
|
|
312
|
+
const args = parseArgs(rest);
|
|
313
|
+
const workspace = option(args.workspace, "--workspace");
|
|
314
|
+
const input = command === "dataset-curation-cleanup"
|
|
315
|
+
? option(args.rowsFile ?? args.input, "--rows-file")
|
|
316
|
+
: undefined;
|
|
317
|
+
const sourceInput = command === "dataset-curation-cleanup"
|
|
318
|
+
? option(args.sourceRowsFile, "--source-rows-file")
|
|
319
|
+
: undefined;
|
|
320
|
+
const contextOptions = {
|
|
321
|
+
moduleUrl: import.meta.url,
|
|
322
|
+
workspace,
|
|
323
|
+
taskId: option(args.taskId, "--task-id"),
|
|
324
|
+
actorId: option(args.actorId, "--actor-id"),
|
|
325
|
+
};
|
|
326
|
+
const initial = createFoundryRuntimeContext(contextOptions);
|
|
327
|
+
const inputs = [input, sourceInput]
|
|
328
|
+
.filter((value) => Boolean(value))
|
|
329
|
+
.map((file) => captureFoundryInput(path.resolve(initial.workspaceRoot, file)));
|
|
330
|
+
const context = inputs.length
|
|
331
|
+
? createFoundryRuntimeContext({ ...contextOptions, workspace: initial.workspaceRoot, inputs })
|
|
332
|
+
: initial;
|
|
333
|
+
const runtime = createFoundryRuntime(context);
|
|
334
|
+
const result = command === "init"
|
|
335
|
+
? runtime.initializeWorkspace()
|
|
336
|
+
: command === "profiles-list"
|
|
337
|
+
? runtime.profiles()
|
|
338
|
+
: await runtime.cleanup({
|
|
339
|
+
input: input ?? "",
|
|
340
|
+
sourceInput,
|
|
341
|
+
type: option(args.type, "--type") ?? "process",
|
|
342
|
+
outputDirectory: option(args.outDir, "--out-dir"),
|
|
343
|
+
profileId: option(args.profile, "--profile"),
|
|
344
|
+
});
|
|
345
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
346
|
+
process.exitCode = exitCodeForCommand(command, {
|
|
347
|
+
status: "status" in result ? String(result.status) : undefined,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
const code = error instanceof FoundryContextError ? error.code : "runtime_operation_failed";
|
|
352
|
+
const message = error instanceof FoundryContextError
|
|
353
|
+
? error.message
|
|
354
|
+
: "Foundry operation failed; preserve the selected input and inspect the local task.";
|
|
355
|
+
process.stdout.write(`${JSON.stringify({ status: "failed", code, message })}\n`);
|
|
356
|
+
process.exitCode = 1;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
export async function runFoundryRuntimeCommand(argv = process.argv, host = {}, prepareHost) {
|
|
360
|
+
const controller = host.signal ? null : new AbortController();
|
|
361
|
+
const abort = () => controller?.abort("host-signal");
|
|
362
|
+
if (controller) {
|
|
363
|
+
process.once("SIGINT", abort);
|
|
364
|
+
process.once("SIGTERM", abort);
|
|
365
|
+
}
|
|
366
|
+
const effectiveHost = {
|
|
367
|
+
...host,
|
|
368
|
+
signal: host.signal ?? controller?.signal,
|
|
369
|
+
};
|
|
370
|
+
const parsed = publicCommand(argv);
|
|
371
|
+
if (!parsed) {
|
|
372
|
+
if (controller) {
|
|
373
|
+
process.removeListener("SIGINT", abort);
|
|
374
|
+
process.removeListener("SIGTERM", abort);
|
|
375
|
+
}
|
|
376
|
+
return runLegacyWorkspaceRuntimeCommand(argv);
|
|
377
|
+
}
|
|
378
|
+
const writeStdout = host.writeStdout ?? ((text) => process.stdout.write(text));
|
|
379
|
+
const setExitCode = host.setExitCode ?? ((code) => (process.exitCode = code));
|
|
380
|
+
let result;
|
|
381
|
+
try {
|
|
382
|
+
const prepared = prepareHost && !effectiveHost.signal?.aborted ? await prepareHost(effectiveHost.signal) : {};
|
|
383
|
+
result = await runPublicCommand(parsed, {
|
|
384
|
+
...effectiveHost,
|
|
385
|
+
...prepared,
|
|
386
|
+
signal: effectiveHost.signal,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
result = effectiveHost.signal?.aborted
|
|
391
|
+
? interruptedResult(parsed.operation, null)
|
|
392
|
+
: error instanceof FoundryContextError && error.code.startsWith("argument_")
|
|
393
|
+
? invalidResult(parsed.operation, null, error.code, error.message)
|
|
394
|
+
: failedResult(parsed.operation, null, error instanceof FoundryContextError ? error.code : "runtime_operation_failed", error instanceof FoundryContextError
|
|
395
|
+
? error.message
|
|
396
|
+
: "Foundry public operation failed before changing task state.", error instanceof FoundryContextError && error.code === "managed_runtime_unsupported"
|
|
397
|
+
? "blocked"
|
|
398
|
+
: "failed");
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
writeStdout(`${JSON.stringify(result)}\n`);
|
|
402
|
+
setExitCode(exitCodeForFoundryOperationResult(result));
|
|
403
|
+
}
|
|
404
|
+
finally {
|
|
405
|
+
if (controller) {
|
|
406
|
+
process.removeListener("SIGINT", abort);
|
|
407
|
+
process.removeListener("SIGTERM", abort);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/** Package bin boundary: never fall back to repository/developer commands. */
|
|
412
|
+
export async function runFoundryPublicCommand(argv = process.argv, host = {}, prepareHost) {
|
|
413
|
+
if (publicCommand(argv))
|
|
414
|
+
return runFoundryRuntimeCommand(argv, host, prepareHost);
|
|
415
|
+
return runFoundryRuntimeCommand([
|
|
416
|
+
argv[0] ?? process.execPath,
|
|
417
|
+
argv[1] ?? "tiangong-foundry",
|
|
418
|
+
"task",
|
|
419
|
+
"__unknown",
|
|
420
|
+
...argv.slice(2),
|
|
421
|
+
], host, prepareHost);
|
|
422
|
+
}
|
|
423
|
+
if (import.meta.main)
|
|
424
|
+
void runFoundryRuntimeCommand();
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiangong-lca/foundry",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Control plane for TianGong LCA external dataset import and TIDAS authoring work.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/tiangong-lca/data-foundry.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/tiangong-lca/data-foundry#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/tiangong-lca/data-foundry/issues"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
},
|
|
18
|
+
"types": "./package-dist/scripts/public-api.d.ts",
|
|
19
|
+
"bin": {
|
|
20
|
+
"tiangong-foundry": "./package-dist/scripts/package-entry.js"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./package-dist/scripts/public-api.d.ts",
|
|
25
|
+
"import": "./package-dist/scripts/public-api.js"
|
|
26
|
+
},
|
|
27
|
+
"./runtime": {
|
|
28
|
+
"types": "./package-dist/scripts/public-api.d.ts",
|
|
29
|
+
"import": "./package-dist/scripts/public-api.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"package-dist/",
|
|
34
|
+
"specs/import-profiles.json",
|
|
35
|
+
"specs/prewrite-content-policy.json",
|
|
36
|
+
"specs/canonical-support/flow-properties-unit-groups.json",
|
|
37
|
+
"specs/schemas/authorization-derivation.schema.json",
|
|
38
|
+
"specs/schemas/execution-context.schema.json",
|
|
39
|
+
"specs/schemas/foundry-facade-request-index.schema.json",
|
|
40
|
+
"specs/schemas/foundry-operation-result.schema.json",
|
|
41
|
+
"specs/schemas/foundry-package-descriptor.schema.json",
|
|
42
|
+
"specs/schemas/foundry-task-start.schema.json",
|
|
43
|
+
"specs/schemas/foundry-semantic-input.schema.json",
|
|
44
|
+
"specs/schemas/foundry-authorization-input.schema.json",
|
|
45
|
+
"specs/schemas/foundry-workspace-migration-plan.schema.json",
|
|
46
|
+
"specs/schemas/foundry-workspace-migration-transfer-plan.schema.json",
|
|
47
|
+
"specs/schemas/foundry-migration-transfer-receipt.schema.json",
|
|
48
|
+
"specs/schemas/foundry-workspace-migration-pending.schema.json",
|
|
49
|
+
"specs/schemas/foundry-migration-adoption-plan.schema.json",
|
|
50
|
+
"specs/schemas/foundry-migration-activation.schema.json",
|
|
51
|
+
"specs/schemas/foundry-workspace-v2.schema.json",
|
|
52
|
+
"specs/schemas/foundry-runtime-selection.schema.json",
|
|
53
|
+
"specs/schemas/foundry-managed-runtime.schema.json",
|
|
54
|
+
"specs/schemas/runtime-qualification.schema.json",
|
|
55
|
+
"specs/schemas/task-authorization.schema.json",
|
|
56
|
+
"specs/schemas/tidas-runtime-expectation.schema.json",
|
|
57
|
+
"docs/architecture.md",
|
|
58
|
+
"docs/package-distribution-contract.md",
|
|
59
|
+
"docs/foundry-task-contracts.md",
|
|
60
|
+
"docs/public-runtime-contract.md",
|
|
61
|
+
"docs/runtime-context-contract.md",
|
|
62
|
+
"docs/workspace-migration-contract.md",
|
|
63
|
+
"docs/safety-policy.md",
|
|
64
|
+
"docs/task-authorization-contract.md",
|
|
65
|
+
"docs/import-profiles/bafu/constraints.md",
|
|
66
|
+
"docs/import-profiles/bafu/leaf-process-classification-authoring.md",
|
|
67
|
+
"docs/import-profiles/bafu/profile.md",
|
|
68
|
+
"docs/import-profiles/uslci/constraints.md",
|
|
69
|
+
"docs/import-profiles/uslci/profile.md",
|
|
70
|
+
"docs/uslci-import-runbook.md",
|
|
71
|
+
"docs/import-profiles/worldsteel/constraints.md",
|
|
72
|
+
"docs/import-profiles/worldsteel/import-coverage.md",
|
|
73
|
+
"docs/import-profiles/worldsteel/import-plan.md",
|
|
74
|
+
"docs/import-profiles/worldsteel/profile.md",
|
|
75
|
+
"README.md",
|
|
76
|
+
"LICENSE"
|
|
77
|
+
],
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=24.19.0 <25"
|
|
80
|
+
},
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@tiangong-lca/cli": "0.1.12"
|
|
84
|
+
},
|
|
85
|
+
"foundryRuntime": {
|
|
86
|
+
"schema": "tiangong-foundry.runtime-layout.v2",
|
|
87
|
+
"asset_root": ".",
|
|
88
|
+
"source_entry": "scripts/foundry.ts",
|
|
89
|
+
"emitted_entry": "dist/scripts/foundry.js",
|
|
90
|
+
"package_entry": "package-dist/scripts/package-entry.js",
|
|
91
|
+
"package_descriptor": "package-dist/assets/foundry-package-descriptor.json"
|
|
92
|
+
}
|
|
93
|
+
}
|