@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,169 @@
|
|
|
1
|
+
function rootKey(table, id, version) {
|
|
2
|
+
return `${String(table ?? "")}:${String(id ?? "")}@${String(version ?? "")}`;
|
|
3
|
+
}
|
|
4
|
+
function canonicalJsonValue(value) {
|
|
5
|
+
if (Array.isArray(value))
|
|
6
|
+
return value.map(canonicalJsonValue);
|
|
7
|
+
if (!value || typeof value !== "object")
|
|
8
|
+
return value;
|
|
9
|
+
return Object.fromEntries(Object.keys(value)
|
|
10
|
+
.sort()
|
|
11
|
+
.map((key) => [key, canonicalJsonValue(value[key])]));
|
|
12
|
+
}
|
|
13
|
+
export function canonicalPayloadSha256(value) {
|
|
14
|
+
return createHash("sha256")
|
|
15
|
+
.update(JSON.stringify(canonicalJsonValue(value)))
|
|
16
|
+
.digest("hex");
|
|
17
|
+
}
|
|
18
|
+
function stringArray(value) {
|
|
19
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : null;
|
|
20
|
+
}
|
|
21
|
+
function sameStrings(left, right) {
|
|
22
|
+
return (left.length === right.length &&
|
|
23
|
+
[...left].sort().every((value, index) => value === [...right].sort()[index]));
|
|
24
|
+
}
|
|
25
|
+
function acceptedTraceHashPayloadMatches(root, check, allowed) {
|
|
26
|
+
if (!allowed ||
|
|
27
|
+
!root.acceptedNormalizedPayloadSha256 ||
|
|
28
|
+
!Array.isArray(root.acceptedNormalizedRemovedPaths) ||
|
|
29
|
+
root.acceptedNormalizedRemovedPaths.length === 0 ||
|
|
30
|
+
check.foundry_verification_mode !== "accepted_normalized_payload" ||
|
|
31
|
+
check.foundry_original_status !== "payload_mismatch" ||
|
|
32
|
+
check.local_payload_sha256 !== root.acceptedNormalizedPayloadSha256 ||
|
|
33
|
+
check.remote_payload_sha256 !== root.acceptedNormalizedPayloadSha256 ||
|
|
34
|
+
typeof check.foundry_original_local_payload_sha256 !== "string" ||
|
|
35
|
+
typeof check.foundry_original_remote_payload_sha256 !== "string" ||
|
|
36
|
+
!/^[a-f0-9]{64}$/u.test(check.foundry_original_local_payload_sha256) ||
|
|
37
|
+
!/^[a-f0-9]{64}$/u.test(check.foundry_original_remote_payload_sha256) ||
|
|
38
|
+
check.foundry_original_local_payload_sha256 !== root.payloadSha256 ||
|
|
39
|
+
check.foundry_original_local_payload_sha256 === check.foundry_original_remote_payload_sha256 ||
|
|
40
|
+
!Array.isArray(check.foundry_accepted_differences) ||
|
|
41
|
+
check.foundry_accepted_differences.length !== 1) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const evidence = check.foundry_accepted_differences[0];
|
|
45
|
+
if (!evidence || typeof evidence !== "object" || Array.isArray(evidence))
|
|
46
|
+
return false;
|
|
47
|
+
const record = evidence;
|
|
48
|
+
const localRemovedPaths = stringArray(record.local_removed_paths);
|
|
49
|
+
const remoteRemovedPaths = stringArray(record.remote_removed_paths);
|
|
50
|
+
return Boolean(record.accepted_difference === "tiangongfoundry_import_trace_summary_trace_hash_only" &&
|
|
51
|
+
record.normalized_payload_sha256 === root.acceptedNormalizedPayloadSha256 &&
|
|
52
|
+
record.original_local_payload_sha256 === check.foundry_original_local_payload_sha256 &&
|
|
53
|
+
record.original_remote_payload_sha256 === check.foundry_original_remote_payload_sha256 &&
|
|
54
|
+
localRemovedPaths?.length &&
|
|
55
|
+
remoteRemovedPaths?.length &&
|
|
56
|
+
sameStrings(localRemovedPaths, root.acceptedNormalizedRemovedPaths) &&
|
|
57
|
+
sameStrings(remoteRemovedPaths, root.acceptedNormalizedRemovedPaths));
|
|
58
|
+
}
|
|
59
|
+
export function validateUniqueRootReadbacks(input) {
|
|
60
|
+
const blockers = [];
|
|
61
|
+
const intendedByKey = new Map();
|
|
62
|
+
for (const root of input.intended) {
|
|
63
|
+
const key = rootKey(root.table, root.id, root.version);
|
|
64
|
+
if (intendedByKey.has(key)) {
|
|
65
|
+
blockers.push({
|
|
66
|
+
code: "intended_root_duplicate",
|
|
67
|
+
message: `Final rows contain duplicate intended root ${key}.`,
|
|
68
|
+
key,
|
|
69
|
+
row_index: root.rowIndex,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
intendedByKey.set(key, root);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const rootChecks = input.checks.filter((check) => check.role === "root" && String(check.path ?? "").endsWith("#readback"));
|
|
77
|
+
const checksByKey = new Map();
|
|
78
|
+
for (const check of rootChecks) {
|
|
79
|
+
const key = rootKey(check.table, check.id, check.version);
|
|
80
|
+
if (!intendedByKey.has(key)) {
|
|
81
|
+
blockers.push({
|
|
82
|
+
code: "root_readback_unexpected",
|
|
83
|
+
message: `Readback contains an unexpected root ${key}.`,
|
|
84
|
+
key,
|
|
85
|
+
row_index: typeof check.row_index === "number" && Number.isInteger(check.row_index)
|
|
86
|
+
? check.row_index
|
|
87
|
+
: null,
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const matches = checksByKey.get(key) ?? [];
|
|
92
|
+
matches.push(check);
|
|
93
|
+
checksByKey.set(key, matches);
|
|
94
|
+
}
|
|
95
|
+
let uniqueReadbackCount = 0;
|
|
96
|
+
for (const [key, root] of intendedByKey) {
|
|
97
|
+
const matches = checksByKey.get(key) ?? [];
|
|
98
|
+
if (matches.length === 0) {
|
|
99
|
+
blockers.push({
|
|
100
|
+
code: "root_readback_missing",
|
|
101
|
+
message: `No root readback proves intended root ${key}.`,
|
|
102
|
+
key,
|
|
103
|
+
row_index: root.rowIndex,
|
|
104
|
+
});
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (matches.length !== 1) {
|
|
108
|
+
blockers.push({
|
|
109
|
+
code: "root_readback_duplicate",
|
|
110
|
+
message: `Root ${key} has ${matches.length} readback checks; expected exactly one.`,
|
|
111
|
+
key,
|
|
112
|
+
row_index: root.rowIndex,
|
|
113
|
+
});
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const check = matches[0];
|
|
117
|
+
uniqueReadbackCount += 1;
|
|
118
|
+
if (typeof check.row_index !== "number" ||
|
|
119
|
+
!Number.isInteger(check.row_index) ||
|
|
120
|
+
check.row_index !== root.rowIndex) {
|
|
121
|
+
blockers.push({
|
|
122
|
+
code: "root_readback_index_mismatch",
|
|
123
|
+
message: `Root ${key} readback row_index does not match the final rows index.`,
|
|
124
|
+
key,
|
|
125
|
+
row_index: typeof check.row_index === "number" && Number.isInteger(check.row_index)
|
|
126
|
+
? check.row_index
|
|
127
|
+
: null,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (check.status !== "ok") {
|
|
131
|
+
blockers.push({
|
|
132
|
+
code: "root_readback_status_not_ok",
|
|
133
|
+
message: `Root ${key} readback status is not ok.`,
|
|
134
|
+
key,
|
|
135
|
+
row_index: root.rowIndex,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const directPayloadMatch = check.local_payload_sha256 === root.payloadSha256 &&
|
|
139
|
+
check.remote_payload_sha256 === root.payloadSha256;
|
|
140
|
+
if (!directPayloadMatch &&
|
|
141
|
+
!acceptedTraceHashPayloadMatches(root, check, input.allowTraceHashOnlyNormalization === true)) {
|
|
142
|
+
blockers.push({
|
|
143
|
+
code: "root_readback_payload_mismatch",
|
|
144
|
+
message: `Root ${key} does not bind both local and remote hashes to the intended payload.`,
|
|
145
|
+
key,
|
|
146
|
+
row_index: root.rowIndex,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (check.remote_user_id !== input.targetUserId) {
|
|
150
|
+
blockers.push({
|
|
151
|
+
code: "root_readback_owner_mismatch",
|
|
152
|
+
message: `Root ${key} is not owned by the intended account.`,
|
|
153
|
+
key,
|
|
154
|
+
row_index: root.rowIndex,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (typeof check.remote_state_code !== "number" ||
|
|
158
|
+
check.remote_state_code !== input.expectedStateCode) {
|
|
159
|
+
blockers.push({
|
|
160
|
+
code: "root_readback_state_mismatch",
|
|
161
|
+
message: `Root ${key} is not in the intended state.`,
|
|
162
|
+
key,
|
|
163
|
+
row_index: root.rowIndex,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { blockers, uniqueReadbackCount };
|
|
168
|
+
}
|
|
169
|
+
import { createHash } from "node:crypto";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Display text only; authoritative canonical descriptions retain their JSON value. */
|
|
2
|
+
export function referenceDescriptionText(reference, asText) {
|
|
3
|
+
const value = reference;
|
|
4
|
+
const description = value?.["common:shortDescription"] ?? value?.shortDescription;
|
|
5
|
+
if (typeof description === "string")
|
|
6
|
+
return description.trim();
|
|
7
|
+
if (description && typeof description === "object" && !Array.isArray(description)) {
|
|
8
|
+
const item = description;
|
|
9
|
+
return asText(item["#text"] ?? item.value);
|
|
10
|
+
}
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type JsonRecord = Record<string, unknown>;
|
|
2
|
+
type CliGetResult = {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
payload?: JsonRecord | null;
|
|
5
|
+
command?: string | null;
|
|
6
|
+
executable?: string;
|
|
7
|
+
cli_package?: string | null;
|
|
8
|
+
exit_code?: number;
|
|
9
|
+
stdout_log?: string | null;
|
|
10
|
+
stderr_log?: string | null;
|
|
11
|
+
parsed?: JsonRecord | null;
|
|
12
|
+
error?: string | null;
|
|
13
|
+
};
|
|
14
|
+
type CliGet = (options: {
|
|
15
|
+
table: string;
|
|
16
|
+
id: string;
|
|
17
|
+
version: string;
|
|
18
|
+
outDir: string;
|
|
19
|
+
repoRoot: string;
|
|
20
|
+
}) => CliGetResult;
|
|
21
|
+
type AcceptedDiffResult = {
|
|
22
|
+
accepted: false;
|
|
23
|
+
reason: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
} | {
|
|
26
|
+
accepted: true;
|
|
27
|
+
verifyReportPath: string;
|
|
28
|
+
acceptanceReportPath: string;
|
|
29
|
+
evidence: JsonRecord[];
|
|
30
|
+
};
|
|
31
|
+
export declare function normalizeAllowedTraceHashDifference(payload: unknown): {
|
|
32
|
+
normalized: unknown;
|
|
33
|
+
removed_paths: string[];
|
|
34
|
+
normalized_sha256: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function acceptTraceHashOnlyRemoteVerificationMismatch({ verifyReportPath, outDir, repoRoot, runCliGet, }: {
|
|
37
|
+
verifyReportPath: string;
|
|
38
|
+
outDir: string;
|
|
39
|
+
repoRoot: string;
|
|
40
|
+
runCliGet?: CliGet;
|
|
41
|
+
}): AcceptedDiffResult;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { resolveTiangongLcaCliRuntimeCommand } from "./foundry-runtime-utils.js";
|
|
6
|
+
import { unwrapDatasetPayload } from "./import-curation/internal/dataset-payload.js";
|
|
7
|
+
function isJsonRecord(value) {
|
|
8
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function asJsonRecord(value) {
|
|
11
|
+
return isJsonRecord(value) ? value : {};
|
|
12
|
+
}
|
|
13
|
+
function isSupportedRootPayloadMismatch(value) {
|
|
14
|
+
return (value.code === "payload_mismatch" &&
|
|
15
|
+
value.role === "root" &&
|
|
16
|
+
typeof value.table === "string" &&
|
|
17
|
+
supportedRootTables.has(value.table));
|
|
18
|
+
}
|
|
19
|
+
const supportedRootTables = new Map([
|
|
20
|
+
["flows", { command: "flow", payloadKeys: ["flow", "payload"] }],
|
|
21
|
+
["processes", { command: "process", payloadKeys: ["process", "payload"] }],
|
|
22
|
+
]);
|
|
23
|
+
function nowIso() {
|
|
24
|
+
return new Date().toISOString();
|
|
25
|
+
}
|
|
26
|
+
function fileExists(filePath) {
|
|
27
|
+
return Boolean(filePath && fs.existsSync(filePath) && fs.statSync(filePath).isFile());
|
|
28
|
+
}
|
|
29
|
+
function readJson(filePath) {
|
|
30
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
31
|
+
}
|
|
32
|
+
function readJsonLines(filePath) {
|
|
33
|
+
if (!fileExists(filePath))
|
|
34
|
+
return [];
|
|
35
|
+
const text = fs.readFileSync(filePath, "utf8").trim();
|
|
36
|
+
return text
|
|
37
|
+
? text
|
|
38
|
+
.split(/\r?\n/u)
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.map((line) => JSON.parse(line))
|
|
41
|
+
: [];
|
|
42
|
+
}
|
|
43
|
+
function readRows(filePath) {
|
|
44
|
+
if (String(filePath).toLowerCase().endsWith(".jsonl"))
|
|
45
|
+
return readJsonLines(filePath);
|
|
46
|
+
const value = readJson(filePath);
|
|
47
|
+
if (Array.isArray(value))
|
|
48
|
+
return value;
|
|
49
|
+
if (isJsonRecord(value) && Array.isArray(value.rows))
|
|
50
|
+
return value.rows;
|
|
51
|
+
return [value];
|
|
52
|
+
}
|
|
53
|
+
function writeJson(filePath, value) {
|
|
54
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
55
|
+
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
56
|
+
}
|
|
57
|
+
function writeJsonLines(filePath, rows) {
|
|
58
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
59
|
+
fs.writeFileSync(filePath, rows.map((row) => JSON.stringify(row)).join("\n") + (rows.length ? "\n" : ""));
|
|
60
|
+
}
|
|
61
|
+
function repoRelative(repoRoot, filePath) {
|
|
62
|
+
if (!filePath)
|
|
63
|
+
return null;
|
|
64
|
+
return path.relative(repoRoot, filePath).split(path.sep).join(path.posix.sep);
|
|
65
|
+
}
|
|
66
|
+
function asText(value) {
|
|
67
|
+
if (value == null)
|
|
68
|
+
return "";
|
|
69
|
+
if (typeof value === "string" || typeof value === "number")
|
|
70
|
+
return String(value).trim();
|
|
71
|
+
if (Array.isArray(value))
|
|
72
|
+
return value.map(asText).filter(Boolean).join("; ");
|
|
73
|
+
if (typeof value === "object") {
|
|
74
|
+
const record = value;
|
|
75
|
+
return asText(record["#text"] ?? record.value ?? record.id);
|
|
76
|
+
}
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
function datasetIdentity(rowValue, table) {
|
|
80
|
+
const row = asJsonRecord(rowValue);
|
|
81
|
+
const type = table === "processes" ? "process" : table === "flows" ? "flow" : null;
|
|
82
|
+
const rootValue = type ? (row[`${type}DataSet`] ?? row) : row;
|
|
83
|
+
const root = asJsonRecord(rootValue);
|
|
84
|
+
const informationContainer = asJsonRecord(root[`${type}Information`]);
|
|
85
|
+
const information = asJsonRecord(informationContainer.dataSetInformation ?? informationContainer["common:dataSetInformation"]);
|
|
86
|
+
const administrativeInformation = asJsonRecord(root.administrativeInformation);
|
|
87
|
+
const publication = asJsonRecord(administrativeInformation.publicationAndOwnership ??
|
|
88
|
+
administrativeInformation["common:publicationAndOwnership"]);
|
|
89
|
+
return {
|
|
90
|
+
id: asText(information["common:UUID"]) ||
|
|
91
|
+
asText(information.UUID) ||
|
|
92
|
+
asText(row?.dataset_id) ||
|
|
93
|
+
asText(row?.id),
|
|
94
|
+
version: asText(publication["common:dataSetVersion"]) ||
|
|
95
|
+
asText(publication.dataSetVersion) ||
|
|
96
|
+
asText(row?.dataset_version) ||
|
|
97
|
+
asText(row?.version) ||
|
|
98
|
+
"00.00.001",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function parseJsonStdout(stdout) {
|
|
102
|
+
const text = String(stdout || "").trim();
|
|
103
|
+
if (!text)
|
|
104
|
+
return null;
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(text);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
const start = text.indexOf("{");
|
|
110
|
+
const end = text.lastIndexOf("}");
|
|
111
|
+
if (start >= 0 && end > start) {
|
|
112
|
+
try {
|
|
113
|
+
return JSON.parse(text.slice(start, end + 1));
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function stableJson(value) {
|
|
123
|
+
if (value == null || typeof value !== "object")
|
|
124
|
+
return JSON.stringify(value);
|
|
125
|
+
if (Array.isArray(value))
|
|
126
|
+
return `[${value.map(stableJson).join(",")}]`;
|
|
127
|
+
const record = asJsonRecord(value);
|
|
128
|
+
const keys = Object.keys(record).sort();
|
|
129
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`).join(",")}}`;
|
|
130
|
+
}
|
|
131
|
+
function sha256StableJson(value) {
|
|
132
|
+
return crypto.createHash("sha256").update(stableJson(value)).digest("hex");
|
|
133
|
+
}
|
|
134
|
+
function traceHashPath(pathParts) {
|
|
135
|
+
return `/${pathParts.join("/")}`;
|
|
136
|
+
}
|
|
137
|
+
function stripTraceHashFromImportTraceSummary(value, pathParts = [], removed = []) {
|
|
138
|
+
if (Array.isArray(value)) {
|
|
139
|
+
return value.map((entry, index) => stripTraceHashFromImportTraceSummary(entry, [...pathParts, String(index)], removed));
|
|
140
|
+
}
|
|
141
|
+
if (!isJsonRecord(value))
|
|
142
|
+
return value;
|
|
143
|
+
const output = {};
|
|
144
|
+
for (const [key, child] of Object.entries(value)) {
|
|
145
|
+
if (key === "tiangongfoundry:importTraceSummary") {
|
|
146
|
+
output[key] = stripTraceHashValue(child, [...pathParts, key], removed);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
output[key] = stripTraceHashFromImportTraceSummary(child, [...pathParts, key], removed);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return output;
|
|
153
|
+
}
|
|
154
|
+
function stripTraceHashValue(value, pathParts, removed) {
|
|
155
|
+
if (Array.isArray(value)) {
|
|
156
|
+
return value.map((entry, index) => stripTraceHashValue(entry, [...pathParts, String(index)], removed));
|
|
157
|
+
}
|
|
158
|
+
if (!isJsonRecord(value))
|
|
159
|
+
return value;
|
|
160
|
+
const output = {};
|
|
161
|
+
for (const [key, child] of Object.entries(value)) {
|
|
162
|
+
if (key === "traceHash") {
|
|
163
|
+
removed.push(traceHashPath([...pathParts, key]));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
output[key] = stripTraceHashFromImportTraceSummary(child, [...pathParts, key], removed);
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
169
|
+
}
|
|
170
|
+
export function normalizeAllowedTraceHashDifference(payload) {
|
|
171
|
+
const removed_paths = [];
|
|
172
|
+
const normalized = stripTraceHashFromImportTraceSummary(payload, [], removed_paths);
|
|
173
|
+
return {
|
|
174
|
+
normalized,
|
|
175
|
+
removed_paths,
|
|
176
|
+
normalized_sha256: sha256StableJson(normalized),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function extractPayloadFromGet(table, json) {
|
|
180
|
+
const config = supportedRootTables.get(table);
|
|
181
|
+
if (!config || !json || typeof json !== "object")
|
|
182
|
+
return null;
|
|
183
|
+
for (const key of config.payloadKeys) {
|
|
184
|
+
if (isJsonRecord(json[key]))
|
|
185
|
+
return json[key];
|
|
186
|
+
}
|
|
187
|
+
if (table === "flows" && json.flowDataSet)
|
|
188
|
+
return json;
|
|
189
|
+
if (table === "processes" && json.processDataSet)
|
|
190
|
+
return json;
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function defaultCliGet({ table, id, version, outDir, repoRoot, }) {
|
|
194
|
+
const config = supportedRootTables.get(table);
|
|
195
|
+
if (!config) {
|
|
196
|
+
return {
|
|
197
|
+
ok: false,
|
|
198
|
+
error: `Unsupported root payload table for accepted remote verification diff: ${table}.`,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
202
|
+
const stdoutLog = path.join(outDir, `${table}-${id}-${version}.stdout.log`);
|
|
203
|
+
const stderrLog = path.join(outDir, `${table}-${id}-${version}.stderr.log`);
|
|
204
|
+
const cli = resolveTiangongLcaCliRuntimeCommand();
|
|
205
|
+
const cliArgs = [config.command, "get", "--id", id, "--version", version, "--json"];
|
|
206
|
+
const spawnArgs = [...cli.args, ...cliArgs];
|
|
207
|
+
const result = spawnSync(cli.command, spawnArgs, {
|
|
208
|
+
cwd: repoRoot,
|
|
209
|
+
env: process.env,
|
|
210
|
+
encoding: "utf8",
|
|
211
|
+
});
|
|
212
|
+
fs.writeFileSync(stdoutLog, result.stdout || "");
|
|
213
|
+
fs.writeFileSync(stderrLog, result.stderr || "");
|
|
214
|
+
const parsed = parseJsonStdout(result.stdout);
|
|
215
|
+
const payload = extractPayloadFromGet(table, parsed);
|
|
216
|
+
return {
|
|
217
|
+
ok: result.status === 0 && Boolean(payload),
|
|
218
|
+
command: [cli.display, ...cliArgs].join(" "),
|
|
219
|
+
executable: cli.command,
|
|
220
|
+
cli_package: cli.package,
|
|
221
|
+
exit_code: result.status ?? 1,
|
|
222
|
+
stdout_log: repoRelative(repoRoot, stdoutLog),
|
|
223
|
+
stderr_log: repoRelative(repoRoot, stderrLog),
|
|
224
|
+
payload,
|
|
225
|
+
parsed,
|
|
226
|
+
error: result.status === 0 && !payload ? "CLI get did not return a supported root payload." : null,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function rewriteCounts(counts, acceptedCount) {
|
|
230
|
+
const output = { ...(counts ?? {}) };
|
|
231
|
+
output.blockers = Math.max(0, Number(output.blockers ?? 0) - acceptedCount);
|
|
232
|
+
output.root_payload_mismatches = Math.max(0, Number(output.root_payload_mismatches ?? 0) - acceptedCount);
|
|
233
|
+
const byStatus = { ...asJsonRecord(output.by_status) };
|
|
234
|
+
byStatus.payload_mismatch = Math.max(0, Number(byStatus.payload_mismatch ?? 0) - acceptedCount);
|
|
235
|
+
byStatus.ok = Number(byStatus.ok ?? 0) + acceptedCount;
|
|
236
|
+
output.by_status = byStatus;
|
|
237
|
+
return output;
|
|
238
|
+
}
|
|
239
|
+
function acceptanceKey({ table, id, version, row_index, path: checkPath, }) {
|
|
240
|
+
return `${table}:${id}@${version}:${row_index}:${checkPath || ""}`;
|
|
241
|
+
}
|
|
242
|
+
export function acceptTraceHashOnlyRemoteVerificationMismatch({ verifyReportPath, outDir, repoRoot, runCliGet = defaultCliGet, }) {
|
|
243
|
+
if (!fileExists(verifyReportPath)) {
|
|
244
|
+
return { accepted: false, reason: "verify_report_missing" };
|
|
245
|
+
}
|
|
246
|
+
const verifyReport = asJsonRecord(readJson(verifyReportPath));
|
|
247
|
+
const blockers = Array.isArray(verifyReport.blockers)
|
|
248
|
+
? verifyReport.blockers.map(asJsonRecord)
|
|
249
|
+
: [];
|
|
250
|
+
if (verifyReport.status === "passed_remote_verification" || blockers.length === 0) {
|
|
251
|
+
return { accepted: false, reason: "verify_report_has_no_blocked_payload_mismatches" };
|
|
252
|
+
}
|
|
253
|
+
const rootPayloadMismatches = blockers.filter(isSupportedRootPayloadMismatch);
|
|
254
|
+
if (rootPayloadMismatches.length !== blockers.length) {
|
|
255
|
+
return { accepted: false, reason: "verify_report_has_non_accepted_blockers" };
|
|
256
|
+
}
|
|
257
|
+
const inputPath = path.resolve(String(verifyReport.input_path || ""));
|
|
258
|
+
if (!fileExists(inputPath))
|
|
259
|
+
return { accepted: false, reason: "verify_report_input_missing" };
|
|
260
|
+
const verifyFiles = asJsonRecord(verifyReport.files);
|
|
261
|
+
const checksPath = path.resolve(String(verifyFiles.checks || ""));
|
|
262
|
+
if (!fileExists(checksPath))
|
|
263
|
+
return { accepted: false, reason: "verify_checks_missing" };
|
|
264
|
+
const rows = readRows(inputPath);
|
|
265
|
+
const checks = readJsonLines(checksPath).map(asJsonRecord);
|
|
266
|
+
const acceptedDir = path.join(outDir, "accepted-post-write-verify");
|
|
267
|
+
const outputsDir = path.join(acceptedDir, "outputs");
|
|
268
|
+
const remoteDir = path.join(acceptedDir, "remote-readback");
|
|
269
|
+
const acceptedByKey = new Map();
|
|
270
|
+
const evidence = [];
|
|
271
|
+
for (const blocker of rootPayloadMismatches) {
|
|
272
|
+
const rowIndex = Number(blocker.row_index);
|
|
273
|
+
if (!Number.isInteger(rowIndex) || rowIndex < 0 || rowIndex >= rows.length) {
|
|
274
|
+
return { accepted: false, reason: "payload_mismatch_row_index_missing", blocker };
|
|
275
|
+
}
|
|
276
|
+
const localPayload = unwrapDatasetPayload(rows[rowIndex], blocker.table === "flows" ? "flow" : "process");
|
|
277
|
+
const localIdentity = datasetIdentity(localPayload, blocker.table);
|
|
278
|
+
const blockerVersion = String(blocker.version || "00.00.001");
|
|
279
|
+
if (localIdentity.id !== blocker.id ||
|
|
280
|
+
String(localIdentity.version || "00.00.001") !== blockerVersion) {
|
|
281
|
+
return {
|
|
282
|
+
accepted: false,
|
|
283
|
+
reason: "payload_mismatch_identity_mismatch",
|
|
284
|
+
blocker,
|
|
285
|
+
localIdentity,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const remote = runCliGet({
|
|
289
|
+
table: blocker.table,
|
|
290
|
+
id: localIdentity.id,
|
|
291
|
+
version: blockerVersion,
|
|
292
|
+
outDir: remoteDir,
|
|
293
|
+
repoRoot,
|
|
294
|
+
});
|
|
295
|
+
if (!remote?.ok || !remote.payload) {
|
|
296
|
+
return { accepted: false, reason: "remote_readback_failed", blocker, remote };
|
|
297
|
+
}
|
|
298
|
+
const localNormalized = normalizeAllowedTraceHashDifference(localPayload);
|
|
299
|
+
const remoteNormalized = normalizeAllowedTraceHashDifference(remote.payload);
|
|
300
|
+
if (localNormalized.removed_paths.length === 0 || remoteNormalized.removed_paths.length === 0) {
|
|
301
|
+
return { accepted: false, reason: "trace_hash_difference_not_present", blocker };
|
|
302
|
+
}
|
|
303
|
+
if (stableJson(localNormalized.normalized) !== stableJson(remoteNormalized.normalized)) {
|
|
304
|
+
return {
|
|
305
|
+
accepted: false,
|
|
306
|
+
reason: "payloads_still_differ_after_trace_hash_normalization",
|
|
307
|
+
blocker,
|
|
308
|
+
local_removed_paths: localNormalized.removed_paths,
|
|
309
|
+
remote_removed_paths: remoteNormalized.removed_paths,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const check = checks.find((candidate) => candidate?.role === "root" &&
|
|
313
|
+
candidate?.table === blocker.table &&
|
|
314
|
+
candidate?.id === blocker.id &&
|
|
315
|
+
String(candidate?.version || "00.00.001") === String(blocker.version || "00.00.001") &&
|
|
316
|
+
Number(candidate?.row_index) === rowIndex &&
|
|
317
|
+
String(candidate?.path ?? "").endsWith("#readback"));
|
|
318
|
+
if (!check || check.status !== "payload_mismatch") {
|
|
319
|
+
return { accepted: false, reason: "payload_mismatch_check_missing", blocker };
|
|
320
|
+
}
|
|
321
|
+
if (check.local_payload_sha256 !== sha256StableJson(localPayload) ||
|
|
322
|
+
check.remote_payload_sha256 !== sha256StableJson(remote.payload))
|
|
323
|
+
return { accepted: false, reason: "payload_mismatch_readback_hash_drift", blocker };
|
|
324
|
+
const accepted = {
|
|
325
|
+
table: blocker.table,
|
|
326
|
+
id: blocker.id,
|
|
327
|
+
version: blocker.version || "00.00.001",
|
|
328
|
+
row_index: rowIndex,
|
|
329
|
+
accepted_difference: "tiangongfoundry_import_trace_summary_trace_hash_only",
|
|
330
|
+
local_removed_paths: localNormalized.removed_paths,
|
|
331
|
+
remote_removed_paths: remoteNormalized.removed_paths,
|
|
332
|
+
normalized_payload_sha256: localNormalized.normalized_sha256,
|
|
333
|
+
original_local_payload_sha256: check.local_payload_sha256 ?? null,
|
|
334
|
+
original_remote_payload_sha256: check.remote_payload_sha256 ?? null,
|
|
335
|
+
remote_readback_command: remote.command ?? null,
|
|
336
|
+
remote_readback_stdout_log: remote.stdout_log ?? null,
|
|
337
|
+
remote_readback_stderr_log: remote.stderr_log ?? null,
|
|
338
|
+
};
|
|
339
|
+
acceptedByKey.set(acceptanceKey({
|
|
340
|
+
table: blocker.table,
|
|
341
|
+
id: localIdentity.id,
|
|
342
|
+
version: blockerVersion,
|
|
343
|
+
row_index: rowIndex,
|
|
344
|
+
path: typeof blocker.path === "string" ? blocker.path : null,
|
|
345
|
+
}), accepted);
|
|
346
|
+
evidence.push(accepted);
|
|
347
|
+
}
|
|
348
|
+
const acceptedChecks = checks.map((check) => {
|
|
349
|
+
const key = acceptanceKey({
|
|
350
|
+
table: String(check.table ?? ""),
|
|
351
|
+
id: String(check.id ?? ""),
|
|
352
|
+
version: String(check.version || "00.00.001"),
|
|
353
|
+
row_index: Number(check.row_index),
|
|
354
|
+
path: check.path == null ? null : String(check.path),
|
|
355
|
+
});
|
|
356
|
+
const accepted = acceptedByKey.get(key);
|
|
357
|
+
if (!accepted)
|
|
358
|
+
return check;
|
|
359
|
+
return {
|
|
360
|
+
...check,
|
|
361
|
+
status: "ok",
|
|
362
|
+
local_payload_sha256: accepted.normalized_payload_sha256,
|
|
363
|
+
remote_payload_sha256: accepted.normalized_payload_sha256,
|
|
364
|
+
foundry_verification_mode: "accepted_normalized_payload",
|
|
365
|
+
foundry_original_status: check.status ?? null,
|
|
366
|
+
foundry_original_local_payload_sha256: accepted.original_local_payload_sha256,
|
|
367
|
+
foundry_original_remote_payload_sha256: accepted.original_remote_payload_sha256,
|
|
368
|
+
foundry_accepted_differences: [accepted],
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
const remainingBadChecks = acceptedChecks.filter((check) => check?.role === "root" && check.status !== "ok");
|
|
372
|
+
if (remainingBadChecks.length > 0) {
|
|
373
|
+
return {
|
|
374
|
+
accepted: false,
|
|
375
|
+
reason: "non_accepted_root_checks_remain",
|
|
376
|
+
count: remainingBadChecks.length,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
const acceptedChecksPath = path.join(outputsDir, "remote-verification.jsonl");
|
|
380
|
+
const acceptedBlockersPath = path.join(outputsDir, "blockers.jsonl");
|
|
381
|
+
const acceptedReportPath = path.join(outputsDir, "remote-verification-report.json");
|
|
382
|
+
const acceptanceReportPath = path.join(acceptedDir, "foundry-accepted-remote-verification-diff.json");
|
|
383
|
+
const acceptedReport = {
|
|
384
|
+
...verifyReport,
|
|
385
|
+
generated_at_utc: nowIso(),
|
|
386
|
+
status: "passed_remote_verification",
|
|
387
|
+
counts: rewriteCounts(asJsonRecord(verifyReport.counts), evidence.length),
|
|
388
|
+
blockers: [],
|
|
389
|
+
files: {
|
|
390
|
+
...verifyFiles,
|
|
391
|
+
report: acceptedReportPath,
|
|
392
|
+
checks: acceptedChecksPath,
|
|
393
|
+
blockers: acceptedBlockersPath,
|
|
394
|
+
foundry_original_report: verifyReportPath,
|
|
395
|
+
foundry_acceptance_report: acceptanceReportPath,
|
|
396
|
+
},
|
|
397
|
+
foundry_accepted_remote_verification: {
|
|
398
|
+
status: "accepted_normalized_payload",
|
|
399
|
+
policy: "tiangongfoundry:importTraceSummary.traceHash may differ after remote persistence canonicalizes import-only trace summaries; all other root payload content must match exactly.",
|
|
400
|
+
original_report: repoRelative(repoRoot, verifyReportPath),
|
|
401
|
+
accepted_at_utc: nowIso(),
|
|
402
|
+
accepted_differences: evidence,
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
const acceptanceReport = {
|
|
406
|
+
schema_version: 1,
|
|
407
|
+
generated_at_utc: nowIso(),
|
|
408
|
+
status: "accepted",
|
|
409
|
+
original_report: repoRelative(repoRoot, verifyReportPath),
|
|
410
|
+
accepted_report: repoRelative(repoRoot, acceptedReportPath),
|
|
411
|
+
accepted_checks: repoRelative(repoRoot, acceptedChecksPath),
|
|
412
|
+
accepted_differences: evidence,
|
|
413
|
+
};
|
|
414
|
+
writeJsonLines(acceptedChecksPath, acceptedChecks);
|
|
415
|
+
writeJsonLines(acceptedBlockersPath, []);
|
|
416
|
+
writeJson(acceptedReportPath, acceptedReport);
|
|
417
|
+
writeJson(acceptanceReportPath, acceptanceReport);
|
|
418
|
+
return {
|
|
419
|
+
accepted: true,
|
|
420
|
+
verifyReportPath: acceptedReportPath,
|
|
421
|
+
acceptanceReportPath,
|
|
422
|
+
evidence,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SameIdentityCommitFailureSummary {
|
|
2
|
+
accepted: boolean;
|
|
3
|
+
alreadyExists: number;
|
|
4
|
+
otherFailures: number;
|
|
5
|
+
}
|
|
6
|
+
type JsonRecord = Record<string, unknown>;
|
|
7
|
+
export declare function summarizeSameIdentityCommitFailures(reports: readonly JsonRecord[]): SameIdentityCommitFailureSummary;
|
|
8
|
+
export {};
|