project-tiny-context-harness 0.8.17 → 0.11.0
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/README.md +93 -30
- package/assets/README.md +158 -44
- package/assets/README.zh-CN.md +88 -29
- package/assets/agents/AGENTS_CORE.md +2 -2
- package/assets/context_templates/context.toml +6 -1
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_helpers.cs +301 -0
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_run.cs +197 -0
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_types.cs +215 -0
- package/assets/runtime/windows-job-supervisor/windows_job_process_supervisor.ps1 +117 -0
- package/assets/skills/design-resource-authoring/SKILL.md +6 -3
- package/assets/skills/design-resource-authoring/references/authority-delta-assessment.md +52 -0
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +5 -1
- package/assets/skills/design-system-authoring/SKILL.md +23 -17
- package/assets/skills/design-system-authoring/references/authority-adoption.md +19 -9
- package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +4 -0
- package/assets/skills/long-task-workflow/SKILL.md +6 -6
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +10 -4
- package/assets/skills/long-task-workflow/references/contract-authoring.md +5 -5
- package/assets/skills/long-task-workflow/references/evidence-design.md +14 -3
- package/assets/skills/long-task-workflow/references/source-authoring.md +11 -8
- package/assets/tools/context_rules.json +53 -0
- package/assets/tools/validate_context.py +302 -77
- package/dist/cli.js +2 -1
- package/dist/commands/context-create.d.ts +1 -0
- package/dist/commands/context-create.js +90 -0
- package/dist/commands/context-inspect.d.ts +1 -0
- package/dist/commands/context-inspect.js +98 -0
- package/dist/commands/context-move.d.ts +1 -0
- package/dist/commands/context-move.js +78 -0
- package/dist/commands/context-register.d.ts +1 -0
- package/dist/commands/context-register.js +110 -0
- package/dist/commands/context-transaction.d.ts +1 -0
- package/dist/commands/context-transaction.js +84 -0
- package/dist/commands/context.d.ts +1 -0
- package/dist/commands/context.js +36 -0
- package/dist/commands/design-authority-delta.d.ts +1 -0
- package/dist/commands/design-authority-delta.js +53 -0
- package/dist/commands/design-authority.d.ts +1 -0
- package/dist/commands/design-authority.js +104 -0
- package/dist/commands/design-resource.js +8 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +61 -3
- package/dist/commands/index.js +19 -2
- package/dist/commands/long-task-authoring.js +20 -2
- package/dist/commands/long-task-workdir.d.ts +2 -0
- package/dist/commands/long-task-workdir.js +23 -0
- package/dist/commands/long-task.js +75 -6
- package/dist/commands/route.d.ts +15 -0
- package/dist/commands/route.js +142 -0
- package/dist/index.d.ts +3 -13
- package/dist/index.js +3 -12
- package/dist/lib/cli-exit.d.ts +14 -0
- package/dist/lib/cli-exit.js +19 -0
- package/dist/lib/context-catalog/catalog-default-footprint.d.ts +3 -0
- package/dist/lib/context-catalog/catalog-default-footprint.js +53 -0
- package/dist/lib/context-catalog/catalog-diagnostics.d.ts +9 -0
- package/dist/lib/context-catalog/catalog-diagnostics.js +34 -0
- package/dist/lib/context-catalog/catalog-discovery.d.ts +7 -0
- package/dist/lib/context-catalog/catalog-discovery.js +81 -0
- package/dist/lib/context-catalog/catalog-load.d.ts +8 -0
- package/dist/lib/context-catalog/catalog-load.js +187 -0
- package/dist/lib/context-catalog/catalog-path-validation.d.ts +7 -0
- package/dist/lib/context-catalog/catalog-path-validation.js +62 -0
- package/dist/lib/context-catalog/catalog-paths.d.ts +11 -0
- package/dist/lib/context-catalog/catalog-paths.js +41 -0
- package/dist/lib/context-catalog/catalog-portable-contract.d.ts +15 -0
- package/dist/lib/context-catalog/catalog-portable-contract.js +68 -0
- package/dist/lib/context-catalog/catalog-staged-path-safety.d.ts +1 -0
- package/dist/lib/context-catalog/catalog-staged-path-safety.js +36 -0
- package/dist/lib/context-catalog/catalog-types.d.ts +40 -0
- package/dist/lib/context-catalog/catalog-types.js +1 -0
- package/dist/lib/context-catalog/catalog-validation.d.ts +9 -0
- package/dist/lib/context-catalog/catalog-validation.js +148 -0
- package/dist/lib/context-create/context-create-path.d.ts +2 -0
- package/dist/lib/context-create/context-create-path.js +30 -0
- package/dist/lib/context-create/context-create-template.d.ts +2 -0
- package/dist/lib/context-create/context-create-template.js +95 -0
- package/dist/lib/context-create/context-create-types.d.ts +28 -0
- package/dist/lib/context-create/context-create-types.js +1 -0
- package/dist/lib/context-create/context-create-write.d.ts +1 -0
- package/dist/lib/context-create/context-create-write.js +85 -0
- package/dist/lib/context-create/context-create.d.ts +2 -0
- package/dist/lib/context-create/context-create.js +84 -0
- package/dist/lib/context-default-footprint.d.ts +2 -3
- package/dist/lib/context-default-footprint.js +49 -57
- package/dist/lib/context-doctor/context-doctor-types.d.ts +16 -0
- package/dist/lib/context-doctor/context-doctor-types.js +15 -0
- package/dist/lib/context-doctor/context-doctor.d.ts +2 -0
- package/dist/lib/context-doctor/context-doctor.js +130 -0
- package/dist/lib/context-graph-snapshot.d.ts +5 -0
- package/dist/lib/context-graph-snapshot.js +46 -25
- package/dist/lib/context-inspect/context-inspect-projection.d.ts +9 -0
- package/dist/lib/context-inspect/context-inspect-projection.js +49 -0
- package/dist/lib/context-inspect/context-inspect-render.d.ts +2 -0
- package/dist/lib/context-inspect/context-inspect-render.js +29 -0
- package/dist/lib/context-inspect/context-inspect-types.d.ts +43 -0
- package/dist/lib/context-inspect/context-inspect-types.js +1 -0
- package/dist/lib/context-inspect/context-inspect.d.ts +2 -0
- package/dist/lib/context-inspect/context-inspect.js +104 -0
- package/dist/lib/context-manifest-schema.d.ts +1 -1
- package/dist/lib/context-manifest-schema.js +4 -20
- package/dist/lib/context-markdown/context-markdown-analysis.d.ts +15 -0
- package/dist/lib/context-markdown/context-markdown-analysis.js +245 -0
- package/dist/lib/context-markdown/context-markdown-extract.d.ts +7 -0
- package/dist/lib/context-markdown/context-markdown-extract.js +114 -0
- package/dist/lib/context-markdown/context-markdown-types.d.ts +57 -0
- package/dist/lib/context-markdown/context-markdown-types.js +1 -0
- package/dist/lib/context-move/context-move-input.d.ts +8 -0
- package/dist/lib/context-move/context-move-input.js +17 -0
- package/dist/lib/context-move/context-move-literal-scan.d.ts +20 -0
- package/dist/lib/context-move/context-move-literal-scan.js +213 -0
- package/dist/lib/context-move/context-move-live-validation.d.ts +3 -0
- package/dist/lib/context-move/context-move-live-validation.js +56 -0
- package/dist/lib/context-move/context-move-markdown-plan.d.ts +22 -0
- package/dist/lib/context-move/context-move-markdown-plan.js +39 -0
- package/dist/lib/context-move/context-move-projection.d.ts +3 -0
- package/dist/lib/context-move/context-move-projection.js +11 -0
- package/dist/lib/context-move/context-move-reference-validation.d.ts +11 -0
- package/dist/lib/context-move/context-move-reference-validation.js +64 -0
- package/dist/lib/context-move/context-move-render.d.ts +2 -0
- package/dist/lib/context-move/context-move-render.js +24 -0
- package/dist/lib/context-move/context-move-support.d.ts +10 -0
- package/dist/lib/context-move/context-move-support.js +88 -0
- package/dist/lib/context-move/context-move-transaction-plan.d.ts +24 -0
- package/dist/lib/context-move/context-move-transaction-plan.js +108 -0
- package/dist/lib/context-move/context-move-types.d.ts +74 -0
- package/dist/lib/context-move/context-move-types.js +1 -0
- package/dist/lib/context-move/context-move.d.ts +8 -0
- package/dist/lib/context-move/context-move.js +180 -0
- package/dist/lib/context-mutation/manifest-lossless-patch.d.ts +28 -0
- package/dist/lib/context-mutation/manifest-lossless-patch.js +208 -0
- package/dist/lib/context-mutation/markdown-link-patch.d.ts +34 -0
- package/dist/lib/context-mutation/markdown-link-patch.js +143 -0
- package/dist/lib/context-mutation/markdown-link-spans.d.ts +10 -0
- package/dist/lib/context-mutation/markdown-link-spans.js +179 -0
- package/dist/lib/context-mutation/mutation-cas.d.ts +13 -0
- package/dist/lib/context-mutation/mutation-cas.js +365 -0
- package/dist/lib/context-mutation/mutation-command-support.d.ts +12 -0
- package/dist/lib/context-mutation/mutation-command-support.js +57 -0
- package/dist/lib/context-mutation/mutation-commit.d.ts +12 -0
- package/dist/lib/context-mutation/mutation-commit.js +89 -0
- package/dist/lib/context-mutation/mutation-directories.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-directories.js +56 -0
- package/dist/lib/context-mutation/mutation-file-state.d.ts +14 -0
- package/dist/lib/context-mutation/mutation-file-state.js +137 -0
- package/dist/lib/context-mutation/mutation-journal-file-validation.d.ts +1 -0
- package/dist/lib/context-mutation/mutation-journal-file-validation.js +106 -0
- package/dist/lib/context-mutation/mutation-journal-io.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-journal-io.js +55 -0
- package/dist/lib/context-mutation/mutation-journal-storage.d.ts +18 -0
- package/dist/lib/context-mutation/mutation-journal-storage.js +283 -0
- package/dist/lib/context-mutation/mutation-journal-validation-support.d.ts +16 -0
- package/dist/lib/context-mutation/mutation-journal-validation-support.js +140 -0
- package/dist/lib/context-mutation/mutation-journal-validation.d.ts +3 -0
- package/dist/lib/context-mutation/mutation-journal-validation.js +177 -0
- package/dist/lib/context-mutation/mutation-journal.d.ts +8 -0
- package/dist/lib/context-mutation/mutation-journal.js +111 -0
- package/dist/lib/context-mutation/mutation-live-validation.d.ts +3 -0
- package/dist/lib/context-mutation/mutation-live-validation.js +51 -0
- package/dist/lib/context-mutation/mutation-long-task-guard.d.ts +6 -0
- package/dist/lib/context-mutation/mutation-long-task-guard.js +57 -0
- package/dist/lib/context-mutation/mutation-recovery.d.ts +4 -0
- package/dist/lib/context-mutation/mutation-recovery.js +189 -0
- package/dist/lib/context-mutation/mutation-staged-fs.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-staged-fs.js +56 -0
- package/dist/lib/context-mutation/mutation-types.d.ts +103 -0
- package/dist/lib/context-mutation/mutation-types.js +1 -0
- package/dist/lib/context-register/context-register-input.d.ts +11 -0
- package/dist/lib/context-register/context-register-input.js +43 -0
- package/dist/lib/context-register/context-register-render.d.ts +2 -0
- package/dist/lib/context-register/context-register-render.js +21 -0
- package/dist/lib/context-register/context-register-support.d.ts +6 -0
- package/dist/lib/context-register/context-register-support.js +46 -0
- package/dist/lib/context-register/context-register-types.d.ts +46 -0
- package/dist/lib/context-register/context-register-types.js +1 -0
- package/dist/lib/context-register/context-register.d.ts +8 -0
- package/dist/lib/context-register/context-register.js +155 -0
- package/dist/lib/context-router/context-route-budget.d.ts +15 -0
- package/dist/lib/context-router/context-route-budget.js +14 -0
- package/dist/lib/context-router/context-route-candidates.d.ts +15 -0
- package/dist/lib/context-router/context-route-candidates.js +112 -0
- package/dist/lib/context-router/context-route-order.d.ts +6 -0
- package/dist/lib/context-router/context-route-order.js +53 -0
- package/dist/lib/context-router/context-route-paths.d.ts +16 -0
- package/dist/lib/context-router/context-route-paths.js +109 -0
- package/dist/lib/context-router/context-route-render.d.ts +2 -0
- package/dist/lib/context-router/context-route-render.js +32 -0
- package/dist/lib/context-router/context-route-scan.d.ts +18 -0
- package/dist/lib/context-router/context-route-scan.js +156 -0
- package/dist/lib/context-router/context-route-selection.d.ts +16 -0
- package/dist/lib/context-router/context-route-selection.js +72 -0
- package/dist/lib/context-router/context-route-terms.d.ts +13 -0
- package/dist/lib/context-router/context-route-terms.js +202 -0
- package/dist/lib/context-router/context-route-types.d.ts +101 -0
- package/dist/lib/context-router/context-route-types.js +1 -0
- package/dist/lib/context-router/context-route.d.ts +2 -0
- package/dist/lib/context-router/context-route.js +127 -0
- package/dist/lib/context-units-migration.d.ts +13 -0
- package/dist/lib/context-units-migration.js +217 -0
- package/dist/lib/design-authority-binding.d.ts +7 -0
- package/dist/lib/design-authority-binding.js +96 -0
- package/dist/lib/design-authority-closure.d.ts +3 -0
- package/dist/lib/design-authority-closure.js +201 -0
- package/dist/lib/design-authority-delta-codec-primitives.d.ts +10 -0
- package/dist/lib/design-authority-delta-codec-primitives.js +58 -0
- package/dist/lib/design-authority-delta-codec.d.ts +2 -0
- package/dist/lib/design-authority-delta-codec.js +193 -0
- package/dist/lib/design-authority-delta-types.d.ts +65 -0
- package/dist/lib/design-authority-delta-types.js +6 -0
- package/dist/lib/design-authority-delta-validation.d.ts +2 -0
- package/dist/lib/design-authority-delta-validation.js +16 -0
- package/dist/lib/design-authority-digest.d.ts +8 -0
- package/dist/lib/design-authority-digest.js +36 -0
- package/dist/lib/design-authority-files.d.ts +9 -0
- package/dist/lib/design-authority-files.js +62 -0
- package/dist/lib/design-authority-format.d.ts +2 -0
- package/dist/lib/design-authority-format.js +93 -0
- package/dist/lib/design-authority-links.d.ts +10 -0
- package/dist/lib/design-authority-links.js +137 -0
- package/dist/lib/design-authority-manifest.d.ts +4 -0
- package/dist/lib/design-authority-manifest.js +144 -0
- package/dist/lib/design-authority-tokens.d.ts +9 -0
- package/dist/lib/design-authority-tokens.js +45 -0
- package/dist/lib/design-authority-types.d.ts +80 -0
- package/dist/lib/design-authority-types.js +23 -0
- package/dist/lib/design-md-tool-adapter.d.ts +9 -0
- package/dist/lib/design-md-tool-adapter.js +152 -0
- package/dist/lib/design-md-tool-normalization.d.ts +7 -0
- package/dist/lib/design-md-tool-normalization.js +78 -0
- package/dist/lib/design-md-tool-types.d.ts +99 -0
- package/dist/lib/design-md-tool-types.js +8 -0
- package/dist/lib/design-resource-handoff-input-types.d.ts +1 -1
- package/dist/lib/design-resource-handoff-manifest-projection.js +3 -0
- package/dist/lib/design-resource-handoff-shape.js +14 -2
- package/dist/lib/design-resource-handoff-types.d.ts +3 -0
- package/dist/lib/design-resource-handoff-validation.js +16 -4
- package/dist/lib/design-resource-implementation-feasibility-validation-support.js +1 -1
- package/dist/lib/design-resource-recovery-current.js +22 -0
- package/dist/lib/design-resource-recovery-shape.js +64 -7
- package/dist/lib/design-resource-recovery-types.d.ts +4 -1
- package/dist/lib/design-resource-symbolic-fact-shape.js +7 -1
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +15 -3
- package/dist/lib/doctor.d.ts +2 -1
- package/dist/lib/doctor.js +29 -1
- package/dist/lib/fs.js +1 -1
- package/dist/lib/long-task-acceptance-reachability-claims.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-claims.js +279 -0
- package/dist/lib/long-task-acceptance-reachability-design.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-design.js +96 -0
- package/dist/lib/long-task-acceptance-reachability-external.d.ts +9 -0
- package/dist/lib/long-task-acceptance-reachability-external.js +123 -0
- package/dist/lib/long-task-acceptance-reachability-helpers.d.ts +64 -0
- package/dist/lib/long-task-acceptance-reachability-helpers.js +473 -0
- package/dist/lib/long-task-acceptance-reachability-semantic.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-semantic.js +122 -0
- package/dist/lib/long-task-acceptance-reachability-types.d.ts +91 -0
- package/dist/lib/long-task-acceptance-reachability-types.js +1 -0
- package/dist/lib/long-task-acceptance-reachability.d.ts +4 -0
- package/dist/lib/long-task-acceptance-reachability.js +115 -0
- package/dist/lib/long-task-activation-validation.d.ts +6 -0
- package/dist/lib/long-task-activation-validation.js +72 -69
- package/dist/lib/long-task-active-authority-lock-context.d.ts +4 -0
- package/dist/lib/long-task-active-authority-lock-context.js +29 -0
- package/dist/lib/long-task-applicability-identity.d.ts +25 -0
- package/dist/lib/long-task-applicability-identity.js +60 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.js +8 -0
- package/dist/lib/long-task-authoring-preflight-types.d.ts +2 -0
- package/dist/lib/long-task-authoring-preflight-types.js +9 -0
- package/dist/lib/long-task-authoring-preflight.js +18 -2
- package/dist/lib/long-task-authority-material-diff.js +4 -0
- package/dist/lib/long-task-authority-materials.js +19 -0
- package/dist/lib/long-task-authority-policy.d.ts +3 -0
- package/dist/lib/long-task-authority-policy.js +3 -0
- package/dist/lib/long-task-authority-revision-details.js +2 -1
- package/dist/lib/long-task-authority-types.d.ts +2 -0
- package/dist/lib/long-task-authority.js +2 -0
- package/dist/lib/long-task-check-shape.js +6 -1
- package/dist/lib/long-task-claim-definitions.js +1 -3
- package/dist/lib/long-task-claim-semantic-proof-floor.d.ts +3 -0
- package/dist/lib/long-task-claim-semantic-proof-floor.js +78 -0
- package/dist/lib/long-task-claims.d.ts +0 -18
- package/dist/lib/long-task-claims.js +15 -14
- package/dist/lib/long-task-command-process.js +3 -0
- package/dist/lib/long-task-compact-authoring.js +3 -0
- package/dist/lib/long-task-compact-projections.js +10 -0
- package/dist/lib/long-task-complete-delivery-evidence-types.d.ts +38 -0
- package/dist/lib/long-task-complete-delivery-evidence-types.js +1 -0
- package/dist/lib/long-task-completion-types.d.ts +109 -0
- package/dist/lib/long-task-completion-types.js +1 -0
- package/dist/lib/long-task-conformance-policy.d.ts +2 -1
- package/dist/lib/long-task-conformance-policy.js +11 -4
- package/dist/lib/long-task-context-authority-topology.js +6 -4
- package/dist/lib/long-task-contract-types.d.ts +52 -1
- package/dist/lib/long-task-counterfactual-sandbox.d.ts +7 -1
- package/dist/lib/long-task-counterfactual-sandbox.js +86 -6
- package/dist/lib/long-task-delivery-compiler-preflight.d.ts +24 -0
- package/dist/lib/long-task-delivery-compiler-preflight.js +32 -0
- package/dist/lib/long-task-delivery-compiler.d.ts +1 -0
- package/dist/lib/long-task-delivery-compiler.js +59 -44
- package/dist/lib/long-task-delivery-parser.d.ts +3 -0
- package/dist/lib/long-task-delivery-parser.js +26 -8
- package/dist/lib/long-task-delivery-types.d.ts +2 -0
- package/dist/lib/long-task-delivery-types.js +2 -0
- package/dist/lib/long-task-delivery-validation.d.ts +6 -1
- package/dist/lib/long-task-delivery-validation.js +19 -4
- package/dist/lib/long-task-design-feasibility-binding.d.ts +1 -0
- package/dist/lib/long-task-design-feasibility-binding.js +3 -3
- package/dist/lib/long-task-design-feasibility-source-closure.js +11 -2
- package/dist/lib/long-task-design-obligation.d.ts +50 -0
- package/dist/lib/long-task-design-obligation.js +99 -0
- package/dist/lib/long-task-design-resource-handoff.d.ts +3 -1
- package/dist/lib/long-task-design-resource-handoff.js +36 -12
- package/dist/lib/long-task-design-resource-method-binding.js +12 -0
- package/dist/lib/long-task-effective-external-takeover.d.ts +15 -0
- package/dist/lib/long-task-effective-external-takeover.js +109 -0
- package/dist/lib/long-task-effective-external-ui-takeover.d.ts +5 -0
- package/dist/lib/long-task-effective-external-ui-takeover.js +117 -0
- package/dist/lib/long-task-evidence-capability-codec.js +91 -0
- package/dist/lib/long-task-evidence-capability-runtime.js +62 -14
- package/dist/lib/long-task-evidence-capability-types.d.ts +3 -2
- package/dist/lib/long-task-evidence-v2.d.ts +6 -1
- package/dist/lib/long-task-evidence-v2.js +253 -170
- package/dist/lib/long-task-execution-observation.d.ts +7 -0
- package/dist/lib/long-task-execution-observation.js +21 -4
- package/dist/lib/long-task-expected-authority.d.ts +4 -0
- package/dist/lib/long-task-expected-authority.js +126 -0
- package/dist/lib/long-task-external-confirmation-artifacts.d.ts +9 -0
- package/dist/lib/long-task-external-confirmation-artifacts.js +138 -0
- package/dist/lib/long-task-external-confirmation-attestation.d.ts +20 -0
- package/dist/lib/long-task-external-confirmation-attestation.js +115 -0
- package/dist/lib/long-task-external-confirmation-challenge.d.ts +23 -0
- package/dist/lib/long-task-external-confirmation-challenge.js +164 -0
- package/dist/lib/long-task-external-confirmation-context.d.ts +14 -0
- package/dist/lib/long-task-external-confirmation-context.js +53 -0
- package/dist/lib/long-task-external-confirmation-evaluation.d.ts +11 -0
- package/dist/lib/long-task-external-confirmation-evaluation.js +454 -0
- package/dist/lib/long-task-external-confirmation-expected.d.ts +8 -0
- package/dist/lib/long-task-external-confirmation-expected.js +200 -0
- package/dist/lib/long-task-external-confirmation-identity.d.ts +10 -0
- package/dist/lib/long-task-external-confirmation-identity.js +77 -0
- package/dist/lib/long-task-external-confirmation-plan.d.ts +25 -0
- package/dist/lib/long-task-external-confirmation-plan.js +148 -0
- package/dist/lib/long-task-external-confirmation-preparation.d.ts +4 -0
- package/dist/lib/long-task-external-confirmation-preparation.js +100 -0
- package/dist/lib/long-task-external-confirmation-shape.d.ts +8 -0
- package/dist/lib/long-task-external-confirmation-shape.js +387 -0
- package/dist/lib/long-task-external-confirmation-state.d.ts +10 -0
- package/dist/lib/long-task-external-confirmation-state.js +109 -0
- package/dist/lib/long-task-external-confirmation-types.d.ts +195 -0
- package/dist/lib/long-task-external-confirmation-types.js +1 -0
- package/dist/lib/long-task-final-integrity.d.ts +2 -0
- package/dist/lib/long-task-final-integrity.js +21 -10
- package/dist/lib/long-task-final-v2.d.ts +7 -2
- package/dist/lib/long-task-final-v2.js +179 -55
- package/dist/lib/long-task-finalization-identity.d.ts +27 -0
- package/dist/lib/long-task-finalization-identity.js +58 -0
- package/dist/lib/long-task-finding-context.d.ts +1 -1
- package/dist/lib/long-task-finding-context.js +139 -13
- package/dist/lib/long-task-freshness.d.ts +27 -0
- package/dist/lib/long-task-freshness.js +128 -5
- package/dist/lib/long-task-git.js +3 -3
- package/dist/lib/long-task-material-input-closure.d.ts +3 -0
- package/dist/lib/long-task-material-input-closure.js +92 -0
- package/dist/lib/long-task-obligation-authority-resolution.d.ts +12 -0
- package/dist/lib/long-task-obligation-authority-resolution.js +57 -0
- package/dist/lib/long-task-obligation-semantic-identity.d.ts +16 -0
- package/dist/lib/long-task-obligation-semantic-identity.js +116 -0
- package/dist/lib/long-task-observation-authority.d.ts +11 -0
- package/dist/lib/long-task-observation-authority.js +137 -6
- package/dist/lib/long-task-process-table.d.ts +2 -5
- package/dist/lib/long-task-process-table.js +21 -53
- package/dist/lib/long-task-process-tree.d.ts +0 -1
- package/dist/lib/long-task-process-tree.js +24 -54
- package/dist/lib/long-task-proof-adequacy.d.ts +12 -0
- package/dist/lib/long-task-proof-adequacy.js +57 -0
- package/dist/lib/long-task-proof-capability-floor.d.ts +6 -0
- package/dist/lib/long-task-proof-capability-floor.js +137 -0
- package/dist/lib/long-task-repair-frontier-checks.d.ts +8 -0
- package/dist/lib/long-task-repair-frontier-checks.js +93 -0
- package/dist/lib/long-task-repair-frontier-groups.d.ts +2 -0
- package/dist/lib/long-task-repair-frontier-groups.js +64 -0
- package/dist/lib/long-task-repair-frontier-utils.d.ts +6 -0
- package/dist/lib/long-task-repair-frontier-utils.js +27 -0
- package/dist/lib/long-task-repair-frontier.d.ts +14 -0
- package/dist/lib/long-task-repair-frontier.js +132 -0
- package/dist/lib/long-task-risk.d.ts +3 -2
- package/dist/lib/long-task-risk.js +73 -24
- package/dist/lib/long-task-root-shape.js +148 -8
- package/dist/lib/long-task-runner-freeze.d.ts +2 -1
- package/dist/lib/long-task-runner-freeze.js +23 -8
- package/dist/lib/long-task-runtime-types.d.ts +34 -40
- package/dist/lib/long-task-semantic-assurance-policy.js +2 -11
- package/dist/lib/long-task-semantic-contract-types.d.ts +2 -1
- package/dist/lib/long-task-semantic-drift-migration.js +48 -2
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +20 -0
- package/dist/lib/long-task-semantic-fact-closure.d.ts +5 -1
- package/dist/lib/long-task-semantic-fact-closure.js +33 -5
- package/dist/lib/long-task-semantic-fact-contract-closure.js +176 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +18 -1
- package/dist/lib/long-task-semantic-fact-input-closure.d.ts +16 -2
- package/dist/lib/long-task-semantic-fact-input-closure.js +138 -15
- package/dist/lib/long-task-semantic-fact-provenance-closure.js +1 -1
- package/dist/lib/long-task-semantic-fact-shape.d.ts +2 -1
- package/dist/lib/long-task-semantic-fact-shape.js +35 -1
- package/dist/lib/long-task-semantic-proof-adequacy.d.ts +2 -0
- package/dist/lib/long-task-semantic-proof-adequacy.js +19 -0
- package/dist/lib/long-task-semantic-proof-profile.d.ts +5 -0
- package/dist/lib/long-task-semantic-proof-profile.js +187 -0
- package/dist/lib/long-task-shape-primitives.d.ts +1 -1
- package/dist/lib/long-task-shape-primitives.js +5 -0
- package/dist/lib/long-task-source-anchors.d.ts +10 -0
- package/dist/lib/long-task-source-anchors.js +102 -0
- package/dist/lib/long-task-source-authority-types.d.ts +46 -0
- package/dist/lib/long-task-source-claim-validation.js +36 -0
- package/dist/lib/long-task-source-conservation-facts.d.ts +8 -0
- package/dist/lib/long-task-source-conservation-facts.js +57 -0
- package/dist/lib/long-task-source-conservation-types.d.ts +34 -0
- package/dist/lib/long-task-source-conservation-types.js +1 -0
- package/dist/lib/long-task-source-conservation.d.ts +7 -0
- package/dist/lib/long-task-source-conservation.js +110 -0
- package/dist/lib/long-task-source-fragments.d.ts +6 -0
- package/dist/lib/long-task-source-fragments.js +219 -0
- package/dist/lib/long-task-source-projection-resolution.d.ts +5 -0
- package/dist/lib/long-task-source-projection-resolution.js +57 -0
- package/dist/lib/long-task-source-projection-validation.d.ts +17 -0
- package/dist/lib/long-task-source-projection-validation.js +154 -0
- package/dist/lib/long-task-source-shape.js +14 -6
- package/dist/lib/long-task-source-supersession.d.ts +5 -0
- package/dist/lib/long-task-source-supersession.js +138 -0
- package/dist/lib/long-task-stage-policy.d.ts +7 -2
- package/dist/lib/long-task-stage-policy.js +67 -23
- package/dist/lib/long-task-state.d.ts +18 -4
- package/dist/lib/long-task-state.js +319 -33
- package/dist/lib/long-task-static-observation-freeze.js +4 -3
- package/dist/lib/long-task-status-projection.d.ts +3 -1
- package/dist/lib/long-task-status-projection.js +44 -13
- package/dist/lib/long-task-status-v2.d.ts +10 -6
- package/dist/lib/long-task-status-v2.js +70 -58
- package/dist/lib/long-task-target-policy.d.ts +8 -3
- package/dist/lib/long-task-target-policy.js +40 -9
- package/dist/lib/long-task-terminal-finalization.d.ts +12 -0
- package/dist/lib/long-task-terminal-finalization.js +190 -0
- package/dist/lib/long-task-ui-design-policy.js +15 -4
- package/dist/lib/long-task-verifier-counterfactuals.d.ts +11 -0
- package/dist/lib/long-task-verifier-counterfactuals.js +96 -0
- package/dist/lib/long-task-verifier-execution.d.ts +9 -0
- package/dist/lib/long-task-verifier-execution.js +67 -0
- package/dist/lib/long-task-verifier-identity.js +16 -5
- package/dist/lib/long-task-verifier-v2.js +52 -65
- package/dist/lib/long-task-windows-job-supervisor-helper.d.ts +1 -0
- package/dist/lib/long-task-windows-job-supervisor-helper.js +104 -0
- package/dist/lib/long-task-windows-job-supervisor-protocol.d.ts +28 -0
- package/dist/lib/long-task-windows-job-supervisor-protocol.js +124 -0
- package/dist/lib/long-task-windows-job-supervisor-result.d.ts +11 -0
- package/dist/lib/long-task-windows-job-supervisor-result.js +152 -0
- package/dist/lib/long-task-windows-job-supervisor.d.ts +2 -0
- package/dist/lib/long-task-windows-job-supervisor.js +126 -0
- package/dist/lib/long-task-workspace-scope.d.ts +1 -0
- package/dist/lib/long-task-workspace-scope.js +4 -1
- package/dist/lib/long-task-workspace.d.ts +1 -0
- package/dist/lib/long-task-workspace.js +10 -0
- package/dist/lib/migrations.js +43 -2
- package/dist/lib/repository-path-safety.d.ts +1 -0
- package/dist/lib/repository-path-safety.js +3 -3
- package/dist/lib/semantic-fact-input-shape.d.ts +7 -2
- package/dist/lib/semantic-fact-input-shape.js +25 -1
- package/dist/lib/semantic-fact-inventory-types.d.ts +8 -2
- package/dist/lib/semantic-fact-policy-census.d.ts +1 -1
- package/dist/lib/semantic-fact-policy-census.js +5 -2
- package/dist/lib/semantic-fact-policy.d.ts +1 -1
- package/dist/lib/semantic-fact-policy.js +2 -2
- package/dist/lib/semantic-fact-proof-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-property-shape.d.ts +1 -1
- package/dist/lib/validators.d.ts +3 -0
- package/dist/lib/validators.js +45 -157
- package/dist/public-api-core.d.ts +12 -0
- package/dist/public-api-core.js +12 -0
- package/dist/public-api-long-task.d.ts +10 -0
- package/dist/public-api-long-task.js +10 -0
- package/dist/public-types.d.ts +5 -1
- package/dist/schemas/design-authority-delta-assessment-v1.schema.json +191 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +166 -2
- package/dist/schemas/long-task-external-confirmation-record-v1.schema.json +155 -0
- package/dist/schemas/long-task-external-confirmation-record-v2.schema.json +209 -0
- package/migrations/README.md +99 -0
- package/package.json +7 -5
- package/source-mappings.yaml +18 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { array, key, literal, nullable, object, repositoryFile, semanticRef, string, text, } from "./long-task-shape-primitives.js";
|
|
2
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
3
|
+
const HASH = /^[a-f0-9]{64}$/u;
|
|
4
|
+
const GIT_OBJECT = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
|
|
5
|
+
const RELEVANT_INPUT = /^(?:bounded|whole):[a-f0-9]{64}$/u;
|
|
6
|
+
const CHALLENGE = /^[A-Za-z0-9_-]{43}$/u;
|
|
7
|
+
export function parseExternalConfirmationRecord(value) {
|
|
8
|
+
if (value &&
|
|
9
|
+
typeof value === "object" &&
|
|
10
|
+
!Array.isArray(value) &&
|
|
11
|
+
value.schema_version ===
|
|
12
|
+
"long-task-external-confirmation-record-v2")
|
|
13
|
+
return parseExternalConfirmationRecordV2(value);
|
|
14
|
+
return parseExternalConfirmationRecordV1(value);
|
|
15
|
+
}
|
|
16
|
+
export function parseExternalConfirmationRecordV1(value) {
|
|
17
|
+
const label = "external_confirmation_record";
|
|
18
|
+
const root = object(value, label, [
|
|
19
|
+
"schema_version",
|
|
20
|
+
"confirmation_ref",
|
|
21
|
+
"compiled_identity",
|
|
22
|
+
"authority_revision",
|
|
23
|
+
"candidate",
|
|
24
|
+
"actor",
|
|
25
|
+
"session",
|
|
26
|
+
"results",
|
|
27
|
+
"artifact_hashes",
|
|
28
|
+
"relevant_input_identity",
|
|
29
|
+
"record_sha256",
|
|
30
|
+
]);
|
|
31
|
+
const schemaVersion = literal(root.schema_version, ["long-task-external-confirmation-record-v1"], `${label}.schema_version`);
|
|
32
|
+
const candidate = object(root.candidate, `${label}.candidate`, [
|
|
33
|
+
"git_head",
|
|
34
|
+
"git_tree",
|
|
35
|
+
"snapshot_sha256",
|
|
36
|
+
]);
|
|
37
|
+
const actor = object(root.actor, `${label}.actor`, [
|
|
38
|
+
"id",
|
|
39
|
+
"role",
|
|
40
|
+
"authority_kind",
|
|
41
|
+
]);
|
|
42
|
+
const session = object(root.session, `${label}.session`, [
|
|
43
|
+
"id",
|
|
44
|
+
"target_ref",
|
|
45
|
+
"environment_identity",
|
|
46
|
+
"started_at",
|
|
47
|
+
"completed_at",
|
|
48
|
+
]);
|
|
49
|
+
const startedAt = timestamp(session.started_at, `${label}.session.started_at`);
|
|
50
|
+
const completedAt = timestamp(session.completed_at, `${label}.session.completed_at`);
|
|
51
|
+
if (Date.parse(completedAt) < Date.parse(startedAt))
|
|
52
|
+
invalid(`${label}.session`, "completed_at precedes started_at");
|
|
53
|
+
const results = array(root.results, `${label}.results`).map((item, index) => parseResult(item, `${label}.results[${index}]`));
|
|
54
|
+
if (!results.length)
|
|
55
|
+
invalid(`${label}.results`, "must not be empty");
|
|
56
|
+
unique(results.map((result) => result.obligation_ref), `${label}.results.obligation_ref`);
|
|
57
|
+
const artifactHashes = hashMap(root.artifact_hashes, `${label}.artifact_hashes`);
|
|
58
|
+
const record = {
|
|
59
|
+
schema_version: schemaVersion,
|
|
60
|
+
confirmation_ref: key(root.confirmation_ref, `${label}.confirmation_ref`),
|
|
61
|
+
compiled_identity: hash(root.compiled_identity, `${label}.compiled_identity`),
|
|
62
|
+
authority_revision: nonnegativeInteger(root.authority_revision, `${label}.authority_revision`),
|
|
63
|
+
candidate: {
|
|
64
|
+
git_head: gitObject(candidate.git_head, `${label}.candidate.git_head`),
|
|
65
|
+
git_tree: gitObject(candidate.git_tree, `${label}.candidate.git_tree`),
|
|
66
|
+
snapshot_sha256: hash(candidate.snapshot_sha256, `${label}.candidate.snapshot_sha256`),
|
|
67
|
+
},
|
|
68
|
+
actor: {
|
|
69
|
+
id: string(actor.id, `${label}.actor.id`),
|
|
70
|
+
role: string(actor.role, `${label}.actor.role`),
|
|
71
|
+
authority_kind: literal(actor.authority_kind, ["human", "expert", "external_system"], `${label}.actor.authority_kind`),
|
|
72
|
+
},
|
|
73
|
+
session: {
|
|
74
|
+
id: string(session.id, `${label}.session.id`),
|
|
75
|
+
target_ref: semanticRef(session.target_ref, `${label}.session.target_ref`),
|
|
76
|
+
environment_identity: string(session.environment_identity, `${label}.session.environment_identity`),
|
|
77
|
+
started_at: startedAt,
|
|
78
|
+
completed_at: completedAt,
|
|
79
|
+
},
|
|
80
|
+
results,
|
|
81
|
+
artifact_hashes: artifactHashes,
|
|
82
|
+
relevant_input_identity: relevantInputIdentity(root.relevant_input_identity, `${label}.relevant_input_identity`),
|
|
83
|
+
record_sha256: hash(root.record_sha256, `${label}.record_sha256`),
|
|
84
|
+
};
|
|
85
|
+
assertJsonValue(record, label, 0);
|
|
86
|
+
const expectedHash = externalConfirmationRecordHash(record);
|
|
87
|
+
if (record.record_sha256 !== expectedHash)
|
|
88
|
+
invalid(`${label}.record_sha256`, "integrity mismatch");
|
|
89
|
+
return record;
|
|
90
|
+
}
|
|
91
|
+
export function parseExternalConfirmationRecordV2(value) {
|
|
92
|
+
const label = "external_confirmation_record";
|
|
93
|
+
const root = object(value, label, [
|
|
94
|
+
"schema_version",
|
|
95
|
+
"confirmation_ref",
|
|
96
|
+
"compiled_identity",
|
|
97
|
+
"authority_revision",
|
|
98
|
+
"candidate",
|
|
99
|
+
"challenge",
|
|
100
|
+
"actor",
|
|
101
|
+
"session",
|
|
102
|
+
"results",
|
|
103
|
+
"artifact_snapshots",
|
|
104
|
+
"relevant_input_identity",
|
|
105
|
+
"attestation",
|
|
106
|
+
"record_sha256",
|
|
107
|
+
]);
|
|
108
|
+
const candidate = parseCandidate(root.candidate, `${label}.candidate`);
|
|
109
|
+
const actor = parseActor(root.actor, `${label}.actor`);
|
|
110
|
+
const session = parseSession(root.session, `${label}.session`);
|
|
111
|
+
const results = array(root.results, `${label}.results`).map((item, index) => parseResultV2(item, `${label}.results[${index}]`));
|
|
112
|
+
if (!results.length)
|
|
113
|
+
invalid(`${label}.results`, "must not be empty");
|
|
114
|
+
unique(results.map((result) => result.obligation_ref), `${label}.results.obligation_ref`);
|
|
115
|
+
const attestation = object(root.attestation, `${label}.attestation`, [
|
|
116
|
+
"scheme",
|
|
117
|
+
"key_id",
|
|
118
|
+
"signature_base64",
|
|
119
|
+
]);
|
|
120
|
+
const record = {
|
|
121
|
+
schema_version: literal(root.schema_version, ["long-task-external-confirmation-record-v2"], `${label}.schema_version`),
|
|
122
|
+
confirmation_ref: key(root.confirmation_ref, `${label}.confirmation_ref`),
|
|
123
|
+
compiled_identity: hash(root.compiled_identity, `${label}.compiled_identity`),
|
|
124
|
+
authority_revision: nonnegativeInteger(root.authority_revision, `${label}.authority_revision`),
|
|
125
|
+
candidate,
|
|
126
|
+
challenge: challenge(root.challenge, `${label}.challenge`),
|
|
127
|
+
actor,
|
|
128
|
+
session,
|
|
129
|
+
results,
|
|
130
|
+
artifact_snapshots: parseArtifactSnapshots(root.artifact_snapshots, `${label}.artifact_snapshots`),
|
|
131
|
+
relevant_input_identity: relevantInputIdentity(root.relevant_input_identity, `${label}.relevant_input_identity`),
|
|
132
|
+
attestation: {
|
|
133
|
+
scheme: literal(attestation.scheme, ["ed25519"], `${label}.attestation.scheme`),
|
|
134
|
+
key_id: key(attestation.key_id, `${label}.attestation.key_id`),
|
|
135
|
+
signature_base64: ed25519Signature(attestation.signature_base64, `${label}.attestation.signature_base64`),
|
|
136
|
+
},
|
|
137
|
+
record_sha256: hash(root.record_sha256, `${label}.record_sha256`),
|
|
138
|
+
};
|
|
139
|
+
assertJsonValue(record, label, 0);
|
|
140
|
+
if (record.record_sha256 !== externalConfirmationRecordV2Hash(record))
|
|
141
|
+
invalid(`${label}.record_sha256`, "integrity mismatch");
|
|
142
|
+
return record;
|
|
143
|
+
}
|
|
144
|
+
export function externalConfirmationRecordHash(record) {
|
|
145
|
+
const { record_sha256: _recordHash, ...unsigned } = record;
|
|
146
|
+
return sha256Hex(canonicalValueJson(unsigned));
|
|
147
|
+
}
|
|
148
|
+
export function signExternalConfirmationRecordV1(unsigned) {
|
|
149
|
+
const record = {
|
|
150
|
+
...unsigned,
|
|
151
|
+
record_sha256: externalConfirmationRecordHash(unsigned),
|
|
152
|
+
};
|
|
153
|
+
return parseExternalConfirmationRecordV1(record);
|
|
154
|
+
}
|
|
155
|
+
export function externalConfirmationRecordV2Hash(record) {
|
|
156
|
+
return sha256Hex(canonicalValueJson(externalConfirmationV2IntegrityPayload(record)));
|
|
157
|
+
}
|
|
158
|
+
export function externalConfirmationV2SignablePayload(record) {
|
|
159
|
+
const { signature_base64: _signature, ...attestation } = record.attestation;
|
|
160
|
+
return canonicalValueJson({ ...record, attestation });
|
|
161
|
+
}
|
|
162
|
+
function externalConfirmationV2IntegrityPayload(record) {
|
|
163
|
+
const { record_sha256: _recordHash, ...withoutHash } = record;
|
|
164
|
+
const { signature_base64: _signature, ...attestation } = withoutHash.attestation;
|
|
165
|
+
return { ...withoutHash, attestation };
|
|
166
|
+
}
|
|
167
|
+
function parseCandidate(value, label) {
|
|
168
|
+
const row = object(value, label, ["git_head", "git_tree", "snapshot_sha256"]);
|
|
169
|
+
return {
|
|
170
|
+
git_head: gitObject(row.git_head, `${label}.git_head`),
|
|
171
|
+
git_tree: gitObject(row.git_tree, `${label}.git_tree`),
|
|
172
|
+
snapshot_sha256: hash(row.snapshot_sha256, `${label}.snapshot_sha256`),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function parseActor(value, label) {
|
|
176
|
+
const row = object(value, label, ["id", "role", "authority_kind"]);
|
|
177
|
+
return {
|
|
178
|
+
id: string(row.id, `${label}.id`),
|
|
179
|
+
role: string(row.role, `${label}.role`),
|
|
180
|
+
authority_kind: literal(row.authority_kind, ["human", "expert", "external_system"], `${label}.authority_kind`),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function parseSession(value, label) {
|
|
184
|
+
const row = object(value, label, [
|
|
185
|
+
"id",
|
|
186
|
+
"target_ref",
|
|
187
|
+
"environment_identity",
|
|
188
|
+
"started_at",
|
|
189
|
+
"completed_at",
|
|
190
|
+
]);
|
|
191
|
+
const startedAt = timestamp(row.started_at, `${label}.started_at`);
|
|
192
|
+
const completedAt = timestamp(row.completed_at, `${label}.completed_at`);
|
|
193
|
+
if (Date.parse(completedAt) < Date.parse(startedAt))
|
|
194
|
+
invalid(label, "completed_at precedes started_at");
|
|
195
|
+
return {
|
|
196
|
+
id: string(row.id, `${label}.id`),
|
|
197
|
+
target_ref: semanticRef(row.target_ref, `${label}.target_ref`),
|
|
198
|
+
environment_identity: string(row.environment_identity, `${label}.environment_identity`),
|
|
199
|
+
started_at: startedAt,
|
|
200
|
+
completed_at: completedAt,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function parseResultV2(value, label) {
|
|
204
|
+
const row = object(value, label, [
|
|
205
|
+
"obligation_ref",
|
|
206
|
+
"fact_ref",
|
|
207
|
+
"claim_ref",
|
|
208
|
+
"applicability_ref",
|
|
209
|
+
"result_kind",
|
|
210
|
+
"verdict",
|
|
211
|
+
"evidence_refs",
|
|
212
|
+
], ["actual", "rationale"]);
|
|
213
|
+
const resultKind = literal(row.result_kind, ["actual", "judgment"], `${label}.result_kind`);
|
|
214
|
+
const verdict = literal(row.verdict, ["passed", "failed", "unable"], `${label}.verdict`);
|
|
215
|
+
const evidenceRefs = array(row.evidence_refs, `${label}.evidence_refs`).map((item, index) => repositoryFile(item, `${label}.evidence_refs[${index}]`));
|
|
216
|
+
unique(evidenceRefs, `${label}.evidence_refs`);
|
|
217
|
+
if (!evidenceRefs.length)
|
|
218
|
+
invalid(`${label}.evidence_refs`, "must not be empty");
|
|
219
|
+
const rationale = Object.hasOwn(row, "rationale")
|
|
220
|
+
? text(row.rationale, `${label}.rationale`)
|
|
221
|
+
: undefined;
|
|
222
|
+
if (resultKind === "judgment") {
|
|
223
|
+
if (Object.hasOwn(row, "actual"))
|
|
224
|
+
invalid(`${label}.actual`, "is not allowed for judgment");
|
|
225
|
+
if (!rationale)
|
|
226
|
+
invalid(`${label}.rationale`, "is required for judgment");
|
|
227
|
+
}
|
|
228
|
+
else if (verdict !== "unable" && !Object.hasOwn(row, "actual"))
|
|
229
|
+
invalid(`${label}.actual`, "is required for an objective result");
|
|
230
|
+
else if (verdict === "unable" && !rationale)
|
|
231
|
+
invalid(`${label}.rationale`, "is required when unable");
|
|
232
|
+
const result = {
|
|
233
|
+
obligation_ref: semanticRef(row.obligation_ref, `${label}.obligation_ref`),
|
|
234
|
+
fact_ref: nullable(row.fact_ref, (item) => semanticRef(item, `${label}.fact_ref`)),
|
|
235
|
+
claim_ref: semanticRef(row.claim_ref, `${label}.claim_ref`),
|
|
236
|
+
applicability_ref: semanticRef(row.applicability_ref, `${label}.applicability_ref`),
|
|
237
|
+
result_kind: resultKind,
|
|
238
|
+
...(Object.hasOwn(row, "actual") ? { actual: row.actual } : {}),
|
|
239
|
+
verdict,
|
|
240
|
+
evidence_refs: evidenceRefs,
|
|
241
|
+
...(rationale ? { rationale } : {}),
|
|
242
|
+
};
|
|
243
|
+
if (Object.hasOwn(result, "actual"))
|
|
244
|
+
assertJsonValue(result.actual, `${label}.actual`, 0);
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
function parseArtifactSnapshots(value, label) {
|
|
248
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
249
|
+
invalid(label, "must be an object");
|
|
250
|
+
const rows = [];
|
|
251
|
+
for (const [rawRef, rawSnapshot] of Object.entries(value)) {
|
|
252
|
+
const evidenceRef = repositoryFile(rawRef, `${label}.${rawRef}`);
|
|
253
|
+
const snapshot = object(rawSnapshot, `${label}.${rawRef}`, [
|
|
254
|
+
"sha256",
|
|
255
|
+
"size_bytes",
|
|
256
|
+
"media_type",
|
|
257
|
+
"store_ref",
|
|
258
|
+
]);
|
|
259
|
+
rows.push([
|
|
260
|
+
evidenceRef,
|
|
261
|
+
{
|
|
262
|
+
sha256: hash(snapshot.sha256, `${label}.${rawRef}.sha256`),
|
|
263
|
+
size_bytes: nonnegativeInteger(snapshot.size_bytes, `${label}.${rawRef}.size_bytes`),
|
|
264
|
+
media_type: nullable(snapshot.media_type, (item) => string(item, `${label}.${rawRef}.media_type`)),
|
|
265
|
+
store_ref: repositoryFile(snapshot.store_ref, `${label}.${rawRef}.store_ref`),
|
|
266
|
+
},
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
if (!rows.length)
|
|
270
|
+
invalid(label, "must not be empty");
|
|
271
|
+
unique(rows.map(([evidenceRef]) => evidenceRef), label);
|
|
272
|
+
return Object.fromEntries(rows.sort(([left], [right]) => left.localeCompare(right)));
|
|
273
|
+
}
|
|
274
|
+
function parseResult(value, label) {
|
|
275
|
+
const row = object(value, label, [
|
|
276
|
+
"obligation_ref",
|
|
277
|
+
"fact_ref",
|
|
278
|
+
"claim_ref",
|
|
279
|
+
"applicability_ref",
|
|
280
|
+
"verdict",
|
|
281
|
+
"evidence_refs",
|
|
282
|
+
], ["actual", "rationale"]);
|
|
283
|
+
const evidenceRefs = array(row.evidence_refs, `${label}.evidence_refs`).map((item, index) => repositoryFile(item, `${label}.evidence_refs[${index}]`));
|
|
284
|
+
unique(evidenceRefs, `${label}.evidence_refs`);
|
|
285
|
+
if (!evidenceRefs.length)
|
|
286
|
+
invalid(`${label}.evidence_refs`, "must not be empty");
|
|
287
|
+
const result = {
|
|
288
|
+
obligation_ref: semanticRef(row.obligation_ref, `${label}.obligation_ref`),
|
|
289
|
+
fact_ref: nullable(row.fact_ref, (item) => semanticRef(item, `${label}.fact_ref`)),
|
|
290
|
+
claim_ref: semanticRef(row.claim_ref, `${label}.claim_ref`),
|
|
291
|
+
applicability_ref: semanticRef(row.applicability_ref, `${label}.applicability_ref`),
|
|
292
|
+
...(Object.hasOwn(row, "actual") ? { actual: row.actual } : {}),
|
|
293
|
+
verdict: literal(row.verdict, ["passed", "failed", "unable"], `${label}.verdict`),
|
|
294
|
+
evidence_refs: evidenceRefs,
|
|
295
|
+
...(Object.hasOwn(row, "rationale")
|
|
296
|
+
? { rationale: text(row.rationale, `${label}.rationale`) }
|
|
297
|
+
: {}),
|
|
298
|
+
};
|
|
299
|
+
if (Object.hasOwn(result, "actual"))
|
|
300
|
+
assertJsonValue(result.actual, `${label}.actual`, 0);
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
function hashMap(value, label) {
|
|
304
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
305
|
+
invalid(label, "must be an object");
|
|
306
|
+
const rows = [];
|
|
307
|
+
for (const [rawPath, rawHash] of Object.entries(value))
|
|
308
|
+
rows.push([
|
|
309
|
+
repositoryFile(rawPath, `${label}.${rawPath}`),
|
|
310
|
+
hash(rawHash, `${label}.${rawPath}`),
|
|
311
|
+
]);
|
|
312
|
+
if (!rows.length)
|
|
313
|
+
invalid(label, "must not be empty");
|
|
314
|
+
unique(rows.map(([file]) => file), label);
|
|
315
|
+
return Object.fromEntries(rows.sort(([left], [right]) => left.localeCompare(right)));
|
|
316
|
+
}
|
|
317
|
+
function hash(value, label) {
|
|
318
|
+
const result = string(value, label);
|
|
319
|
+
if (!HASH.test(result))
|
|
320
|
+
invalid(label, "must be a lowercase SHA-256 digest");
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
function gitObject(value, label) {
|
|
324
|
+
const result = string(value, label);
|
|
325
|
+
if (!GIT_OBJECT.test(result))
|
|
326
|
+
invalid(label, "must be a Git object id");
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
function relevantInputIdentity(value, label) {
|
|
330
|
+
const result = string(value, label);
|
|
331
|
+
if (!RELEVANT_INPUT.test(result))
|
|
332
|
+
invalid(label, "must be bounded:<sha256> or whole:<sha256>");
|
|
333
|
+
return result;
|
|
334
|
+
}
|
|
335
|
+
function challenge(value, label) {
|
|
336
|
+
const result = string(value, label);
|
|
337
|
+
if (!CHALLENGE.test(result))
|
|
338
|
+
invalid(label, "must be a canonical 256-bit base64url challenge");
|
|
339
|
+
return result;
|
|
340
|
+
}
|
|
341
|
+
function ed25519Signature(value, label) {
|
|
342
|
+
const result = string(value, label);
|
|
343
|
+
const decoded = Buffer.from(result, "base64");
|
|
344
|
+
if (decoded.length !== 64 || decoded.toString("base64") !== result)
|
|
345
|
+
invalid(label, "must be a canonical 64-byte Ed25519 signature");
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
function timestamp(value, label) {
|
|
349
|
+
const result = string(value, label);
|
|
350
|
+
const epoch = Date.parse(result);
|
|
351
|
+
if (!Number.isFinite(epoch) || new Date(epoch).toISOString() !== result)
|
|
352
|
+
invalid(label, "must be a canonical ISO-8601 timestamp");
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
function nonnegativeInteger(value, label) {
|
|
356
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
357
|
+
invalid(label, "must be a non-negative safe integer");
|
|
358
|
+
return value;
|
|
359
|
+
}
|
|
360
|
+
function unique(values, label) {
|
|
361
|
+
if (new Set(values).size !== values.length)
|
|
362
|
+
invalid(label, "must not contain duplicates");
|
|
363
|
+
}
|
|
364
|
+
function assertJsonValue(value, label, depth) {
|
|
365
|
+
if (depth > 64)
|
|
366
|
+
invalid(label, "JSON nesting exceeds 64 levels");
|
|
367
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
368
|
+
return;
|
|
369
|
+
if (typeof value === "number") {
|
|
370
|
+
if (!Number.isFinite(value))
|
|
371
|
+
invalid(label, "number must be finite");
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (Array.isArray(value)) {
|
|
375
|
+
value.forEach((item, index) => assertJsonValue(item, `${label}[${index}]`, depth + 1));
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (value && typeof value === "object") {
|
|
379
|
+
for (const [name, item] of Object.entries(value))
|
|
380
|
+
assertJsonValue(item, `${label}.${name}`, depth + 1);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
invalid(label, "must be JSON-serializable");
|
|
384
|
+
}
|
|
385
|
+
function invalid(label, message) {
|
|
386
|
+
throw new Error(`external_confirmation_record_invalid:${label}:${message}`);
|
|
387
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExternalConfirmationRecord, ExternalConfirmationRecordV2 } from "./long-task-external-confirmation-types.js";
|
|
2
|
+
export interface StoredExternalConfirmationRecordV1 {
|
|
3
|
+
record: ExternalConfirmationRecord | null;
|
|
4
|
+
error: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function externalConfirmationRecordPath(workdir: string, confirmationRef: string): string;
|
|
7
|
+
export declare function captureStoredExternalConfirmationRecordIdentities(repository: string, workdir: string, confirmationRefs: readonly string[]): Promise<Record<string, string>>;
|
|
8
|
+
export declare function readStoredExternalConfirmationRecord(repository: string, workdir: string, confirmationRef: string): Promise<StoredExternalConfirmationRecordV1>;
|
|
9
|
+
export declare function writeStoredExternalConfirmationRecord(repository: string, workdir: string, record: ExternalConfirmationRecordV2): Promise<string>;
|
|
10
|
+
export declare function revokeStoredExternalConfirmationRecord(repository: string, workdir: string, confirmationRef: string): Promise<boolean>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { lstat, open, readFile, rename, rm } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { assertProtectedRepositoryFile, assertSafeRepositoryFilePath, ensureSafeRepositoryDirectory, } from "./repository-path-safety.js";
|
|
4
|
+
import { runtimePath } from "./long-task-state.js";
|
|
5
|
+
import { parseExternalConfirmationRecord, parseExternalConfirmationRecordV2, } from "./long-task-external-confirmation-shape.js";
|
|
6
|
+
import { canonicalJson, sha256Hex } from "./strict-codec.js";
|
|
7
|
+
const EXTERNAL_CONFIRMATIONS_FOLDER = "external-confirmations";
|
|
8
|
+
const MAX_RECORD_BYTES = 16 * 1024 * 1024;
|
|
9
|
+
export function externalConfirmationRecordPath(workdir, confirmationRef) {
|
|
10
|
+
assertConfirmationKey(confirmationRef);
|
|
11
|
+
return runtimePath(workdir, `${EXTERNAL_CONFIRMATIONS_FOLDER}/${confirmationRef}.json`);
|
|
12
|
+
}
|
|
13
|
+
export async function captureStoredExternalConfirmationRecordIdentities(repository, workdir, confirmationRefs) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const confirmationRef of [...new Set(confirmationRefs)].sort()) {
|
|
16
|
+
const file = externalConfirmationRecordPath(workdir, confirmationRef);
|
|
17
|
+
const status = await lstat(file).catch((error) => {
|
|
18
|
+
if (error.code === "ENOENT")
|
|
19
|
+
return null;
|
|
20
|
+
throw error;
|
|
21
|
+
});
|
|
22
|
+
if (!status) {
|
|
23
|
+
result[confirmationRef] = "absent";
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const protectedFile = await assertProtectedRepositoryFile(repository, file, `external_confirmation_record:${confirmationRef}`);
|
|
27
|
+
result[confirmationRef] =
|
|
28
|
+
`sha256:${sha256Hex(await readFile(protectedFile))}`;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
export async function readStoredExternalConfirmationRecord(repository, workdir, confirmationRef) {
|
|
33
|
+
const file = externalConfirmationRecordPath(workdir, confirmationRef);
|
|
34
|
+
const status = await lstat(file).catch((error) => {
|
|
35
|
+
if (error.code === "ENOENT")
|
|
36
|
+
return null;
|
|
37
|
+
throw error;
|
|
38
|
+
});
|
|
39
|
+
if (!status)
|
|
40
|
+
return { record: null, error: null };
|
|
41
|
+
try {
|
|
42
|
+
const protectedFile = await assertProtectedRepositoryFile(repository, file, `external_confirmation_record:${confirmationRef}`);
|
|
43
|
+
if (status.size > MAX_RECORD_BYTES)
|
|
44
|
+
throw new Error(`external_confirmation_record_too_large:${confirmationRef}:${status.size}`);
|
|
45
|
+
return {
|
|
46
|
+
record: parseExternalConfirmationRecord(JSON.parse(await readFile(protectedFile, "utf8"))),
|
|
47
|
+
error: null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return { record: null, error: message(error) };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function writeStoredExternalConfirmationRecord(repository, workdir, record) {
|
|
55
|
+
const parsed = parseExternalConfirmationRecordV2(record);
|
|
56
|
+
const folder = path.dirname(externalConfirmationRecordPath(workdir, parsed.confirmation_ref));
|
|
57
|
+
await ensureSafeRepositoryDirectory(repository, repositoryRelative(repository, folder), `external_confirmation_folder:${parsed.confirmation_ref}`);
|
|
58
|
+
const file = externalConfirmationRecordPath(workdir, parsed.confirmation_ref);
|
|
59
|
+
await assertSafeRepositoryFilePath(repository, repositoryRelative(repository, file), `external_confirmation_record:${parsed.confirmation_ref}`, { destinationMayBeAbsent: true });
|
|
60
|
+
const temporary = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
61
|
+
const handle = await open(temporary, "wx");
|
|
62
|
+
try {
|
|
63
|
+
await handle.writeFile(canonicalJson(parsed), "utf8");
|
|
64
|
+
await handle.sync();
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
await handle.close().catch(() => undefined);
|
|
68
|
+
await rm(temporary, { force: true });
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
await handle.close();
|
|
72
|
+
try {
|
|
73
|
+
await rename(temporary, file);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
await rm(temporary, { force: true });
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
return file;
|
|
80
|
+
}
|
|
81
|
+
export async function revokeStoredExternalConfirmationRecord(repository, workdir, confirmationRef) {
|
|
82
|
+
const file = externalConfirmationRecordPath(workdir, confirmationRef);
|
|
83
|
+
const status = await lstat(file).catch((error) => {
|
|
84
|
+
if (error.code === "ENOENT")
|
|
85
|
+
return null;
|
|
86
|
+
throw error;
|
|
87
|
+
});
|
|
88
|
+
if (!status)
|
|
89
|
+
return false;
|
|
90
|
+
const safe = await assertSafeRepositoryFilePath(repository, repositoryRelative(repository, file), `external_confirmation_record:${confirmationRef}`, { destinationMayBeAbsent: true });
|
|
91
|
+
await rm(safe.absolute, { force: true });
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function repositoryRelative(repository, candidate) {
|
|
95
|
+
const relative = path.relative(path.resolve(repository), path.resolve(candidate));
|
|
96
|
+
if (!relative ||
|
|
97
|
+
relative === ".." ||
|
|
98
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
99
|
+
path.isAbsolute(relative))
|
|
100
|
+
throw new Error("external_confirmation_state_outside_repository");
|
|
101
|
+
return relative.replace(/\\/gu, "/");
|
|
102
|
+
}
|
|
103
|
+
function assertConfirmationKey(value) {
|
|
104
|
+
if (!/^[a-z0-9][a-z0-9-]*$/u.test(value))
|
|
105
|
+
throw new Error(`external_confirmation_key_invalid:${value}`);
|
|
106
|
+
}
|
|
107
|
+
function message(error) {
|
|
108
|
+
return error instanceof Error ? error.message : String(error);
|
|
109
|
+
}
|