project-tiny-context-harness 0.2.85 → 0.6.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 +163 -428
- package/assets/README.md +283 -455
- package/assets/README.zh-CN.md +199 -123
- package/assets/agents/AGENTS_CORE.md +54 -67
- package/assets/context_templates/context.toml +3 -0
- package/assets/context_templates/global.md +6 -6
- package/assets/github/harness.yml +2 -2
- package/assets/skills/context_development_engineer/SKILL.md +91 -107
- package/assets/skills/context_product_plan/SKILL.md +18 -28
- package/assets/skills/context_surface_contract/SKILL.md +35 -38
- package/assets/skills/context_uiux_design/SKILL.md +31 -30
- package/assets/skills/long-task-workflow/SKILL.md +76 -0
- package/assets/skills/long-task-workflow/agents/openai.yaml +4 -0
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +41 -0
- package/assets/skills/long-task-workflow/references/contract-authoring.md +62 -0
- package/assets/skills/long-task-workflow/references/evidence-design.md +45 -0
- package/assets/skills/normal-long-task/SKILL.md +12 -489
- package/assets/skills/source-plan-authoring/SKILL.md +379 -0
- package/assets/tools/validate_context.py +293 -127
- package/dist/cli.js +3 -1
- package/dist/commands/check-modularity.js +33 -10
- package/dist/commands/composite-campaign.d.ts +1 -0
- package/dist/commands/composite-campaign.js +8 -0
- package/dist/commands/composite-long-task.d.ts +1 -6
- package/dist/commands/composite-long-task.js +7 -163
- package/dist/commands/delivery-set.d.ts +1 -0
- package/dist/commands/delivery-set.js +8 -0
- package/dist/commands/disable.d.ts +1 -0
- package/dist/commands/disable.js +15 -0
- package/dist/commands/enable.d.ts +1 -0
- package/dist/commands/enable.js +14 -0
- package/dist/commands/export-context-args.js +13 -4
- package/dist/commands/export-context.js +18 -7
- package/dist/commands/index.js +42 -30
- package/dist/commands/init.js +12 -6
- package/dist/commands/long-task-authoring.d.ts +3 -0
- package/dist/commands/long-task-authoring.js +92 -0
- package/dist/commands/long-task-explain.d.ts +1 -0
- package/dist/commands/long-task-explain.js +52 -0
- package/dist/commands/long-task.d.ts +1 -0
- package/dist/commands/long-task.js +226 -0
- package/dist/commands/package-source.js +2 -2
- package/dist/commands/upgrade.js +10 -10
- package/dist/index.d.ts +11 -1
- package/dist/index.js +8 -0
- package/dist/lib/config.js +34 -8
- package/dist/lib/context-default-footprint.d.ts +16 -0
- package/dist/lib/context-default-footprint.js +107 -0
- package/dist/lib/context-export.js +105 -41
- package/dist/lib/context-graph-snapshot.d.ts +18 -0
- package/dist/lib/context-graph-snapshot.js +171 -0
- package/dist/lib/context-manifest-schema.d.ts +28 -0
- package/dist/lib/context-manifest-schema.js +150 -0
- package/dist/lib/context-manifest.js +28 -20
- package/dist/lib/context-templates.js +5 -5
- package/dist/lib/design-md.js +1 -1
- package/dist/lib/doctor.js +54 -1
- package/dist/lib/harness-root.js +25 -8
- package/dist/lib/init.js +6 -3
- package/dist/lib/legacy-managed-scan.js +23 -7
- package/dist/lib/legacy-sdlc-migration.js +21 -11
- package/dist/lib/long-task-acceptance-reference.d.ts +22 -0
- package/dist/lib/long-task-acceptance-reference.js +46 -0
- package/dist/lib/long-task-acceptance-shape.d.ts +5 -0
- package/dist/lib/long-task-acceptance-shape.js +131 -0
- package/dist/lib/long-task-activation-validation.d.ts +21 -0
- package/dist/lib/long-task-activation-validation.js +136 -0
- package/dist/lib/long-task-artifacts.d.ts +5 -0
- package/dist/lib/long-task-artifacts.js +34 -0
- package/dist/lib/long-task-assertions-v2.d.ts +22 -0
- package/dist/lib/long-task-assertions-v2.js +212 -0
- package/dist/lib/long-task-authoring-authority-preview.d.ts +5 -0
- package/dist/lib/long-task-authoring-authority-preview.js +85 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.d.ts +8 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.js +179 -0
- package/dist/lib/long-task-authoring-preflight-repair-order.d.ts +8 -0
- package/dist/lib/long-task-authoring-preflight-repair-order.js +95 -0
- package/dist/lib/long-task-authoring-preflight-types.d.ts +46 -0
- package/dist/lib/long-task-authoring-preflight-types.js +38 -0
- package/dist/lib/long-task-authoring-preflight.d.ts +3 -0
- package/dist/lib/long-task-authoring-preflight.js +44 -0
- package/dist/lib/long-task-authority-material-diff.d.ts +17 -0
- package/dist/lib/long-task-authority-material-diff.js +152 -0
- package/dist/lib/long-task-authority-materials.d.ts +7 -0
- package/dist/lib/long-task-authority-materials.js +83 -0
- package/dist/lib/long-task-authority-policy.d.ts +168 -0
- package/dist/lib/long-task-authority-policy.js +181 -0
- package/dist/lib/long-task-authority-revision-details.d.ts +19 -0
- package/dist/lib/long-task-authority-revision-details.js +192 -0
- package/dist/lib/long-task-authority-revision-enforcement.d.ts +3 -0
- package/dist/lib/long-task-authority-revision-enforcement.js +41 -0
- package/dist/lib/long-task-authority-revision-types.d.ts +50 -0
- package/dist/lib/long-task-authority-revision-types.js +1 -0
- package/dist/lib/long-task-authority-revision.d.ts +4 -0
- package/dist/lib/long-task-authority-revision.js +188 -0
- package/dist/lib/long-task-authority-transition-policy.d.ts +62 -0
- package/dist/lib/long-task-authority-transition-policy.js +62 -0
- package/dist/lib/long-task-authority-types.d.ts +96 -0
- package/dist/lib/long-task-authority-types.js +1 -0
- package/dist/lib/long-task-authority.d.ts +7 -0
- package/dist/lib/long-task-authority.js +142 -0
- package/dist/lib/long-task-boundary-check.d.ts +15 -0
- package/dist/lib/long-task-boundary-check.js +9 -0
- package/dist/lib/long-task-check-evidence-decoder.d.ts +3 -0
- package/dist/lib/long-task-check-evidence-decoder.js +74 -0
- package/dist/lib/long-task-check-execution-policy.d.ts +18 -0
- package/dist/lib/long-task-check-execution-policy.js +36 -0
- package/dist/lib/long-task-check-runner.d.ts +2 -0
- package/dist/lib/long-task-check-runner.js +181 -0
- package/dist/lib/long-task-check-shape.d.ts +2 -0
- package/dist/lib/long-task-check-shape.js +136 -0
- package/dist/lib/long-task-claim-definitions.d.ts +7 -0
- package/dist/lib/long-task-claim-definitions.js +78 -0
- package/dist/lib/long-task-claim-proof-policy.d.ts +4 -0
- package/dist/lib/long-task-claim-proof-policy.js +57 -0
- package/dist/lib/long-task-claims.d.ts +10 -0
- package/dist/lib/long-task-claims.js +187 -0
- package/dist/lib/long-task-context-authority-topology.d.ts +7 -0
- package/dist/lib/long-task-context-authority-topology.js +37 -0
- package/dist/lib/long-task-context-authority.d.ts +14 -0
- package/dist/lib/long-task-context-authority.js +66 -0
- package/dist/lib/long-task-contract-types.d.ts +203 -0
- package/dist/lib/long-task-contract-types.js +1 -0
- package/dist/lib/long-task-counterfactual-claim-policy.d.ts +10 -0
- package/dist/lib/long-task-counterfactual-claim-policy.js +57 -0
- package/dist/lib/long-task-counterfactual-sandbox.d.ts +6 -0
- package/dist/lib/long-task-counterfactual-sandbox.js +87 -0
- package/dist/lib/long-task-counterfactual-types.d.ts +24 -0
- package/dist/lib/long-task-counterfactual-types.js +1 -0
- package/dist/lib/long-task-delivery-compiler.d.ts +10 -0
- package/dist/lib/long-task-delivery-compiler.js +129 -0
- package/dist/lib/long-task-delivery-parser.d.ts +13 -0
- package/dist/lib/long-task-delivery-parser.js +90 -0
- package/dist/lib/long-task-delivery-preflight.d.ts +5 -0
- package/dist/lib/long-task-delivery-preflight.js +151 -0
- package/dist/lib/long-task-delivery-shape.d.ts +5 -0
- package/dist/lib/long-task-delivery-shape.js +5 -0
- package/dist/lib/long-task-delivery-types.d.ts +8 -0
- package/dist/lib/long-task-delivery-types.js +8 -0
- package/dist/lib/long-task-delivery-validation.d.ts +3 -0
- package/dist/lib/long-task-delivery-validation.js +175 -0
- package/dist/lib/long-task-evidence-adapter-policy.d.ts +4 -0
- package/dist/lib/long-task-evidence-adapter-policy.js +15 -0
- package/dist/lib/long-task-evidence-adapter-types.d.ts +1 -0
- package/dist/lib/long-task-evidence-adapter-types.js +1 -0
- package/dist/lib/long-task-evidence-findings.d.ts +5 -0
- package/dist/lib/long-task-evidence-findings.js +113 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +4 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.js +98 -0
- package/dist/lib/long-task-evidence-v2.d.ts +5 -0
- package/dist/lib/long-task-evidence-v2.js +226 -0
- package/dist/lib/long-task-explain-acceptance-link.d.ts +46 -0
- package/dist/lib/long-task-explain-acceptance-link.js +96 -0
- package/dist/lib/long-task-explain-claim-links.d.ts +45 -0
- package/dist/lib/long-task-explain-claim-links.js +88 -0
- package/dist/lib/long-task-explain-source-links.d.ts +93 -0
- package/dist/lib/long-task-explain-source-links.js +51 -0
- package/dist/lib/long-task-final-v2.d.ts +2 -0
- package/dist/lib/long-task-final-v2.js +124 -0
- package/dist/lib/long-task-finding-context.d.ts +3 -0
- package/dist/lib/long-task-finding-context.js +63 -0
- package/dist/lib/long-task-freshness.d.ts +3 -0
- package/dist/lib/long-task-freshness.js +80 -0
- package/dist/lib/long-task-hook-install.d.ts +9 -0
- package/dist/lib/long-task-hook-install.js +184 -0
- package/dist/lib/long-task-hook-preflight.d.ts +7 -0
- package/dist/lib/long-task-hook-preflight.js +58 -0
- package/dist/lib/long-task-observation-ownership.d.ts +2 -0
- package/dist/lib/long-task-observation-ownership.js +22 -0
- package/dist/lib/long-task-outcome-parser.d.ts +4 -0
- package/dist/lib/long-task-outcome-parser.js +100 -0
- package/dist/lib/long-task-paths.d.ts +49 -0
- package/dist/lib/long-task-paths.js +418 -0
- package/dist/lib/long-task-playwright-counterfactual-policy.d.ts +7 -0
- package/dist/lib/long-task-playwright-counterfactual-policy.js +125 -0
- package/dist/lib/long-task-playwright-evidence.d.ts +6 -0
- package/dist/lib/long-task-playwright-evidence.js +244 -0
- package/dist/lib/long-task-product-shape.d.ts +6 -0
- package/dist/lib/long-task-product-shape.js +73 -0
- package/dist/lib/long-task-progress.d.ts +4 -0
- package/dist/lib/long-task-progress.js +114 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -0
- package/dist/lib/long-task-protected-files.js +30 -0
- package/dist/lib/long-task-required-proof-surfaces.d.ts +2 -0
- package/dist/lib/long-task-required-proof-surfaces.js +13 -0
- package/dist/lib/long-task-requirement-shape.d.ts +2 -0
- package/dist/lib/long-task-requirement-shape.js +18 -0
- package/dist/lib/long-task-risk-surfaces.d.ts +2 -0
- package/dist/lib/long-task-risk-surfaces.js +60 -0
- package/dist/lib/long-task-risk-types.d.ts +5 -0
- package/dist/lib/long-task-risk-types.js +12 -0
- package/dist/lib/long-task-risk.d.ts +9 -0
- package/dist/lib/long-task-risk.js +132 -0
- package/dist/lib/long-task-root-shape.d.ts +4 -0
- package/dist/lib/long-task-root-shape.js +86 -0
- package/dist/lib/long-task-runner-environment.d.ts +7 -0
- package/dist/lib/long-task-runner-environment.js +57 -0
- package/dist/lib/long-task-runner-files.d.ts +3 -0
- package/dist/lib/long-task-runner-files.js +39 -0
- package/dist/lib/long-task-runner-freeze.d.ts +2 -0
- package/dist/lib/long-task-runner-freeze.js +168 -0
- package/dist/lib/long-task-runtime-types.d.ts +214 -0
- package/dist/lib/long-task-runtime-types.js +1 -0
- package/dist/lib/long-task-shape-primitives.d.ts +17 -0
- package/dist/lib/long-task-shape-primitives.js +81 -0
- package/dist/lib/long-task-source-authority-types.d.ts +13 -0
- package/dist/lib/long-task-source-authority-types.js +1 -0
- package/dist/lib/long-task-source-claim-validation.d.ts +5 -0
- package/dist/lib/long-task-source-claim-validation.js +96 -0
- package/dist/lib/long-task-source-continuity.d.ts +4 -0
- package/dist/lib/long-task-source-continuity.js +57 -0
- package/dist/lib/long-task-source-inventory.d.ts +2 -0
- package/dist/lib/long-task-source-inventory.js +21 -0
- package/dist/lib/long-task-source-item-parser.d.ts +3 -0
- package/dist/lib/long-task-source-item-parser.js +112 -0
- package/dist/lib/long-task-source-shape.d.ts +2 -0
- package/dist/lib/long-task-source-shape.js +56 -0
- package/dist/lib/long-task-source-target-continuity.d.ts +4 -0
- package/dist/lib/long-task-source-target-continuity.js +80 -0
- package/dist/lib/long-task-source-target-index.d.ts +12 -0
- package/dist/lib/long-task-source-target-index.js +76 -0
- package/dist/lib/long-task-source-validation.d.ts +3 -0
- package/dist/lib/long-task-source-validation.js +46 -0
- package/dist/lib/long-task-state.d.ts +91 -0
- package/dist/lib/long-task-state.js +611 -0
- package/dist/lib/long-task-status-projection.d.ts +21 -0
- package/dist/lib/long-task-status-projection.js +116 -0
- package/dist/lib/long-task-status-v2.d.ts +37 -0
- package/dist/lib/long-task-status-v2.js +306 -0
- package/dist/lib/long-task-technical-shape.d.ts +3 -0
- package/dist/lib/long-task-technical-shape.js +44 -0
- package/dist/lib/long-task-verifier-authority.d.ts +12 -0
- package/dist/lib/long-task-verifier-authority.js +47 -0
- package/dist/lib/long-task-verifier-identity.d.ts +2 -0
- package/dist/lib/long-task-verifier-identity.js +55 -0
- package/dist/lib/long-task-verifier-v2.d.ts +13 -0
- package/dist/lib/long-task-verifier-v2.js +266 -0
- package/dist/lib/long-task-workspace-runtime-types.d.ts +23 -0
- package/dist/lib/long-task-workspace-runtime-types.js +1 -0
- package/dist/lib/long-task-workspace.d.ts +25 -0
- package/dist/lib/long-task-workspace.js +366 -0
- package/dist/lib/managed-file.js +20 -5
- package/dist/lib/migrations.js +156 -32
- package/dist/lib/modularity.d.ts +27 -1
- package/dist/lib/modularity.js +499 -23
- package/dist/lib/package-json-config.js +14 -5
- package/dist/lib/package-source.js +4 -2
- package/dist/lib/profiles.d.ts +13 -0
- package/dist/lib/profiles.js +66 -0
- package/dist/lib/schema-guard.js +4 -2
- package/dist/lib/source-files.js +14 -7
- package/dist/lib/source-pack-classify.js +91 -19
- package/dist/lib/source-pack-config.js +25 -8
- package/dist/lib/source-pack-export.js +84 -25
- package/dist/lib/source-pack-manifest.js +18 -6
- package/dist/lib/source-pack-records.js +35 -11
- package/dist/lib/source-pack-render.js +47 -18
- package/dist/lib/stable-json.d.ts +2 -0
- package/dist/lib/stable-json.js +21 -0
- package/dist/lib/strict-codec.d.ts +4 -0
- package/dist/lib/strict-codec.js +65 -0
- package/dist/lib/sync-engine.js +76 -24
- package/dist/lib/types.d.ts +8 -1
- package/dist/lib/upgrade.js +4 -3
- package/dist/lib/validators.js +218 -191
- package/dist/long-task-hook.d.ts +2 -0
- package/dist/long-task-hook.js +55 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +340 -0
- package/dist/schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json +18 -0
- package/migrations/README.md +8 -3
- package/package.json +17 -6
- package/source-mappings.yaml +0 -3
- package/assets/protected-harness-baseline.json +0 -20
- package/assets/skills/composite-long-task-workflow/SKILL.md +0 -245
- package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -62
- package/assets/skills/composite-long-task-workflow/assets/goal-objective.template.md +0 -17
- package/assets/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md +0 -682
- package/dist/commands/superpowers.d.ts +0 -1
- package/dist/commands/superpowers.js +0 -8
- package/dist/lib/composite-long-task-renderer.d.ts +0 -12
- package/dist/lib/composite-long-task-renderer.js +0 -109
- package/dist/lib/plan-acceptance-artifacts.d.ts +0 -1
- package/dist/lib/plan-acceptance-artifacts.js +0 -220
- package/dist/lib/plan-acceptance-evidence.d.ts +0 -2
- package/dist/lib/plan-acceptance-evidence.js +0 -108
- package/dist/lib/plan-acceptance-json.d.ts +0 -15
- package/dist/lib/plan-acceptance-json.js +0 -133
- package/dist/lib/plan-acceptance-validator.d.ts +0 -2
- package/dist/lib/plan-acceptance-validator.js +0 -209
- package/dist/lib/plan-contract-validator.d.ts +0 -2
- package/dist/lib/plan-contract-validator.js +0 -127
- package/dist/lib/plan-validator-common.d.ts +0 -24
- package/dist/lib/plan-validator-common.js +0 -196
- package/dist/lib/superpowers-task-ac010.d.ts +0 -6
- package/dist/lib/superpowers-task-ac010.js +0 -26
- package/dist/lib/superpowers-task-assertion-normalizers.d.ts +0 -3
- package/dist/lib/superpowers-task-assertion-normalizers.js +0 -74
- package/dist/lib/superpowers-task-assertions.d.ts +0 -20
- package/dist/lib/superpowers-task-assertions.js +0 -257
- package/dist/lib/superpowers-task-attempt.d.ts +0 -4
- package/dist/lib/superpowers-task-attempt.js +0 -102
- package/dist/lib/superpowers-task-command-run-correlation.d.ts +0 -8
- package/dist/lib/superpowers-task-command-run-correlation.js +0 -103
- package/dist/lib/superpowers-task-command-specs.d.ts +0 -3
- package/dist/lib/superpowers-task-command-specs.js +0 -52
- package/dist/lib/superpowers-task-compile-diagnostics.d.ts +0 -5
- package/dist/lib/superpowers-task-compile-diagnostics.js +0 -20
- package/dist/lib/superpowers-task-compile-guards.d.ts +0 -2
- package/dist/lib/superpowers-task-compile-guards.js +0 -66
- package/dist/lib/superpowers-task-compile.d.ts +0 -6
- package/dist/lib/superpowers-task-compile.js +0 -133
- package/dist/lib/superpowers-task-completion-output.d.ts +0 -91
- package/dist/lib/superpowers-task-completion-output.js +0 -374
- package/dist/lib/superpowers-task-conformance.d.ts +0 -2
- package/dist/lib/superpowers-task-conformance.js +0 -24
- package/dist/lib/superpowers-task-contradictions.d.ts +0 -6
- package/dist/lib/superpowers-task-contradictions.js +0 -126
- package/dist/lib/superpowers-task-current-evidence.d.ts +0 -3
- package/dist/lib/superpowers-task-current-evidence.js +0 -176
- package/dist/lib/superpowers-task-delivery.d.ts +0 -4
- package/dist/lib/superpowers-task-delivery.js +0 -96
- package/dist/lib/superpowers-task-derive.d.ts +0 -14
- package/dist/lib/superpowers-task-derive.js +0 -393
- package/dist/lib/superpowers-task-events.d.ts +0 -1
- package/dist/lib/superpowers-task-events.js +0 -13
- package/dist/lib/superpowers-task-evidence-kernel.d.ts +0 -19
- package/dist/lib/superpowers-task-evidence-kernel.js +0 -347
- package/dist/lib/superpowers-task-evidence-records.d.ts +0 -2
- package/dist/lib/superpowers-task-evidence-records.js +0 -55
- package/dist/lib/superpowers-task-evidence.d.ts +0 -10
- package/dist/lib/superpowers-task-evidence.js +0 -147
- package/dist/lib/superpowers-task-fields.d.ts +0 -22
- package/dist/lib/superpowers-task-fields.js +0 -276
- package/dist/lib/superpowers-task-final-card.d.ts +0 -3
- package/dist/lib/superpowers-task-final-card.js +0 -35
- package/dist/lib/superpowers-task-gates.d.ts +0 -12
- package/dist/lib/superpowers-task-gates.js +0 -267
- package/dist/lib/superpowers-task-harness-drift.d.ts +0 -11
- package/dist/lib/superpowers-task-harness-drift.js +0 -90
- package/dist/lib/superpowers-task-next-slices.d.ts +0 -1
- package/dist/lib/superpowers-task-next-slices.js +0 -12
- package/dist/lib/superpowers-task-protected-baseline.d.ts +0 -10
- package/dist/lib/superpowers-task-protected-baseline.js +0 -66
- package/dist/lib/superpowers-task-source-compile.d.ts +0 -5
- package/dist/lib/superpowers-task-source-compile.js +0 -226
- package/dist/lib/superpowers-task-source-parser.d.ts +0 -23
- package/dist/lib/superpowers-task-source-parser.js +0 -218
- package/dist/lib/superpowers-task-state-schema.d.ts +0 -460
- package/dist/lib/superpowers-task-state-schema.js +0 -66
- package/dist/lib/superpowers-task-state-shape.d.ts +0 -3
- package/dist/lib/superpowers-task-state-shape.js +0 -50
- package/dist/lib/superpowers-task-state.d.ts +0 -16
- package/dist/lib/superpowers-task-state.js +0 -246
- package/dist/lib/superpowers-task-status.d.ts +0 -2
- package/dist/lib/superpowers-task-status.js +0 -24
- package/dist/lib/superpowers-task-under-specified.d.ts +0 -7
- package/dist/lib/superpowers-task-under-specified.js +0 -61
- package/dist/lib/superpowers-task-unregistered-evidence.d.ts +0 -11
- package/dist/lib/superpowers-task-unregistered-evidence.js +0 -72
- package/dist/lib/superpowers-task-validator.d.ts +0 -5
- package/dist/lib/superpowers-task-validator.js +0 -293
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function parseAcceptanceReference(ref) {
|
|
2
|
+
const parts = ref.split(".");
|
|
3
|
+
if (parts.length !== 3 || parts.some((part) => !part))
|
|
4
|
+
throw new Error(`acceptance_reference_invalid:${ref}`);
|
|
5
|
+
const [owner, checkKey, assertionKey] = parts;
|
|
6
|
+
return owner === "GLOBAL"
|
|
7
|
+
? {
|
|
8
|
+
scope: "global",
|
|
9
|
+
check_key: checkKey,
|
|
10
|
+
assertion_key: assertionKey,
|
|
11
|
+
}
|
|
12
|
+
: {
|
|
13
|
+
scope: "outcome",
|
|
14
|
+
outcome_key: owner,
|
|
15
|
+
check_key: checkKey,
|
|
16
|
+
assertion_key: assertionKey,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function resolveAcceptanceAssertion(contract, ref) {
|
|
20
|
+
let reference;
|
|
21
|
+
try {
|
|
22
|
+
reference = parseAcceptanceReference(ref);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const contractLike = contract;
|
|
28
|
+
const checks = reference.scope === "global"
|
|
29
|
+
? contractLike.global.acceptance.checks
|
|
30
|
+
: contractLike.outcomes.find((outcome) => outcome.key === reference.outcome_key)?.acceptance.checks;
|
|
31
|
+
const check = checks?.find((item) => item.key === reference.check_key);
|
|
32
|
+
const assertion = check
|
|
33
|
+
? [...check.positive_assertions, ...check.negative_assertions].find((item) => item.key === reference.assertion_key)
|
|
34
|
+
: null;
|
|
35
|
+
if (!check || !assertion)
|
|
36
|
+
return null;
|
|
37
|
+
return {
|
|
38
|
+
ref,
|
|
39
|
+
scope: reference.scope,
|
|
40
|
+
outcome_key: reference.scope === "outcome" ? reference.outcome_key : null,
|
|
41
|
+
check_key: reference.check_key,
|
|
42
|
+
assertion_key: reference.assertion_key,
|
|
43
|
+
check,
|
|
44
|
+
assertion,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CounterfactualControlV2, EnvironmentRequirementV2, GlobalCounterfactualControlV2, PopulationRequirementV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function parseCounterfactuals(value: unknown, label: string): CounterfactualControlV2[];
|
|
3
|
+
export declare function parseGlobalCounterfactuals(value: unknown, label: string): GlobalCounterfactualControlV2[];
|
|
4
|
+
export declare function parsePopulation(value: unknown, label: string): PopulationRequirementV2;
|
|
5
|
+
export declare function parseEnvironmentRequirements(value: unknown, label: string): EnvironmentRequirementV2[];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { parseKeyedStatements } from "./long-task-product-shape.js";
|
|
2
|
+
import { array, fail, key, literal, object, repositoryFile, repositoryFiles, string, strings, } from "./long-task-shape-primitives.js";
|
|
3
|
+
export function parseCounterfactuals(value, label) {
|
|
4
|
+
return array(value, label).map((item, index) => {
|
|
5
|
+
const itemLabel = `${label}[${index}]`;
|
|
6
|
+
const row = object(item, itemLabel, [
|
|
7
|
+
"key",
|
|
8
|
+
"binding_key",
|
|
9
|
+
"claims",
|
|
10
|
+
"check_key",
|
|
11
|
+
"mutation",
|
|
12
|
+
"expected_assertion_failures",
|
|
13
|
+
]);
|
|
14
|
+
const mutation = object(row.mutation, `${itemLabel}.mutation`, ["type"], ["paths", "path", "fixture_path"]);
|
|
15
|
+
const type = literal(mutation.type, ["remove_paths", "replace_file"], `${itemLabel}.mutation.type`);
|
|
16
|
+
return {
|
|
17
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
18
|
+
binding_key: key(row.binding_key, `${itemLabel}.binding_key`),
|
|
19
|
+
claims: strings(row.claims, `${itemLabel}.claims`),
|
|
20
|
+
check_key: key(row.check_key, `${itemLabel}.check_key`),
|
|
21
|
+
mutation: type === "remove_paths"
|
|
22
|
+
? {
|
|
23
|
+
type,
|
|
24
|
+
paths: repositoryFiles(mutation.paths, `${itemLabel}.mutation.paths`),
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
type,
|
|
28
|
+
path: repositoryFile(mutation.path, `${itemLabel}.mutation.path`),
|
|
29
|
+
fixture_path: repositoryFile(mutation.fixture_path, `${itemLabel}.mutation.fixture_path`),
|
|
30
|
+
},
|
|
31
|
+
expected_assertion_failures: strings(row.expected_assertion_failures, `${itemLabel}.expected_assertion_failures`).map((item, assertionIndex) => key(item, `${itemLabel}.expected_assertion_failures[${assertionIndex}]`)),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export function parseGlobalCounterfactuals(value, label) {
|
|
36
|
+
return array(value, label).map((item, index) => {
|
|
37
|
+
const itemLabel = `${label}[${index}]`;
|
|
38
|
+
const row = object(item, itemLabel, [
|
|
39
|
+
"key",
|
|
40
|
+
"binding_ref",
|
|
41
|
+
"claims",
|
|
42
|
+
"check_key",
|
|
43
|
+
"mutation",
|
|
44
|
+
"expected_assertion_failures",
|
|
45
|
+
]);
|
|
46
|
+
const bindingRef = string(row.binding_ref, `${itemLabel}.binding_ref`);
|
|
47
|
+
if (!/^[a-z0-9][a-z0-9-]*\.[a-z0-9][a-z0-9-]*$/u.test(bindingRef))
|
|
48
|
+
fail(`${itemLabel}.binding_ref`, "must be <outcome-key>.<binding-key>");
|
|
49
|
+
const claims = strings(row.claims, `${itemLabel}.claims`);
|
|
50
|
+
if (!claims.length)
|
|
51
|
+
fail(`${itemLabel}.claims`, "must not be empty");
|
|
52
|
+
const failures = strings(row.expected_assertion_failures, `${itemLabel}.expected_assertion_failures`).map((entry, assertionIndex) => key(entry, `${itemLabel}.expected_assertion_failures[${assertionIndex}]`));
|
|
53
|
+
if (!failures.length)
|
|
54
|
+
fail(`${itemLabel}.expected_assertion_failures`, "must not be empty");
|
|
55
|
+
return {
|
|
56
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
57
|
+
binding_ref: bindingRef,
|
|
58
|
+
claims,
|
|
59
|
+
check_key: key(row.check_key, `${itemLabel}.check_key`),
|
|
60
|
+
mutation: parseCounterfactualMutation(row.mutation, `${itemLabel}.mutation`),
|
|
61
|
+
expected_assertion_failures: failures,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function parseCounterfactualMutation(value, label) {
|
|
66
|
+
const mutation = object(value, label, ["type"], ["paths", "path", "fixture_path"]);
|
|
67
|
+
const type = literal(mutation.type, ["remove_paths", "replace_file"], `${label}.type`);
|
|
68
|
+
return type === "remove_paths"
|
|
69
|
+
? {
|
|
70
|
+
type,
|
|
71
|
+
paths: repositoryFiles(mutation.paths, `${label}.paths`),
|
|
72
|
+
}
|
|
73
|
+
: {
|
|
74
|
+
type,
|
|
75
|
+
path: repositoryFile(mutation.path, `${label}.path`),
|
|
76
|
+
fixture_path: repositoryFile(mutation.fixture_path, `${label}.fixture_path`),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function parsePopulation(value, label) {
|
|
80
|
+
const row = object(value, label, [
|
|
81
|
+
"check_key",
|
|
82
|
+
"claims",
|
|
83
|
+
"observations",
|
|
84
|
+
"exclusion_rules",
|
|
85
|
+
]);
|
|
86
|
+
const observations = object(row.observations, `${label}.observations`, [
|
|
87
|
+
"eligible_ids",
|
|
88
|
+
"observed_ids",
|
|
89
|
+
"excluded_items",
|
|
90
|
+
]);
|
|
91
|
+
return {
|
|
92
|
+
check_key: key(row.check_key, `${label}.check_key`),
|
|
93
|
+
claims: strings(row.claims, `${label}.claims`),
|
|
94
|
+
observations: {
|
|
95
|
+
eligible_ids: string(observations.eligible_ids, `${label}.observations.eligible_ids`),
|
|
96
|
+
observed_ids: string(observations.observed_ids, `${label}.observations.observed_ids`),
|
|
97
|
+
excluded_items: string(observations.excluded_items, `${label}.observations.excluded_items`),
|
|
98
|
+
},
|
|
99
|
+
exclusion_rules: parseKeyedStatements(row.exclusion_rules, `${label}.exclusion_rules`),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function parseEnvironmentRequirements(value, label) {
|
|
103
|
+
return array(value, label).map((item, index) => {
|
|
104
|
+
const itemLabel = `${label}[${index}]`;
|
|
105
|
+
const base = object(item, itemLabel, ["key", "kind"], ["target", "host", "port", "timeout_ms"]);
|
|
106
|
+
const kindValue = literal(base.kind, ["executable", "file", "directory", "env_var", "loopback_tcp"], `${itemLabel}.kind`);
|
|
107
|
+
const requirementKey = key(base.key, `${itemLabel}.key`);
|
|
108
|
+
if (kindValue !== "loopback_tcp")
|
|
109
|
+
return {
|
|
110
|
+
key: requirementKey,
|
|
111
|
+
kind: kindValue,
|
|
112
|
+
target: kindValue === "file" || kindValue === "directory"
|
|
113
|
+
? repositoryFile(base.target, `${itemLabel}.target`)
|
|
114
|
+
: string(base.target, `${itemLabel}.target`),
|
|
115
|
+
};
|
|
116
|
+
const host = literal(base.host, ["127.0.0.1", "::1", "localhost"], `${itemLabel}.host`);
|
|
117
|
+
const port = Number(base.port);
|
|
118
|
+
const timeout = Number(base.timeout_ms);
|
|
119
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
120
|
+
fail(`${itemLabel}.port`, "must be an integer from 1 to 65535");
|
|
121
|
+
if (!Number.isInteger(timeout) || timeout < 10 || timeout > 60_000)
|
|
122
|
+
fail(`${itemLabel}.timeout_ms`, "must be an integer from 10 to 60000");
|
|
123
|
+
return {
|
|
124
|
+
key: requirementKey,
|
|
125
|
+
kind: kindValue,
|
|
126
|
+
host,
|
|
127
|
+
port,
|
|
128
|
+
timeout_ms: timeout,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AuthoringPreflightDiagnosticV1 } from "./long-task-authoring-preflight-types.js";
|
|
2
|
+
import { type CompiledClaimsV2 } from "./long-task-claims.js";
|
|
3
|
+
import type { CompiledCheckV2, CompiledOutcomeV2, CompiledSourceItemV2, ContextAuthoritySnapshotV2, DeliveryContractV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
4
|
+
import { type RiskDecisionV2 } from "./long-task-risk.js";
|
|
5
|
+
export interface ActivationValidationResult {
|
|
6
|
+
claims: CompiledClaimsV2 | null;
|
|
7
|
+
risk: RiskDecisionV2 | null;
|
|
8
|
+
source_hashes: Record<string, string> | null;
|
|
9
|
+
source_items: CompiledSourceItemV2[] | null;
|
|
10
|
+
context_snapshot: ContextAuthoritySnapshotV2 | null;
|
|
11
|
+
workspace: WorkspaceManifestV2 | null;
|
|
12
|
+
global_checks: CompiledCheckV2[];
|
|
13
|
+
outcomes: CompiledOutcomeV2[];
|
|
14
|
+
}
|
|
15
|
+
export declare function validateContractForActivation(options: {
|
|
16
|
+
contract: DeliveryContractV2;
|
|
17
|
+
repository: string;
|
|
18
|
+
workdir: string;
|
|
19
|
+
mode: "collect" | "fail_fast";
|
|
20
|
+
diagnostics?: AuthoringPreflightDiagnosticV1[];
|
|
21
|
+
}): Promise<ActivationValidationResult>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { captureContextGraphSnapshot } from "./context-graph-snapshot.js";
|
|
2
|
+
import { addDiagnosticError } from "./long-task-authoring-preflight-diagnostics.js";
|
|
3
|
+
import { compileProductClaimCoverage, } from "./long-task-claims.js";
|
|
4
|
+
import { hashDeclaredFiles, validateCounterfactualPaths, validateTechnicalPaths, validateVerificationInputSeparation, } from "./long-task-delivery-preflight.js";
|
|
5
|
+
import { validateClaimEvidenceSensitivity } from "./long-task-evidence-sensitivity-policy.js";
|
|
6
|
+
import { deliveryContractStructureDiagnostics, validateDeliveryContractStructure, } from "./long-task-delivery-validation.js";
|
|
7
|
+
import { validateRawExecutionObservationOwnership } from "./long-task-observation-ownership.js";
|
|
8
|
+
import { freezeDeliveryCheck } from "./long-task-runner-freeze.js";
|
|
9
|
+
import { classifyLongTaskRisk, validateRiskProof, } from "./long-task-risk.js";
|
|
10
|
+
import { validateSourceContinuity } from "./long-task-source-continuity.js";
|
|
11
|
+
import { compileSourceInventory } from "./long-task-source-inventory.js";
|
|
12
|
+
import { validateSourceTargetContinuity } from "./long-task-source-target-continuity.js";
|
|
13
|
+
import { validateSourceAnchors } from "./long-task-source-validation.js";
|
|
14
|
+
import { captureWorkspaceManifest, repoRelative, } from "./long-task-workspace.js";
|
|
15
|
+
export async function validateContractForActivation(options) {
|
|
16
|
+
const { contract, repository, workdir, mode } = options;
|
|
17
|
+
const diagnostics = options.diagnostics ?? [];
|
|
18
|
+
if (mode === "collect")
|
|
19
|
+
for (const error of deliveryContractStructureDiagnostics(contract))
|
|
20
|
+
addDiagnosticError(diagnostics, error);
|
|
21
|
+
else
|
|
22
|
+
validateDeliveryContractStructure(contract);
|
|
23
|
+
const claims = await attempt(mode, diagnostics, () => compileProductClaimCoverage(contract));
|
|
24
|
+
if (mode === "fail_fast") {
|
|
25
|
+
const decisions = contract.source_claims
|
|
26
|
+
.filter((claim) => claim.disposition.type === "decision_required")
|
|
27
|
+
.map((claim) => claim.key);
|
|
28
|
+
if (decisions.length)
|
|
29
|
+
throw new Error(`source_claim_decision_required:${decisions.join(",")}`);
|
|
30
|
+
}
|
|
31
|
+
const sourceHashes = await attempt(mode, diagnostics, () => hashDeclaredFiles(repository, contract.task.source_paths, "source"));
|
|
32
|
+
await attempt(mode, diagnostics, () => validateSourceAnchors(repository, contract.source_claims));
|
|
33
|
+
const sourceItems = await attempt(mode, diagnostics, async () => {
|
|
34
|
+
const items = await compileSourceInventory(repository, contract.task.source_paths);
|
|
35
|
+
validateSourceContinuity(contract, items, mode === "collect"
|
|
36
|
+
? (error) => addDiagnosticError(diagnostics, new Error(error))
|
|
37
|
+
: undefined);
|
|
38
|
+
validateSourceTargetContinuity(contract, items, mode === "collect"
|
|
39
|
+
? (error) => addDiagnosticError(diagnostics, new Error(error))
|
|
40
|
+
: undefined);
|
|
41
|
+
return items;
|
|
42
|
+
});
|
|
43
|
+
const risk = await attempt(mode, diagnostics, () => {
|
|
44
|
+
const decision = classifyLongTaskRisk(contract);
|
|
45
|
+
validateRiskProof(contract, decision);
|
|
46
|
+
return decision;
|
|
47
|
+
});
|
|
48
|
+
const context = await attempt(mode, diagnostics, () => captureContextGraphSnapshot(repository, contract.task.context_refs, contract.task.context_snapshot_mode));
|
|
49
|
+
const workdirRelative = repoRelative(repository, workdir);
|
|
50
|
+
const workspace = await attempt(mode, diagnostics, async () => {
|
|
51
|
+
const manifest = await captureWorkspaceManifest(repository, workdir);
|
|
52
|
+
validateTechnicalPaths(contract, repository, workdirRelative, manifest);
|
|
53
|
+
return manifest;
|
|
54
|
+
});
|
|
55
|
+
if (!workspace)
|
|
56
|
+
return emptyCompiledResult(claims, risk, sourceHashes, sourceItems, context);
|
|
57
|
+
const globalChecks = [];
|
|
58
|
+
for (const check of contract.global.acceptance.checks) {
|
|
59
|
+
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, null, repository, workspace), null, check.key);
|
|
60
|
+
if (frozen)
|
|
61
|
+
globalChecks.push(frozen);
|
|
62
|
+
}
|
|
63
|
+
const outcomes = [];
|
|
64
|
+
for (const outcome of contract.outcomes) {
|
|
65
|
+
const checks = [];
|
|
66
|
+
for (const check of outcome.acceptance.checks) {
|
|
67
|
+
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, outcome.key, repository, workspace), outcome.key, check.key);
|
|
68
|
+
if (frozen)
|
|
69
|
+
checks.push(frozen);
|
|
70
|
+
}
|
|
71
|
+
outcomes.push({
|
|
72
|
+
...outcome,
|
|
73
|
+
internal_id: `OUT.${outcome.key}`,
|
|
74
|
+
generated_claims: claims?.by_outcome[outcome.key] ?? [],
|
|
75
|
+
risk_reasons: risk?.reasons_by_outcome[outcome.key] ?? [],
|
|
76
|
+
acceptance: { ...outcome.acceptance, checks },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const allChecks = [
|
|
80
|
+
...globalChecks,
|
|
81
|
+
...outcomes.flatMap((outcome) => outcome.acceptance.checks),
|
|
82
|
+
];
|
|
83
|
+
await attempt(mode, diagnostics, () => validateVerificationInputSeparation(contract, allChecks, workdirRelative));
|
|
84
|
+
await attempt(mode, diagnostics, () => validateRawExecutionObservationOwnership(allChecks));
|
|
85
|
+
if (allGlobalChecksFrozen(contract, globalChecks) &&
|
|
86
|
+
allOutcomeChecksFrozen(contract, outcomes)) {
|
|
87
|
+
await attempt(mode, diagnostics, () => validateCounterfactualPaths(contract, globalChecks, outcomes, repository, workdirRelative, [
|
|
88
|
+
...contract.task.source_paths,
|
|
89
|
+
...(context?.files ?? contract.task.context_refs),
|
|
90
|
+
]));
|
|
91
|
+
await attempt(mode, diagnostics, () => validateClaimEvidenceSensitivity(contract, globalChecks, outcomes, mode === "collect"
|
|
92
|
+
? (error) => addDiagnosticError(diagnostics, new Error(error))
|
|
93
|
+
: undefined));
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
claims,
|
|
97
|
+
risk,
|
|
98
|
+
source_hashes: sourceHashes,
|
|
99
|
+
source_items: sourceItems,
|
|
100
|
+
context_snapshot: context,
|
|
101
|
+
workspace,
|
|
102
|
+
global_checks: globalChecks,
|
|
103
|
+
outcomes,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async function attempt(mode, diagnostics, action, outcomeKey, checkKey) {
|
|
107
|
+
try {
|
|
108
|
+
return await action();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (mode === "fail_fast")
|
|
112
|
+
throw error;
|
|
113
|
+
addDiagnosticError(diagnostics, error, outcomeKey, checkKey);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function emptyCompiledResult(claims, risk, sourceHashes, sourceItems, context) {
|
|
118
|
+
return {
|
|
119
|
+
claims,
|
|
120
|
+
risk,
|
|
121
|
+
source_hashes: sourceHashes,
|
|
122
|
+
source_items: sourceItems,
|
|
123
|
+
context_snapshot: context,
|
|
124
|
+
workspace: null,
|
|
125
|
+
global_checks: [],
|
|
126
|
+
outcomes: [],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function allGlobalChecksFrozen(contract, checks) {
|
|
130
|
+
return checks.length === contract.global.acceptance.checks.length;
|
|
131
|
+
}
|
|
132
|
+
function allOutcomeChecksFrozen(contract, outcomes) {
|
|
133
|
+
return outcomes.every((outcome) => outcome.acceptance.checks.length ===
|
|
134
|
+
contract.outcomes.find((item) => item.key === outcome.key).acceptance
|
|
135
|
+
.checks.length);
|
|
136
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { matchesRepoPattern } from "./long-task-paths.js";
|
|
4
|
+
import { sha256Hex } from "./strict-codec.js";
|
|
5
|
+
export async function collectCheckArtifacts(check, snapshotRoot) {
|
|
6
|
+
if (!check.artifact_globs.length)
|
|
7
|
+
return { hashes: {}, errors: [] };
|
|
8
|
+
const candidates = [];
|
|
9
|
+
async function visit(directory, relative = "") {
|
|
10
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
11
|
+
if (!relative && entry.name === ".git")
|
|
12
|
+
continue;
|
|
13
|
+
const next = relative ? `${relative}/${entry.name}` : entry.name;
|
|
14
|
+
if (entry.isSymbolicLink() || entry.name === "node_modules")
|
|
15
|
+
continue;
|
|
16
|
+
if (entry.isDirectory())
|
|
17
|
+
await visit(path.join(directory, entry.name), next);
|
|
18
|
+
else if (entry.isFile())
|
|
19
|
+
candidates.push(next);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
await visit(snapshotRoot);
|
|
23
|
+
const selected = [
|
|
24
|
+
...new Set(check.artifact_globs.flatMap((pattern) => candidates.filter((candidate) => matchesRepoPattern(candidate, pattern)))),
|
|
25
|
+
].sort();
|
|
26
|
+
const hashes = Object.fromEntries(await Promise.all(selected.map(async (relative) => [
|
|
27
|
+
relative,
|
|
28
|
+
sha256Hex(await readFile(path.join(snapshotRoot, ...relative.split("/")))),
|
|
29
|
+
])));
|
|
30
|
+
const errors = check.artifact_globs
|
|
31
|
+
.filter((pattern) => !selected.some((file) => matchesRepoPattern(file, pattern)))
|
|
32
|
+
.map((pattern) => `artifact_glob_empty:${pattern}`);
|
|
33
|
+
return { hashes, errors };
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DeliveryAssertionV2, PopulationRequirementV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface AssertionComparison {
|
|
3
|
+
comparable: boolean;
|
|
4
|
+
passed: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface DeliveryAssertionEvaluation {
|
|
7
|
+
passed: boolean;
|
|
8
|
+
status: "passed" | "observation_missing" | "observation_type_mismatch" | "assertion_value_mismatch";
|
|
9
|
+
expected?: unknown;
|
|
10
|
+
actual?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function evaluateDeliveryAssertion(assertion: DeliveryAssertionV2, observations: Record<string, unknown>): boolean;
|
|
13
|
+
export declare function evaluateDeliveryAssertionDetailed(assertion: DeliveryAssertionV2, observations: Record<string, unknown>): DeliveryAssertionEvaluation;
|
|
14
|
+
export declare function evaluatePopulation(requirement: PopulationRequirementV2, observations: Record<string, unknown>): {
|
|
15
|
+
passed: boolean;
|
|
16
|
+
actual: unknown;
|
|
17
|
+
reason: string | null;
|
|
18
|
+
};
|
|
19
|
+
export declare function observationValue(observations: Record<string, unknown>, name: string): {
|
|
20
|
+
found: boolean;
|
|
21
|
+
value: unknown;
|
|
22
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
2
|
+
export function evaluateDeliveryAssertion(assertion, observations) {
|
|
3
|
+
return evaluateDeliveryAssertionDetailed(assertion, observations).passed;
|
|
4
|
+
}
|
|
5
|
+
export function evaluateDeliveryAssertionDetailed(assertion, observations) {
|
|
6
|
+
const { found, value } = observationValue(observations, assertion.observation);
|
|
7
|
+
if (!found)
|
|
8
|
+
return {
|
|
9
|
+
passed: false,
|
|
10
|
+
status: "observation_missing",
|
|
11
|
+
expected: assertion.expected,
|
|
12
|
+
};
|
|
13
|
+
if (assertion.operator === "exists")
|
|
14
|
+
return { passed: true, status: "passed", actual: value };
|
|
15
|
+
const expected = assertion.expected;
|
|
16
|
+
let comparison;
|
|
17
|
+
switch (assertion.operator) {
|
|
18
|
+
case "truthy":
|
|
19
|
+
return result(Boolean(value), true, value);
|
|
20
|
+
case "falsy":
|
|
21
|
+
return result(!value, false, value);
|
|
22
|
+
case "equals":
|
|
23
|
+
comparison = comparableEquals(value, expected, false);
|
|
24
|
+
break;
|
|
25
|
+
case "not_equals":
|
|
26
|
+
comparison = comparableEquals(value, expected, true);
|
|
27
|
+
break;
|
|
28
|
+
case "contains":
|
|
29
|
+
comparison = contains(value, expected);
|
|
30
|
+
break;
|
|
31
|
+
case "not_contains":
|
|
32
|
+
comparison = contains(value, expected);
|
|
33
|
+
comparison = {
|
|
34
|
+
comparable: comparison.comparable,
|
|
35
|
+
passed: comparison.comparable && !comparison.passed,
|
|
36
|
+
};
|
|
37
|
+
break;
|
|
38
|
+
case "matches":
|
|
39
|
+
comparison = matches(value, expected);
|
|
40
|
+
break;
|
|
41
|
+
case "not_matches":
|
|
42
|
+
comparison = matches(value, expected);
|
|
43
|
+
comparison = {
|
|
44
|
+
comparable: comparison.comparable,
|
|
45
|
+
passed: comparison.comparable && !comparison.passed,
|
|
46
|
+
};
|
|
47
|
+
break;
|
|
48
|
+
case "greater_than":
|
|
49
|
+
comparison = numbers(value, expected, (a, b) => a > b);
|
|
50
|
+
break;
|
|
51
|
+
case "greater_or_equal":
|
|
52
|
+
comparison = numbers(value, expected, (a, b) => a >= b);
|
|
53
|
+
break;
|
|
54
|
+
case "less_than":
|
|
55
|
+
comparison = numbers(value, expected, (a, b) => a < b);
|
|
56
|
+
break;
|
|
57
|
+
case "less_or_equal":
|
|
58
|
+
comparison = numbers(value, expected, (a, b) => a <= b);
|
|
59
|
+
break;
|
|
60
|
+
case "set_equals":
|
|
61
|
+
comparison = sets(value, expected, (a, b) => a.size === b.size && [...a].every((item) => b.has(item)));
|
|
62
|
+
break;
|
|
63
|
+
case "subset_of":
|
|
64
|
+
comparison = sets(value, expected, (a, b) => [...a].every((item) => b.has(item)));
|
|
65
|
+
break;
|
|
66
|
+
case "superset_of":
|
|
67
|
+
comparison = sets(value, expected, (a, b) => [...b].every((item) => a.has(item)));
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (!comparison.comparable)
|
|
71
|
+
return {
|
|
72
|
+
passed: false,
|
|
73
|
+
status: "observation_type_mismatch",
|
|
74
|
+
expected,
|
|
75
|
+
actual: value,
|
|
76
|
+
};
|
|
77
|
+
return result(comparison.passed, expected, value);
|
|
78
|
+
}
|
|
79
|
+
export function evaluatePopulation(requirement, observations) {
|
|
80
|
+
const eligible = observationValue(observations, requirement.observations.eligible_ids).value;
|
|
81
|
+
const observed = observationValue(observations, requirement.observations.observed_ids).value;
|
|
82
|
+
const excluded = observationValue(observations, requirement.observations.excluded_items).value;
|
|
83
|
+
const actual = {
|
|
84
|
+
eligible_ids: eligible,
|
|
85
|
+
observed_ids: observed,
|
|
86
|
+
excluded_items: excluded,
|
|
87
|
+
};
|
|
88
|
+
if (!validIds(eligible))
|
|
89
|
+
return failure(actual, "eligible_ids_invalid");
|
|
90
|
+
if (!validIds(observed))
|
|
91
|
+
return failure(actual, "observed_ids_invalid");
|
|
92
|
+
if (!Array.isArray(excluded))
|
|
93
|
+
return failure(actual, "excluded_items_invalid");
|
|
94
|
+
const eligibleSet = new Set(eligible);
|
|
95
|
+
const observedSet = new Set(observed);
|
|
96
|
+
const excludedIds = [];
|
|
97
|
+
const rules = new Set(requirement.exclusion_rules.map((item) => item.key));
|
|
98
|
+
for (const item of excluded) {
|
|
99
|
+
if (!item ||
|
|
100
|
+
typeof item !== "object" ||
|
|
101
|
+
Array.isArray(item) ||
|
|
102
|
+
typeof item.id !== "string" ||
|
|
103
|
+
!item.id ||
|
|
104
|
+
typeof item.rule !== "string")
|
|
105
|
+
return failure(actual, "excluded_item_invalid");
|
|
106
|
+
const id = item.id;
|
|
107
|
+
const rule = item.rule;
|
|
108
|
+
if (!rules.has(rule))
|
|
109
|
+
return failure(actual, `exclusion_rule_unknown:${rule}`);
|
|
110
|
+
excludedIds.push(id);
|
|
111
|
+
}
|
|
112
|
+
if (new Set(excludedIds).size !== excludedIds.length)
|
|
113
|
+
return failure(actual, "excluded_ids_duplicate");
|
|
114
|
+
const excludedSet = new Set(excludedIds);
|
|
115
|
+
if (![...observedSet].every((id) => eligibleSet.has(id)))
|
|
116
|
+
return failure(actual, "observed_not_eligible_subset");
|
|
117
|
+
if (![...excludedSet].every((id) => eligibleSet.has(id)))
|
|
118
|
+
return failure(actual, "excluded_not_eligible_subset");
|
|
119
|
+
if ([...observedSet].some((id) => excludedSet.has(id)))
|
|
120
|
+
return failure(actual, "observed_excluded_overlap");
|
|
121
|
+
const covered = new Set([...observedSet, ...excludedSet]);
|
|
122
|
+
if (covered.size !== eligibleSet.size ||
|
|
123
|
+
[...eligibleSet].some((id) => !covered.has(id)))
|
|
124
|
+
return failure(actual, "eligible_population_incomplete");
|
|
125
|
+
return {
|
|
126
|
+
passed: true,
|
|
127
|
+
actual: { ...actual, coverage_percent: 100 },
|
|
128
|
+
reason: null,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function observationValue(observations, name) {
|
|
132
|
+
if (Object.hasOwn(observations, name))
|
|
133
|
+
return { found: true, value: observations[name] };
|
|
134
|
+
let current = observations;
|
|
135
|
+
for (const part of name.split(".")) {
|
|
136
|
+
if (!current ||
|
|
137
|
+
typeof current !== "object" ||
|
|
138
|
+
Array.isArray(current) ||
|
|
139
|
+
!Object.hasOwn(current, part))
|
|
140
|
+
return { found: false, value: undefined };
|
|
141
|
+
current = current[part];
|
|
142
|
+
}
|
|
143
|
+
return { found: true, value: current };
|
|
144
|
+
}
|
|
145
|
+
function validIds(value) {
|
|
146
|
+
return (Array.isArray(value) &&
|
|
147
|
+
value.every((item) => typeof item === "string" && item.length > 0) &&
|
|
148
|
+
new Set(value).size === value.length);
|
|
149
|
+
}
|
|
150
|
+
function failure(actual, reason) {
|
|
151
|
+
return { passed: false, actual, reason };
|
|
152
|
+
}
|
|
153
|
+
function contains(value, expected) {
|
|
154
|
+
if (typeof value === "string" && typeof expected === "string")
|
|
155
|
+
return { comparable: true, passed: value.includes(expected) };
|
|
156
|
+
if (Array.isArray(value))
|
|
157
|
+
return {
|
|
158
|
+
comparable: true,
|
|
159
|
+
passed: value.some((item) => canonicalValueJson(item) === canonicalValueJson(expected)),
|
|
160
|
+
};
|
|
161
|
+
return { comparable: false, passed: false };
|
|
162
|
+
}
|
|
163
|
+
function comparableEquals(value, expected, negate) {
|
|
164
|
+
if (valueKind(value) !== valueKind(expected))
|
|
165
|
+
return { comparable: false, passed: false };
|
|
166
|
+
const equal = canonicalValueJson(value) === canonicalValueJson(expected);
|
|
167
|
+
return { comparable: true, passed: negate ? !equal : equal };
|
|
168
|
+
}
|
|
169
|
+
function matches(value, expected) {
|
|
170
|
+
if (typeof value !== "string" || typeof expected !== "string")
|
|
171
|
+
return { comparable: false, passed: false };
|
|
172
|
+
try {
|
|
173
|
+
return {
|
|
174
|
+
comparable: true,
|
|
175
|
+
passed: new RegExp(expected, "u").test(value),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return { comparable: false, passed: false };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function numbers(left, right, compare) {
|
|
183
|
+
if (typeof left !== "number" ||
|
|
184
|
+
typeof right !== "number" ||
|
|
185
|
+
!Number.isFinite(left) ||
|
|
186
|
+
!Number.isFinite(right))
|
|
187
|
+
return { comparable: false, passed: false };
|
|
188
|
+
return { comparable: true, passed: compare(left, right) };
|
|
189
|
+
}
|
|
190
|
+
function sets(left, right, compare) {
|
|
191
|
+
if (!Array.isArray(left) || !Array.isArray(right))
|
|
192
|
+
return { comparable: false, passed: false };
|
|
193
|
+
return {
|
|
194
|
+
comparable: true,
|
|
195
|
+
passed: compare(new Set(left.map(canonicalValueJson)), new Set(right.map(canonicalValueJson))),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function result(passed, expected, actual) {
|
|
199
|
+
return {
|
|
200
|
+
passed,
|
|
201
|
+
status: passed ? "passed" : "assertion_value_mismatch",
|
|
202
|
+
expected,
|
|
203
|
+
actual,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function valueKind(value) {
|
|
207
|
+
if (value === null)
|
|
208
|
+
return "null";
|
|
209
|
+
if (Array.isArray(value))
|
|
210
|
+
return "array";
|
|
211
|
+
return typeof value;
|
|
212
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AuthoringPreflightDiagnosticV1, AuthoringRevisionPreviewV1 } from "./long-task-authoring-preflight-types.js";
|
|
2
|
+
import type { ContextAuthoritySnapshotV2, CompiledSourceItemV2, DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
3
|
+
import { type ActiveLongTaskAuthorityV3 } from "./long-task-state.js";
|
|
4
|
+
export declare function loadAuthoringActiveAuthority(repository: string, workdir: string, diagnostics: AuthoringPreflightDiagnosticV1[]): Promise<ActiveLongTaskAuthorityV3 | null>;
|
|
5
|
+
export declare function authoringRevisionPreview(contract: DeliveryContractV2, sourceHashes: Record<string, string> | null, sourceItems: CompiledSourceItemV2[] | null, context: ContextAuthoritySnapshotV2 | null, active: ActiveLongTaskAuthorityV3 | null): AuthoringRevisionPreviewV1;
|