@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,515 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { createFileArtifactFact, createFoundryCommandSpec } from "../foundry-command-spec.js";
|
|
4
|
+
import { taskAuthorizationAllows, taskAuthorizationMatches, taskAuthorizationWaivesQa, } from "../task-authorization.js";
|
|
5
|
+
import { datasetIdentity, detectDatasetType } from "../import-curation/internal/dataset-payload.js";
|
|
6
|
+
import { readRows } from "../import-curation/internal/runtime-io.js";
|
|
7
|
+
import { flowPrewriteIdentityBlockers } from "../import-curation/internal/workflow-identity-preflight.js";
|
|
8
|
+
function commitCommandForDatasetType(datasetType, rowsFile, outDir, { appendOption, resolveTiangongLcaCliBin, resolveTiangongLcaCliCommand, targetUserId = null, allowAccountLocalSupportAndElementary = false, } = {}) {
|
|
9
|
+
const cliPrefix = () => {
|
|
10
|
+
if (resolveTiangongLcaCliCommand) {
|
|
11
|
+
const cli = resolveTiangongLcaCliCommand();
|
|
12
|
+
return [cli.command, ...cli.args];
|
|
13
|
+
}
|
|
14
|
+
return [resolveTiangongLcaCliBin()];
|
|
15
|
+
};
|
|
16
|
+
if (["unitgroup", "flowproperty"].includes(datasetType)) {
|
|
17
|
+
if (!allowAccountLocalSupportAndElementary) {
|
|
18
|
+
throw new Error(`${datasetType} rows are reference-only for Foundry imports and cannot be committed through dataset save-draft.`);
|
|
19
|
+
}
|
|
20
|
+
// Override: mint account-local (My Data, state_code=0) support rows.
|
|
21
|
+
return [
|
|
22
|
+
...cliPrefix(),
|
|
23
|
+
"dataset",
|
|
24
|
+
"save-draft",
|
|
25
|
+
"--type",
|
|
26
|
+
datasetType,
|
|
27
|
+
"--input",
|
|
28
|
+
rowsFile,
|
|
29
|
+
"--out-dir",
|
|
30
|
+
path.join(outDir, "commit", `${datasetType}-save-draft`),
|
|
31
|
+
"--allow-account-local-support",
|
|
32
|
+
"--commit",
|
|
33
|
+
"--json",
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
if (datasetType === "support") {
|
|
37
|
+
const supportArgs = [
|
|
38
|
+
...cliPrefix(),
|
|
39
|
+
"dataset",
|
|
40
|
+
"save-draft",
|
|
41
|
+
"--type",
|
|
42
|
+
"auto",
|
|
43
|
+
"--input",
|
|
44
|
+
rowsFile,
|
|
45
|
+
"--out-dir",
|
|
46
|
+
path.join(outDir, "commit", "support-save-draft"),
|
|
47
|
+
"--commit",
|
|
48
|
+
"--json",
|
|
49
|
+
];
|
|
50
|
+
// A mixed support set may carry account-local FP/UG (P1a), which are
|
|
51
|
+
// reference-only types gated behind the override. No-op for contact/source-
|
|
52
|
+
// only support sets, so it is safe to pass whenever the override is active.
|
|
53
|
+
if (allowAccountLocalSupportAndElementary) {
|
|
54
|
+
supportArgs.push("--allow-account-local-support");
|
|
55
|
+
}
|
|
56
|
+
return supportArgs;
|
|
57
|
+
}
|
|
58
|
+
if (["contact", "source"].includes(datasetType)) {
|
|
59
|
+
return [
|
|
60
|
+
...cliPrefix(),
|
|
61
|
+
"dataset",
|
|
62
|
+
"save-draft",
|
|
63
|
+
"--type",
|
|
64
|
+
datasetType,
|
|
65
|
+
"--input",
|
|
66
|
+
rowsFile,
|
|
67
|
+
"--out-dir",
|
|
68
|
+
path.join(outDir, "commit", `${datasetType}-save-draft`),
|
|
69
|
+
"--commit",
|
|
70
|
+
"--json",
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
if (datasetType === "flow") {
|
|
74
|
+
const args = [
|
|
75
|
+
...cliPrefix(),
|
|
76
|
+
"flow",
|
|
77
|
+
"publish-version",
|
|
78
|
+
"--input-file",
|
|
79
|
+
rowsFile,
|
|
80
|
+
"--out-dir",
|
|
81
|
+
path.join(outDir, "commit", "flow-publish-version"),
|
|
82
|
+
"--commit",
|
|
83
|
+
"--json",
|
|
84
|
+
];
|
|
85
|
+
appendOption(args, "--target-user-id", targetUserId);
|
|
86
|
+
return args;
|
|
87
|
+
}
|
|
88
|
+
if (datasetType === "lifecyclemodel") {
|
|
89
|
+
return [
|
|
90
|
+
...cliPrefix(),
|
|
91
|
+
"lifecyclemodel",
|
|
92
|
+
"save-draft",
|
|
93
|
+
"--input",
|
|
94
|
+
rowsFile,
|
|
95
|
+
"--out-dir",
|
|
96
|
+
path.join(outDir, "commit", "lifecyclemodel-save-draft"),
|
|
97
|
+
"--commit",
|
|
98
|
+
"--json",
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
const args = [
|
|
102
|
+
...cliPrefix(),
|
|
103
|
+
"process",
|
|
104
|
+
"save-draft",
|
|
105
|
+
"--input",
|
|
106
|
+
rowsFile,
|
|
107
|
+
"--out-dir",
|
|
108
|
+
path.join(outDir, "commit", "process-save-draft"),
|
|
109
|
+
"--commit",
|
|
110
|
+
"--json",
|
|
111
|
+
];
|
|
112
|
+
appendOption(args, "--target-user-id", targetUserId);
|
|
113
|
+
return args;
|
|
114
|
+
}
|
|
115
|
+
export function createCommitHandoffCommands({ executionEnvironment = process.env, appendOption, asText, countJsonLinesFile, fileExists, fullContextProofCheck, nowIso, profileFor, readJsonArtifactOption, repoRelativePath, repoRoot, resolveRepoPath, resolveTiangongLcaCliCommand, resolveTiangongLcaCliBin, shellQuote: _shellQuote, validateTraceQueueCoverageForRows, writeJson, }) {
|
|
116
|
+
function validateTraceQueuesForCommitHandoff({ datasetType, finalRowsFile, traceFiles, counts, blockers, }) {
|
|
117
|
+
for (const [key, expectedCount] of [
|
|
118
|
+
["unresolved_traces", Number(counts.unresolved_trace_entries ?? 0) || 0],
|
|
119
|
+
[
|
|
120
|
+
"source_exchange_completeness_traces",
|
|
121
|
+
Number(counts.source_exchange_completeness_entries ?? 0) || 0,
|
|
122
|
+
],
|
|
123
|
+
["source_reference_rewrites", Number(counts.source_reference_rewrites ?? 0) || 0],
|
|
124
|
+
]) {
|
|
125
|
+
const queuePath = traceFiles?.[key];
|
|
126
|
+
const resolved = resolveRepoPath(queuePath);
|
|
127
|
+
if (!resolved) {
|
|
128
|
+
if (expectedCount > 0) {
|
|
129
|
+
blockers.push({
|
|
130
|
+
code: "commit_handoff_trace_queue_missing",
|
|
131
|
+
message: `${key} has ${expectedCount} entries but no queue file is recorded before commit handoff.`,
|
|
132
|
+
trace_queue: key,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!fileExists(resolved)) {
|
|
138
|
+
blockers.push({
|
|
139
|
+
code: "commit_handoff_trace_queue_file_missing",
|
|
140
|
+
message: `${key} is recorded but the queue file is not readable before commit handoff.`,
|
|
141
|
+
trace_queue: key,
|
|
142
|
+
file: queuePath,
|
|
143
|
+
});
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const actualCount = countJsonLinesFile(resolved);
|
|
147
|
+
if (actualCount < expectedCount) {
|
|
148
|
+
blockers.push({
|
|
149
|
+
code: "commit_handoff_trace_queue_count_incomplete",
|
|
150
|
+
message: `${key} has ${actualCount} JSONL rows; expected at least ${expectedCount} before commit handoff.`,
|
|
151
|
+
trace_queue: key,
|
|
152
|
+
file: repoRelativePath(resolved),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (finalRowsFile && fileExists(finalRowsFile)) {
|
|
157
|
+
validateTraceQueueCoverageForRows({
|
|
158
|
+
datasetType,
|
|
159
|
+
finalRowsFile,
|
|
160
|
+
traceQueues: traceFiles,
|
|
161
|
+
counts,
|
|
162
|
+
blockers,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function runDatasetCommitHandoffPlan(options) {
|
|
167
|
+
if (options.help) {
|
|
168
|
+
return {
|
|
169
|
+
schema_version: 1,
|
|
170
|
+
status: "help",
|
|
171
|
+
command: "dataset-commit-handoff-plan",
|
|
172
|
+
usage: [
|
|
173
|
+
"node scripts/foundry.ts dataset-commit-handoff-plan --finalize-report <dataset-post-authoring-finalize-report.json> --out-dir <handoff-dir>",
|
|
174
|
+
"node scripts/foundry.ts dataset-commit-handoff-plan --finalize-report <dataset-post-authoring-finalize-report.json> --state-code <expected-state-code> --out-dir <handoff-dir>",
|
|
175
|
+
],
|
|
176
|
+
purpose: "Build a read-only explicit commit handoff plan from a ready post-authoring finalize report. It never writes the database.",
|
|
177
|
+
remote_write_mode: "read-only",
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const finalizeArtifact = readJsonArtifactOption(options.finalizeReport || options.report || options.input);
|
|
181
|
+
if (!finalizeArtifact) {
|
|
182
|
+
throw new Error("--finalize-report is required and must point to dataset-post-authoring-finalize-report.json.");
|
|
183
|
+
}
|
|
184
|
+
const finalizeReport = finalizeArtifact.value;
|
|
185
|
+
const datasetType = String(options.type || finalizeReport.dataset_type || "")
|
|
186
|
+
.trim()
|
|
187
|
+
.toLowerCase();
|
|
188
|
+
if (!["contact", "source", "support", "process", "flow", "lifecyclemodel"].includes(datasetType)) {
|
|
189
|
+
throw new Error(`Unsupported dataset type for commit handoff: ${datasetType || "(missing)"}.`);
|
|
190
|
+
}
|
|
191
|
+
const finalizeDir = path.dirname(finalizeArtifact.path);
|
|
192
|
+
const outDir = resolveRepoPath(options.outDir || path.join(finalizeDir, "commit-handoff"));
|
|
193
|
+
const finalRowsFile = resolveRepoPath(options.rowsFile ||
|
|
194
|
+
options.finalRowsFile ||
|
|
195
|
+
finalizeReport.files?.final_rows ||
|
|
196
|
+
finalizeReport.final_rows_file);
|
|
197
|
+
const mutationArtifact = readJsonArtifactOption(options.mutationManifest || finalizeReport.files?.mutation_manifest);
|
|
198
|
+
const targetUserId = asText(options.targetUserId ||
|
|
199
|
+
mutationArtifact?.value?.target_user_id ||
|
|
200
|
+
finalizeReport.target_user_id ||
|
|
201
|
+
executionEnvironment.FOUNDRY_TARGET_USER_ID);
|
|
202
|
+
const verifiedProjectRef = asText(executionEnvironment.FOUNDRY_VERIFIED_PROJECT_REF);
|
|
203
|
+
const verifiedUserId = asText(executionEnvironment.FOUNDRY_VERIFIED_USER_ID);
|
|
204
|
+
const accountMode = asText(options.accountMode || executionEnvironment.FOUNDRY_ACCOUNT_MODE).toLowerCase() ||
|
|
205
|
+
"ordinary";
|
|
206
|
+
const explicitStateCode = asText(options.stateCode ?? options.expectedStateCode);
|
|
207
|
+
const stateCode = explicitStateCode || "0";
|
|
208
|
+
const stateCodeSource = explicitStateCode ? "explicit_option" : "default_draft_write_state";
|
|
209
|
+
const commitSupportsTargetUserId = ["flow", "process"].includes(datasetType);
|
|
210
|
+
const blockers = [];
|
|
211
|
+
if (finalizeReport.status !== "ready_for_remote_write") {
|
|
212
|
+
blockers.push({
|
|
213
|
+
code: "finalize_report_not_ready",
|
|
214
|
+
message: `Finalize report status is ${finalizeReport.status ?? "missing"}.`,
|
|
215
|
+
report: repoRelativePath(finalizeArtifact.path),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const locationAuditBlockers = Number(finalizeReport.counts?.location_audit_blockers ?? 0);
|
|
219
|
+
if (!Number.isFinite(locationAuditBlockers) || locationAuditBlockers !== 0) {
|
|
220
|
+
blockers.push({
|
|
221
|
+
code: "location_audit_blockers_present",
|
|
222
|
+
message: `Finalize report still records ${Number.isFinite(locationAuditBlockers) ? locationAuditBlockers : "unknown"} location audit blockers; all rows must satisfy tidas_locations_category.json before commit handoff.`,
|
|
223
|
+
report: repoRelativePath(finalizeArtifact.path),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (!mutationArtifact) {
|
|
227
|
+
blockers.push({
|
|
228
|
+
code: "mutation_manifest_required",
|
|
229
|
+
message: "Commit handoff requires the dataset-mutation-manifest referenced by finalize report.",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else if (mutationArtifact.value?.status !== "ready_for_remote_write") {
|
|
233
|
+
blockers.push({
|
|
234
|
+
code: "mutation_manifest_not_ready",
|
|
235
|
+
message: `Mutation manifest status is ${mutationArtifact.value?.status ?? "missing"}.`,
|
|
236
|
+
report: repoRelativePath(mutationArtifact.path),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (!finalRowsFile || !fileExists(finalRowsFile)) {
|
|
240
|
+
blockers.push({
|
|
241
|
+
code: "final_rows_missing",
|
|
242
|
+
message: "Commit handoff requires readable final rows from the finalize report.",
|
|
243
|
+
rows_file: finalizeReport.files?.final_rows ?? finalizeReport.final_rows_file ?? null,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (!targetUserId) {
|
|
247
|
+
blockers.push({
|
|
248
|
+
code: "target_user_id_required",
|
|
249
|
+
message: "Commit handoff requires explicit target_user_id evidence from mutation manifest or options.",
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (verifiedUserId && verifiedUserId !== targetUserId) {
|
|
253
|
+
blockers.push({
|
|
254
|
+
code: "verified_account_target_user_mismatch",
|
|
255
|
+
message: "Commit handoff target_user_id must match the receipt-verified account user.",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
if (!["ordinary", "production-test"].includes(accountMode)) {
|
|
259
|
+
blockers.push({
|
|
260
|
+
code: "account_mode_invalid",
|
|
261
|
+
message: `Unsupported receipt-bound account mode: ${accountMode}.`,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
const handoffFullContextCheck = fullContextProofCheck({
|
|
265
|
+
profileId: finalizeReport.profile ?? mutationArtifact?.value?.profile,
|
|
266
|
+
datasetType,
|
|
267
|
+
mutationArtifact,
|
|
268
|
+
codePrefix: "commit_handoff",
|
|
269
|
+
});
|
|
270
|
+
blockers.push(...handoffFullContextCheck.blockers);
|
|
271
|
+
const handoffProfileId = asText(finalizeReport.profile ?? mutationArtifact?.value?.profile ?? "generic")
|
|
272
|
+
.trim()
|
|
273
|
+
.toLowerCase();
|
|
274
|
+
const handoffProfile = typeof profileFor === "function"
|
|
275
|
+
? profileFor(repoRoot, handoffProfileId, { ...options, rowsFile: finalRowsFile })
|
|
276
|
+
: null;
|
|
277
|
+
const authorization = handoffProfile?.authorization;
|
|
278
|
+
if (mutationArtifact?.value.profile &&
|
|
279
|
+
asText(mutationArtifact.value.profile).trim().toLowerCase() !== handoffProfileId) {
|
|
280
|
+
blockers.push({
|
|
281
|
+
code: "task_profile_mismatch",
|
|
282
|
+
message: "Finalize and mutation reports must name the same task profile.",
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
const requiredQaWaivers = mutationArtifact?.value.required_qa_waiver_codes;
|
|
286
|
+
if (requiredQaWaivers !== undefined &&
|
|
287
|
+
(!Array.isArray(requiredQaWaivers) ||
|
|
288
|
+
requiredQaWaivers.length === 0 ||
|
|
289
|
+
!requiredQaWaivers.every((code) => typeof code === "string" && taskAuthorizationWaivesQa(authorization, datasetType, code)))) {
|
|
290
|
+
blockers.push({
|
|
291
|
+
code: "task_authorization_qa_waiver_required",
|
|
292
|
+
message: "Mutation-manifest QA exceptions require current task authorization for the exact final rows.",
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if ((handoffProfileId !== "generic" ||
|
|
296
|
+
mutationArtifact?.value.profile_rules_sha256 !== undefined) &&
|
|
297
|
+
(!handoffProfile?.rulesSha256 ||
|
|
298
|
+
mutationArtifact?.value.profile_rules_sha256 !== handoffProfile.rulesSha256)) {
|
|
299
|
+
blockers.push({
|
|
300
|
+
code: "task_profile_rules_evidence_required",
|
|
301
|
+
message: "Rebuild the mutation manifest against the current profile rules; a legacy ready report cannot carry historical task exceptions.",
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
if (taskAuthorizationMatches(authorization, options.taskAuthorizationBinding) &&
|
|
305
|
+
(authorization.binding.user_id !== targetUserId ||
|
|
306
|
+
(verifiedProjectRef && authorization.binding.project_ref !== verifiedProjectRef))) {
|
|
307
|
+
blockers.push({
|
|
308
|
+
code: "task_authorization_account_mismatch",
|
|
309
|
+
message: "Task authorization must match the handoff target account and current verified project.",
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const requiredSupportActions = new Set();
|
|
313
|
+
if (finalRowsFile && fileExists(finalRowsFile)) {
|
|
314
|
+
for (const [index, row] of readRows(finalRowsFile).entries()) {
|
|
315
|
+
const actualType = detectDatasetType(row, datasetType) ?? datasetType;
|
|
316
|
+
if (actualType === "flowproperty" || actualType === "unitgroup") {
|
|
317
|
+
const action = actualType === "flowproperty" ? "flowproperty_write" : "unitgroup_write";
|
|
318
|
+
requiredSupportActions.add(action);
|
|
319
|
+
if (!taskAuthorizationAllows(authorization, action)) {
|
|
320
|
+
blockers.push({
|
|
321
|
+
code: "task_authorization_action_required",
|
|
322
|
+
action,
|
|
323
|
+
row_index: index,
|
|
324
|
+
message: "This account-local support row requires current task authorization for its exact action.",
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (actualType === "flow") {
|
|
329
|
+
blockers.push(...flowPrewriteIdentityBlockers(datasetIdentity(row, index, actualType).payload, actualType, taskAuthorizationAllows(handoffProfile?.authorization, "elementary_flow_write")));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (requiredSupportActions.size > 0 &&
|
|
334
|
+
!taskAuthorizationAllows(authorization, "canonical_support_local_mint")) {
|
|
335
|
+
blockers.push({
|
|
336
|
+
code: "task_authorization_action_required",
|
|
337
|
+
action: "canonical_support_local_mint",
|
|
338
|
+
message: "The canonical-gap support route requires current task mint authorization in addition to each support write action.",
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
const allowAccountLocalSupportAndElementary = requiredSupportActions.size > 0 &&
|
|
342
|
+
[...requiredSupportActions].every((action) => taskAuthorizationAllows(handoffProfile?.authorization, action));
|
|
343
|
+
const commitArgs = finalRowsFile
|
|
344
|
+
? commitCommandForDatasetType(datasetType, finalRowsFile, outDir, {
|
|
345
|
+
appendOption,
|
|
346
|
+
resolveTiangongLcaCliCommand,
|
|
347
|
+
resolveTiangongLcaCliBin,
|
|
348
|
+
targetUserId,
|
|
349
|
+
allowAccountLocalSupportAndElementary,
|
|
350
|
+
})
|
|
351
|
+
: [];
|
|
352
|
+
const cliPrefix = resolveTiangongLcaCliCommand
|
|
353
|
+
? (() => {
|
|
354
|
+
const cli = resolveTiangongLcaCliCommand();
|
|
355
|
+
return [cli.command, ...cli.args];
|
|
356
|
+
})()
|
|
357
|
+
: [resolveTiangongLcaCliBin()];
|
|
358
|
+
const verifyArgs = finalRowsFile
|
|
359
|
+
? [
|
|
360
|
+
...cliPrefix,
|
|
361
|
+
"dataset",
|
|
362
|
+
"verify-remote",
|
|
363
|
+
"--input",
|
|
364
|
+
finalRowsFile,
|
|
365
|
+
"--out-dir",
|
|
366
|
+
path.join(outDir, "post-write-verify"),
|
|
367
|
+
"--root-policy",
|
|
368
|
+
String(options.rootPolicy || options.remoteRootPolicy || "candidate"),
|
|
369
|
+
"--compare-root-payload",
|
|
370
|
+
"--json",
|
|
371
|
+
]
|
|
372
|
+
: [];
|
|
373
|
+
if (targetUserId) {
|
|
374
|
+
verifyArgs.push("--target-user-id", targetUserId);
|
|
375
|
+
}
|
|
376
|
+
if (stateCode) {
|
|
377
|
+
verifyArgs.push("--state-code", stateCode);
|
|
378
|
+
}
|
|
379
|
+
const finalRowsArtifact = finalRowsFile && fileExists(finalRowsFile)
|
|
380
|
+
? createFileArtifactFact({
|
|
381
|
+
role: "final_rows",
|
|
382
|
+
path: repoRelativePath(finalRowsFile),
|
|
383
|
+
filePath: finalRowsFile,
|
|
384
|
+
})
|
|
385
|
+
: null;
|
|
386
|
+
const requestedAuthorization = options.taskAuthorization;
|
|
387
|
+
if (taskAuthorizationMatches(requestedAuthorization, options.taskAuthorizationBinding) &&
|
|
388
|
+
requestedAuthorization.binding.input_scope_sha256 !== finalRowsArtifact?.sha256) {
|
|
389
|
+
blockers.push({
|
|
390
|
+
code: "task_authorization_input_mismatch",
|
|
391
|
+
message: "Task authorization must bind the exact current final-row bytes before emitting a write command.",
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
const traceFiles = {
|
|
395
|
+
unresolved_traces: finalizeReport.files?.unresolved_traces ??
|
|
396
|
+
mutationArtifact?.value?.files?.unresolved_traces ??
|
|
397
|
+
null,
|
|
398
|
+
source_exchange_completeness_traces: finalizeReport.files?.source_exchange_completeness_traces ??
|
|
399
|
+
mutationArtifact?.value?.files?.source_exchange_completeness_traces ??
|
|
400
|
+
null,
|
|
401
|
+
source_reference_rewrites: finalizeReport.files?.source_reference_rewrites ??
|
|
402
|
+
mutationArtifact?.value?.files?.source_reference_rewrites ??
|
|
403
|
+
null,
|
|
404
|
+
};
|
|
405
|
+
validateTraceQueuesForCommitHandoff({
|
|
406
|
+
datasetType,
|
|
407
|
+
finalRowsFile,
|
|
408
|
+
traceFiles,
|
|
409
|
+
counts: {
|
|
410
|
+
unresolved_trace_entries: mutationArtifact?.value?.counts?.unresolved_trace_entries ??
|
|
411
|
+
finalizeReport.counts?.unresolved_trace_entries ??
|
|
412
|
+
0,
|
|
413
|
+
source_exchange_completeness_entries: mutationArtifact?.value?.counts?.source_exchange_completeness_entries ??
|
|
414
|
+
finalizeReport.counts?.source_exchange_completeness_entries ??
|
|
415
|
+
0,
|
|
416
|
+
source_reference_rewrites: mutationArtifact?.value?.counts?.source_reference_rewrites ??
|
|
417
|
+
finalizeReport.counts?.source_reference_rewrites ??
|
|
418
|
+
0,
|
|
419
|
+
},
|
|
420
|
+
blockers,
|
|
421
|
+
});
|
|
422
|
+
const readyForExplicitCommit = blockers.length === 0;
|
|
423
|
+
const report = {
|
|
424
|
+
schema_version: 1,
|
|
425
|
+
generated_at_utc: nowIso(),
|
|
426
|
+
status: blockers.length === 0 ? "ready_for_explicit_commit" : "blocked",
|
|
427
|
+
dataset_type: datasetType,
|
|
428
|
+
profile: finalizeReport.profile ?? mutationArtifact?.value?.profile ?? null,
|
|
429
|
+
remote_write_mode: "read-only",
|
|
430
|
+
finalize_report: repoRelativePath(finalizeArtifact.path),
|
|
431
|
+
mutation_manifest: mutationArtifact ? repoRelativePath(mutationArtifact.path) : null,
|
|
432
|
+
final_rows_file: finalRowsFile ? repoRelativePath(finalRowsFile) : null,
|
|
433
|
+
final_rows_artifact: finalRowsArtifact
|
|
434
|
+
? {
|
|
435
|
+
path: finalRowsArtifact.path,
|
|
436
|
+
bytes: finalRowsArtifact.bytes,
|
|
437
|
+
sha256: finalRowsArtifact.sha256,
|
|
438
|
+
}
|
|
439
|
+
: null,
|
|
440
|
+
target_user_id: targetUserId || null,
|
|
441
|
+
verified_project_ref: verifiedProjectRef || null,
|
|
442
|
+
verified_user_id: verifiedUserId || null,
|
|
443
|
+
account_mode: accountMode,
|
|
444
|
+
expected_state_code: stateCode || null,
|
|
445
|
+
expected_state_code_source: stateCodeSource,
|
|
446
|
+
account_write_guard: {
|
|
447
|
+
target_user_id_required: true,
|
|
448
|
+
target_user_id: targetUserId || null,
|
|
449
|
+
commit_command_supports_target_user_id: commitSupportsTargetUserId,
|
|
450
|
+
commit_account_binding: commitSupportsTargetUserId
|
|
451
|
+
? "target_user_id_cli_argument"
|
|
452
|
+
: "current_cli_auth_session",
|
|
453
|
+
verify_account_binding: "target_user_id_cli_argument",
|
|
454
|
+
execution_precondition: commitSupportsTargetUserId
|
|
455
|
+
? "Run the commit command with the target-user-id argument emitted in this plan."
|
|
456
|
+
: "Run the commit command only in a CLI session authenticated as the recorded target_user_id; this published CLI commit command does not accept --target-user-id.",
|
|
457
|
+
},
|
|
458
|
+
policy: {
|
|
459
|
+
commit_boundary: "This plan does not write the database. An approved runner must execute the authoritative commit CommandSpec, then the post_write_verify CommandSpec, without a shell.",
|
|
460
|
+
post_write_verify_required: true,
|
|
461
|
+
compare_root_payload_required: true,
|
|
462
|
+
trace_queue_policy: "Foundry common:other trace queue files must be retained with commit/readback evidence for later database-side curation.",
|
|
463
|
+
},
|
|
464
|
+
counts: {
|
|
465
|
+
blockers: blockers.length,
|
|
466
|
+
write_candidates: mutationArtifact?.value?.counts?.write_candidates ??
|
|
467
|
+
finalizeReport.counts?.write_candidates ??
|
|
468
|
+
0,
|
|
469
|
+
unresolved_trace_entries: mutationArtifact?.value?.counts?.unresolved_trace_entries ??
|
|
470
|
+
finalizeReport.counts?.unresolved_trace_entries ??
|
|
471
|
+
0,
|
|
472
|
+
source_exchange_completeness_entries: mutationArtifact?.value?.counts?.source_exchange_completeness_entries ??
|
|
473
|
+
finalizeReport.counts?.source_exchange_completeness_entries ??
|
|
474
|
+
0,
|
|
475
|
+
source_reference_rewrites: mutationArtifact?.value?.counts?.source_reference_rewrites ??
|
|
476
|
+
finalizeReport.counts?.source_reference_rewrites ??
|
|
477
|
+
0,
|
|
478
|
+
},
|
|
479
|
+
blockers,
|
|
480
|
+
commands: {
|
|
481
|
+
commit: readyForExplicitCommit && finalRowsArtifact
|
|
482
|
+
? createFoundryCommandSpec({
|
|
483
|
+
executable: commitArgs[0],
|
|
484
|
+
argv: commitArgs.slice(1),
|
|
485
|
+
binding: { artifacts: [finalRowsArtifact] },
|
|
486
|
+
})
|
|
487
|
+
: null,
|
|
488
|
+
post_write_verify: readyForExplicitCommit && finalRowsArtifact
|
|
489
|
+
? createFoundryCommandSpec({
|
|
490
|
+
executable: verifyArgs[0],
|
|
491
|
+
argv: verifyArgs.slice(1),
|
|
492
|
+
binding: { artifacts: [finalRowsArtifact] },
|
|
493
|
+
})
|
|
494
|
+
: null,
|
|
495
|
+
},
|
|
496
|
+
files: {
|
|
497
|
+
trace_queues: traceFiles,
|
|
498
|
+
expected_commit_report_dir: repoRelativePath(path.join(outDir, "commit")),
|
|
499
|
+
expected_post_write_verify_dir: repoRelativePath(path.join(outDir, "post-write-verify")),
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
const reportPath = path.join(outDir, "dataset-commit-handoff-plan.json");
|
|
503
|
+
writeJson(reportPath, report);
|
|
504
|
+
return {
|
|
505
|
+
...report,
|
|
506
|
+
files: {
|
|
507
|
+
...report.files,
|
|
508
|
+
report: repoRelativePath(reportPath),
|
|
509
|
+
},
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
return {
|
|
513
|
+
runDatasetCommitHandoffPlan,
|
|
514
|
+
};
|
|
515
|
+
}
|