@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,90 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
export const runtimeEnvFilePolicyKey = "FOUNDRY_RUNTIME_ENV_FILE_POLICY";
|
|
5
|
+
export const runtimeEnvFilePolicyDisabled = "disabled";
|
|
6
|
+
export function copyFoundryIsolatedExecutable(sourcePath, targetPath) {
|
|
7
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
8
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
9
|
+
fs.chmodSync(targetPath, fs.statSync(sourcePath).mode & 0o777);
|
|
10
|
+
}
|
|
11
|
+
const credentialLikeEnvironmentKey = /(?:^|_)(?:API_?KEY|ACCESS_?KEY|KEY|TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE_?KEY|CREDENTIALS?|COOKIE|SESSION|AUTH)(?:$|_)/iu;
|
|
12
|
+
const allowedOverrideEnvironmentKeys = new Set(["TIANGONG_LCA_CLI_BIN", "TIDAS_BIN"]);
|
|
13
|
+
export function createFoundryIsolatedChildEnvironment({ tempRoot, sourceEnv = process.env, overrides = {}, }) {
|
|
14
|
+
const homeDir = path.join(tempRoot, "home");
|
|
15
|
+
const tempDir = path.join(tempRoot, "tmp");
|
|
16
|
+
const configDir = path.join(tempRoot, "config");
|
|
17
|
+
const cacheDir = path.join(tempRoot, "cache");
|
|
18
|
+
const dataDir = path.join(tempRoot, "data");
|
|
19
|
+
const stateDir = path.join(tempRoot, "state");
|
|
20
|
+
const corepackHome = path.join(tempRoot, "corepack");
|
|
21
|
+
for (const directory of [
|
|
22
|
+
homeDir,
|
|
23
|
+
tempDir,
|
|
24
|
+
configDir,
|
|
25
|
+
cacheDir,
|
|
26
|
+
dataDir,
|
|
27
|
+
stateDir,
|
|
28
|
+
corepackHome,
|
|
29
|
+
]) {
|
|
30
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
const environment = {
|
|
33
|
+
HOME: homeDir,
|
|
34
|
+
USERPROFILE: homeDir,
|
|
35
|
+
TMPDIR: tempDir,
|
|
36
|
+
TEMP: tempDir,
|
|
37
|
+
TMP: tempDir,
|
|
38
|
+
APPDATA: path.join(dataDir, "appdata"),
|
|
39
|
+
LOCALAPPDATA: path.join(dataDir, "local-appdata"),
|
|
40
|
+
XDG_CONFIG_HOME: configDir,
|
|
41
|
+
XDG_CACHE_HOME: cacheDir,
|
|
42
|
+
XDG_DATA_HOME: dataDir,
|
|
43
|
+
XDG_STATE_HOME: stateDir,
|
|
44
|
+
COREPACK_HOME: corepackHome,
|
|
45
|
+
NPM_CONFIG_USERCONFIG: path.join(configDir, "npmrc"),
|
|
46
|
+
NPM_CONFIG_CACHE: path.join(cacheDir, "npm"),
|
|
47
|
+
NPM_CONFIG_UPDATE_NOTIFIER: "false",
|
|
48
|
+
NPM_CONFIG_FUND: "false",
|
|
49
|
+
NPM_CONFIG_AUDIT: "false",
|
|
50
|
+
GIT_CONFIG_GLOBAL: path.join(configDir, "gitconfig"),
|
|
51
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
52
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
53
|
+
CI: "1",
|
|
54
|
+
HUSKY: "0",
|
|
55
|
+
LANG: "C",
|
|
56
|
+
LC_ALL: "C",
|
|
57
|
+
TZ: "UTC",
|
|
58
|
+
NO_COLOR: "1",
|
|
59
|
+
[runtimeEnvFilePolicyKey]: runtimeEnvFilePolicyDisabled,
|
|
60
|
+
};
|
|
61
|
+
for (const key of [
|
|
62
|
+
"PATH",
|
|
63
|
+
"Path",
|
|
64
|
+
"SystemRoot",
|
|
65
|
+
"SYSTEMROOT",
|
|
66
|
+
"WINDIR",
|
|
67
|
+
"windir",
|
|
68
|
+
"ComSpec",
|
|
69
|
+
"COMSPEC",
|
|
70
|
+
"PATHEXT",
|
|
71
|
+
]) {
|
|
72
|
+
const value = sourceEnv[key];
|
|
73
|
+
if (value !== undefined)
|
|
74
|
+
environment[key] = value;
|
|
75
|
+
}
|
|
76
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
77
|
+
if (value === undefined)
|
|
78
|
+
continue;
|
|
79
|
+
if (!allowedOverrideEnvironmentKeys.has(key)) {
|
|
80
|
+
throw new Error(`Refusing non-allowlisted environment override in isolated child: ${key}`);
|
|
81
|
+
}
|
|
82
|
+
environment[key] = value;
|
|
83
|
+
}
|
|
84
|
+
for (const key of Object.keys(environment)) {
|
|
85
|
+
if (credentialLikeEnvironmentKey.test(key)) {
|
|
86
|
+
throw new Error(`Refusing credential-like environment key in isolated child: ${key}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return environment;
|
|
90
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import { type QualifiedFoundryRuntime } from "./foundry-runtime-qualification.ts";
|
|
3
|
+
import { type AuthIdentityReceipt } from "./identity-preflight-proof.ts";
|
|
4
|
+
import { type FoundryAuthentication } from "./foundry-authentication-environment.ts";
|
|
5
|
+
export type { FoundryPublicOAuthConfiguration, FoundryAuthentication, } from "./foundry-authentication-environment.ts";
|
|
6
|
+
export interface VerifiedFoundryIdentity {
|
|
7
|
+
readonly receipt: AuthIdentityReceipt;
|
|
8
|
+
readonly workspaceId: string;
|
|
9
|
+
readonly taskId: string;
|
|
10
|
+
readonly actorId: string;
|
|
11
|
+
readonly runtimeManifestSha256: string;
|
|
12
|
+
readonly runtimeEntrySha256: string;
|
|
13
|
+
readonly runtimeQualificationSha256: string | null;
|
|
14
|
+
readonly mode: "oauth" | "headless";
|
|
15
|
+
}
|
|
16
|
+
/** The owner CLI performs all token/session and server identity work. No auth material is persisted here. */
|
|
17
|
+
export declare function verifyFoundryRuntimeIdentity(context: FoundryRuntimeContext, authentication?: FoundryAuthentication, systemEnvironment?: NodeJS.ProcessEnv, qualification?: QualifiedFoundryRuntime): VerifiedFoundryIdentity;
|
|
18
|
+
export declare function assertVerifiedFoundryIdentity(context: FoundryRuntimeContext, identity: VerifiedFoundryIdentity, qualification?: QualifiedFoundryRuntime): void;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import childProcess, {} from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertFoundryRuntimeContext, FoundryContextError, } from "./foundry-runtime-context.js";
|
|
6
|
+
import { assertQualifiedFoundryRuntime, } from "./foundry-runtime-qualification.js";
|
|
7
|
+
import { resolveInstalledTiangongLcaCliPackage } from "./foundry-runtime-utils.js";
|
|
8
|
+
import { parseFreshIntentBoundAuthReceipt, } from "./identity-preflight-proof.js";
|
|
9
|
+
import { createFoundryAuthenticationEnvironment, } from "./foundry-authentication-environment.js";
|
|
10
|
+
const verifiedIdentities = new WeakSet();
|
|
11
|
+
const maxAgeMs = 60_000;
|
|
12
|
+
function reject(code, message) {
|
|
13
|
+
throw new FoundryContextError(code, message);
|
|
14
|
+
}
|
|
15
|
+
function freezeReceipt(value) {
|
|
16
|
+
if (!value || typeof value !== "object" || Object.isFrozen(value))
|
|
17
|
+
return;
|
|
18
|
+
for (const child of Object.values(value))
|
|
19
|
+
freezeReceipt(child);
|
|
20
|
+
Object.freeze(value);
|
|
21
|
+
}
|
|
22
|
+
/** The owner CLI performs all token/session and server identity work. No auth material is persisted here. */
|
|
23
|
+
export function verifyFoundryRuntimeIdentity(context, authentication = { mode: "oauth" }, systemEnvironment = process.env, qualification) {
|
|
24
|
+
assertFoundryRuntimeContext(context);
|
|
25
|
+
if (qualification)
|
|
26
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
27
|
+
if (!["oauth", "headless"].includes(authentication.mode))
|
|
28
|
+
reject("authentication_mode_invalid", "Select the CLI OAuth or explicit headless mode.");
|
|
29
|
+
const account = context.accountIntent;
|
|
30
|
+
if (!context.workspaceId || !context.taskId || !context.actorId || !account)
|
|
31
|
+
reject("account_intent_required", "Fresh task identity requires explicit workspace, task, actor, project and user intent.");
|
|
32
|
+
const cli = resolveInstalledTiangongLcaCliPackage();
|
|
33
|
+
const environment = createFoundryAuthenticationEnvironment(authentication, account.sessionReference, systemEnvironment);
|
|
34
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "foundry-identity-"));
|
|
35
|
+
fs.chmodSync(cwd, 0o700);
|
|
36
|
+
try {
|
|
37
|
+
let result;
|
|
38
|
+
try {
|
|
39
|
+
result = childProcess.spawnSync(process.execPath, [
|
|
40
|
+
cli.binPath,
|
|
41
|
+
"auth",
|
|
42
|
+
"identity-receipt",
|
|
43
|
+
"--expected-project-ref",
|
|
44
|
+
account.projectRef,
|
|
45
|
+
"--expected-user-id",
|
|
46
|
+
account.userId,
|
|
47
|
+
"--timeout-ms",
|
|
48
|
+
"10000",
|
|
49
|
+
"--json",
|
|
50
|
+
], {
|
|
51
|
+
cwd,
|
|
52
|
+
env: environment,
|
|
53
|
+
shell: false,
|
|
54
|
+
windowsHide: true,
|
|
55
|
+
encoding: "utf8",
|
|
56
|
+
timeout: 20_000,
|
|
57
|
+
maxBuffer: 256 * 1024,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
reject("needs_auth", "The owner CLI identity command could not be started.");
|
|
62
|
+
}
|
|
63
|
+
if (result.error || result.signal || result.status !== 0 || result.stderr !== "")
|
|
64
|
+
reject("needs_auth", "The owner CLI could not verify the intended task account.");
|
|
65
|
+
let receipt;
|
|
66
|
+
try {
|
|
67
|
+
receipt = parseFreshIntentBoundAuthReceipt(JSON.parse(result.stdout), {
|
|
68
|
+
nowMs: Date.now(),
|
|
69
|
+
maxAgeMs,
|
|
70
|
+
expectedProjectRef: account.projectRef,
|
|
71
|
+
expectedUserId: account.userId,
|
|
72
|
+
sessionMode: authentication.mode,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
reject("identity_receipt_invalid", "The owner CLI did not return a current intent-bound identity receipt.");
|
|
77
|
+
}
|
|
78
|
+
if (receipt.cli.package_name !== cli.packageName ||
|
|
79
|
+
receipt.cli.package_version !== cli.packageVersion)
|
|
80
|
+
reject("identity_runtime_mismatch", "Identity receipt does not match the qualified installed CLI.");
|
|
81
|
+
freezeReceipt(receipt);
|
|
82
|
+
const identity = Object.freeze({
|
|
83
|
+
receipt,
|
|
84
|
+
workspaceId: context.workspaceId,
|
|
85
|
+
taskId: context.taskId,
|
|
86
|
+
actorId: context.actorId,
|
|
87
|
+
runtimeManifestSha256: context.runtime.packageManifestSha256,
|
|
88
|
+
runtimeEntrySha256: context.runtime.entrySha256,
|
|
89
|
+
runtimeQualificationSha256: qualification?.qualification_sha256 ?? null,
|
|
90
|
+
mode: authentication.mode,
|
|
91
|
+
});
|
|
92
|
+
verifiedIdentities.add(identity);
|
|
93
|
+
return identity;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
delete environment.TIANGONG_LCA_ACCESS_TOKEN;
|
|
97
|
+
fs.rmSync(cwd, { recursive: true, force: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function assertVerifiedFoundryIdentity(context, identity, qualification) {
|
|
101
|
+
assertFoundryRuntimeContext(context);
|
|
102
|
+
if (qualification)
|
|
103
|
+
assertQualifiedFoundryRuntime(context, qualification);
|
|
104
|
+
if (!identity ||
|
|
105
|
+
!verifiedIdentities.has(identity) ||
|
|
106
|
+
identity.workspaceId !== context.workspaceId ||
|
|
107
|
+
identity.taskId !== context.taskId ||
|
|
108
|
+
identity.actorId !== context.actorId ||
|
|
109
|
+
identity.runtimeManifestSha256 !== context.runtime.packageManifestSha256 ||
|
|
110
|
+
identity.runtimeEntrySha256 !== context.runtime.entrySha256 ||
|
|
111
|
+
(qualification !== undefined &&
|
|
112
|
+
identity.runtimeQualificationSha256 !== qualification.qualification_sha256) ||
|
|
113
|
+
!context.accountIntent)
|
|
114
|
+
reject("identity_context_mismatch", "Identity proof is not bound to the current task context.");
|
|
115
|
+
try {
|
|
116
|
+
parseFreshIntentBoundAuthReceipt(identity.receipt, {
|
|
117
|
+
nowMs: Date.now(),
|
|
118
|
+
maxAgeMs,
|
|
119
|
+
expectedProjectRef: context.accountIntent.projectRef,
|
|
120
|
+
expectedUserId: context.accountIntent.userId,
|
|
121
|
+
sessionMode: identity.mode,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
reject("identity_receipt_stale", "Current task identity must be verified again before permission admission.");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface FoundryRuntimePaths {
|
|
2
|
+
repoRoot: string;
|
|
3
|
+
entryPath: string;
|
|
4
|
+
entryRepoRelativePath: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FoundryRuntimeIdentity extends FoundryRuntimePaths {
|
|
7
|
+
runtimeRoot: string;
|
|
8
|
+
assetRoot: string;
|
|
9
|
+
packageName: string;
|
|
10
|
+
packageVersion: string;
|
|
11
|
+
packageManifestSha256: string;
|
|
12
|
+
entrySha256: string;
|
|
13
|
+
mode: "source" | "emitted";
|
|
14
|
+
}
|
|
15
|
+
export declare function describeFoundryRuntime(moduleUrl: string): FoundryRuntimeIdentity;
|
|
16
|
+
export declare function resolveFoundryRuntimePaths(moduleUrl: string): FoundryRuntimePaths;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { assertFoundryPackage, foundryPackageDescriptorPath } from "./foundry-package-contract.js";
|
|
6
|
+
const foundryPackageName = "@tiangong-lca/foundry";
|
|
7
|
+
const supportedEntryExtensions = new Set([".js", ".ts"]);
|
|
8
|
+
const layoutSchemaV1 = "tiangong-foundry.runtime-layout.v1";
|
|
9
|
+
const layoutSchemaV2 = "tiangong-foundry.runtime-layout.v2";
|
|
10
|
+
function record(value) {
|
|
11
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
12
|
+
? value
|
|
13
|
+
: null;
|
|
14
|
+
}
|
|
15
|
+
function isWithinRoot(root, target) {
|
|
16
|
+
const relative = path.relative(root, target);
|
|
17
|
+
return (relative === "" ||
|
|
18
|
+
(!path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`)));
|
|
19
|
+
}
|
|
20
|
+
function layoutPath(value, directory = false) {
|
|
21
|
+
return (typeof value === "string" &&
|
|
22
|
+
value.length > 0 &&
|
|
23
|
+
!path.posix.isAbsolute(value) &&
|
|
24
|
+
!value.includes("\\") &&
|
|
25
|
+
!value.includes(":") &&
|
|
26
|
+
!value.includes("\0") &&
|
|
27
|
+
((directory && value === ".") ||
|
|
28
|
+
value.split("/").every((part) => part !== "" && part !== "." && part !== "..")));
|
|
29
|
+
}
|
|
30
|
+
function readRuntimePackage(root) {
|
|
31
|
+
const manifestPath = path.join(root, "package.json");
|
|
32
|
+
if (!fs.existsSync(manifestPath))
|
|
33
|
+
return null;
|
|
34
|
+
let fd;
|
|
35
|
+
try {
|
|
36
|
+
fd = fs.openSync(manifestPath, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
let bytes;
|
|
42
|
+
try {
|
|
43
|
+
const before = fs.fstatSync(fd, { bigint: true });
|
|
44
|
+
if (!before.isFile() || before.size > BigInt(1024 * 1024))
|
|
45
|
+
return null;
|
|
46
|
+
bytes = fs.readFileSync(fd);
|
|
47
|
+
const after = fs.fstatSync(fd, { bigint: true });
|
|
48
|
+
if (before.dev !== after.dev ||
|
|
49
|
+
before.ino !== after.ino ||
|
|
50
|
+
before.size !== after.size ||
|
|
51
|
+
before.mtimeNs !== after.mtimeNs ||
|
|
52
|
+
BigInt(bytes.length) !== after.size)
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
fs.closeSync(fd);
|
|
57
|
+
}
|
|
58
|
+
let manifest;
|
|
59
|
+
try {
|
|
60
|
+
manifest = record(JSON.parse(bytes.toString("utf8")));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (manifest?.name !== foundryPackageName || !manifest.foundryRuntime)
|
|
66
|
+
return null;
|
|
67
|
+
const layout = record(manifest.foundryRuntime);
|
|
68
|
+
const isV1 = layout?.schema === layoutSchemaV1 && Object.keys(layout).length === 4;
|
|
69
|
+
const isV2 = layout?.schema === layoutSchemaV2 && Object.keys(layout).length === 6;
|
|
70
|
+
if (!layout ||
|
|
71
|
+
(!isV1 && !isV2) ||
|
|
72
|
+
!layoutPath(layout.asset_root, true) ||
|
|
73
|
+
!layoutPath(layout.source_entry) ||
|
|
74
|
+
!layoutPath(layout.emitted_entry) ||
|
|
75
|
+
(isV2 && (!layoutPath(layout.package_entry) || !layoutPath(layout.package_descriptor))) ||
|
|
76
|
+
!String(layout.source_entry).endsWith(".ts") ||
|
|
77
|
+
!String(layout.emitted_entry).endsWith(".js") ||
|
|
78
|
+
(isV2 && !String(layout.package_entry).endsWith(".js")) ||
|
|
79
|
+
typeof manifest.version !== "string" ||
|
|
80
|
+
!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u.test(manifest.version)) {
|
|
81
|
+
throw new Error("Invalid Foundry runtime layout descriptor.");
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
root,
|
|
85
|
+
name: manifest.name,
|
|
86
|
+
version: manifest.version,
|
|
87
|
+
manifestSha256: createHash("sha256").update(bytes).digest("hex"),
|
|
88
|
+
layout: {
|
|
89
|
+
schema: layout.schema,
|
|
90
|
+
asset_root: layout.asset_root,
|
|
91
|
+
source_entry: layout.source_entry,
|
|
92
|
+
emitted_entry: layout.emitted_entry,
|
|
93
|
+
package_entry: isV2 ? String(layout.package_entry) : null,
|
|
94
|
+
package_descriptor: isV2 ? String(layout.package_descriptor) : null,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function describeFoundryRuntime(moduleUrl) {
|
|
99
|
+
const requestedModulePath = fileURLToPath(moduleUrl);
|
|
100
|
+
const extension = path.extname(requestedModulePath);
|
|
101
|
+
if (!supportedEntryExtensions.has(extension)) {
|
|
102
|
+
throw new Error(`Unsupported Foundry runtime module extension '${extension}' at ${requestedModulePath}.`);
|
|
103
|
+
}
|
|
104
|
+
const modulePath = fs.realpathSync(requestedModulePath);
|
|
105
|
+
let current = path.dirname(modulePath);
|
|
106
|
+
let runtimePackage = null;
|
|
107
|
+
while (true) {
|
|
108
|
+
runtimePackage = readRuntimePackage(current);
|
|
109
|
+
if (runtimePackage)
|
|
110
|
+
break;
|
|
111
|
+
const parent = path.dirname(current);
|
|
112
|
+
if (parent === current)
|
|
113
|
+
break;
|
|
114
|
+
current = parent;
|
|
115
|
+
}
|
|
116
|
+
if (!runtimePackage) {
|
|
117
|
+
throw new Error(`Unable to resolve trusted Foundry repository root from ${modulePath}.`);
|
|
118
|
+
}
|
|
119
|
+
const mode = extension === ".ts" ? "source" : "emitted";
|
|
120
|
+
const candidates = mode === "source"
|
|
121
|
+
? [runtimePackage.layout.source_entry]
|
|
122
|
+
: [runtimePackage.layout.emitted_entry, runtimePackage.layout.package_entry].filter((entry) => Boolean(entry));
|
|
123
|
+
const selected = candidates
|
|
124
|
+
.map((declared) => ({ declared, target: path.resolve(runtimePackage.root, declared) }))
|
|
125
|
+
.filter(({ target }) => fs.existsSync(target) && fs.lstatSync(target).isFile())
|
|
126
|
+
.map(({ declared, target }) => ({ declared, entryPath: fs.realpathSync(target) }))
|
|
127
|
+
.find(({ entryPath: candidate }) => isWithinRoot(path.dirname(candidate), modulePath));
|
|
128
|
+
if (!selected)
|
|
129
|
+
throw new Error(`Active Foundry entry is missing for ${modulePath}.`);
|
|
130
|
+
const { declared: declaredEntry, entryPath } = selected;
|
|
131
|
+
const assetRoot = fs.realpathSync(path.resolve(runtimePackage.root, runtimePackage.layout.asset_root));
|
|
132
|
+
if (!isWithinRoot(runtimePackage.root, entryPath) ||
|
|
133
|
+
!isWithinRoot(runtimePackage.root, assetRoot) ||
|
|
134
|
+
!fs.statSync(assetRoot).isDirectory() ||
|
|
135
|
+
!isWithinRoot(path.dirname(entryPath), modulePath)) {
|
|
136
|
+
throw new Error("Foundry runtime module or assets escape the declared package layout.");
|
|
137
|
+
}
|
|
138
|
+
if (declaredEntry === runtimePackage.layout.package_entry) {
|
|
139
|
+
if (runtimePackage.layout.package_descriptor !== foundryPackageDescriptorPath)
|
|
140
|
+
throw new Error("Foundry package descriptor path differs from the public package contract.");
|
|
141
|
+
assertFoundryPackage(runtimePackage.root);
|
|
142
|
+
}
|
|
143
|
+
return Object.freeze({
|
|
144
|
+
repoRoot: runtimePackage.root,
|
|
145
|
+
runtimeRoot: runtimePackage.root,
|
|
146
|
+
assetRoot,
|
|
147
|
+
entryPath,
|
|
148
|
+
entryRepoRelativePath: path.relative(runtimePackage.root, entryPath).split(path.sep).join("/"),
|
|
149
|
+
packageName: runtimePackage.name,
|
|
150
|
+
packageVersion: runtimePackage.version,
|
|
151
|
+
packageManifestSha256: runtimePackage.manifestSha256,
|
|
152
|
+
entrySha256: createHash("sha256").update(fs.readFileSync(entryPath)).digest("hex"),
|
|
153
|
+
mode,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export function resolveFoundryRuntimePaths(moduleUrl) {
|
|
157
|
+
const { repoRoot, entryPath, entryRepoRelativePath } = describeFoundryRuntime(moduleUrl);
|
|
158
|
+
return { repoRoot, entryPath, entryRepoRelativePath };
|
|
159
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type CliRuntimeExpectation } from "@tiangong-lca/cli/runtime";
|
|
2
|
+
import { type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
3
|
+
import { TIDAS_VALIDATION_DESCRIBE_SCHEMA } from "./tidas-adapter.ts";
|
|
4
|
+
export declare const FOUNDRY_RUNTIME_QUALIFICATION_SCHEMA: "tiangong-foundry.runtime-qualification.v1";
|
|
5
|
+
export declare const FOUNDRY_TIDAS_EXPECTATION_SCHEMA: "tiangong-foundry.tidas-runtime-expectation.v1";
|
|
6
|
+
export interface ContentFact {
|
|
7
|
+
readonly bytes: number;
|
|
8
|
+
readonly sha256: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FoundryTidasRuntimeExpectation {
|
|
11
|
+
readonly schema: typeof FOUNDRY_TIDAS_EXPECTATION_SCHEMA;
|
|
12
|
+
readonly platform: string;
|
|
13
|
+
readonly binary_version: string;
|
|
14
|
+
readonly executable: Readonly<ContentFact>;
|
|
15
|
+
readonly validation: Readonly<{
|
|
16
|
+
schema_version: typeof TIDAS_VALIDATION_DESCRIBE_SCHEMA;
|
|
17
|
+
asset_fingerprint: string;
|
|
18
|
+
protocols: readonly string[];
|
|
19
|
+
event_schema_versions: readonly string[];
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface QualifiedFoundryRuntime {
|
|
23
|
+
readonly schema: typeof FOUNDRY_RUNTIME_QUALIFICATION_SCHEMA;
|
|
24
|
+
readonly foundry: Readonly<{
|
|
25
|
+
package_name: string;
|
|
26
|
+
package_version: string;
|
|
27
|
+
package_manifest_sha256: string;
|
|
28
|
+
entry_sha256: string;
|
|
29
|
+
platform: string;
|
|
30
|
+
}>;
|
|
31
|
+
readonly cli: Readonly<{
|
|
32
|
+
expectation: Readonly<CliRuntimeExpectation>;
|
|
33
|
+
content_sha256: string;
|
|
34
|
+
}>;
|
|
35
|
+
readonly tidas: Readonly<{
|
|
36
|
+
expectation: Readonly<FoundryTidasRuntimeExpectation>;
|
|
37
|
+
executable_path: string;
|
|
38
|
+
}>;
|
|
39
|
+
readonly qualification_sha256: string;
|
|
40
|
+
}
|
|
41
|
+
declare function parseTidasExpectation(value: unknown, platform: string): FoundryTidasRuntimeExpectation;
|
|
42
|
+
export { parseTidasExpectation as parseFoundryTidasRuntimeExpectation };
|
|
43
|
+
export declare function qualifyFoundryRuntime(context: FoundryRuntimeContext, options: {
|
|
44
|
+
cliExpectation: unknown;
|
|
45
|
+
tidasExpectation: unknown;
|
|
46
|
+
tidasExecutable: string;
|
|
47
|
+
}): QualifiedFoundryRuntime;
|
|
48
|
+
export declare function assertQualifiedFoundryRuntime(context: FoundryRuntimeContext, qualification: QualifiedFoundryRuntime): void;
|
|
49
|
+
export declare function foundryRuntimeQualificationIdentity(context: FoundryRuntimeContext, qualification: QualifiedFoundryRuntime): Readonly<{
|
|
50
|
+
schema: "tiangong-foundry.runtime-qualification.v1";
|
|
51
|
+
qualification_sha256: string;
|
|
52
|
+
cli: Readonly<{
|
|
53
|
+
package_version: string;
|
|
54
|
+
platform: "darwin-arm64" | "linux-arm64" | "linux-x64" | "win32-x64";
|
|
55
|
+
content_sha256: string;
|
|
56
|
+
node_version: string;
|
|
57
|
+
node_sha256: string;
|
|
58
|
+
}>;
|
|
59
|
+
tidas: Readonly<{
|
|
60
|
+
binary_version: string;
|
|
61
|
+
executable: Readonly<ContentFact>;
|
|
62
|
+
asset_fingerprint: string;
|
|
63
|
+
protocols: readonly string[];
|
|
64
|
+
event_schema_versions: readonly string[];
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|