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,151 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { validateCounterfactualBindingClaims, validateGlobalCounterfactualBindingClaims, } from "./long-task-counterfactual-claim-policy.js";
|
|
3
|
+
import { assertRepositoryPattern, matchesRepoPattern, proveRepositoryPatternSubset, repositoryPatternsMayOverlap, } from "./long-task-paths.js";
|
|
4
|
+
import { assertProtectedRepositoryFile } from "./long-task-protected-files.js";
|
|
5
|
+
import { sha256Hex } from "./strict-codec.js";
|
|
6
|
+
import { repoRelative, resolveInsideRepository, } from "./long-task-workspace.js";
|
|
7
|
+
export function validateVerificationInputSeparation(contract, checks, workdirRelative) {
|
|
8
|
+
const implementation = contract.outcomes.flatMap((outcome) => [
|
|
9
|
+
...outcome.technical.expected_change_paths,
|
|
10
|
+
...outcome.technical.allowed_support_paths,
|
|
11
|
+
]);
|
|
12
|
+
for (const check of checks)
|
|
13
|
+
for (const source of Object.keys(check.verification_input_hashes)) {
|
|
14
|
+
if (implementation.some((pattern) => repositoryPatternsMayOverlap(pattern, source)))
|
|
15
|
+
throw new Error(`verification_input_overlaps_implementation:${check.key}:${source}`);
|
|
16
|
+
if (source === workdirRelative ||
|
|
17
|
+
source.startsWith(`${workdirRelative}/`) ||
|
|
18
|
+
source === ".git" ||
|
|
19
|
+
source.startsWith(".git/") ||
|
|
20
|
+
source.split("/").includes("node_modules") ||
|
|
21
|
+
check.artifact_globs.some((artifact) => repositoryPatternsMayOverlap(artifact, source)))
|
|
22
|
+
throw new Error(`verification_input_protected:${check.key}:${source}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function validateTechnicalPaths(contract, repository, workdirRelative, baseline) {
|
|
26
|
+
const forbidden = [
|
|
27
|
+
...contract.global.technical.forbidden_paths.map((entry) => entry.path),
|
|
28
|
+
...contract.outcomes.flatMap((outcome) => outcome.technical.forbidden_paths),
|
|
29
|
+
].map((pattern, index) => assertRepositoryPattern(repository, pattern, `forbidden_paths[${index}]`));
|
|
30
|
+
for (const outcome of contract.outcomes) {
|
|
31
|
+
const allowed = [
|
|
32
|
+
...outcome.technical.expected_change_paths,
|
|
33
|
+
...outcome.technical.allowed_support_paths,
|
|
34
|
+
].map((pattern, index) => assertRepositoryPattern(repository, pattern, `${outcome.key}.allowed_paths[${index}]`));
|
|
35
|
+
for (const pattern of allowed) {
|
|
36
|
+
if (repositoryPatternsMayOverlap(pattern, workdirRelative))
|
|
37
|
+
throw new Error(`protected_path_declared:long_task_workdir:${pattern}`);
|
|
38
|
+
if (forbidden.some((blocked) => repositoryPatternsMayOverlap(pattern, blocked)))
|
|
39
|
+
throw new Error(`allowed_forbidden_path_overlap:${pattern}`);
|
|
40
|
+
}
|
|
41
|
+
for (const binding of outcome.technical.bindings) {
|
|
42
|
+
const carriers = binding.carrier_paths.map((carrier) => assertRepositoryPattern(repository, carrier, `${outcome.key}.${binding.key}.carrier_path`));
|
|
43
|
+
for (const carrier of carriers) {
|
|
44
|
+
if (binding.existence === "existing" &&
|
|
45
|
+
!baseline.files.some((file) => matchesRepoPattern(file.path, carrier)))
|
|
46
|
+
throw new Error(`binding_carrier_path_not_found:${outcome.key}:${carrier}`);
|
|
47
|
+
if (!allowed.some((pattern) => proveRepositoryPatternSubset(carrier, pattern).status ===
|
|
48
|
+
"proven_subset"))
|
|
49
|
+
throw new Error(`binding_carrier_outside_change_paths:${outcome.key}:${carrier}`);
|
|
50
|
+
}
|
|
51
|
+
if (binding.kind === "file") {
|
|
52
|
+
const target = assertRepositoryPattern(repository, binding.target, `${outcome.key}.${binding.key}.target`);
|
|
53
|
+
if (!carriers.some((carrier) => matchesRepoPattern(target, carrier)))
|
|
54
|
+
throw new Error(`binding_target_outside_carrier:${outcome.key}:${binding.key}`);
|
|
55
|
+
}
|
|
56
|
+
if (binding.kind === "path_glob") {
|
|
57
|
+
const target = assertRepositoryPattern(repository, binding.target, `${outcome.key}.${binding.key}.target`);
|
|
58
|
+
if (binding.existence === "existing" &&
|
|
59
|
+
!baseline.files.some((file) => matchesRepoPattern(file.path, target)))
|
|
60
|
+
throw new Error(`binding_target_not_found:${outcome.key}:${binding.key}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function validateCounterfactualPaths(contract, compiledGlobalChecks, compiledOutcomes, repository, workdirRelative, protectedAuthorityPaths) {
|
|
66
|
+
const allChecks = [
|
|
67
|
+
...compiledGlobalChecks,
|
|
68
|
+
...compiledOutcomes.flatMap((outcome) => outcome.acceptance.checks),
|
|
69
|
+
];
|
|
70
|
+
const protectedInputs = new Set([
|
|
71
|
+
...contract.task.source_paths,
|
|
72
|
+
...protectedAuthorityPaths,
|
|
73
|
+
...allChecks.flatMap((check) => [
|
|
74
|
+
...Object.keys(check.verification_input_hashes),
|
|
75
|
+
check.runner.resolved_target,
|
|
76
|
+
]),
|
|
77
|
+
]);
|
|
78
|
+
for (const outcome of contract.outcomes) {
|
|
79
|
+
const compiled = compiledOutcomes.find((item) => item.key === outcome.key);
|
|
80
|
+
for (const control of outcome.acceptance.counterfactual_controls) {
|
|
81
|
+
const binding = outcome.technical.bindings.find((item) => item.key === control.binding_key);
|
|
82
|
+
if (!binding)
|
|
83
|
+
throw new Error(`counterfactual_binding_unknown:${outcome.key}:${control.key}:${control.binding_key}`);
|
|
84
|
+
validateCounterfactualBindingClaims(outcome, control, binding);
|
|
85
|
+
const check = compiled.acceptance.checks.find((item) => item.key === control.check_key);
|
|
86
|
+
await validateScopeCounterfactualPaths({
|
|
87
|
+
scope: outcome.key,
|
|
88
|
+
controlKey: control.key,
|
|
89
|
+
mutation: control.mutation,
|
|
90
|
+
binding,
|
|
91
|
+
check,
|
|
92
|
+
repository,
|
|
93
|
+
workdirRelative,
|
|
94
|
+
protectedInputs,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const control of contract.global.acceptance.counterfactual_controls) {
|
|
99
|
+
const { outcome, binding } = validateGlobalCounterfactualBindingClaims(contract, control);
|
|
100
|
+
const check = compiledGlobalChecks.find((item) => item.key === control.check_key);
|
|
101
|
+
await validateScopeCounterfactualPaths({
|
|
102
|
+
scope: "GLOBAL",
|
|
103
|
+
controlKey: control.key,
|
|
104
|
+
mutation: control.mutation,
|
|
105
|
+
binding,
|
|
106
|
+
check,
|
|
107
|
+
repository,
|
|
108
|
+
workdirRelative,
|
|
109
|
+
protectedInputs,
|
|
110
|
+
bindingRef: `${outcome.key}.${binding.key}`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function validateScopeCounterfactualPaths(options) {
|
|
115
|
+
const mutated = options.mutation.type === "remove_paths"
|
|
116
|
+
? options.mutation.paths
|
|
117
|
+
: [options.mutation.path];
|
|
118
|
+
for (const relative of mutated) {
|
|
119
|
+
const target = resolveInsideRepository(options.repository, relative, `${options.scope}.counterfactual`);
|
|
120
|
+
const normalized = repoRelative(options.repository, target);
|
|
121
|
+
if (options.protectedInputs.has(normalized))
|
|
122
|
+
throw new Error(`counterfactual_verification_input_protected:${options.scope}:${relative}`);
|
|
123
|
+
if (normalized === options.workdirRelative ||
|
|
124
|
+
normalized.startsWith(`${options.workdirRelative}/`) ||
|
|
125
|
+
normalized === ".git" ||
|
|
126
|
+
normalized.startsWith(".git/") ||
|
|
127
|
+
normalized.split("/").includes("node_modules"))
|
|
128
|
+
throw new Error(`counterfactual_path_protected:${options.scope}:${relative}`);
|
|
129
|
+
if (!options.binding.carrier_paths.some((pattern) => proveRepositoryPatternSubset(normalized, pattern).status ===
|
|
130
|
+
"proven_subset"))
|
|
131
|
+
throw new Error(`counterfactual_path_outside_binding:${options.scope}:${options.controlKey}:${relative}`);
|
|
132
|
+
if (options.binding.existence === "existing" &&
|
|
133
|
+
!(await stat(target).catch(() => null)))
|
|
134
|
+
throw new Error(`counterfactual_path_not_found:${options.scope}:${relative}`);
|
|
135
|
+
}
|
|
136
|
+
if (options.mutation.type !== "replace_file")
|
|
137
|
+
return;
|
|
138
|
+
const fixtureTarget = resolveInsideRepository(options.repository, options.mutation.fixture_path, `${options.scope}.counterfactual.fixture`);
|
|
139
|
+
const fixture = repoRelative(options.repository, await assertProtectedRepositoryFile(options.repository, fixtureTarget, `${options.scope}.counterfactual.fixture`));
|
|
140
|
+
if (!Object.hasOwn(options.check.verification_input_hashes, fixture))
|
|
141
|
+
throw new Error(`counterfactual_fixture_must_be_verification_input:${options.scope}:${fixture}`);
|
|
142
|
+
}
|
|
143
|
+
export async function hashDeclaredFiles(repository, files, label) {
|
|
144
|
+
const result = {};
|
|
145
|
+
for (const [index, file] of files.entries()) {
|
|
146
|
+
const target = resolveInsideRepository(repository, file, `${label}[${index}]`);
|
|
147
|
+
const protectedTarget = await assertProtectedRepositoryFile(repository, target, `${label}[${index}]`);
|
|
148
|
+
result[repoRelative(repository, protectedTarget)] = sha256Hex(await readFile(protectedTarget));
|
|
149
|
+
}
|
|
150
|
+
return Object.fromEntries(Object.entries(result).sort(([a], [b]) => a.localeCompare(b)));
|
|
151
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./long-task-contract-types.js";
|
|
2
|
+
export * from "./long-task-counterfactual-types.js";
|
|
3
|
+
export * from "./long-task-authority-types.js";
|
|
4
|
+
export * from "./long-task-evidence-adapter-types.js";
|
|
5
|
+
export * from "./long-task-risk-types.js";
|
|
6
|
+
export * from "./long-task-runtime-types.js";
|
|
7
|
+
export * from "./long-task-source-authority-types.js";
|
|
8
|
+
export * from "./long-task-workspace-runtime-types.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./long-task-contract-types.js";
|
|
2
|
+
export * from "./long-task-counterfactual-types.js";
|
|
3
|
+
export * from "./long-task-authority-types.js";
|
|
4
|
+
export * from "./long-task-evidence-adapter-types.js";
|
|
5
|
+
export * from "./long-task-risk-types.js";
|
|
6
|
+
export * from "./long-task-runtime-types.js";
|
|
7
|
+
export * from "./long-task-source-authority-types.js";
|
|
8
|
+
export * from "./long-task-workspace-runtime-types.js";
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { assertCompiledClaimsCovered, compileProductClaimCoverage, } from "./long-task-claims.js";
|
|
2
|
+
import { fail } from "./long-task-delivery-shape.js";
|
|
3
|
+
import { proveRepositoryPatternSubset } from "./long-task-paths.js";
|
|
4
|
+
import { validateSourceClaimMappings } from "./long-task-source-claim-validation.js";
|
|
5
|
+
import { validateDeclaredCheckSafety } from "./long-task-claim-proof-policy.js";
|
|
6
|
+
import { validateEvidenceAdapterCompatibility } from "./long-task-evidence-adapter-policy.js";
|
|
7
|
+
export function validateDeliveryContractStructure(contract) {
|
|
8
|
+
validateUniqueKeys(contract);
|
|
9
|
+
validateDependencies(contract);
|
|
10
|
+
validateOwnerAndBindings(contract);
|
|
11
|
+
validateDeclaredCheckSafety(contract);
|
|
12
|
+
validateEvidenceAdapters(contract);
|
|
13
|
+
const claims = compileProductClaimCoverage(contract, {
|
|
14
|
+
allow_uncovered: true,
|
|
15
|
+
});
|
|
16
|
+
validateSourceClaimMappings(contract, claims);
|
|
17
|
+
assertCompiledClaimsCovered(claims);
|
|
18
|
+
}
|
|
19
|
+
export function deliveryContractStructureDiagnostics(contract) {
|
|
20
|
+
const diagnostics = [];
|
|
21
|
+
const report = (message) => diagnostics.push(message);
|
|
22
|
+
validateUniqueKeys(contract, report);
|
|
23
|
+
validateDependencies(contract, report);
|
|
24
|
+
validateOwnerAndBindings(contract, report);
|
|
25
|
+
validateDeclaredCheckSafety(contract, report);
|
|
26
|
+
validateEvidenceAdapters(contract, report);
|
|
27
|
+
let claims = null;
|
|
28
|
+
capture(diagnostics, () => {
|
|
29
|
+
claims = compileProductClaimCoverage(contract, { allow_uncovered: true });
|
|
30
|
+
});
|
|
31
|
+
if (claims) {
|
|
32
|
+
validateSourceClaimMappings(contract, claims, report);
|
|
33
|
+
capture(diagnostics, () => assertCompiledClaimsCovered(claims));
|
|
34
|
+
}
|
|
35
|
+
return [...new Set(diagnostics)];
|
|
36
|
+
}
|
|
37
|
+
function validateEvidenceAdapters(contract, report) {
|
|
38
|
+
for (const check of contract.global.acceptance.checks)
|
|
39
|
+
captureOrReport(report, () => validateEvidenceAdapterCompatibility(check, null));
|
|
40
|
+
for (const outcome of contract.outcomes)
|
|
41
|
+
for (const check of outcome.acceptance.checks)
|
|
42
|
+
captureOrReport(report, () => validateEvidenceAdapterCompatibility(check, outcome.key));
|
|
43
|
+
}
|
|
44
|
+
function validateUniqueKeys(contract, report) {
|
|
45
|
+
unique(contract.outcomes.map((outcome) => outcome.key), "outcome_key_duplicate", report);
|
|
46
|
+
unique(contract.global.acceptance.checks.map((check) => check.key), "global_check_key_duplicate", report);
|
|
47
|
+
unique(contract.source_claims.map((claim) => claim.key), "source_claim_key_duplicate", report);
|
|
48
|
+
for (const [fact, outcomes] of Object.entries(contract.risk.facts))
|
|
49
|
+
unique(outcomes, `risk_fact_outcome_duplicate:${fact}`, report);
|
|
50
|
+
unique(contract.global.acceptance.counterfactual_controls.map((control) => control.key), "global_counterfactual_key_duplicate", report);
|
|
51
|
+
unique(contract.global.acceptance.external_confirmations.map((item) => item.key), "external_confirmation_key_duplicate", report);
|
|
52
|
+
unique([
|
|
53
|
+
...contract.global.product.non_goals,
|
|
54
|
+
...contract.global.technical.constraints,
|
|
55
|
+
...contract.global.technical.forbidden_paths,
|
|
56
|
+
...contract.global.technical.forbidden_shortcuts,
|
|
57
|
+
].map((item) => item.key), "global_constraint_key_duplicate", report);
|
|
58
|
+
for (const outcome of contract.outcomes) {
|
|
59
|
+
unique(outcome.acceptance.checks.map((check) => check.key), `check_key_duplicate:${outcome.key}`, report);
|
|
60
|
+
unique(outcome.product.requirements.map((item) => item.key), `requirement_key_duplicate:${outcome.key}`, report);
|
|
61
|
+
unique(outcome.product.controls.map((control) => control.key), `control_key_duplicate:${outcome.key}`, report);
|
|
62
|
+
unique(outcome.product.non_completing_outcomes.map((item) => item.key), `non_completing_key_duplicate:${outcome.key}`, report);
|
|
63
|
+
unique(outcome.technical.obligations.map((item) => item.key), `obligation_key_duplicate:${outcome.key}`, report);
|
|
64
|
+
unique(outcome.technical.forbidden_shortcuts.map((item) => item.key), `forbidden_shortcut_key_duplicate:${outcome.key}`, report);
|
|
65
|
+
unique(outcome.technical.bindings.map((item) => item.key), `binding_key_duplicate:${outcome.key}`, report);
|
|
66
|
+
unique(outcome.acceptance.counterfactual_controls.map((item) => item.key), `counterfactual_key_duplicate:${outcome.key}`, report);
|
|
67
|
+
for (const check of outcome.acceptance.checks) {
|
|
68
|
+
unique(check.environment_requirements.map((item) => item.key), `environment_requirement_key_duplicate:${outcome.key}:${check.key}`, report);
|
|
69
|
+
unique([...check.positive_assertions, ...check.negative_assertions].map((assertion) => assertion.key), `assertion_key_duplicate:${outcome.key}:${check.key}`, report);
|
|
70
|
+
unique([...check.positive_assertions, ...check.negative_assertions].map((assertion) => assertion.observation), `assertion_observation_duplicate:${outcome.key}:${check.key}`, report);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const check of contract.global.acceptance.checks)
|
|
74
|
+
unique([...check.positive_assertions, ...check.negative_assertions].map((assertion) => assertion.observation), `assertion_observation_duplicate:GLOBAL:${check.key}`, report);
|
|
75
|
+
}
|
|
76
|
+
function validateOwnerAndBindings(contract, report) {
|
|
77
|
+
const contextRefs = new Set(contract.task.context_refs);
|
|
78
|
+
for (const outcome of contract.outcomes) {
|
|
79
|
+
for (const reference of outcome.product.owner.context_refs)
|
|
80
|
+
if (!contextRefs.has(reference))
|
|
81
|
+
issue(report, "owner_context_ref_unknown", `${outcome.key}:${reference}`);
|
|
82
|
+
if (!outcome.product.owner.path_globs.length)
|
|
83
|
+
issue(report, "owner_path_globs_empty", outcome.key);
|
|
84
|
+
for (const candidate of [
|
|
85
|
+
...outcome.technical.expected_change_paths,
|
|
86
|
+
...outcome.technical.allowed_support_paths,
|
|
87
|
+
])
|
|
88
|
+
if (!outcome.product.owner.path_globs.some((owner) => isProvenSubset(candidate, owner)))
|
|
89
|
+
issue(report, "path_outside_owner_boundary", `${outcome.key}:${candidate}`);
|
|
90
|
+
const checks = new Map(outcome.acceptance.checks.map((check) => [check.key, check]));
|
|
91
|
+
for (const binding of outcome.technical.bindings) {
|
|
92
|
+
for (const carrier of binding.carrier_paths)
|
|
93
|
+
if (!outcome.product.owner.path_globs.some((owner) => isProvenSubset(carrier, owner)))
|
|
94
|
+
issue(report, "binding_carrier_outside_owner_boundary", `${outcome.key}:${binding.key}:${carrier}`);
|
|
95
|
+
if (binding.kind === "verified") {
|
|
96
|
+
const check = checks.get(binding.verification_check_key ?? "");
|
|
97
|
+
if (!check) {
|
|
98
|
+
issue(report, "verified_binding_check_unknown", `${outcome.key}:${binding.key}`);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const obligationClaim = `obligation.${binding.key}`;
|
|
102
|
+
const covered = [
|
|
103
|
+
...check.positive_assertions,
|
|
104
|
+
...check.negative_assertions,
|
|
105
|
+
].some((assertion) => assertion.claims.includes(obligationClaim));
|
|
106
|
+
if (!covered)
|
|
107
|
+
issue(report, "verified_binding_obligation_uncovered", `${outcome.key}:${binding.key}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function isProvenSubset(candidate, owner) {
|
|
113
|
+
return (proveRepositoryPatternSubset(candidate, owner).status === "proven_subset");
|
|
114
|
+
}
|
|
115
|
+
function unique(values, code, report) {
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
for (const value of values) {
|
|
118
|
+
if (seen.has(value))
|
|
119
|
+
issue(report, code, value);
|
|
120
|
+
seen.add(value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function capture(diagnostics, action) {
|
|
124
|
+
try {
|
|
125
|
+
action();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
diagnostics.push(error instanceof Error ? error.message : String(error));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function validateDependencies(contract, report) {
|
|
132
|
+
const outcomes = new Map(contract.outcomes.map((outcome) => [outcome.key, outcome]));
|
|
133
|
+
for (const outcome of contract.outcomes)
|
|
134
|
+
for (const dependency of outcome.depends_on) {
|
|
135
|
+
if (dependency === outcome.key)
|
|
136
|
+
issue(report, "outcome_dependency_self", outcome.key);
|
|
137
|
+
if (!outcomes.has(dependency))
|
|
138
|
+
issue(report, "outcome_dependency_unknown", `${outcome.key}:${dependency}`);
|
|
139
|
+
}
|
|
140
|
+
const visiting = new Set();
|
|
141
|
+
const visited = new Set();
|
|
142
|
+
const visit = (value) => {
|
|
143
|
+
if (visiting.has(value)) {
|
|
144
|
+
issue(report, "outcome_dependency_cycle", value);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (visited.has(value))
|
|
148
|
+
return;
|
|
149
|
+
visiting.add(value);
|
|
150
|
+
for (const dependency of outcomes.get(value).depends_on)
|
|
151
|
+
if (outcomes.has(dependency))
|
|
152
|
+
visit(dependency);
|
|
153
|
+
visiting.delete(value);
|
|
154
|
+
visited.add(value);
|
|
155
|
+
};
|
|
156
|
+
for (const outcome of outcomes.keys())
|
|
157
|
+
visit(outcome);
|
|
158
|
+
}
|
|
159
|
+
function issue(report, code, detail) {
|
|
160
|
+
if (!report)
|
|
161
|
+
fail(code, detail);
|
|
162
|
+
report(`delivery_contract_invalid:${code}:${detail}`);
|
|
163
|
+
}
|
|
164
|
+
function captureOrReport(report, action) {
|
|
165
|
+
if (!report) {
|
|
166
|
+
action();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
action();
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
report(error instanceof Error ? error.message : String(error));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DeliveryCheckV2, EvidenceAdapter, ProofSurface, RunnerType } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function evidenceAdapterForRunner(type: RunnerType): EvidenceAdapter;
|
|
3
|
+
export declare function validateEvidenceAdapterCompatibility(check: DeliveryCheckV2, outcomeKey: string | null): void;
|
|
4
|
+
export declare function adapterSupportsProofSurface(adapter: EvidenceAdapter, surface: ProofSurface): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function evidenceAdapterForRunner(type) {
|
|
2
|
+
return type === "playwright_test"
|
|
3
|
+
? "playwright_json_v1"
|
|
4
|
+
: "structured_json_v2";
|
|
5
|
+
}
|
|
6
|
+
export function validateEvidenceAdapterCompatibility(check, outcomeKey) {
|
|
7
|
+
const adapter = evidenceAdapterForRunner(check.runner.type);
|
|
8
|
+
if (!adapterSupportsProofSurface(adapter, check.proof_surface))
|
|
9
|
+
throw new Error(`evidence_adapter_mismatch:${outcomeKey ?? "GLOBAL"}:${check.key}:${check.proof_surface}:${adapter}`);
|
|
10
|
+
}
|
|
11
|
+
export function adapterSupportsProofSurface(adapter, surface) {
|
|
12
|
+
return surface === "ui_browser"
|
|
13
|
+
? adapter === "playwright_json_v1"
|
|
14
|
+
: adapter === "structured_json_v2";
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EvidenceAdapter = "structured_json_v2" | "playwright_json_v1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CheckExecutionResultV2, CompiledCheckV2, CompiledOutcomeV2, LongTaskFindingV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function evaluateAssertionResults(check: CompiledCheckV2, observations: Record<string, unknown>): CheckExecutionResultV2["assertion_results"];
|
|
3
|
+
export declare function classifyCheckStatus(raw: RawCommandExecutionV2, findings: LongTaskFindingV2[]): CheckExecutionResultV2["status"];
|
|
4
|
+
export declare function assertionFinding(check: CompiledCheckV2, result: CheckExecutionResultV2["assertion_results"][number], observations: Record<string, unknown>, outcome?: CompiledOutcomeV2): LongTaskFindingV2;
|
|
5
|
+
export declare function checkFinding(check: CompiledCheckV2, code: string, message: string, nextAction: string): LongTaskFindingV2;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { evaluateDeliveryAssertionDetailed, observationValue, } from "./long-task-assertions-v2.js";
|
|
2
|
+
export function evaluateAssertionResults(check, observations) {
|
|
3
|
+
const assertions = [
|
|
4
|
+
...check.positive_assertions.map((assertion) => ({
|
|
5
|
+
assertion,
|
|
6
|
+
polarity: "positive",
|
|
7
|
+
})),
|
|
8
|
+
...check.negative_assertions.map((assertion) => ({
|
|
9
|
+
assertion,
|
|
10
|
+
polarity: "negative",
|
|
11
|
+
})),
|
|
12
|
+
];
|
|
13
|
+
return assertions.map(({ assertion, polarity }) => {
|
|
14
|
+
const evaluation = evaluateDeliveryAssertionDetailed(assertion, observations);
|
|
15
|
+
return {
|
|
16
|
+
key: assertion.key,
|
|
17
|
+
...(assertion.criterion ? { criterion: assertion.criterion } : {}),
|
|
18
|
+
polarity,
|
|
19
|
+
passed: evaluation.passed,
|
|
20
|
+
claims: assertion.claims,
|
|
21
|
+
observation: assertion.observation,
|
|
22
|
+
status: evaluation.status,
|
|
23
|
+
...(Object.hasOwn(evaluation, "expected")
|
|
24
|
+
? { expected: evaluation.expected }
|
|
25
|
+
: {}),
|
|
26
|
+
...(Object.hasOwn(evaluation, "actual")
|
|
27
|
+
? { actual: evaluation.actual }
|
|
28
|
+
: {}),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function classifyCheckStatus(raw, findings) {
|
|
33
|
+
if (raw.execution_status !== "completed")
|
|
34
|
+
return raw.execution_status;
|
|
35
|
+
if (raw.exit_code !== 0 ||
|
|
36
|
+
findings.some((item) => item.code === "test_failed"))
|
|
37
|
+
return "test_failed";
|
|
38
|
+
if (findings.some((item) => item.code === "invalid_evidence" || item.code === "artifact_missing"))
|
|
39
|
+
return "invalid_evidence";
|
|
40
|
+
if (findings.some((item) => item.assertion_key) ||
|
|
41
|
+
findings.some((item) => item.code === "population_coverage_failed"))
|
|
42
|
+
return "assertion_failed";
|
|
43
|
+
return "passed";
|
|
44
|
+
}
|
|
45
|
+
export function assertionFinding(check, result, observations, outcome) {
|
|
46
|
+
const ac = playwrightCase(result.observation);
|
|
47
|
+
let code = result.status;
|
|
48
|
+
let message = `Assertion ${result.key} did not match its expected value.`;
|
|
49
|
+
let nextAction = "Fix the observable behavior or the named acceptance assertion, then rerun this Check.";
|
|
50
|
+
if (ac) {
|
|
51
|
+
const prefix = `playwright.case.${ac}`;
|
|
52
|
+
const executed = observationValue(observations, `${prefix}.executed`);
|
|
53
|
+
const skipped = observationValue(observations, `${prefix}.skipped`);
|
|
54
|
+
const flaky = observationValue(observations, `${prefix}.flaky`);
|
|
55
|
+
const unexpected = observationValue(observations, `${prefix}.unexpected`);
|
|
56
|
+
if (flaky.found && flaky.value === true) {
|
|
57
|
+
code = "acceptance_case_flaky";
|
|
58
|
+
message = `Acceptance case ${ac} was flaky.`;
|
|
59
|
+
nextAction =
|
|
60
|
+
"Remove flakiness from every declared Playwright project instance and rerun this Check.";
|
|
61
|
+
}
|
|
62
|
+
else if (unexpected.found && unexpected.value === true) {
|
|
63
|
+
code = "acceptance_case_unexpected";
|
|
64
|
+
message = `Acceptance case ${ac} had an unexpected result.`;
|
|
65
|
+
nextAction =
|
|
66
|
+
"Fix the unexpected Playwright result in every declared project and rerun this Check.";
|
|
67
|
+
}
|
|
68
|
+
else if (skipped.found && skipped.value === true) {
|
|
69
|
+
code = "acceptance_case_skipped";
|
|
70
|
+
message = `Acceptance case ${ac} was skipped.`;
|
|
71
|
+
nextAction =
|
|
72
|
+
"Make the declared [ac:<key>] Playwright case executable and rerun this Check.";
|
|
73
|
+
}
|
|
74
|
+
else if (executed.found && executed.value === false) {
|
|
75
|
+
code = "acceptance_case_not_executed";
|
|
76
|
+
message = `Acceptance case ${ac} was not executed.`;
|
|
77
|
+
nextAction =
|
|
78
|
+
"Add or restore the declared [ac:<key>] Playwright case and rerun this Check.";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (result.status === "observation_missing") {
|
|
82
|
+
message = `Observation ${result.observation} was missing.`;
|
|
83
|
+
nextAction =
|
|
84
|
+
"Emit the declared Observation from the Check evidence and rerun it.";
|
|
85
|
+
}
|
|
86
|
+
else if (result.status === "observation_type_mismatch") {
|
|
87
|
+
message = `Observation ${result.observation} had an incompatible type.`;
|
|
88
|
+
nextAction =
|
|
89
|
+
"Fix the Observation type or the Contract operator and rerun this Check.";
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...checkFinding(check, code, message, nextAction),
|
|
93
|
+
claim_keys: result.claims,
|
|
94
|
+
assertion_key: result.key,
|
|
95
|
+
...(result.criterion ? { criterion: result.criterion } : {}),
|
|
96
|
+
observation: result.observation,
|
|
97
|
+
...(Object.hasOwn(result, "expected") ? { expected: result.expected } : {}),
|
|
98
|
+
...(Object.hasOwn(result, "actual") ? { actual: result.actual } : {}),
|
|
99
|
+
...(outcome ? { owner_paths: outcome.product.owner.path_globs } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function checkFinding(check, code, message, nextAction) {
|
|
103
|
+
return {
|
|
104
|
+
code,
|
|
105
|
+
outcome_key: check.outcome_key,
|
|
106
|
+
check_key: check.key,
|
|
107
|
+
message,
|
|
108
|
+
next_action: nextAction,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function playwrightCase(observation) {
|
|
112
|
+
return (/^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(observation)?.[1] ?? null);
|
|
113
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompiledCheckV2, CompiledOutcomeV2, DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function validateClaimEvidenceSensitivity(contract: DeliveryContractV2, globalChecks: CompiledCheckV2[], outcomes: CompiledOutcomeV2[], report?: ValidationReporter): void;
|
|
3
|
+
type ValidationReporter = (message: string) => void;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const NON_RESULT_SENSITIVITY_PREFIXES = [
|
|
2
|
+
"requirement.",
|
|
3
|
+
"control.",
|
|
4
|
+
"obligation.",
|
|
5
|
+
"non_completing.",
|
|
6
|
+
"forbidden_shortcut.",
|
|
7
|
+
];
|
|
8
|
+
export function validateClaimEvidenceSensitivity(contract, globalChecks, outcomes, report) {
|
|
9
|
+
validateGlobalStructuredSensitivity(contract, globalChecks, report);
|
|
10
|
+
const weakOutcomes = new Set(contract.risk.facts.weak_observability);
|
|
11
|
+
for (const outcome of outcomes) {
|
|
12
|
+
const population = outcome.acceptance.population;
|
|
13
|
+
const counterfactualsByCheck = groupCounterfactuals(outcome);
|
|
14
|
+
for (const check of outcome.acceptance.checks) {
|
|
15
|
+
const counterfactuals = counterfactualsByCheck.get(check.key) ?? [];
|
|
16
|
+
if (check.evidence_adapter === "structured_json_v2") {
|
|
17
|
+
const assertionClaims = new Set(assertions(check).flatMap((assertion) => assertion.claims));
|
|
18
|
+
const populationClaims = new Set(population?.check_key === check.key ? population.claims : []);
|
|
19
|
+
const declaredClaims = new Set([
|
|
20
|
+
...assertionClaims,
|
|
21
|
+
...populationClaims,
|
|
22
|
+
]);
|
|
23
|
+
const counterfactualClaims = new Set(counterfactuals.flatMap((control) => control.claims));
|
|
24
|
+
const required = [...declaredClaims].filter((claim) => weakOutcomes.has(outcome.key) || !populationClaims.has(claim));
|
|
25
|
+
const missing = required
|
|
26
|
+
.filter((claim) => !counterfactualClaims.has(claim))
|
|
27
|
+
.sort();
|
|
28
|
+
if (missing.length)
|
|
29
|
+
issue(report, `structured_evidence_sensitivity_required:${outcome.key}:${check.key}:${missing.join(",")}`);
|
|
30
|
+
validateResultRoots(outcome.key, check, counterfactuals, report);
|
|
31
|
+
}
|
|
32
|
+
if (check.evidence_adapter === "playwright_json_v1" &&
|
|
33
|
+
weakOutcomes.has(outcome.key))
|
|
34
|
+
validateWeakPlaywrightSensitivity(outcome.key, check, counterfactuals, report);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function validateGlobalStructuredSensitivity(contract, checks, report) {
|
|
39
|
+
for (const check of checks) {
|
|
40
|
+
if (check.evidence_adapter !== "structured_json_v2")
|
|
41
|
+
continue;
|
|
42
|
+
const claims = new Set(assertions(check).flatMap((assertion) => assertion.claims));
|
|
43
|
+
if (!claims.size)
|
|
44
|
+
continue;
|
|
45
|
+
const controls = contract.global.acceptance.counterfactual_controls.filter((control) => control.check_key === check.key);
|
|
46
|
+
const covered = new Set(controls.flatMap((control) => control.claims));
|
|
47
|
+
const missing = [...claims].filter((claim) => !covered.has(claim)).sort();
|
|
48
|
+
if (missing.length)
|
|
49
|
+
issue(report, `global_structured_evidence_sensitivity_required:${check.key}:${missing.join(",")}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function validateWeakPlaywrightSensitivity(outcomeKey, check, counterfactuals, report) {
|
|
53
|
+
for (const assertion of assertions(check).filter((item) => item.claims.length > 0)) {
|
|
54
|
+
const relevant = counterfactuals.filter((control) => control.expected_assertion_failures.includes(assertion.key));
|
|
55
|
+
if (!relevant.length) {
|
|
56
|
+
issue(report, `playwright_weak_observability_sensitivity_required:${outcomeKey}:${check.key}:${assertion.key}`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const covered = new Set(relevant.flatMap((control) => control.claims));
|
|
60
|
+
const missing = assertion.claims
|
|
61
|
+
.filter((claim) => !covered.has(claim))
|
|
62
|
+
.sort();
|
|
63
|
+
if (missing.length)
|
|
64
|
+
issue(report, `playwright_weak_observability_claim_sensitivity_required:${outcomeKey}:${check.key}:${missing.join(",")}`);
|
|
65
|
+
}
|
|
66
|
+
validateResultRoots(outcomeKey, check, counterfactuals, report);
|
|
67
|
+
}
|
|
68
|
+
function validateResultRoots(outcomeKey, check, counterfactuals, report) {
|
|
69
|
+
for (const assertion of assertions(check)) {
|
|
70
|
+
if (!assertion.claims.includes("result"))
|
|
71
|
+
continue;
|
|
72
|
+
const resultSensitive = counterfactuals.some((control) => control.expected_assertion_failures.includes(assertion.key) &&
|
|
73
|
+
control.claims.includes("result") &&
|
|
74
|
+
control.claims.some(isNonResultSensitivityClaim));
|
|
75
|
+
if (!resultSensitive)
|
|
76
|
+
issue(report, `structured_result_counterfactual_non_result_required:${outcomeKey}:${check.key}:${assertion.key}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function assertions(check) {
|
|
80
|
+
return [...check.positive_assertions, ...check.negative_assertions];
|
|
81
|
+
}
|
|
82
|
+
function groupCounterfactuals(outcome) {
|
|
83
|
+
const grouped = new Map();
|
|
84
|
+
for (const control of outcome.acceptance.counterfactual_controls) {
|
|
85
|
+
const controls = grouped.get(control.check_key) ?? [];
|
|
86
|
+
controls.push(control);
|
|
87
|
+
grouped.set(control.check_key, controls);
|
|
88
|
+
}
|
|
89
|
+
return grouped;
|
|
90
|
+
}
|
|
91
|
+
function isNonResultSensitivityClaim(claim) {
|
|
92
|
+
return NON_RESULT_SENSITIVITY_PREFIXES.some((prefix) => claim.startsWith(prefix));
|
|
93
|
+
}
|
|
94
|
+
function issue(report, message) {
|
|
95
|
+
if (!report)
|
|
96
|
+
throw new Error(message);
|
|
97
|
+
report(message);
|
|
98
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CheckExecutionResultV2, CompiledCheckV2, CompiledDeliveryContractV2, CompiledOutcomeV2, LongTaskFindingV2, RawCommandExecutionV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function evaluateCheckEvidence(check: CompiledCheckV2, raw: RawCommandExecutionV2, snapshotRoot: string, outcome?: CompiledOutcomeV2): Promise<CheckExecutionResultV2>;
|
|
3
|
+
export declare function evaluateOutcomeCounterfactuals(outcome: CompiledOutcomeV2, snapshotRoot: string, manifest?: WorkspaceManifestV2): Promise<LongTaskFindingV2[]>;
|
|
4
|
+
export declare function evaluateGlobalCounterfactuals(compiled: CompiledDeliveryContractV2, snapshotRoot: string, selectedCheckKeys?: ReadonlySet<string>, manifest?: WorkspaceManifestV2): Promise<LongTaskFindingV2[]>;
|
|
5
|
+
export declare function isValidCounterfactualCheckResult(result: CheckExecutionResultV2, expectedAssertionFailures: string[]): boolean;
|