@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,152 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { FoundryContextError } from "./foundry-runtime-context.js";
|
|
5
|
+
import { migrationCredentialPath, } from "./foundry-migration-inventory.js";
|
|
6
|
+
import { modelExecutionAttemptDisposition } from "./foundry-execution-attempt.js";
|
|
7
|
+
const maxDocumentBytes = 8 * 1024 * 1024;
|
|
8
|
+
const digestPattern = /^[a-f0-9]{64}$/u;
|
|
9
|
+
function fail(code, message) {
|
|
10
|
+
throw new FoundryContextError(code, message);
|
|
11
|
+
}
|
|
12
|
+
function record(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
14
|
+
fail("migration_document_invalid", "Migration evidence must be a JSON object.");
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function inside(root, target) {
|
|
18
|
+
const relative = path.relative(root, target);
|
|
19
|
+
return (!relative ||
|
|
20
|
+
(!path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`)));
|
|
21
|
+
}
|
|
22
|
+
export function normalizeMigrationStagePath(value) {
|
|
23
|
+
if (typeof value !== "string")
|
|
24
|
+
fail("migration_path_invalid", "Stage paths must be strings.");
|
|
25
|
+
const normalized = value.replaceAll("\\", "/");
|
|
26
|
+
if (!normalized ||
|
|
27
|
+
normalized.length > 4096 ||
|
|
28
|
+
path.isAbsolute(normalized) ||
|
|
29
|
+
normalized.includes(":") ||
|
|
30
|
+
normalized.split("").some((character) => character.charCodeAt(0) < 32) ||
|
|
31
|
+
normalized.split("/").some((part) => !part || part === "." || part === ".."))
|
|
32
|
+
fail("migration_path_invalid", "Select a portable relative path within the source state root.");
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
function readEvidence(inventory, selected) {
|
|
36
|
+
const relative = normalizeMigrationStagePath(selected);
|
|
37
|
+
if (migrationCredentialPath(relative))
|
|
38
|
+
fail("migration_credential_forbidden", "Credential or session storage cannot be migration stage evidence.");
|
|
39
|
+
const fact = inventory.entries.find((entry) => entry.path === relative);
|
|
40
|
+
if (!fact ||
|
|
41
|
+
fact.kind !== "file" ||
|
|
42
|
+
fact.bytes === null ||
|
|
43
|
+
fact.sha256 === null ||
|
|
44
|
+
fact.bytes > maxDocumentBytes)
|
|
45
|
+
fail("migration_evidence_invalid", "Stage evidence must be a bounded hashed inventory file.");
|
|
46
|
+
const sourceRoot = path.join(inventory.workspace_root, ".foundry");
|
|
47
|
+
let target = sourceRoot;
|
|
48
|
+
for (const part of ["", ...relative.split("/")]) {
|
|
49
|
+
if (part)
|
|
50
|
+
target = path.join(target, part);
|
|
51
|
+
const stat = fs.lstatSync(target);
|
|
52
|
+
if (stat.isSymbolicLink() ||
|
|
53
|
+
(target !== path.join(sourceRoot, relative) && !stat.isDirectory()))
|
|
54
|
+
fail("migration_evidence_invalid", "Stage evidence cannot traverse a link or non-directory.");
|
|
55
|
+
}
|
|
56
|
+
const canonical = fs.realpathSync(target);
|
|
57
|
+
if (!inside(sourceRoot, canonical))
|
|
58
|
+
fail("migration_evidence_invalid", "Stage evidence escapes the source state root.");
|
|
59
|
+
const before = fs.lstatSync(canonical, { bigint: true });
|
|
60
|
+
if (!before.isFile() || before.size !== BigInt(fact.bytes))
|
|
61
|
+
fail("migration_source_changed", "Selected stage evidence changed after inventory.");
|
|
62
|
+
const fd = fs.openSync(canonical, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
63
|
+
let bytes;
|
|
64
|
+
try {
|
|
65
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
66
|
+
if (!opened.isFile() ||
|
|
67
|
+
opened.ino !== before.ino ||
|
|
68
|
+
opened.dev !== before.dev ||
|
|
69
|
+
opened.size !== before.size)
|
|
70
|
+
fail("migration_source_changed", "Selected stage evidence changed while opening.");
|
|
71
|
+
bytes = Buffer.alloc(Number(before.size));
|
|
72
|
+
let offset = 0;
|
|
73
|
+
while (offset < bytes.length) {
|
|
74
|
+
const count = fs.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
75
|
+
if (!count)
|
|
76
|
+
break;
|
|
77
|
+
offset += count;
|
|
78
|
+
}
|
|
79
|
+
const after = fs.fstatSync(fd, { bigint: true });
|
|
80
|
+
const linked = fs.lstatSync(canonical, { bigint: true });
|
|
81
|
+
if (offset !== bytes.length ||
|
|
82
|
+
after.size !== before.size ||
|
|
83
|
+
after.mtimeNs !== before.mtimeNs ||
|
|
84
|
+
after.ctimeNs !== before.ctimeNs ||
|
|
85
|
+
linked.ino !== before.ino ||
|
|
86
|
+
linked.dev !== before.dev ||
|
|
87
|
+
linked.isSymbolicLink() ||
|
|
88
|
+
createHash("sha256").update(bytes).digest("hex") !== fact.sha256)
|
|
89
|
+
fail("migration_source_changed", "Selected stage bytes or identity changed while reading.");
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
fs.closeSync(fd);
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
return { value: record(JSON.parse(bytes.toString("utf8"))), sha256: fact.sha256 };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof FoundryContextError)
|
|
99
|
+
throw error;
|
|
100
|
+
return fail("migration_document_invalid", "Stage evidence must contain complete JSON.");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function inspectFoundryMigrationStage(inventory, selected) {
|
|
104
|
+
const { value, sha256 } = readEvidence(inventory, selected);
|
|
105
|
+
if (value.schema_version !== "foundry-execution-capsule-stage.v1" ||
|
|
106
|
+
typeof value.stage_id !== "string" ||
|
|
107
|
+
!/^[a-zA-Z0-9][a-zA-Z0-9._/-]{0,255}$/u.test(value.stage_id) ||
|
|
108
|
+
typeof value.producer_id !== "string" ||
|
|
109
|
+
!/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,255}$/u.test(value.producer_id) ||
|
|
110
|
+
!Number.isSafeInteger(value.revision) ||
|
|
111
|
+
Number(value.revision) < 1 ||
|
|
112
|
+
typeof value.scope_binding_sha256 !== "string" ||
|
|
113
|
+
!digestPattern.test(value.scope_binding_sha256))
|
|
114
|
+
fail("migration_stage_unsupported", "Selected evidence is not a recognized content-bound legacy stage.");
|
|
115
|
+
const attempt = record(value.attempt_state);
|
|
116
|
+
const modeled = modelExecutionAttemptDisposition({
|
|
117
|
+
dispatch_state: typeof attempt.dispatch_state === "string" ? attempt.dispatch_state : undefined,
|
|
118
|
+
readback_state: typeof attempt.readback_state === "string" ? attempt.readback_state : undefined,
|
|
119
|
+
});
|
|
120
|
+
const countsValid = Number.isSafeInteger(attempt.attempt_count) &&
|
|
121
|
+
Number(attempt.attempt_count) >= 0 &&
|
|
122
|
+
Number.isSafeInteger(attempt.primary_attempt_count) &&
|
|
123
|
+
Number(attempt.primary_attempt_count) >= 0 &&
|
|
124
|
+
Number(attempt.primary_attempt_count) <= Number(attempt.attempt_count);
|
|
125
|
+
const pristine = countsValid &&
|
|
126
|
+
attempt.status === "UNATTEMPTED" &&
|
|
127
|
+
attempt.attempt_count === 0 &&
|
|
128
|
+
attempt.primary_attempt_count === 0 &&
|
|
129
|
+
attempt.dispatch_state === "NOT_DISPATCHED" &&
|
|
130
|
+
attempt.mutation_state === "NONE" &&
|
|
131
|
+
attempt.readback_state === "NOT_STARTED";
|
|
132
|
+
const disposition = (modeled.disposition === "UNATTEMPTED" && !pristine) ||
|
|
133
|
+
!countsValid ||
|
|
134
|
+
(modeled.terminal && Number(attempt.attempt_count) === 0)
|
|
135
|
+
? "UNKNOWN_DO_NOT_REPLAY"
|
|
136
|
+
: modeled.disposition;
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
path: selected,
|
|
139
|
+
sha256,
|
|
140
|
+
stage_id: value.stage_id,
|
|
141
|
+
producer_id: value.producer_id,
|
|
142
|
+
revision: Number(value.revision),
|
|
143
|
+
scope_binding_sha256: value.scope_binding_sha256,
|
|
144
|
+
disposition,
|
|
145
|
+
migration_action: disposition === "UNATTEMPTED"
|
|
146
|
+
? "rebuild-local-preparation"
|
|
147
|
+
: disposition === "UNKNOWN_DO_NOT_REPLAY"
|
|
148
|
+
? "owner-readback-only"
|
|
149
|
+
: "retain-terminal",
|
|
150
|
+
grants_write_authority: false,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FoundryInputFact } from "./foundry-runtime-context-types.ts";
|
|
2
|
+
export declare function transferFail(code: string, message: string): never;
|
|
3
|
+
export declare function transferBytes(value: unknown): Buffer;
|
|
4
|
+
export declare function transferHash(bytes: Buffer): string;
|
|
5
|
+
export declare function transferPath(root: string, relative: string): string;
|
|
6
|
+
export declare function transferRead(file: string, limit?: number): Buffer;
|
|
7
|
+
export declare function transferWriteOnce(root: string, relative: string, bytes: Buffer, scratchRelative?: string): void;
|
|
8
|
+
export declare function transferFileFact(file: string): FoundryInputFact;
|
|
9
|
+
export declare function transferCopy(root: string, relative: string, source: FoundryInputFact, scratch: string): void;
|
|
10
|
+
export declare function transferTree(root: string): {
|
|
11
|
+
files: string[];
|
|
12
|
+
directories: string[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
+
import { FoundryContextError } from "./foundry-runtime-error.js";
|
|
5
|
+
export function transferFail(code, message) {
|
|
6
|
+
throw new FoundryContextError(code, message);
|
|
7
|
+
}
|
|
8
|
+
export function transferBytes(value) {
|
|
9
|
+
return Buffer.from(JSON.stringify(value, null, 2) + "\n");
|
|
10
|
+
}
|
|
11
|
+
export function transferHash(bytes) {
|
|
12
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
13
|
+
}
|
|
14
|
+
export function transferPath(root, relative) {
|
|
15
|
+
if (path.isAbsolute(relative) ||
|
|
16
|
+
relative.includes("\\") ||
|
|
17
|
+
relative.includes(":") ||
|
|
18
|
+
relative.split("/").some((p) => p === ".." || p === "." || !p))
|
|
19
|
+
transferFail("migration_path_invalid", "Transfer paths must be contained relative paths.");
|
|
20
|
+
const target = path.join(root, relative);
|
|
21
|
+
let current = root;
|
|
22
|
+
for (const part of ["", ...relative.split("/")]) {
|
|
23
|
+
if (part)
|
|
24
|
+
current = path.join(current, part);
|
|
25
|
+
try {
|
|
26
|
+
const stat = fs.lstatSync(current);
|
|
27
|
+
if (stat.isSymbolicLink() || (current !== target && !stat.isDirectory()))
|
|
28
|
+
transferFail("migration_path_invalid", "Transfer state cannot traverse a link or non-directory.");
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error.code !== "ENOENT")
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
}
|
|
37
|
+
export function transferRead(file, limit = 16 * 1024 * 1024) {
|
|
38
|
+
const before = fs.lstatSync(file, { bigint: true });
|
|
39
|
+
if (!before.isFile() || before.isSymbolicLink() || before.size > BigInt(limit))
|
|
40
|
+
transferFail("migration_state_invalid", "Transfer metadata must be a bounded regular file.");
|
|
41
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
42
|
+
try {
|
|
43
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
44
|
+
if (opened.ino !== before.ino || opened.dev !== before.dev || opened.size !== before.size)
|
|
45
|
+
transferFail("migration_state_changed", "Transfer metadata changed while opening.");
|
|
46
|
+
const bytes = Buffer.alloc(Number(before.size));
|
|
47
|
+
let offset = 0;
|
|
48
|
+
while (offset < bytes.length) {
|
|
49
|
+
const count = fs.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
50
|
+
if (!count)
|
|
51
|
+
break;
|
|
52
|
+
offset += count;
|
|
53
|
+
}
|
|
54
|
+
const after = fs.fstatSync(fd, { bigint: true });
|
|
55
|
+
const linked = fs.lstatSync(file, { bigint: true });
|
|
56
|
+
if (offset !== bytes.length ||
|
|
57
|
+
after.size !== before.size ||
|
|
58
|
+
after.mtimeNs !== before.mtimeNs ||
|
|
59
|
+
after.ctimeNs !== before.ctimeNs ||
|
|
60
|
+
linked.isSymbolicLink() ||
|
|
61
|
+
linked.ino !== before.ino ||
|
|
62
|
+
linked.dev !== before.dev)
|
|
63
|
+
transferFail("migration_state_changed", "Transfer metadata changed while reading.");
|
|
64
|
+
return bytes;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
fs.closeSync(fd);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function transferWriteOnce(root, relative, bytes, scratchRelative) {
|
|
71
|
+
const file = transferPath(root, relative);
|
|
72
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
73
|
+
transferPath(root, relative);
|
|
74
|
+
if (fs.existsSync(file)) {
|
|
75
|
+
if (!transferRead(file).equals(bytes))
|
|
76
|
+
transferFail("migration_destination_conflict", "Existing transfer metadata has different bytes.");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const temp = path.join(scratchRelative ? transferPath(root, scratchRelative) : path.dirname(file), `write-${randomUUID()}.tmp`);
|
|
80
|
+
const fd = fs.openSync(temp, "wx", 0o600);
|
|
81
|
+
try {
|
|
82
|
+
fs.writeFileSync(fd, bytes);
|
|
83
|
+
fs.fsyncSync(fd);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
fs.closeSync(fd);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
fs.linkSync(temp, file);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error.code !== "EEXIST")
|
|
93
|
+
throw error;
|
|
94
|
+
if (!transferRead(file).equals(bytes))
|
|
95
|
+
transferFail("migration_destination_conflict", "Concurrent transfer metadata differs.");
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
if (fs.existsSync(temp))
|
|
99
|
+
fs.unlinkSync(temp);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function transferFileFact(file) {
|
|
103
|
+
const before = fs.lstatSync(file, { bigint: true });
|
|
104
|
+
if (!before.isFile() || before.isSymbolicLink() || before.size > 64n * 1024n * 1024n)
|
|
105
|
+
transferFail("migration_file_invalid", "Transfer file must be bounded and regular.");
|
|
106
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
107
|
+
try {
|
|
108
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
109
|
+
if (opened.ino !== before.ino || opened.dev !== before.dev)
|
|
110
|
+
transferFail("migration_source_changed", "Transfer file identity changed.");
|
|
111
|
+
const hash = createHash("sha256"), buffer = Buffer.alloc(1024 * 1024);
|
|
112
|
+
let bytes = 0;
|
|
113
|
+
while (true) {
|
|
114
|
+
const count = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
115
|
+
if (!count)
|
|
116
|
+
break;
|
|
117
|
+
bytes += count;
|
|
118
|
+
if (bytes > Number(before.size))
|
|
119
|
+
transferFail("migration_source_changed", "Transfer file grew.");
|
|
120
|
+
hash.update(buffer.subarray(0, count));
|
|
121
|
+
}
|
|
122
|
+
const after = fs.fstatSync(fd, { bigint: true });
|
|
123
|
+
const linked = fs.lstatSync(file, { bigint: true });
|
|
124
|
+
if (bytes !== Number(before.size) ||
|
|
125
|
+
after.size !== before.size ||
|
|
126
|
+
after.mtimeNs !== before.mtimeNs ||
|
|
127
|
+
after.ctimeNs !== before.ctimeNs ||
|
|
128
|
+
linked.isSymbolicLink() ||
|
|
129
|
+
linked.ino !== before.ino ||
|
|
130
|
+
linked.dev !== before.dev)
|
|
131
|
+
transferFail("migration_source_changed", "Transfer file changed during hashing.");
|
|
132
|
+
return { path: fs.realpathSync(file), bytes, sha256: hash.digest("hex") };
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
fs.closeSync(fd);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export function transferCopy(root, relative, source, scratch) {
|
|
139
|
+
const file = transferPath(root, relative);
|
|
140
|
+
if (fs.existsSync(file)) {
|
|
141
|
+
const current = transferFileFact(file);
|
|
142
|
+
if (current.bytes !== source.bytes || current.sha256 !== source.sha256)
|
|
143
|
+
transferFail("migration_destination_conflict", "An existing archived file differs; it was preserved.");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
147
|
+
transferPath(root, relative);
|
|
148
|
+
const before = fs.lstatSync(source.path, { bigint: true });
|
|
149
|
+
if (!before.isFile() || before.isSymbolicLink() || before.size !== BigInt(source.bytes))
|
|
150
|
+
transferFail("migration_source_changed", "Source changed before transfer.");
|
|
151
|
+
const temp = path.join(scratch, `copy-${randomUUID()}.tmp`);
|
|
152
|
+
const input = fs.openSync(source.path, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
|
|
153
|
+
let output;
|
|
154
|
+
try {
|
|
155
|
+
const opened = fs.fstatSync(input, { bigint: true });
|
|
156
|
+
if (opened.ino !== before.ino || opened.dev !== before.dev)
|
|
157
|
+
transferFail("migration_source_changed", "Source identity changed before copy.");
|
|
158
|
+
output = fs.openSync(temp, "wx", 0o600);
|
|
159
|
+
const buffer = Buffer.alloc(1024 * 1024), hash = createHash("sha256");
|
|
160
|
+
let bytes = 0;
|
|
161
|
+
while (true) {
|
|
162
|
+
const count = fs.readSync(input, buffer, 0, buffer.length, null);
|
|
163
|
+
if (!count)
|
|
164
|
+
break;
|
|
165
|
+
bytes += count;
|
|
166
|
+
if (bytes > source.bytes)
|
|
167
|
+
transferFail("migration_source_changed", "Source grew during copy.");
|
|
168
|
+
hash.update(buffer.subarray(0, count));
|
|
169
|
+
let offset = 0;
|
|
170
|
+
while (offset < count)
|
|
171
|
+
offset += fs.writeSync(output, buffer, offset, count - offset);
|
|
172
|
+
}
|
|
173
|
+
const after = fs.fstatSync(input, { bigint: true });
|
|
174
|
+
if (bytes !== source.bytes ||
|
|
175
|
+
hash.digest("hex") !== source.sha256 ||
|
|
176
|
+
after.size !== before.size ||
|
|
177
|
+
after.mtimeNs !== before.mtimeNs ||
|
|
178
|
+
after.ctimeNs !== before.ctimeNs)
|
|
179
|
+
transferFail("migration_source_changed", "Source bytes changed during transfer.");
|
|
180
|
+
fs.fsyncSync(output);
|
|
181
|
+
fs.closeSync(output);
|
|
182
|
+
output = undefined;
|
|
183
|
+
transferPath(root, relative);
|
|
184
|
+
try {
|
|
185
|
+
fs.linkSync(temp, file);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
if (error.code !== "EEXIST")
|
|
189
|
+
throw error;
|
|
190
|
+
const existing = transferFileFact(file);
|
|
191
|
+
if (existing.bytes !== source.bytes || existing.sha256 !== source.sha256)
|
|
192
|
+
transferFail("migration_destination_conflict", "Concurrent archive bytes differ.");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
fs.closeSync(input);
|
|
197
|
+
if (output !== undefined)
|
|
198
|
+
fs.closeSync(output);
|
|
199
|
+
if (fs.existsSync(temp))
|
|
200
|
+
fs.unlinkSync(temp);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export function transferTree(root) {
|
|
204
|
+
const files = [], directories = [];
|
|
205
|
+
const walk = (relative, depth) => {
|
|
206
|
+
if (depth > 80 || files.length + directories.length > 30_000)
|
|
207
|
+
transferFail("migration_inventory_limit", "Transfer tree exceeds its bounds.");
|
|
208
|
+
const directory = relative ? transferPath(root, relative) : root;
|
|
209
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
210
|
+
const value = relative ? `${relative}/${entry.name}` : entry.name;
|
|
211
|
+
const stat = fs.lstatSync(transferPath(root, value));
|
|
212
|
+
if (stat.isSymbolicLink())
|
|
213
|
+
transferFail("migration_path_invalid", "Archived state cannot contain links.");
|
|
214
|
+
if (stat.isDirectory()) {
|
|
215
|
+
directories.push(value);
|
|
216
|
+
walk(value, depth + 1);
|
|
217
|
+
}
|
|
218
|
+
else if (stat.isFile())
|
|
219
|
+
files.push(value);
|
|
220
|
+
else
|
|
221
|
+
transferFail("migration_state_invalid", "Archived state contains unsupported entries.");
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
walk("", 0);
|
|
225
|
+
return { files: files.sort(), directories: directories.sort() };
|
|
226
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type FoundryRuntimeContext } from "./foundry-runtime-context.ts";
|
|
2
|
+
import { type FoundryMigrationPlanningOptions } from "./foundry-migration-plan.ts";
|
|
3
|
+
export declare const FOUNDRY_MIGRATION_TRANSFER_RECEIPT_SCHEMA: "tiangong-foundry.migration-transfer-receipt.v1";
|
|
4
|
+
interface CopiedFile {
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly destination: string;
|
|
7
|
+
readonly bytes: number;
|
|
8
|
+
readonly sha256: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FoundryMigrationTransferReceipt {
|
|
11
|
+
readonly schema: typeof FOUNDRY_MIGRATION_TRANSFER_RECEIPT_SCHEMA;
|
|
12
|
+
readonly state: "staged";
|
|
13
|
+
readonly activated: false;
|
|
14
|
+
readonly remote_write_allowed: false;
|
|
15
|
+
readonly plan_sha256: string;
|
|
16
|
+
readonly workspace_id: string;
|
|
17
|
+
readonly actor_id: string;
|
|
18
|
+
readonly files: readonly CopiedFile[];
|
|
19
|
+
readonly directories: readonly string[];
|
|
20
|
+
readonly files_sha256: string;
|
|
21
|
+
readonly receipt_sha256: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MigrationTransferOptions {
|
|
24
|
+
readonly signal?: AbortSignal;
|
|
25
|
+
readonly checkpoint?: (phase: "claimed" | "copied" | "audited", index: number) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function withFoundryMigrationLock<T>(context: FoundryRuntimeContext, sourceRoot: string, body: () => T | Promise<T>): Promise<T>;
|
|
28
|
+
export declare function stageFoundryMigration(context: FoundryRuntimeContext, planning: FoundryMigrationPlanningOptions, provided: unknown, options?: MigrationTransferOptions): Promise<{
|
|
29
|
+
receipt: FoundryMigrationTransferReceipt;
|
|
30
|
+
path: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function auditFoundryMigration(context: FoundryRuntimeContext, planning: FoundryMigrationPlanningOptions, provided: unknown): {
|
|
33
|
+
receipt: FoundryMigrationTransferReceipt;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
export {};
|