@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,392 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { sha256Json } from "./identity-preflight-proof.js";
|
|
5
|
+
export const FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA = "tiangong-foundry.package-descriptor.v1";
|
|
6
|
+
export const foundryPackageDescriptorPath = "package-dist/assets/foundry-package-descriptor.json";
|
|
7
|
+
export const foundryPackageStaticFiles = Object.freeze([
|
|
8
|
+
"package-dist/",
|
|
9
|
+
"specs/import-profiles.json",
|
|
10
|
+
"specs/prewrite-content-policy.json",
|
|
11
|
+
"specs/canonical-support/flow-properties-unit-groups.json",
|
|
12
|
+
"specs/schemas/authorization-derivation.schema.json",
|
|
13
|
+
"specs/schemas/execution-context.schema.json",
|
|
14
|
+
"specs/schemas/foundry-facade-request-index.schema.json",
|
|
15
|
+
"specs/schemas/foundry-operation-result.schema.json",
|
|
16
|
+
"specs/schemas/foundry-package-descriptor.schema.json",
|
|
17
|
+
"specs/schemas/foundry-task-start.schema.json",
|
|
18
|
+
"specs/schemas/foundry-semantic-input.schema.json",
|
|
19
|
+
"specs/schemas/foundry-authorization-input.schema.json",
|
|
20
|
+
"specs/schemas/foundry-workspace-migration-plan.schema.json",
|
|
21
|
+
"specs/schemas/foundry-workspace-migration-transfer-plan.schema.json",
|
|
22
|
+
"specs/schemas/foundry-migration-transfer-receipt.schema.json",
|
|
23
|
+
"specs/schemas/foundry-workspace-migration-pending.schema.json",
|
|
24
|
+
"specs/schemas/foundry-migration-adoption-plan.schema.json",
|
|
25
|
+
"specs/schemas/foundry-migration-activation.schema.json",
|
|
26
|
+
"specs/schemas/foundry-workspace-v2.schema.json",
|
|
27
|
+
"specs/schemas/foundry-runtime-selection.schema.json",
|
|
28
|
+
"specs/schemas/foundry-managed-runtime.schema.json",
|
|
29
|
+
"specs/schemas/runtime-qualification.schema.json",
|
|
30
|
+
"specs/schemas/task-authorization.schema.json",
|
|
31
|
+
"specs/schemas/tidas-runtime-expectation.schema.json",
|
|
32
|
+
"docs/architecture.md",
|
|
33
|
+
"docs/package-distribution-contract.md",
|
|
34
|
+
"docs/foundry-task-contracts.md",
|
|
35
|
+
"docs/public-runtime-contract.md",
|
|
36
|
+
"docs/runtime-context-contract.md",
|
|
37
|
+
"docs/workspace-migration-contract.md",
|
|
38
|
+
"docs/safety-policy.md",
|
|
39
|
+
"docs/task-authorization-contract.md",
|
|
40
|
+
"docs/import-profiles/bafu/constraints.md",
|
|
41
|
+
"docs/import-profiles/bafu/leaf-process-classification-authoring.md",
|
|
42
|
+
"docs/import-profiles/bafu/profile.md",
|
|
43
|
+
"docs/import-profiles/uslci/constraints.md",
|
|
44
|
+
"docs/import-profiles/uslci/profile.md",
|
|
45
|
+
"docs/uslci-import-runbook.md",
|
|
46
|
+
"docs/import-profiles/worldsteel/constraints.md",
|
|
47
|
+
"docs/import-profiles/worldsteel/import-coverage.md",
|
|
48
|
+
"docs/import-profiles/worldsteel/import-plan.md",
|
|
49
|
+
"docs/import-profiles/worldsteel/profile.md",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE",
|
|
52
|
+
]);
|
|
53
|
+
const packageName = "@tiangong-lca/foundry";
|
|
54
|
+
const packageVersion = "0.1.2";
|
|
55
|
+
const packageDescription = "Control plane for TianGong LCA external dataset import and TIDAS authoring work.";
|
|
56
|
+
const cliPackageName = "@tiangong-lca/cli";
|
|
57
|
+
const cliPackageVersion = "0.1.12";
|
|
58
|
+
const packageBin = "package-dist/scripts/package-entry.js";
|
|
59
|
+
const packageApi = "package-dist/scripts/public-api.js";
|
|
60
|
+
const packageTypes = "package-dist/scripts/public-api.d.ts";
|
|
61
|
+
const supportedPlatforms = Object.freeze([
|
|
62
|
+
"linux-x64",
|
|
63
|
+
"linux-arm64",
|
|
64
|
+
"darwin-arm64",
|
|
65
|
+
"win32-x64",
|
|
66
|
+
]);
|
|
67
|
+
const protocolSchemas = Object.freeze([
|
|
68
|
+
"tiangong-foundry.operation-result.v1",
|
|
69
|
+
"tiangong-foundry.task-start.v1",
|
|
70
|
+
"tiangong-foundry.semantic-input.v1",
|
|
71
|
+
"tiangong-foundry.authorization-input.v1",
|
|
72
|
+
"tiangong-foundry.facade-request-index.v1",
|
|
73
|
+
"tiangong-foundry.workspace-migration-plan.v1",
|
|
74
|
+
"tiangong-foundry.workspace-migration-transfer-plan.v2",
|
|
75
|
+
"tiangong-foundry.migration-transfer-receipt.v1",
|
|
76
|
+
"tiangong-foundry.workspace-migration-pending.v1",
|
|
77
|
+
"tiangong-foundry.migration-adoption-plan.v1",
|
|
78
|
+
"tiangong-foundry.migration-activation.v1",
|
|
79
|
+
"tiangong-foundry.workspace.v2",
|
|
80
|
+
"tiangong-foundry.workspace-runtime-selection.v1",
|
|
81
|
+
"tiangong-foundry.managed-runtime.v1",
|
|
82
|
+
"tiangong-foundry.runtime-qualification.v1",
|
|
83
|
+
"tiangong-foundry.tidas-runtime-expectation.v1",
|
|
84
|
+
"tiangong-foundry.execution-context.v1",
|
|
85
|
+
"tiangong-foundry.authorization-derivation.v1",
|
|
86
|
+
"tiangong-foundry.task-authorization.v1",
|
|
87
|
+
]);
|
|
88
|
+
const shaPattern = /^[0-9a-f]{64}$/u;
|
|
89
|
+
const maxDescriptorBytes = 8 * 1024 * 1024;
|
|
90
|
+
const maxPayloadFiles = 5_000;
|
|
91
|
+
const maxPayloadFileBytes = 32 * 1024 * 1024;
|
|
92
|
+
const maxPayloadBytes = 64 * 1024 * 1024;
|
|
93
|
+
function expectedPackageManifest() {
|
|
94
|
+
return {
|
|
95
|
+
name: packageName,
|
|
96
|
+
version: packageVersion,
|
|
97
|
+
type: "module",
|
|
98
|
+
description: packageDescription,
|
|
99
|
+
repository: {
|
|
100
|
+
type: "git",
|
|
101
|
+
url: "git+https://github.com/tiangong-lca/data-foundry.git",
|
|
102
|
+
},
|
|
103
|
+
homepage: "https://github.com/tiangong-lca/data-foundry#readme",
|
|
104
|
+
bugs: { url: "https://github.com/tiangong-lca/data-foundry/issues" },
|
|
105
|
+
publishConfig: { access: "public", registry: "https://registry.npmjs.org/" },
|
|
106
|
+
types: `./${packageTypes}`,
|
|
107
|
+
bin: { "tiangong-foundry": `./${packageBin}` },
|
|
108
|
+
exports: {
|
|
109
|
+
".": { types: `./${packageTypes}`, import: `./${packageApi}` },
|
|
110
|
+
"./runtime": { types: `./${packageTypes}`, import: `./${packageApi}` },
|
|
111
|
+
},
|
|
112
|
+
files: [...foundryPackageStaticFiles],
|
|
113
|
+
engines: { node: ">=24.19.0 <25" },
|
|
114
|
+
license: "MIT",
|
|
115
|
+
dependencies: { [cliPackageName]: cliPackageVersion },
|
|
116
|
+
foundryRuntime: {
|
|
117
|
+
schema: "tiangong-foundry.runtime-layout.v2",
|
|
118
|
+
asset_root: ".",
|
|
119
|
+
source_entry: "scripts/foundry.ts",
|
|
120
|
+
emitted_entry: "dist/scripts/foundry.js",
|
|
121
|
+
package_entry: packageBin,
|
|
122
|
+
package_descriptor: foundryPackageDescriptorPath,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export class FoundryPackageError extends Error {
|
|
127
|
+
code;
|
|
128
|
+
constructor(code, message) {
|
|
129
|
+
super(message);
|
|
130
|
+
this.name = "FoundryPackageError";
|
|
131
|
+
this.code = code;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function fail(code, message) {
|
|
135
|
+
throw new FoundryPackageError(code, message);
|
|
136
|
+
}
|
|
137
|
+
function object(value, label) {
|
|
138
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
139
|
+
fail("package_descriptor_invalid", `${label} must be an object.`);
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function exact(value, keys, label) {
|
|
143
|
+
if (Object.keys(value).length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)))
|
|
144
|
+
fail("package_descriptor_invalid", `${label} has missing or unsupported fields.`);
|
|
145
|
+
}
|
|
146
|
+
function portableFile(value) {
|
|
147
|
+
if (typeof value !== "string" ||
|
|
148
|
+
!value ||
|
|
149
|
+
value.length > 4_096 ||
|
|
150
|
+
path.posix.isAbsolute(value) ||
|
|
151
|
+
value.includes("\\") ||
|
|
152
|
+
value.includes(":") ||
|
|
153
|
+
value.includes("\0") ||
|
|
154
|
+
value.split("/").some((part) => !part || part === "." || part === ".."))
|
|
155
|
+
fail("package_descriptor_invalid", "Package file path is not portable and contained.");
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
function fileFact(value) {
|
|
159
|
+
const item = object(value, "Package file fact");
|
|
160
|
+
exact(item, ["path", "bytes", "sha256"], "Package file fact");
|
|
161
|
+
const selectedPath = portableFile(item.path);
|
|
162
|
+
if (selectedPath === foundryPackageDescriptorPath ||
|
|
163
|
+
!Number.isSafeInteger(item.bytes) ||
|
|
164
|
+
Number(item.bytes) < 0 ||
|
|
165
|
+
Number(item.bytes) > maxPayloadFileBytes ||
|
|
166
|
+
typeof item.sha256 !== "string" ||
|
|
167
|
+
!shaPattern.test(item.sha256))
|
|
168
|
+
fail("package_descriptor_invalid", "Package file fact has invalid bytes or SHA-256.");
|
|
169
|
+
return Object.freeze({ path: selectedPath, bytes: Number(item.bytes), sha256: item.sha256 });
|
|
170
|
+
}
|
|
171
|
+
function sameArray(left, right) {
|
|
172
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
173
|
+
}
|
|
174
|
+
function comparePortable(left, right) {
|
|
175
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
176
|
+
}
|
|
177
|
+
function deepFreeze(value) {
|
|
178
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
179
|
+
for (const child of Object.values(value))
|
|
180
|
+
deepFreeze(child);
|
|
181
|
+
Object.freeze(value);
|
|
182
|
+
}
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
export function assertFoundryPackageDescriptor(value) {
|
|
186
|
+
const item = object(value, "Foundry package descriptor");
|
|
187
|
+
exact(item, ["schema", "package", "runtime", "files", "files_sha256"], "Descriptor");
|
|
188
|
+
const packageIdentity = object(item.package, "Package identity");
|
|
189
|
+
exact(packageIdentity, ["name", "version", "cli_dependency", "bin", "public_api", "types"], "Package identity");
|
|
190
|
+
const cli = object(packageIdentity.cli_dependency, "CLI dependency");
|
|
191
|
+
exact(cli, ["name", "version"], "CLI dependency");
|
|
192
|
+
const runtime = object(item.runtime, "Package runtime");
|
|
193
|
+
exact(runtime, [
|
|
194
|
+
"layout_schema",
|
|
195
|
+
"supported_platforms",
|
|
196
|
+
"workspace_read_schemas",
|
|
197
|
+
"workspace_write_schema",
|
|
198
|
+
"workspace_write_schemas",
|
|
199
|
+
"protocol_schemas",
|
|
200
|
+
], "Package runtime");
|
|
201
|
+
if (item.schema !== FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA ||
|
|
202
|
+
packageIdentity.name !== packageName ||
|
|
203
|
+
packageIdentity.version !== packageVersion ||
|
|
204
|
+
cli.name !== cliPackageName ||
|
|
205
|
+
cli.version !== cliPackageVersion ||
|
|
206
|
+
packageIdentity.bin !== packageBin ||
|
|
207
|
+
packageIdentity.public_api !== packageApi ||
|
|
208
|
+
packageIdentity.types !== packageTypes ||
|
|
209
|
+
runtime.layout_schema !== "tiangong-foundry.runtime-layout.v2" ||
|
|
210
|
+
!Array.isArray(runtime.supported_platforms) ||
|
|
211
|
+
!sameArray(runtime.supported_platforms, supportedPlatforms) ||
|
|
212
|
+
!Array.isArray(runtime.workspace_read_schemas) ||
|
|
213
|
+
!sameArray(runtime.workspace_read_schemas, [
|
|
214
|
+
"tiangong-foundry.workspace.v1",
|
|
215
|
+
"tiangong-foundry.workspace.v2",
|
|
216
|
+
]) ||
|
|
217
|
+
!Array.isArray(runtime.workspace_write_schemas) ||
|
|
218
|
+
!sameArray(runtime.workspace_write_schemas, [
|
|
219
|
+
"tiangong-foundry.workspace.v1",
|
|
220
|
+
"tiangong-foundry.workspace.v2",
|
|
221
|
+
]) ||
|
|
222
|
+
runtime.workspace_write_schema !== "tiangong-foundry.workspace.v1" ||
|
|
223
|
+
!Array.isArray(runtime.protocol_schemas) ||
|
|
224
|
+
!sameArray(runtime.protocol_schemas, protocolSchemas) ||
|
|
225
|
+
!Array.isArray(item.files) ||
|
|
226
|
+
!item.files.length ||
|
|
227
|
+
item.files.length > maxPayloadFiles ||
|
|
228
|
+
typeof item.files_sha256 !== "string" ||
|
|
229
|
+
!shaPattern.test(item.files_sha256))
|
|
230
|
+
fail("package_descriptor_invalid", "Package identity or runtime compatibility is invalid.");
|
|
231
|
+
const files = item.files.map(fileFact);
|
|
232
|
+
const paths = files.map((file) => file.path);
|
|
233
|
+
if (!sameArray(paths, [...paths].sort(comparePortable)) ||
|
|
234
|
+
new Set(paths).size !== paths.length ||
|
|
235
|
+
files.reduce((total, file) => total + file.bytes, 0) > maxPayloadBytes ||
|
|
236
|
+
item.files_sha256 !== sha256Json(files))
|
|
237
|
+
fail("package_descriptor_invalid", "Package file inventory order, uniqueness or digest is invalid.");
|
|
238
|
+
for (const required of ["README.md", "LICENSE", packageBin, packageApi, packageTypes])
|
|
239
|
+
if (!paths.includes(required))
|
|
240
|
+
fail("package_descriptor_invalid", `Package descriptor omits required payload ${required}.`);
|
|
241
|
+
return deepFreeze({
|
|
242
|
+
schema: FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA,
|
|
243
|
+
package: {
|
|
244
|
+
name: packageName,
|
|
245
|
+
version: packageVersion,
|
|
246
|
+
cli_dependency: { name: cliPackageName, version: cliPackageVersion },
|
|
247
|
+
bin: packageBin,
|
|
248
|
+
public_api: packageApi,
|
|
249
|
+
types: packageTypes,
|
|
250
|
+
},
|
|
251
|
+
runtime: {
|
|
252
|
+
layout_schema: "tiangong-foundry.runtime-layout.v2",
|
|
253
|
+
supported_platforms: [...supportedPlatforms],
|
|
254
|
+
workspace_read_schemas: ["tiangong-foundry.workspace.v1", "tiangong-foundry.workspace.v2"],
|
|
255
|
+
workspace_write_schemas: ["tiangong-foundry.workspace.v1", "tiangong-foundry.workspace.v2"],
|
|
256
|
+
workspace_write_schema: "tiangong-foundry.workspace.v1",
|
|
257
|
+
protocol_schemas: [...protocolSchemas],
|
|
258
|
+
},
|
|
259
|
+
files,
|
|
260
|
+
files_sha256: item.files_sha256,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function readPackageFile(root, relative) {
|
|
264
|
+
const target = path.resolve(root, relative);
|
|
265
|
+
const within = path.relative(root, target);
|
|
266
|
+
if (path.isAbsolute(within) || within === ".." || within.startsWith(`..${path.sep}`))
|
|
267
|
+
fail("package_file_invalid", "Package payload escapes its root.");
|
|
268
|
+
let fd;
|
|
269
|
+
try {
|
|
270
|
+
fd = fs.openSync(target, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return fail("package_file_invalid", `Package payload is missing or linked: ${relative}.`);
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const before = fs.fstatSync(fd, { bigint: true });
|
|
277
|
+
if (!before.isFile() || before.size > BigInt(maxPayloadFileBytes))
|
|
278
|
+
fail("package_file_invalid", `Package payload is not a bounded file: ${relative}.`);
|
|
279
|
+
const bytes = fs.readFileSync(fd);
|
|
280
|
+
const after = fs.fstatSync(fd, { bigint: true });
|
|
281
|
+
if (before.dev !== after.dev ||
|
|
282
|
+
before.ino !== after.ino ||
|
|
283
|
+
before.size !== after.size ||
|
|
284
|
+
before.mtimeNs !== after.mtimeNs ||
|
|
285
|
+
BigInt(bytes.length) !== after.size)
|
|
286
|
+
fail("package_file_invalid", `Package payload changed while read: ${relative}.`);
|
|
287
|
+
return Object.freeze({
|
|
288
|
+
fact: Object.freeze({
|
|
289
|
+
path: relative,
|
|
290
|
+
bytes: bytes.length,
|
|
291
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
292
|
+
}),
|
|
293
|
+
content: bytes,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
fs.closeSync(fd);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function captureFile(root, relative) {
|
|
301
|
+
return readPackageFile(root, relative).fact;
|
|
302
|
+
}
|
|
303
|
+
function packageFiles(root) {
|
|
304
|
+
const files = [];
|
|
305
|
+
const walk = (directory, relativeDirectory, depth) => {
|
|
306
|
+
if (depth > 32)
|
|
307
|
+
fail("package_file_invalid", "Package payload exceeds its depth limit.");
|
|
308
|
+
for (const entry of fs
|
|
309
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
310
|
+
.sort((a, b) => comparePortable(a.name, b.name))) {
|
|
311
|
+
const relative = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
312
|
+
const target = path.join(directory, entry.name);
|
|
313
|
+
const stat = fs.lstatSync(target);
|
|
314
|
+
if (relativeDirectory === "" && entry.name === "node_modules") {
|
|
315
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
316
|
+
fail("package_file_invalid", "Installed package node_modules must be a real directory.");
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (stat.isSymbolicLink())
|
|
320
|
+
fail("package_file_invalid", `Package payload contains a link: ${relative}.`);
|
|
321
|
+
if (stat.isDirectory())
|
|
322
|
+
walk(target, relative, depth + 1);
|
|
323
|
+
else if (stat.isFile())
|
|
324
|
+
files.push(relative);
|
|
325
|
+
else
|
|
326
|
+
fail("package_file_invalid", `Package payload contains an unsupported entry: ${relative}.`);
|
|
327
|
+
if (files.length > maxPayloadFiles + 1)
|
|
328
|
+
fail("package_file_invalid", "Package payload exceeds its file-count limit.");
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
walk(root, "", 0);
|
|
332
|
+
return files.sort(comparePortable);
|
|
333
|
+
}
|
|
334
|
+
export function assertFoundryPackage(packageRoot) {
|
|
335
|
+
const root = fs.realpathSync(packageRoot);
|
|
336
|
+
if (!fs.statSync(root).isDirectory())
|
|
337
|
+
fail("package_root_invalid", "Package root is not a directory.");
|
|
338
|
+
const capturedDescriptor = readPackageFile(root, foundryPackageDescriptorPath);
|
|
339
|
+
if (capturedDescriptor.fact.bytes > maxDescriptorBytes)
|
|
340
|
+
fail("package_descriptor_invalid", "Package descriptor exceeds its byte limit.");
|
|
341
|
+
const descriptor = assertFoundryPackageDescriptor(JSON.parse(capturedDescriptor.content.toString("utf8")));
|
|
342
|
+
const actualPaths = packageFiles(root).filter((file) => file !== foundryPackageDescriptorPath && file !== "package.json");
|
|
343
|
+
const expectedPaths = descriptor.files.map((file) => file.path);
|
|
344
|
+
if (!sameArray(actualPaths, expectedPaths))
|
|
345
|
+
fail("package_file_set_changed", "Installed package has missing or extra payload files.");
|
|
346
|
+
for (const expected of descriptor.files) {
|
|
347
|
+
const actual = captureFile(root, expected.path);
|
|
348
|
+
if (actual.bytes !== expected.bytes || actual.sha256 !== expected.sha256)
|
|
349
|
+
fail("package_file_changed", `Installed package payload changed: ${expected.path}.`);
|
|
350
|
+
}
|
|
351
|
+
const manifest = object(JSON.parse(readPackageFile(root, "package.json").content.toString("utf8")), "Installed package manifest");
|
|
352
|
+
if (sha256Json(manifest) !== sha256Json(expectedPackageManifest()))
|
|
353
|
+
fail("package_manifest_changed", "Installed public package manifest changed.");
|
|
354
|
+
const bin = readPackageFile(root, packageBin).content.toString("utf8");
|
|
355
|
+
if (!bin.startsWith("#!/usr/bin/env node\n"))
|
|
356
|
+
fail("package_bin_invalid", "Installed Foundry bin lacks its portable Node shebang.");
|
|
357
|
+
for (const file of actualPaths) {
|
|
358
|
+
if (file.endsWith(".map") ||
|
|
359
|
+
(file.endsWith(".ts") && !file.endsWith(".d.ts")) ||
|
|
360
|
+
/^package-dist\/scripts\/(?:commands|cases)\//u.test(file) ||
|
|
361
|
+
/(?:^|\/)(?:test|tests|\.git|\.github|\.agents|\.env|inputs|outputs|tasks|reports|\.foundry)(?:\/|\.|$)/iu.test(file))
|
|
362
|
+
fail("package_private_file", `Installed package exposes a private/source path: ${file}.`);
|
|
363
|
+
}
|
|
364
|
+
return descriptor;
|
|
365
|
+
}
|
|
366
|
+
export function createFoundryPackageDescriptor(files) {
|
|
367
|
+
const ordered = [...files].sort((left, right) => comparePortable(left.path, right.path));
|
|
368
|
+
return assertFoundryPackageDescriptor({
|
|
369
|
+
schema: FOUNDRY_PACKAGE_DESCRIPTOR_SCHEMA,
|
|
370
|
+
package: {
|
|
371
|
+
name: packageName,
|
|
372
|
+
version: packageVersion,
|
|
373
|
+
cli_dependency: { name: cliPackageName, version: cliPackageVersion },
|
|
374
|
+
bin: packageBin,
|
|
375
|
+
public_api: packageApi,
|
|
376
|
+
types: packageTypes,
|
|
377
|
+
},
|
|
378
|
+
runtime: {
|
|
379
|
+
layout_schema: "tiangong-foundry.runtime-layout.v2",
|
|
380
|
+
supported_platforms: [...supportedPlatforms],
|
|
381
|
+
workspace_read_schemas: ["tiangong-foundry.workspace.v1", "tiangong-foundry.workspace.v2"],
|
|
382
|
+
workspace_write_schemas: ["tiangong-foundry.workspace.v1", "tiangong-foundry.workspace.v2"],
|
|
383
|
+
workspace_write_schema: "tiangong-foundry.workspace.v1",
|
|
384
|
+
protocol_schemas: [...protocolSchemas],
|
|
385
|
+
},
|
|
386
|
+
files: ordered,
|
|
387
|
+
files_sha256: sha256Json(ordered),
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
export function captureFoundryPackageFile(packageRoot, relative) {
|
|
391
|
+
return captureFile(fs.realpathSync(packageRoot), portableFile(relative));
|
|
392
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { FoundryContextError } from "./foundry-runtime-error.js";
|
|
3
|
+
export function migrationCredentialPath(relative) {
|
|
4
|
+
const parts = relative.split(/[\\/]/u);
|
|
5
|
+
return parts.some((part, index) => {
|
|
6
|
+
if (part === "task-accounts" &&
|
|
7
|
+
parts[index - 1] === "state" &&
|
|
8
|
+
index === parts.length - 2 &&
|
|
9
|
+
/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}\.json$/u.test(parts[index + 1]))
|
|
10
|
+
return false;
|
|
11
|
+
return (/^\.env(?:\.|$)|(?:^|[-_.])(?:sessions?|tokens?|cookies?|credentials?|secrets?|passwords?|passwd|accounts?|private-key)(?:[-_.]|$)/iu.test(part) && !/^account-intent\.json$/u.test(part));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function assertNotFoundrySessionFile(file, reference) {
|
|
15
|
+
if (reference &&
|
|
16
|
+
fs.existsSync(reference) &&
|
|
17
|
+
fs.existsSync(file) &&
|
|
18
|
+
fs.realpathSync(reference) === fs.realpathSync(file))
|
|
19
|
+
throw new FoundryContextError("credential_input_forbidden", "CLI-owned session storage cannot be opened as workspace or migration evidence.");
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { FoundryContextError } from "./foundry-runtime-error.js";
|
|
4
|
+
export function foundryPathContains(root, target) {
|
|
5
|
+
const relative = path.relative(root, target);
|
|
6
|
+
return !path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`);
|
|
7
|
+
}
|
|
8
|
+
export function canonicalFoundryCachePath(selected) {
|
|
9
|
+
let current = path.resolve(selected);
|
|
10
|
+
const tail = [];
|
|
11
|
+
while (!fs.existsSync(current)) {
|
|
12
|
+
const parent = path.dirname(current);
|
|
13
|
+
if (parent === current)
|
|
14
|
+
throw new FoundryContextError("runtime_cache_boundary", "Managed cache paths require an accessible filesystem root.");
|
|
15
|
+
tail.unshift(path.basename(current));
|
|
16
|
+
current = parent;
|
|
17
|
+
}
|
|
18
|
+
return path.join(fs.realpathSync(current), ...tail);
|
|
19
|
+
}
|
|
20
|
+
export function assertFoundryCacheRootSeparated(cache, protectedRoot) {
|
|
21
|
+
const selected = canonicalFoundryCachePath(cache);
|
|
22
|
+
const root = canonicalFoundryCachePath(protectedRoot);
|
|
23
|
+
if (foundryPathContains(root, selected) || foundryPathContains(selected, root))
|
|
24
|
+
throw new FoundryContextError("runtime_cache_boundary", "Managed components must stay outside workspace, source and package data.");
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type FoundryCommand } from "./foundry-command-registry.ts";
|
|
2
|
+
import { type CommandCategory } from "./foundry-command-metadata.ts";
|
|
3
|
+
export type FoundryRuntimeDisposition = "facade-adapter" | "developer-maintenance" | "task-control" | "native-runtime-stage" | "task-stage";
|
|
4
|
+
export interface FoundryRuntimeCommandPolicy {
|
|
5
|
+
readonly command: FoundryCommand;
|
|
6
|
+
readonly source_category: CommandCategory;
|
|
7
|
+
readonly disposition: FoundryRuntimeDisposition;
|
|
8
|
+
readonly distribution: "public-facade" | "internal-only" | "excluded";
|
|
9
|
+
readonly facade_operation: "workspace.init" | "doctor" | null;
|
|
10
|
+
readonly asset_root: "runtime";
|
|
11
|
+
readonly input_root: "none" | "workspace-selection" | "task-lineage";
|
|
12
|
+
readonly output_root: "none" | "workspace-state" | "task-artifacts";
|
|
13
|
+
readonly child_process: "none" | "tidas" | "cli-or-owner";
|
|
14
|
+
readonly runtime_qualification: "not-required" | "required-before-child";
|
|
15
|
+
readonly authorization: "not-required" | "required-before-restricted-action";
|
|
16
|
+
readonly declared_inputs: readonly string[];
|
|
17
|
+
readonly declared_outputs: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export declare const foundryRuntimeCommandPolicies: readonly FoundryRuntimeCommandPolicy[];
|
|
20
|
+
export declare function foundryRuntimeCommandPolicy(command: string): FoundryRuntimeCommandPolicy;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { knownCommands } from "./foundry-command-registry.js";
|
|
2
|
+
import { commandMetadata } from "./foundry-command-metadata.js";
|
|
3
|
+
import { FoundryContextError } from "./foundry-runtime-context.js";
|
|
4
|
+
const developerMaintenance = new Set([
|
|
5
|
+
"env-check",
|
|
6
|
+
"workflow-check",
|
|
7
|
+
"storage-check",
|
|
8
|
+
"surface-audit",
|
|
9
|
+
"workspace-map",
|
|
10
|
+
"capabilities-list",
|
|
11
|
+
]);
|
|
12
|
+
const facadeAdapters = new Set(["init", "doctor"]);
|
|
13
|
+
const taskControl = new Set([
|
|
14
|
+
"profiles-list",
|
|
15
|
+
"route-task",
|
|
16
|
+
"tasks-list",
|
|
17
|
+
"tasks-check",
|
|
18
|
+
"task-complete",
|
|
19
|
+
"acceptance-check",
|
|
20
|
+
]);
|
|
21
|
+
const nativeRuntime = new Set([
|
|
22
|
+
"tidas-handshake",
|
|
23
|
+
"dataset-tidas-import",
|
|
24
|
+
"dataset-tidas-validate",
|
|
25
|
+
]);
|
|
26
|
+
const taskStages = new Set([
|
|
27
|
+
"execution-capsule-admit",
|
|
28
|
+
"dataset-incremental-change-set-compose",
|
|
29
|
+
"dataset-topology-convergence-compose",
|
|
30
|
+
"dataset-curation-queue-build",
|
|
31
|
+
"dataset-curation-gate",
|
|
32
|
+
"dataset-authoring-plan",
|
|
33
|
+
"dataset-authoring-task-build",
|
|
34
|
+
"dataset-authoring-patch-collect",
|
|
35
|
+
"dataset-identity-decision-task-build",
|
|
36
|
+
"dataset-classification-decision-task-build",
|
|
37
|
+
"dataset-library-classification-decisions-project",
|
|
38
|
+
"dataset-bafu-leaf-classification-tasks-prepare",
|
|
39
|
+
"dataset-bafu-leaf-classification-category-map-project",
|
|
40
|
+
"dataset-bafu-identity-decisions-autofill",
|
|
41
|
+
"dataset-bafu-authoring-patches-autofill",
|
|
42
|
+
"dataset-classification-decisions-apply",
|
|
43
|
+
"dataset-location-decision-task-build",
|
|
44
|
+
"dataset-location-decisions-suggest",
|
|
45
|
+
"dataset-location-decisions-apply",
|
|
46
|
+
"dataset-curation-cleanup",
|
|
47
|
+
"dataset-patch-apply",
|
|
48
|
+
"dataset-support-cache-refresh",
|
|
49
|
+
"dataset-canonical-support-mappings-autofill",
|
|
50
|
+
"dataset-bundle-sample-rows",
|
|
51
|
+
"dataset-identity-preflight-requests-build",
|
|
52
|
+
"dataset-identity-preflight-query-audit",
|
|
53
|
+
"dataset-identity-preflight-run",
|
|
54
|
+
"dataset-identity-preflight-index-merge",
|
|
55
|
+
"dataset-library-index-build",
|
|
56
|
+
"dataset-library-authoring-plan",
|
|
57
|
+
"dataset-library-identity-decisions-from-preflight",
|
|
58
|
+
"dataset-library-decisions-apply",
|
|
59
|
+
"dataset-process-scope-run",
|
|
60
|
+
"dataset-bafu-process-scope-e2e",
|
|
61
|
+
"dataset-bafu-batch-import-run",
|
|
62
|
+
"dataset-uslci-batch-import-run",
|
|
63
|
+
"dataset-worldsteel-batch-import-run",
|
|
64
|
+
"dataset-bafu-universe-coverage-report",
|
|
65
|
+
"dataset-identity-reference-rewrites-apply",
|
|
66
|
+
"dataset-identity-decisions-apply",
|
|
67
|
+
"dataset-post-authoring-finalize",
|
|
68
|
+
"dataset-commit-handoff-plan",
|
|
69
|
+
"dataset-post-write-closeout",
|
|
70
|
+
"dataset-import-completion-report",
|
|
71
|
+
"dataset-import-ledger-report",
|
|
72
|
+
"dataset-mutation-manifest",
|
|
73
|
+
]);
|
|
74
|
+
const cliChildStages = new Set([
|
|
75
|
+
"dataset-curation-queue-build",
|
|
76
|
+
"dataset-patch-apply",
|
|
77
|
+
"dataset-support-cache-refresh",
|
|
78
|
+
"dataset-identity-preflight-run",
|
|
79
|
+
"dataset-post-authoring-finalize",
|
|
80
|
+
"dataset-process-scope-run",
|
|
81
|
+
"dataset-bafu-process-scope-e2e",
|
|
82
|
+
"dataset-bafu-batch-import-run",
|
|
83
|
+
"dataset-uslci-batch-import-run",
|
|
84
|
+
"dataset-worldsteel-batch-import-run",
|
|
85
|
+
]);
|
|
86
|
+
const restrictedStages = new Set([
|
|
87
|
+
"dataset-identity-decisions-apply",
|
|
88
|
+
"dataset-library-decisions-apply",
|
|
89
|
+
"dataset-bundle-sample-rows",
|
|
90
|
+
"dataset-post-authoring-finalize",
|
|
91
|
+
"dataset-commit-handoff-plan",
|
|
92
|
+
"dataset-mutation-manifest",
|
|
93
|
+
"dataset-process-scope-run",
|
|
94
|
+
"dataset-bafu-process-scope-e2e",
|
|
95
|
+
"dataset-bafu-batch-import-run",
|
|
96
|
+
"dataset-uslci-batch-import-run",
|
|
97
|
+
"dataset-worldsteel-batch-import-run",
|
|
98
|
+
]);
|
|
99
|
+
const explicitlyClassified = [
|
|
100
|
+
...facadeAdapters,
|
|
101
|
+
...developerMaintenance,
|
|
102
|
+
...taskControl,
|
|
103
|
+
...nativeRuntime,
|
|
104
|
+
...taskStages,
|
|
105
|
+
];
|
|
106
|
+
if (explicitlyClassified.length !== knownCommands.length ||
|
|
107
|
+
new Set(explicitlyClassified).size !== knownCommands.length ||
|
|
108
|
+
knownCommands.some((command) => !explicitlyClassified.includes(command)))
|
|
109
|
+
throw new FoundryContextError("runtime_command_policy_missing", "Every internal command requires one explicit runtime ownership disposition.");
|
|
110
|
+
function disposition(command) {
|
|
111
|
+
if (facadeAdapters.has(command))
|
|
112
|
+
return "facade-adapter";
|
|
113
|
+
if (developerMaintenance.has(command))
|
|
114
|
+
return "developer-maintenance";
|
|
115
|
+
if (taskControl.has(command))
|
|
116
|
+
return "task-control";
|
|
117
|
+
if (nativeRuntime.has(command))
|
|
118
|
+
return "native-runtime-stage";
|
|
119
|
+
if (taskStages.has(command))
|
|
120
|
+
return "task-stage";
|
|
121
|
+
throw new FoundryContextError("runtime_command_policy_missing", "Every internal command requires one explicit runtime ownership disposition.");
|
|
122
|
+
}
|
|
123
|
+
function build(command) {
|
|
124
|
+
const metadata = commandMetadata[command];
|
|
125
|
+
if (!metadata)
|
|
126
|
+
throw new FoundryContextError("runtime_command_policy_missing", "Every internal command requires one explicit runtime ownership disposition.");
|
|
127
|
+
const selected = disposition(command);
|
|
128
|
+
const childProcess = selected === "native-runtime-stage"
|
|
129
|
+
? "tidas"
|
|
130
|
+
: cliChildStages.has(command) || metadata.category === "cli-wrapper"
|
|
131
|
+
? "cli-or-owner"
|
|
132
|
+
: "none";
|
|
133
|
+
const policy = Object.freeze({
|
|
134
|
+
command,
|
|
135
|
+
source_category: metadata.category,
|
|
136
|
+
disposition: selected,
|
|
137
|
+
distribution: selected === "facade-adapter"
|
|
138
|
+
? "public-facade"
|
|
139
|
+
: selected === "developer-maintenance"
|
|
140
|
+
? "excluded"
|
|
141
|
+
: "internal-only",
|
|
142
|
+
facade_operation: command === "init" ? "workspace.init" : command === "doctor" ? "doctor" : null,
|
|
143
|
+
asset_root: "runtime",
|
|
144
|
+
input_root: selected === "developer-maintenance" || command === "doctor" || command === "tidas-handshake"
|
|
145
|
+
? "none"
|
|
146
|
+
: selected === "facade-adapter" || selected === "task-control"
|
|
147
|
+
? "workspace-selection"
|
|
148
|
+
: "task-lineage",
|
|
149
|
+
output_root: selected === "developer-maintenance" || command === "doctor" || command === "tidas-handshake"
|
|
150
|
+
? "none"
|
|
151
|
+
: selected === "facade-adapter" || selected === "task-control"
|
|
152
|
+
? "workspace-state"
|
|
153
|
+
: "task-artifacts",
|
|
154
|
+
child_process: childProcess,
|
|
155
|
+
runtime_qualification: childProcess === "none" ? "not-required" : "required-before-child",
|
|
156
|
+
authorization: restrictedStages.has(command)
|
|
157
|
+
? "required-before-restricted-action"
|
|
158
|
+
: "not-required",
|
|
159
|
+
declared_inputs: Object.freeze([...metadata.inputs]),
|
|
160
|
+
declared_outputs: Object.freeze([...metadata.outputs]),
|
|
161
|
+
});
|
|
162
|
+
return policy;
|
|
163
|
+
}
|
|
164
|
+
export const foundryRuntimeCommandPolicies = Object.freeze(knownCommands.map(build));
|
|
165
|
+
const policyByCommand = new Map(foundryRuntimeCommandPolicies.map((policy) => [policy.command, policy]));
|
|
166
|
+
export function foundryRuntimeCommandPolicy(command) {
|
|
167
|
+
if (!Object.hasOwn(commandMetadata, command))
|
|
168
|
+
throw new FoundryContextError("runtime_command_unknown", "Unknown or inherited command names have no runtime authority.");
|
|
169
|
+
const policy = policyByCommand.get(command);
|
|
170
|
+
if (!policy)
|
|
171
|
+
throw new FoundryContextError("runtime_command_policy_missing", "The selected command has no runtime ownership disposition.");
|
|
172
|
+
return policy;
|
|
173
|
+
}
|