@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,542 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { taskAuthorizationAllows } from "../task-authorization.js";
|
|
4
|
+
import * as mutationManifestWorkflow from "./internal/mutation-manifest-workflow.js";
|
|
5
|
+
const { asText, buildEvidenceScopeBlockers, buildFullContextAiCompletionBlockers, buildReferenceClosureBlockers, buildReferenceReuseItems, buildWriteCandidateItem, datasetTypeFromOptions, datasetTypePlural, decisionApplyContextRelevantToRowsFile, decisionCounts, decisionTaskContextBundleHashesFromContext, ensureArray, evidenceScopeBlocker, fileExists, fullContextAiCompletionRequirement, identityDecisionApplyReportOptionValues, identityDecisionUnresolvedReferenceKeys, identityKey, identityReferenceRewriteProofKeys, mapCurationEntities, mapRowsByIdentity, mapSchemaRows, nowIso, operationCounts, plannedRootReferenceIds, plannedRootReferenceKeys, profileFor, readCanonicalSupportRewriteContext, readClassificationDecisionApplyContext, readCleanupTransformContext, readDatasetSaveDraftDryRunArtifacts, readFileArtifactIfOption, readFlowDryRunArtifacts, readIdentityDecisionApplyContexts, readIdentityReferenceRewriteContext, readJsonArtifactsIfOption, readJsonIfOption, readLifecyclemodelDryRunArtifacts, readLocationDecisionApplyContext, readPatchApplyContext, readPolicySnapshots, readProcessDryRunArtifacts, readRows, readRowsIfExists, publicCanonicalSourceReferenceKeys, readSourceContactRewriteContext, readSourceReferenceRewriteContext, sourceContactSupportCanonicalUnitGroupProofKeys, sourceContactSupportTrueSourceProofKeys, sourceReferenceRewriteProofKeys, readUnresolvedExchangeExternalizationContext, referenceKey, remoteVerifyBlockerKeys, repoRelativePath, resolveRepoPath, sourceContactRewriteSemanticEvidenceCount, supportDatasetTypes, writeJson, writeJsonLines, } = mutationManifestWorkflow;
|
|
6
|
+
function asRecord(value) {
|
|
7
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
8
|
+
}
|
|
9
|
+
function optionList(value) {
|
|
10
|
+
return ensureArray(value).flatMap((entry) => String(entry ?? "")
|
|
11
|
+
.split(",")
|
|
12
|
+
.map((item) => item.trim())
|
|
13
|
+
.filter(Boolean));
|
|
14
|
+
}
|
|
15
|
+
function readJsonLinesIfExists(filePath) {
|
|
16
|
+
if (!filePath || !fs.existsSync(filePath) || !fs.statSync(filePath).isFile())
|
|
17
|
+
return [];
|
|
18
|
+
return fs
|
|
19
|
+
.readFileSync(filePath, "utf8")
|
|
20
|
+
.trim()
|
|
21
|
+
.split(/\r?\n/u)
|
|
22
|
+
.filter(Boolean)
|
|
23
|
+
.map((line) => JSON.parse(line));
|
|
24
|
+
}
|
|
25
|
+
function verifiedReferenceLedgerProof(repoRoot, options) {
|
|
26
|
+
const ledgerFiles = optionList(options.verifiedReferenceLedger ??
|
|
27
|
+
options.verifiedReferenceLedgers ??
|
|
28
|
+
options.verifiedReferenceLedgerFile ??
|
|
29
|
+
options.verifiedReferenceLedgerFiles ??
|
|
30
|
+
options.verifiedFlowLedger ??
|
|
31
|
+
options.verifiedFlowLedgers)
|
|
32
|
+
.map((filePath) => resolveRepoPath(repoRoot, filePath))
|
|
33
|
+
.filter((filePath) => Boolean(filePath && fs.existsSync(filePath) && fs.statSync(filePath).isFile()));
|
|
34
|
+
const keys = new Set();
|
|
35
|
+
let rows = 0;
|
|
36
|
+
for (const filePath of ledgerFiles) {
|
|
37
|
+
for (const row of readJsonLinesIfExists(filePath)) {
|
|
38
|
+
rows += 1;
|
|
39
|
+
const datasetType = asText(row.row_dataset_type ?? row.dataset_type ?? row.type ?? row.scope_dataset_type);
|
|
40
|
+
const table = asText(row.table) || datasetTypePlural[datasetType];
|
|
41
|
+
const id = asText(row.dataset_id ?? row.id ?? row.flow_id ?? row.process_id);
|
|
42
|
+
const version = asText(row.version ?? row.dataset_version ?? row.flow_version ?? row.process_version) ||
|
|
43
|
+
"00.00.001";
|
|
44
|
+
if (!table || !id)
|
|
45
|
+
continue;
|
|
46
|
+
keys.add(referenceKey({ table, id, version }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
files: ledgerFiles.map((filePath) => repoRelativePath(repoRoot, filePath)),
|
|
51
|
+
rows,
|
|
52
|
+
proven_keys: keys.size,
|
|
53
|
+
keys,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function runDatasetMutationManifest({ repoRoot, options = {}, } = {}) {
|
|
57
|
+
const datasetType = datasetTypeFromOptions(options);
|
|
58
|
+
if (options.help) {
|
|
59
|
+
return {
|
|
60
|
+
schema_version: 1,
|
|
61
|
+
status: "help",
|
|
62
|
+
command: "dataset-mutation-manifest",
|
|
63
|
+
usage: [
|
|
64
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type flow --rows-file <ready-flow-rows.jsonl> --schema-report <validation-report.json> --dry-run-report <flow-publish-report.json> --target-user-id <uuid>",
|
|
65
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type process --rows-file <ready-processes.jsonl> --schema-report <validation-report.json> --dry-run-report <save-draft-summary.json> --remote-verify-report <remote-verification-report.json> --target-user-id <uuid>",
|
|
66
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type lifecyclemodel --rows-file <ready-lifecyclemodels.jsonl> --schema-report <validation-report.json> --dry-run-report <save-draft-summary.json> --target-user-id <uuid>",
|
|
67
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type flow --rows-file <classified-flows.jsonl> --classification-decision-apply-report <classification-decisions-apply-report.json> --schema-report <validation-report.json> --dry-run-report <save-draft-summary.json> --target-user-id <uuid>",
|
|
68
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type process --rows-file <located-processes.jsonl> --location-decision-apply-report <location-decisions-apply-report.json> --schema-report <validation-report.json> --dry-run-report <save-draft-summary.json> --target-user-id <uuid>",
|
|
69
|
+
"node scripts/foundry.ts dataset-mutation-manifest --type process --rows-file <patched-cleaned-rows.jsonl> --patch-collect-report <authoring-patch-collect-report.json> --require-patch-collect-report --patch-apply-report <dataset-patch-apply-report.json> --cleanup-report <dataset-curation-cleanup-report.json> --schema-report <validation-report.json> --dry-run-report <save-draft-summary.json> --target-user-id <uuid>",
|
|
70
|
+
],
|
|
71
|
+
purpose: "Build a prewrite mutation manifest that separates write/update candidates, reusable existing references, and blocked rows before any commit.",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const root = repoRoot;
|
|
75
|
+
const rowsFile = resolveRepoPath(root, options.rowsFile || options.input);
|
|
76
|
+
const referenceRowsFile = resolveRepoPath(root, options.referenceRowsFile || options.referenceRows || options.reuseRowsFile);
|
|
77
|
+
const schemaReportArtifact = readJsonIfOption(root, options.schemaReport);
|
|
78
|
+
const curationGateArtifact = readJsonIfOption(root, options.curationGateReport);
|
|
79
|
+
const dryRunReportArtifact = readJsonIfOption(root, options.dryRunReport);
|
|
80
|
+
const remoteVerifyArtifact = readJsonIfOption(root, options.remoteVerifyReport);
|
|
81
|
+
const cleanupArtifact = readJsonIfOption(root, options.cleanupReport);
|
|
82
|
+
const patchApplyArtifact = readJsonIfOption(root, options.patchApplyReport);
|
|
83
|
+
const patchCollectArtifact = readJsonIfOption(root, options.patchCollectReport ?? options.authoringPatchCollectReport);
|
|
84
|
+
const classificationDecisionApplyArtifact = readJsonIfOption(root, options.classificationDecisionApplyReport ?? options.classificationDecisionsApplyReport);
|
|
85
|
+
const locationDecisionApplyArtifact = readJsonIfOption(root, options.locationDecisionApplyReport ?? options.locationDecisionsApplyReport);
|
|
86
|
+
const identityDecisionApplyArtifacts = readJsonArtifactsIfOption(root, identityDecisionApplyReportOptionValues(options));
|
|
87
|
+
const identityDecisionApplyArtifact = identityDecisionApplyArtifacts[0] ?? null;
|
|
88
|
+
const patchEvidenceFile = readFileArtifactIfOption(root, options.patchEvidenceFile || options.patchEvidence);
|
|
89
|
+
const defaultOut = `.foundry/workspaces/${datasetType}-dataset-mutation-manifest`;
|
|
90
|
+
const outDir = resolveRepoPath(root, options.outDir || defaultOut);
|
|
91
|
+
const targetUserId = asText(options.targetUserId ??
|
|
92
|
+
options.targetOwnerId ??
|
|
93
|
+
dryRunReportArtifact?.value?.target_user_id_override ??
|
|
94
|
+
process.env.FOUNDRY_TARGET_USER_ID);
|
|
95
|
+
const profileId = String(options.profile || "generic")
|
|
96
|
+
.trim()
|
|
97
|
+
.toLowerCase();
|
|
98
|
+
const profile = profileFor(root, profileId, options);
|
|
99
|
+
const fullContextRequirement = fullContextAiCompletionRequirement(profile, datasetType, root);
|
|
100
|
+
const classificationDecisionApplyContext = classificationDecisionApplyArtifact
|
|
101
|
+
? readClassificationDecisionApplyContext(root, classificationDecisionApplyArtifact)
|
|
102
|
+
: null;
|
|
103
|
+
const locationDecisionApplyContext = locationDecisionApplyArtifact
|
|
104
|
+
? readLocationDecisionApplyContext(root, locationDecisionApplyArtifact)
|
|
105
|
+
: null;
|
|
106
|
+
const identityDecisionApplyContext = readIdentityDecisionApplyContexts(root, identityDecisionApplyArtifacts);
|
|
107
|
+
const unresolvedExchangeExternalizationArtifact = readJsonIfOption(root, options.unresolvedExchangeExternalizationReport);
|
|
108
|
+
const unresolvedExchangeExternalizationContext = readUnresolvedExchangeExternalizationContext(root, unresolvedExchangeExternalizationArtifact);
|
|
109
|
+
const canonicalSupportRewriteArtifact = readJsonIfOption(root, options.canonicalSupportRewriteReport || options.canonicalSupportRewritesReport);
|
|
110
|
+
const canonicalSupportRewriteContext = readCanonicalSupportRewriteContext(root, canonicalSupportRewriteArtifact);
|
|
111
|
+
const sourceContactRewriteArtifact = readJsonIfOption(root, options.sourceContactRewriteReport ?? options.sourceContactRewritesReport);
|
|
112
|
+
const sourceContactRewriteContext = readSourceContactRewriteContext(root, sourceContactRewriteArtifact);
|
|
113
|
+
const cleanupContext = readCleanupTransformContext(root, cleanupArtifact);
|
|
114
|
+
const sourceContactRewriteSemanticEvidenceEntries = sourceContactRewriteSemanticEvidenceCount({
|
|
115
|
+
repoRoot: root,
|
|
116
|
+
datasetType,
|
|
117
|
+
rowsFile,
|
|
118
|
+
sourceContactRewriteContext: sourceContactRewriteContext,
|
|
119
|
+
canonicalSupportRewriteContext: canonicalSupportRewriteContext,
|
|
120
|
+
cleanupContext: cleanupContext,
|
|
121
|
+
});
|
|
122
|
+
const hasClassificationDecisionProof = classificationDecisionApplyContext?.status === "completed" &&
|
|
123
|
+
classificationDecisionApplyContext.decisions.length > 0 &&
|
|
124
|
+
decisionApplyContextRelevantToRowsFile({
|
|
125
|
+
repoRoot: root,
|
|
126
|
+
rowsFile: rowsFile,
|
|
127
|
+
cleanupArtifact,
|
|
128
|
+
context: classificationDecisionApplyContext,
|
|
129
|
+
});
|
|
130
|
+
const hasLocationDecisionProof = locationDecisionApplyContext?.status === "completed" &&
|
|
131
|
+
locationDecisionApplyContext.decisions.length > 0 &&
|
|
132
|
+
decisionApplyContextRelevantToRowsFile({
|
|
133
|
+
repoRoot: root,
|
|
134
|
+
rowsFile: rowsFile,
|
|
135
|
+
cleanupArtifact,
|
|
136
|
+
context: locationDecisionApplyContext,
|
|
137
|
+
});
|
|
138
|
+
const hasIdentityDecisionProof = identityDecisionApplyContext?.status === "completed" &&
|
|
139
|
+
identityDecisionApplyContext.decisions.length > 0 &&
|
|
140
|
+
decisionApplyContextRelevantToRowsFile({
|
|
141
|
+
repoRoot: root,
|
|
142
|
+
rowsFile: rowsFile,
|
|
143
|
+
cleanupArtifact,
|
|
144
|
+
context: identityDecisionApplyContext,
|
|
145
|
+
});
|
|
146
|
+
const requirePatchCollectReport = options.requirePatchCollectReport === true ||
|
|
147
|
+
options.requirePatchCollectReport === "true" ||
|
|
148
|
+
(Boolean(fullContextRequirement) &&
|
|
149
|
+
!hasClassificationDecisionProof &&
|
|
150
|
+
!hasLocationDecisionProof &&
|
|
151
|
+
!hasIdentityDecisionProof &&
|
|
152
|
+
sourceContactRewriteSemanticEvidenceEntries <= 0);
|
|
153
|
+
if (!rowsFile || !fileExists(rowsFile)) {
|
|
154
|
+
throw new Error("--rows-file is required and must point to JSON/JSONL write-candidate rows.");
|
|
155
|
+
}
|
|
156
|
+
if (!schemaReportArtifact) {
|
|
157
|
+
throw new Error("--schema-report is required for mutation manifest generation.");
|
|
158
|
+
}
|
|
159
|
+
const rows = readRows(rowsFile);
|
|
160
|
+
const referenceRows = readRowsIfExists(referenceRowsFile);
|
|
161
|
+
const schemaRows = mapSchemaRows(schemaReportArtifact.value);
|
|
162
|
+
const curationEntities = mapCurationEntities(curationGateArtifact?.value);
|
|
163
|
+
const writeRows = mapRowsByIdentity(rows, datasetType);
|
|
164
|
+
const writeCandidateKeys = new Set(writeRows.keys());
|
|
165
|
+
const sourceReferenceRewriteContext = readSourceReferenceRewriteContext({
|
|
166
|
+
repoRoot: root,
|
|
167
|
+
rowsFile,
|
|
168
|
+
options,
|
|
169
|
+
writeRows,
|
|
170
|
+
});
|
|
171
|
+
const identityReferenceRewriteContext = readIdentityReferenceRewriteContext({
|
|
172
|
+
repoRoot: root,
|
|
173
|
+
rowsFile,
|
|
174
|
+
options,
|
|
175
|
+
writeRows,
|
|
176
|
+
referenceRows,
|
|
177
|
+
datasetType,
|
|
178
|
+
});
|
|
179
|
+
const verifiedReferenceProof = verifiedReferenceLedgerProof(root, options);
|
|
180
|
+
const plannedRootKeys = plannedRootReferenceKeys(rows, datasetType);
|
|
181
|
+
const plannedRootIds = plannedRootReferenceIds(rows, datasetType);
|
|
182
|
+
const remoteVerifyBlockers = remoteVerifyBlockerKeys(remoteVerifyArtifact?.value, {
|
|
183
|
+
plannedRootKeys,
|
|
184
|
+
plannedRootIds,
|
|
185
|
+
});
|
|
186
|
+
const patchApplyContext = patchApplyArtifact || patchEvidenceFile
|
|
187
|
+
? readPatchApplyContext(root, patchApplyArtifact, patchEvidenceFile)
|
|
188
|
+
: null;
|
|
189
|
+
const evidenceScopeBlockers = buildEvidenceScopeBlockers({
|
|
190
|
+
repoRoot: root,
|
|
191
|
+
rowsFile,
|
|
192
|
+
schemaReportArtifact,
|
|
193
|
+
curationGateArtifact,
|
|
194
|
+
dryRunReportArtifact,
|
|
195
|
+
cleanupArtifact,
|
|
196
|
+
patchApplyArtifact,
|
|
197
|
+
patchApplyContext,
|
|
198
|
+
patchCollectArtifact,
|
|
199
|
+
requirePatchCollectReport,
|
|
200
|
+
remoteVerifyArtifact,
|
|
201
|
+
identityDecisionApplyContext,
|
|
202
|
+
requireCurationGate: options.requireCurationGate === undefined
|
|
203
|
+
? !(datasetType === "support" || supportDatasetTypes.has(datasetType))
|
|
204
|
+
: options.requireCurationGate === true || options.requireCurationGate === "true",
|
|
205
|
+
identityReferenceRewriteContext,
|
|
206
|
+
unresolvedExchangeExternalizationContext,
|
|
207
|
+
canonicalSupportRewriteContext,
|
|
208
|
+
});
|
|
209
|
+
evidenceScopeBlockers.push(...buildFullContextAiCompletionBlockers({
|
|
210
|
+
repoRoot: root,
|
|
211
|
+
profile,
|
|
212
|
+
datasetType,
|
|
213
|
+
curationGateArtifact,
|
|
214
|
+
rowsFile,
|
|
215
|
+
patchApplyArtifact,
|
|
216
|
+
patchApplyContext: patchApplyContext,
|
|
217
|
+
patchCollectArtifact,
|
|
218
|
+
cleanupArtifact,
|
|
219
|
+
classificationDecisionApplyArtifact,
|
|
220
|
+
classificationDecisionApplyContext: classificationDecisionApplyContext,
|
|
221
|
+
locationDecisionApplyArtifact,
|
|
222
|
+
locationDecisionApplyContext: locationDecisionApplyContext,
|
|
223
|
+
identityDecisionApplyArtifact,
|
|
224
|
+
identityDecisionApplyContext,
|
|
225
|
+
identityReferenceRewriteContext: identityReferenceRewriteContext,
|
|
226
|
+
unresolvedExchangeExternalizationContext: unresolvedExchangeExternalizationContext,
|
|
227
|
+
sourceContactRewriteContext: sourceContactRewriteContext,
|
|
228
|
+
canonicalSupportRewriteContext: canonicalSupportRewriteContext,
|
|
229
|
+
cleanupContext: cleanupContext,
|
|
230
|
+
}));
|
|
231
|
+
evidenceScopeBlockers.push(...buildReferenceClosureBlockers({
|
|
232
|
+
repoRoot: root,
|
|
233
|
+
rows,
|
|
234
|
+
datasetType,
|
|
235
|
+
remoteVerifyArtifact,
|
|
236
|
+
provenReferenceKeys: new Set([
|
|
237
|
+
...identityReferenceRewriteProofKeys(identityReferenceRewriteContext),
|
|
238
|
+
...sourceReferenceRewriteProofKeys(sourceReferenceRewriteContext),
|
|
239
|
+
// FIX C: true sources the source/contact-rewrite stage committed into THIS
|
|
240
|
+
// scope's support set (including review-report sources defensively harvested
|
|
241
|
+
// even when their kind did not classify as true_source). The first
|
|
242
|
+
// process.finalize must pass closure for these once they are in the support
|
|
243
|
+
// commit. Only sources actually committed by that stage are surfaced here, so
|
|
244
|
+
// this cannot loosen closure for any source not in the scope's support set.
|
|
245
|
+
...sourceContactSupportTrueSourceProofKeys(sourceContactRewriteContext),
|
|
246
|
+
// CLASS 1 fix: a minted (account-local) Flow Property whose reference Unit Group
|
|
247
|
+
// is a public canonical UG keeps the canonical UG as a remote reference (the
|
|
248
|
+
// FP's referenceToReferenceUnitGroup was rewritten to the canonical published
|
|
249
|
+
// version, and the canonical UG is never written). Prove that canonical UG
|
|
250
|
+
// id@published-version so closure passes for the FP->UG edge without writing the
|
|
251
|
+
// UG. Only UGs the source/contact-rewrite stage proved against the canonical
|
|
252
|
+
// support cache are surfaced, so this cannot prove a non-canonical UG.
|
|
253
|
+
...sourceContactSupportCanonicalUnitGroupProofKeys(sourceContactRewriteContext),
|
|
254
|
+
// Direct references to the well-known public canonical sources (ILCD
|
|
255
|
+
// format + compliance-system) are always reusable from remote, even when
|
|
256
|
+
// they were not produced by an in-scope rewrite mapping — e.g. minted
|
|
257
|
+
// account-local FP/UG (P1a) reference the canonical compliance source
|
|
258
|
+
// directly. Without this, their closure blocked on a source that is in
|
|
259
|
+
// fact a fixed public canonical dataset.
|
|
260
|
+
...publicCanonicalSourceReferenceKeys,
|
|
261
|
+
...verifiedReferenceProof.keys,
|
|
262
|
+
]),
|
|
263
|
+
unresolvedReferenceKeys: identityDecisionUnresolvedReferenceKeys(identityDecisionApplyContext),
|
|
264
|
+
allowAccountLocalSupportAndElementary: taskAuthorizationAllows(profile.authorization, "flowproperty_write") &&
|
|
265
|
+
taskAuthorizationAllows(profile.authorization, "unitgroup_write"),
|
|
266
|
+
}));
|
|
267
|
+
if (dryRunReportArtifact?.value?.mode === "commit" ||
|
|
268
|
+
dryRunReportArtifact?.value?.commit === true) {
|
|
269
|
+
evidenceScopeBlockers.push(evidenceScopeBlocker({
|
|
270
|
+
code: "dry_run_report_is_commit_report",
|
|
271
|
+
stage: "dry_run",
|
|
272
|
+
message: "dataset-mutation-manifest --dry-run-report must point to a dry-run summary, not a commit summary. Keep commit reports as post-write evidence alongside dataset verify-remote.",
|
|
273
|
+
report: dryRunReportArtifact.path,
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
const dryRun = {
|
|
277
|
+
flow: datasetType === "flow" && dryRunReportArtifact
|
|
278
|
+
? readFlowDryRunArtifacts(root, dryRunReportArtifact.value)
|
|
279
|
+
: null,
|
|
280
|
+
process: datasetType === "process" && dryRunReportArtifact
|
|
281
|
+
? readProcessDryRunArtifacts(root, dryRunReportArtifact.value)
|
|
282
|
+
: null,
|
|
283
|
+
lifecyclemodel: datasetType === "lifecyclemodel" && dryRunReportArtifact
|
|
284
|
+
? readLifecyclemodelDryRunArtifacts(root, dryRunReportArtifact.value)
|
|
285
|
+
: null,
|
|
286
|
+
datasetSaveDraft: (datasetType === "support" || supportDatasetTypes.has(datasetType)) && dryRunReportArtifact
|
|
287
|
+
? readDatasetSaveDraftDryRunArtifacts(root, dryRunReportArtifact.value)
|
|
288
|
+
: null,
|
|
289
|
+
};
|
|
290
|
+
const writeEntries = [...writeRows.values()];
|
|
291
|
+
for (const entry of writeEntries) {
|
|
292
|
+
entry.identity.sourceRowsFile =
|
|
293
|
+
repoRelativePath(root, rowsFile);
|
|
294
|
+
}
|
|
295
|
+
const writeItems = writeEntries.map(({ row, identity, index }) => {
|
|
296
|
+
const itemDatasetType = identity.dataset_type || datasetType;
|
|
297
|
+
const key = identityKey(identity);
|
|
298
|
+
return buildWriteCandidateItem({
|
|
299
|
+
repoRoot: root,
|
|
300
|
+
datasetType: itemDatasetType,
|
|
301
|
+
row,
|
|
302
|
+
identity,
|
|
303
|
+
rowIndex: index,
|
|
304
|
+
schemaRow: schemaRows.get(key) ?? schemaRows.get(identity.id) ?? null,
|
|
305
|
+
curationEntity: curationEntities.get(key) ?? curationEntities.get(identity.id) ?? null,
|
|
306
|
+
curationWaivedQaCodes: ensureArray(asRecord(curationGateArtifact?.value?.policy).waived_qa_codes),
|
|
307
|
+
curationGateProvided: Boolean(curationGateArtifact),
|
|
308
|
+
dryRun,
|
|
309
|
+
remoteVerifyBlockers,
|
|
310
|
+
targetUserId,
|
|
311
|
+
cleanupStatus: cleanupArtifact?.value?.status ?? "not_provided",
|
|
312
|
+
patchApplyContext: patchApplyContext,
|
|
313
|
+
sourceReferenceRewritesByKey: sourceReferenceRewriteContext.byIdentity,
|
|
314
|
+
identityReferenceRewritesByKey: identityReferenceRewriteContext.byIdentity,
|
|
315
|
+
identityDecisionApplyContext,
|
|
316
|
+
cleanupContext: cleanupContext,
|
|
317
|
+
evidenceScopeBlockers,
|
|
318
|
+
allowAccountLocalSupportAndElementary: itemDatasetType === "flow"
|
|
319
|
+
? taskAuthorizationAllows(profile.authorization, "elementary_flow_write")
|
|
320
|
+
: itemDatasetType === "flowproperty"
|
|
321
|
+
? taskAuthorizationAllows(profile.authorization, "flowproperty_write") &&
|
|
322
|
+
taskAuthorizationAllows(profile.authorization, "canonical_support_local_mint")
|
|
323
|
+
: itemDatasetType === "unitgroup"
|
|
324
|
+
? taskAuthorizationAllows(profile.authorization, "unitgroup_write") &&
|
|
325
|
+
taskAuthorizationAllows(profile.authorization, "canonical_support_local_mint")
|
|
326
|
+
: false,
|
|
327
|
+
profile,
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
const referenceItems = buildReferenceReuseItems({
|
|
331
|
+
repoRoot: root,
|
|
332
|
+
datasetType,
|
|
333
|
+
rows: referenceRows,
|
|
334
|
+
writeCandidateKeys,
|
|
335
|
+
identityReferenceRewritesByKey: identityReferenceRewriteContext.byIdentity,
|
|
336
|
+
});
|
|
337
|
+
const items = [...writeItems, ...referenceItems];
|
|
338
|
+
const unresolvedTraceItems = items.flatMap((item) => ensureArray(item?.foundry_traces?.unresolved_traces));
|
|
339
|
+
const unresolvedExchangeTraceItems = items.flatMap((item) => ensureArray(item?.foundry_traces?.unresolved_exchange_traces));
|
|
340
|
+
const sourceExchangeCompletenessItems = items.flatMap((item) => ensureArray(item?.foundry_traces?.source_exchange_completeness));
|
|
341
|
+
const blockerCount = items.reduce((total, item) => total + item.blockers.length, 0);
|
|
342
|
+
const cleanupStatus = cleanupArtifact?.value?.status ?? "not_provided";
|
|
343
|
+
const remoteVerifyStatus = remoteVerifyArtifact?.value?.status ?? "not_provided";
|
|
344
|
+
const status = blockerCount > 0
|
|
345
|
+
? "blocked"
|
|
346
|
+
: writeItems.length > 0
|
|
347
|
+
? "ready_for_remote_write"
|
|
348
|
+
: "ready_reference_only";
|
|
349
|
+
const readyWriteRows = status === "ready_for_remote_write"
|
|
350
|
+
? writeEntries
|
|
351
|
+
.filter((entry, index) => {
|
|
352
|
+
const item = writeItems[index];
|
|
353
|
+
return item?.decision === "write_or_update" && item.blockers.length === 0;
|
|
354
|
+
})
|
|
355
|
+
.map((entry) => entry.row)
|
|
356
|
+
: [];
|
|
357
|
+
const blockedWriteRows = writeEntries
|
|
358
|
+
.filter((entry, index) => writeItems[index]?.blockers.length > 0)
|
|
359
|
+
.map((entry) => entry.row);
|
|
360
|
+
const usesQaWaivers = writeEntries.some(({ identity }) => {
|
|
361
|
+
const entity = curationEntities.get(identityKey(identity)) ?? curationEntities.get(identity.id);
|
|
362
|
+
return (entity?.status === "ready_with_profile_waivers" ||
|
|
363
|
+
Number(entity?.waived_finding_count ?? 0) > 0);
|
|
364
|
+
});
|
|
365
|
+
const report = {
|
|
366
|
+
schema_version: 1,
|
|
367
|
+
generated_at_utc: nowIso(),
|
|
368
|
+
status,
|
|
369
|
+
profile: profile.id,
|
|
370
|
+
profile_rules_sha256: profile.rulesSha256,
|
|
371
|
+
...(usesQaWaivers
|
|
372
|
+
? {
|
|
373
|
+
required_qa_waiver_codes: ensureArray(asRecord(curationGateArtifact?.value?.policy).waived_qa_codes),
|
|
374
|
+
}
|
|
375
|
+
: {}),
|
|
376
|
+
dataset_type: datasetType,
|
|
377
|
+
rows_file: repoRelativePath(root, rowsFile),
|
|
378
|
+
reference_rows_file: referenceRowsFile && fileExists(referenceRowsFile)
|
|
379
|
+
? repoRelativePath(root, referenceRowsFile)
|
|
380
|
+
: null,
|
|
381
|
+
target_user_id: targetUserId || null,
|
|
382
|
+
policy_snapshots: readPolicySnapshots(root, profile),
|
|
383
|
+
evidence: {
|
|
384
|
+
schema_report: repoRelativePath(root, schemaReportArtifact.path),
|
|
385
|
+
curation_gate_report: curationGateArtifact
|
|
386
|
+
? repoRelativePath(root, curationGateArtifact.path)
|
|
387
|
+
: null,
|
|
388
|
+
cleanup_report: cleanupArtifact ? repoRelativePath(root, cleanupArtifact.path) : null,
|
|
389
|
+
cleanup_status: cleanupStatus,
|
|
390
|
+
patch_apply_report: patchApplyArtifact
|
|
391
|
+
? repoRelativePath(root, patchApplyArtifact.path)
|
|
392
|
+
: null,
|
|
393
|
+
patch_apply_status: patchApplyContext?.status ?? "not_provided",
|
|
394
|
+
patch_collect_report: patchCollectArtifact
|
|
395
|
+
? repoRelativePath(root, patchCollectArtifact.path)
|
|
396
|
+
: null,
|
|
397
|
+
patch_collect_status: patchCollectArtifact?.value?.status ?? "not_provided",
|
|
398
|
+
patch_collect_required: requirePatchCollectReport,
|
|
399
|
+
patch_evidence_file: patchApplyContext?.evidenceFile
|
|
400
|
+
? repoRelativePath(root, patchApplyContext.evidenceFile)
|
|
401
|
+
: null,
|
|
402
|
+
patch_evidence_count: patchApplyContext?.evidenceRows.length ?? 0,
|
|
403
|
+
classification_decision_apply_report: classificationDecisionApplyArtifact
|
|
404
|
+
? repoRelativePath(root, classificationDecisionApplyArtifact.path)
|
|
405
|
+
: null,
|
|
406
|
+
classification_decision_apply_status: classificationDecisionApplyContext?.status ?? "not_provided",
|
|
407
|
+
classification_decision_count: classificationDecisionApplyContext?.decisions.length ?? 0,
|
|
408
|
+
classification_decision_task: classificationDecisionApplyContext?.decisionTaskProof?.path ?? null,
|
|
409
|
+
classification_decision_tasks: classificationDecisionApplyContext?.decisionTaskProofs?.map((proof) => proof.path) ?? [],
|
|
410
|
+
classification_decision_context_bundle_sha256: classificationDecisionApplyContext?.decisionTaskProof?.context_bundle_sha256 ?? null,
|
|
411
|
+
classification_decision_context_bundle_sha256s: decisionTaskContextBundleHashesFromContext(classificationDecisionApplyContext),
|
|
412
|
+
location_decision_apply_report: locationDecisionApplyArtifact
|
|
413
|
+
? repoRelativePath(root, locationDecisionApplyArtifact.path)
|
|
414
|
+
: null,
|
|
415
|
+
location_decision_apply_status: locationDecisionApplyContext?.status ?? "not_provided",
|
|
416
|
+
location_decision_count: locationDecisionApplyContext?.decisions.length ?? 0,
|
|
417
|
+
location_decision_task: locationDecisionApplyContext?.decisionTaskProof?.path ?? null,
|
|
418
|
+
location_decision_tasks: locationDecisionApplyContext?.decisionTaskProofs?.map((proof) => proof.path) ?? [],
|
|
419
|
+
location_decision_context_bundle_sha256: locationDecisionApplyContext?.decisionTaskProof?.context_bundle_sha256 ?? null,
|
|
420
|
+
location_decision_context_bundle_sha256s: decisionTaskContextBundleHashesFromContext(locationDecisionApplyContext),
|
|
421
|
+
identity_decision_apply_report: identityDecisionApplyArtifact
|
|
422
|
+
? repoRelativePath(root, identityDecisionApplyArtifact.path)
|
|
423
|
+
: null,
|
|
424
|
+
identity_decision_apply_reports: identityDecisionApplyArtifacts.map((artifact) => repoRelativePath(root, artifact.path)),
|
|
425
|
+
identity_decision_apply_status: identityDecisionApplyContext?.status ?? "not_provided",
|
|
426
|
+
identity_decision_count: identityDecisionApplyContext?.decisions.length ?? 0,
|
|
427
|
+
identity_decision_authoring_packages: identityDecisionApplyContext?.authoringPackageProofs.map((proof) => asRecord(proof).path) ??
|
|
428
|
+
[],
|
|
429
|
+
dry_run_report: dryRunReportArtifact
|
|
430
|
+
? repoRelativePath(root, dryRunReportArtifact.path)
|
|
431
|
+
: null,
|
|
432
|
+
remote_verify_report: remoteVerifyArtifact
|
|
433
|
+
? repoRelativePath(root, remoteVerifyArtifact.path)
|
|
434
|
+
: null,
|
|
435
|
+
remote_verify_status: remoteVerifyStatus,
|
|
436
|
+
canonical_support_rewrite_report: canonicalSupportRewriteContext?.reportPathRelative ?? null,
|
|
437
|
+
canonical_support_rewrite_status: canonicalSupportRewriteContext?.status ?? "not_provided",
|
|
438
|
+
canonical_support_rewrite_input_rows: canonicalSupportRewriteContext?.inputRowsFileRelative ?? null,
|
|
439
|
+
canonical_support_rewrite_output_rows: canonicalSupportRewriteContext?.outputRowsFileRelative ?? null,
|
|
440
|
+
canonical_support_rewrite_deferred_rows: canonicalSupportRewriteContext?.deferredRowsFileRelative ?? null,
|
|
441
|
+
canonical_support_rewrite_input_row_count: canonicalSupportRewriteContext?.counts?.input_rows ?? null,
|
|
442
|
+
canonical_support_rewrite_output_row_count: canonicalSupportRewriteContext?.counts?.output_rows ?? null,
|
|
443
|
+
canonical_support_rewrite_deferred_row_count: canonicalSupportRewriteContext?.counts?.deferred_rows ?? 0,
|
|
444
|
+
canonical_support_rewrite_blockers: canonicalSupportRewriteContext?.blockers.length ?? 0,
|
|
445
|
+
canonical_support_rewrite_deferred_blockers: canonicalSupportRewriteContext?.deferredBlockers.length ?? 0,
|
|
446
|
+
unresolved_exchange_externalization_report: unresolvedExchangeExternalizationContext?.reportPathRelative ?? null,
|
|
447
|
+
unresolved_exchange_externalization_status: unresolvedExchangeExternalizationContext?.status ?? "not_provided",
|
|
448
|
+
unresolved_exchange_externalized_count: unresolvedExchangeExternalizationContext?.externalizedExchanges ?? 0,
|
|
449
|
+
unresolved_exchange_externalization_input_rows_file: unresolvedExchangeExternalizationContext?.inputRowsFileRelative ?? null,
|
|
450
|
+
unresolved_exchange_externalization_output_rows_file: unresolvedExchangeExternalizationContext?.outputRowsFileRelative ?? null,
|
|
451
|
+
unresolved_exchange_externalization_traces_file: unresolvedExchangeExternalizationContext?.tracesFileRelative ?? null,
|
|
452
|
+
source_reference_rewrites_file: sourceReferenceRewriteContext.sourceFile &&
|
|
453
|
+
sourceReferenceRewriteContext.sourceRows.length > 0
|
|
454
|
+
? repoRelativePath(root, sourceReferenceRewriteContext.sourceFile)
|
|
455
|
+
: null,
|
|
456
|
+
identity_reference_rewrites_file: identityReferenceRewriteContext.sourceFile &&
|
|
457
|
+
identityReferenceRewriteContext.sourceRows.length > 0
|
|
458
|
+
? repoRelativePath(root, identityReferenceRewriteContext.sourceFile)
|
|
459
|
+
: null,
|
|
460
|
+
verified_reference_ledger_files: verifiedReferenceProof.files,
|
|
461
|
+
verified_reference_ledger_rows: verifiedReferenceProof.rows,
|
|
462
|
+
verified_reference_ledger_proven_keys: verifiedReferenceProof.proven_keys,
|
|
463
|
+
full_context_ai_completion_required: Boolean(fullContextRequirement),
|
|
464
|
+
full_context_ai_completion_proof: fullContextRequirement?.proof ?? null,
|
|
465
|
+
scope_blockers: evidenceScopeBlockers,
|
|
466
|
+
},
|
|
467
|
+
counts: {
|
|
468
|
+
write_candidates: readyWriteRows.length,
|
|
469
|
+
planned_write_candidates: writeItems.length,
|
|
470
|
+
blocked_write_candidates: blockedWriteRows.length,
|
|
471
|
+
reference_reuse: referenceItems.filter((item) => item.decision === "reuse_existing_reference")
|
|
472
|
+
.length,
|
|
473
|
+
covered_by_write_candidate: referenceItems.filter((item) => item.decision === "covered_by_write_candidate").length,
|
|
474
|
+
blocked_items: items.filter((item) => item.blockers.length > 0).length,
|
|
475
|
+
blockers: blockerCount,
|
|
476
|
+
decisions: decisionCounts(items),
|
|
477
|
+
operations: operationCounts(items),
|
|
478
|
+
ai_patch_evidence_entries: writeItems.reduce((total, item) => total + item.ai_patch_evidence_count, 0),
|
|
479
|
+
ai_classification_decision_entries: classificationDecisionApplyContext?.decisions.length ?? 0,
|
|
480
|
+
ai_location_decision_entries: locationDecisionApplyContext?.decisions.length ?? 0,
|
|
481
|
+
ai_identity_decision_entries: identityDecisionApplyContext?.decisions.length ?? 0,
|
|
482
|
+
source_contact_rewrite_semantic_evidence_entries: sourceContactRewriteSemanticEvidenceEntries,
|
|
483
|
+
unresolved_trace_entries: unresolvedTraceItems.length,
|
|
484
|
+
unresolved_exchange_trace_entries: unresolvedExchangeTraceItems.length,
|
|
485
|
+
source_exchange_completeness_entries: sourceExchangeCompletenessItems.length,
|
|
486
|
+
source_reference_rewrites: sourceReferenceRewriteContext.scopedRows.length,
|
|
487
|
+
identity_reference_rewrites: identityReferenceRewriteContext.scopedRows.length,
|
|
488
|
+
verified_reference_ledger_rows: verifiedReferenceProof.rows,
|
|
489
|
+
verified_reference_ledger_proven_keys: verifiedReferenceProof.proven_keys,
|
|
490
|
+
identity_reference_reuse_rows: referenceItems.filter((item) => item.identity_reference_rewrite_count > 0).length,
|
|
491
|
+
unresolved_exchange_externalized: unresolvedExchangeExternalizationContext?.externalizedExchanges ?? 0,
|
|
492
|
+
},
|
|
493
|
+
items,
|
|
494
|
+
};
|
|
495
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
496
|
+
const reportPath = path.join(outDir, "dataset-mutation-manifest.json");
|
|
497
|
+
const itemsPath = path.join(outDir, "dataset-mutation-manifest-items.jsonl");
|
|
498
|
+
const writeRowsPath = path.join(outDir, `${datasetTypePlural[datasetType]}.write-candidates.jsonl`);
|
|
499
|
+
const blockedWriteRowsPath = path.join(outDir, `${datasetTypePlural[datasetType]}.blocked-write-candidates.jsonl`);
|
|
500
|
+
const referenceRowsPath = path.join(outDir, `${datasetTypePlural[datasetType]}.reference-reuse.jsonl`);
|
|
501
|
+
const unresolvedTracesPath = path.join(outDir, "unresolved-traces.jsonl");
|
|
502
|
+
const unresolvedExchangeTracesPath = path.join(outDir, "unresolved-exchange-traces.jsonl");
|
|
503
|
+
const sourceExchangeCompletenessPath = path.join(outDir, "source-exchange-completeness-traces.jsonl");
|
|
504
|
+
const sourceReferenceRewritesPath = path.join(outDir, "source-reference-rewrites.jsonl");
|
|
505
|
+
const identityReferenceRewritesPath = path.join(outDir, "identity-reference-rewrites.jsonl");
|
|
506
|
+
const files = {
|
|
507
|
+
report: repoRelativePath(root, reportPath),
|
|
508
|
+
items: repoRelativePath(root, itemsPath),
|
|
509
|
+
write_candidates: repoRelativePath(root, writeRowsPath),
|
|
510
|
+
blocked_write_candidates: repoRelativePath(root, blockedWriteRowsPath),
|
|
511
|
+
reference_reuse: repoRelativePath(root, referenceRowsPath),
|
|
512
|
+
unresolved_traces: repoRelativePath(root, unresolvedTracesPath),
|
|
513
|
+
source_exchange_completeness_traces: repoRelativePath(root, sourceExchangeCompletenessPath),
|
|
514
|
+
source_reference_rewrites: repoRelativePath(root, sourceReferenceRewritesPath),
|
|
515
|
+
identity_reference_rewrites: repoRelativePath(root, identityReferenceRewritesPath),
|
|
516
|
+
unresolved_exchange_externalization_report: unresolvedExchangeExternalizationContext?.reportPathRelative ?? null,
|
|
517
|
+
unresolved_exchange_traces: unresolvedExchangeExternalizationContext?.tracesFileRelative ?? null,
|
|
518
|
+
};
|
|
519
|
+
// `items` can be enormous for mega-scopes (thousands of flow mutations); embedding
|
|
520
|
+
// it inline here overflows JSON.stringify's max string length (RangeError: Invalid
|
|
521
|
+
// string length) and aborts the finalize stage. It is persisted verbatim to the
|
|
522
|
+
// items JSONL (files.items) and stays on the in-memory return value for in-process
|
|
523
|
+
// consumers, so omit the redundant inline copy from the written report file.
|
|
524
|
+
const { items: _omitInlineItems, ...reportWithoutItems } = report;
|
|
525
|
+
writeJson(reportPath, { ...reportWithoutItems, files });
|
|
526
|
+
// Stream these JSONL writes: mega-scopes (1000+ flow mutations) produce row sets
|
|
527
|
+
// whose JSON.stringify-joined form exceeds V8's max string length, so build them
|
|
528
|
+
// line-by-line on disk instead of as one in-memory string.
|
|
529
|
+
writeJsonLines(itemsPath, items);
|
|
530
|
+
writeJsonLines(writeRowsPath, readyWriteRows);
|
|
531
|
+
writeJsonLines(blockedWriteRowsPath, blockedWriteRows);
|
|
532
|
+
writeJsonLines(referenceRowsPath, referenceRows);
|
|
533
|
+
writeJsonLines(unresolvedTracesPath, unresolvedTraceItems);
|
|
534
|
+
writeJsonLines(unresolvedExchangeTracesPath, unresolvedExchangeTraceItems);
|
|
535
|
+
writeJsonLines(sourceExchangeCompletenessPath, sourceExchangeCompletenessItems);
|
|
536
|
+
writeJsonLines(sourceReferenceRewritesPath, sourceReferenceRewriteContext.scopedRows);
|
|
537
|
+
writeJsonLines(identityReferenceRewritesPath, identityReferenceRewriteContext.scopedRows);
|
|
538
|
+
return {
|
|
539
|
+
...report,
|
|
540
|
+
files,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface JsonRecord {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
}
|
|
4
|
+
interface PatchCollectOptions extends JsonRecord {
|
|
5
|
+
help?: unknown;
|
|
6
|
+
taskManifest?: string | null;
|
|
7
|
+
manifest?: string | null;
|
|
8
|
+
input?: string | null;
|
|
9
|
+
outDir?: string | null;
|
|
10
|
+
out?: string | null;
|
|
11
|
+
patchOut?: string | null;
|
|
12
|
+
}
|
|
13
|
+
interface PatchCollectArgs {
|
|
14
|
+
repoRoot?: string;
|
|
15
|
+
options?: PatchCollectOptions;
|
|
16
|
+
}
|
|
17
|
+
export declare function runDatasetAuthoringPatchCollect({ repoRoot, options, }?: PatchCollectArgs): JsonRecord;
|
|
18
|
+
export {};
|