project-tiny-context-harness 0.2.85 → 0.6.1
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 +164 -427
- package/assets/README.md +284 -455
- package/assets/README.zh-CN.md +200 -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 +63 -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 +467 -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,226 @@
|
|
|
1
|
+
import { copyFile, rm, stat } from "node:fs/promises";
|
|
2
|
+
import { evaluatePopulation } from "./long-task-assertions-v2.js";
|
|
3
|
+
import { collectCheckArtifacts } from "./long-task-artifacts.js";
|
|
4
|
+
import { executeCheckRunner } from "./long-task-check-runner.js";
|
|
5
|
+
import { createCounterfactualSandbox } from "./long-task-counterfactual-sandbox.js";
|
|
6
|
+
import { assertionFinding, checkFinding, classifyCheckStatus, evaluateAssertionResults, } from "./long-task-evidence-findings.js";
|
|
7
|
+
import { classifyPlaywrightCounterfactual } from "./long-task-playwright-counterfactual-policy.js";
|
|
8
|
+
import { resolveInsideRepository } from "./long-task-workspace.js";
|
|
9
|
+
export async function evaluateCheckEvidence(check, raw, snapshotRoot, outcome) {
|
|
10
|
+
const artifacts = await collectCheckArtifacts(check, snapshotRoot);
|
|
11
|
+
const assertionResults = evaluateAssertionResults(check, raw.observations);
|
|
12
|
+
const executionCompleted = raw.execution_status === "completed";
|
|
13
|
+
const findings = [];
|
|
14
|
+
if (!executionCompleted)
|
|
15
|
+
findings.push(checkFinding(check, raw.execution_status, raw.error ?? raw.execution_status, raw.execution_status === "blocked_external"
|
|
16
|
+
? "Satisfy the declared Environment Requirement and rerun this Check."
|
|
17
|
+
: "Repair the declared runner or evidence protocol and rerun this Check."));
|
|
18
|
+
if (executionCompleted && raw.exit_code !== 0)
|
|
19
|
+
findings.push(checkFinding(check, "test_failed", `command exited ${raw.exit_code}`, "Fix the implementation or declared verification command, then rerun this Check."));
|
|
20
|
+
if (executionCompleted &&
|
|
21
|
+
raw.observations["playwright.zero_or_all_skipped"] === true)
|
|
22
|
+
findings.push(checkFinding(check, "test_failed", "Playwright executed zero tests or skipped every test.", "Make the declared Playwright target execute at least one non-skipped test."));
|
|
23
|
+
if (executionCompleted) {
|
|
24
|
+
for (const error of artifacts.errors)
|
|
25
|
+
findings.push(checkFinding(check, "artifact_missing", error, "Produce the artifact declared for this Check and rerun it."));
|
|
26
|
+
for (const result of assertionResults)
|
|
27
|
+
if (!result.passed)
|
|
28
|
+
findings.push(assertionFinding(check, result, raw.observations, outcome));
|
|
29
|
+
}
|
|
30
|
+
const population = outcome?.acceptance.population;
|
|
31
|
+
let populationPassed = true;
|
|
32
|
+
if (executionCompleted && population?.check_key === check.key) {
|
|
33
|
+
const result = evaluatePopulation(population, raw.observations);
|
|
34
|
+
populationPassed = result.passed;
|
|
35
|
+
if (!result.passed)
|
|
36
|
+
findings.push({
|
|
37
|
+
...checkFinding(check, "population_coverage_failed", result.reason ?? "full population coverage was not proven", "Fix entity enumeration/exclusion behavior and rerun the population Check."),
|
|
38
|
+
expected: { coverage_percent: 100 },
|
|
39
|
+
actual: result.actual,
|
|
40
|
+
claim_keys: population.claims,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const status = classifyCheckStatus(raw, findings);
|
|
44
|
+
const claimProofs = status === "passed"
|
|
45
|
+
? assertionResults.flatMap((result) => result.claims.map((claim) => ({
|
|
46
|
+
check_key: check.key,
|
|
47
|
+
assertion_key: result.key,
|
|
48
|
+
polarity: result.polarity,
|
|
49
|
+
proof_surface: check.proof_surface,
|
|
50
|
+
})))
|
|
51
|
+
: [];
|
|
52
|
+
if (status === "passed" &&
|
|
53
|
+
population &&
|
|
54
|
+
population.check_key === check.key &&
|
|
55
|
+
populationPassed)
|
|
56
|
+
claimProofs.push(...population.claims.map(() => ({
|
|
57
|
+
check_key: check.key,
|
|
58
|
+
assertion_key: null,
|
|
59
|
+
polarity: "population",
|
|
60
|
+
proof_surface: check.proof_surface,
|
|
61
|
+
})));
|
|
62
|
+
return {
|
|
63
|
+
internal_id: check.internal_id,
|
|
64
|
+
outcome_key: check.outcome_key,
|
|
65
|
+
check_key: check.key,
|
|
66
|
+
status,
|
|
67
|
+
evidence_adapter: check.evidence_adapter,
|
|
68
|
+
execution_identity: raw.raw_execution_identity,
|
|
69
|
+
assertion_results: assertionResults,
|
|
70
|
+
observations: raw.observations,
|
|
71
|
+
artifact_hashes: artifacts.hashes,
|
|
72
|
+
claim_proofs: claimProofs,
|
|
73
|
+
findings,
|
|
74
|
+
attempts: raw.attempts,
|
|
75
|
+
duration_ms: raw.duration_ms,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export async function evaluateOutcomeCounterfactuals(outcome, snapshotRoot, manifest) {
|
|
79
|
+
return evaluateCounterfactualSet(outcome.acceptance.counterfactual_controls.map((control) => ({
|
|
80
|
+
control,
|
|
81
|
+
check: outcome.acceptance.checks.find((item) => item.key === control.check_key),
|
|
82
|
+
evidenceOutcome: outcome,
|
|
83
|
+
findingOutcomeKey: outcome.key,
|
|
84
|
+
owningOutcome: outcome,
|
|
85
|
+
bindingRef: `${outcome.key}.${control.binding_key}`,
|
|
86
|
+
})), snapshotRoot, manifest);
|
|
87
|
+
}
|
|
88
|
+
export async function evaluateGlobalCounterfactuals(compiled, snapshotRoot, selectedCheckKeys, manifest) {
|
|
89
|
+
return evaluateCounterfactualSet((compiled.global.acceptance.counterfactual_controls ?? [])
|
|
90
|
+
.filter((control) => !selectedCheckKeys || selectedCheckKeys.has(control.check_key))
|
|
91
|
+
.map((control) => {
|
|
92
|
+
const [outcomeKey] = control.binding_ref.split(".");
|
|
93
|
+
return {
|
|
94
|
+
control,
|
|
95
|
+
check: compiled.global.acceptance.checks.find((item) => item.key === control.check_key),
|
|
96
|
+
findingOutcomeKey: null,
|
|
97
|
+
owningOutcome: compiled.outcomes.find((outcome) => outcome.key === outcomeKey),
|
|
98
|
+
bindingRef: control.binding_ref,
|
|
99
|
+
};
|
|
100
|
+
}), snapshotRoot, manifest);
|
|
101
|
+
}
|
|
102
|
+
async function evaluateCounterfactualSet(entries, snapshotRoot, manifest) {
|
|
103
|
+
const findings = [];
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
const { control, check } = entry;
|
|
106
|
+
const owningBinding = entry.owningOutcome.technical.bindings.find((binding) => `${entry.owningOutcome.key}.${binding.key}` === entry.bindingRef);
|
|
107
|
+
const sandbox = await createCounterfactualSandbox(snapshotRoot, check, control, owningBinding?.carrier_paths ?? [], manifest);
|
|
108
|
+
const root = sandbox.root;
|
|
109
|
+
try {
|
|
110
|
+
const mutationTargets = control.mutation.type === "remove_paths"
|
|
111
|
+
? control.mutation.paths
|
|
112
|
+
: [control.mutation.path];
|
|
113
|
+
const missingTargets = [];
|
|
114
|
+
for (const target of mutationTargets)
|
|
115
|
+
if (!(await stat(resolveInsideRepository(root, target, "counterfactual.target")).catch(() => null)))
|
|
116
|
+
missingTargets.push(target);
|
|
117
|
+
if (missingTargets.length) {
|
|
118
|
+
findings.push(counterfactualIntegrityFinding(entry, {
|
|
119
|
+
execution_status: "not_run",
|
|
120
|
+
finding_codes: ["counterfactual_mutation_target_missing"],
|
|
121
|
+
missing_targets: missingTargets,
|
|
122
|
+
}));
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (control.mutation.type === "remove_paths") {
|
|
126
|
+
for (const target of control.mutation.paths)
|
|
127
|
+
await rm(resolveInsideRepository(root, target, "counterfactual.remove_paths"), { recursive: true, force: true });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
await copyFile(resolveInsideRepository(root, control.mutation.fixture_path, "counterfactual.fixture"), resolveInsideRepository(root, control.mutation.path, "counterfactual.path"));
|
|
131
|
+
}
|
|
132
|
+
const raw = await executeCheckRunner(check, root);
|
|
133
|
+
const result = await evaluateCheckEvidence(check, raw, root, entry.evidenceOutcome);
|
|
134
|
+
const playwrightClassification = result.evidence_adapter === "playwright_json_v1"
|
|
135
|
+
? classifyPlaywrightCounterfactual(raw, result, control)
|
|
136
|
+
: null;
|
|
137
|
+
const sensitivityResult = playwrightClassification?.normalized_result ?? result;
|
|
138
|
+
const failedAssertions = result.assertion_results
|
|
139
|
+
.filter((assertion) => !assertion.passed)
|
|
140
|
+
.map((assertion) => assertion.key)
|
|
141
|
+
.sort();
|
|
142
|
+
const expected = [...control.expected_assertion_failures].sort();
|
|
143
|
+
const acceptedExit = playwrightClassification
|
|
144
|
+
? playwrightClassification.accepted_test_failure_exit
|
|
145
|
+
: raw.exit_code === 0;
|
|
146
|
+
const valid = raw.execution_status === "completed" &&
|
|
147
|
+
acceptedExit &&
|
|
148
|
+
isValidCounterfactualCheckResult(sensitivityResult, expected);
|
|
149
|
+
if (!valid)
|
|
150
|
+
findings.push(counterfactualIntegrityFinding(entry, playwrightClassification
|
|
151
|
+
? playwrightCounterfactualDiagnostic(raw, result, expected, playwrightClassification.rejection_reasons)
|
|
152
|
+
: {
|
|
153
|
+
execution_status: raw.execution_status,
|
|
154
|
+
exit_code: raw.exit_code,
|
|
155
|
+
result_status: result.status,
|
|
156
|
+
failed_assertions: failedAssertions,
|
|
157
|
+
finding_codes: result.findings.map((finding) => finding.code),
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
await sandbox.dispose();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return findings;
|
|
165
|
+
}
|
|
166
|
+
function playwrightCounterfactualDiagnostic(raw, result, expectedAssertions, rejectionReasons) {
|
|
167
|
+
const caseIds = result.assertion_results
|
|
168
|
+
.map((assertion) => /^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(assertion.observation)?.[1])
|
|
169
|
+
.filter((item) => Boolean(item));
|
|
170
|
+
const unexpectedCaseIds = caseIds.filter((id) => raw.observations[`playwright.case.${id}.unexpected`] === true);
|
|
171
|
+
const timedOutCaseIds = caseIds.filter((id) => Number(raw.observations[`playwright.case.${id}.timed_out_instances`]) > 0);
|
|
172
|
+
const interruptedCaseIds = caseIds.filter((id) => Number(raw.observations[`playwright.case.${id}.interrupted_instances`]) >
|
|
173
|
+
0);
|
|
174
|
+
return {
|
|
175
|
+
execution_status: raw.execution_status,
|
|
176
|
+
exit_code: raw.exit_code,
|
|
177
|
+
result_status: result.status,
|
|
178
|
+
report_error_count: raw.observations["playwright.report_error_count"] ?? null,
|
|
179
|
+
expected_assertions: expectedAssertions,
|
|
180
|
+
unexpected_case_ids: [...new Set(unexpectedCaseIds)].sort(),
|
|
181
|
+
declared_unexpected_instances: raw.observations["playwright.declared_unexpected_instances"] ?? null,
|
|
182
|
+
unbound_unexpected_instances: raw.observations["playwright.unbound_unexpected_instances"] ?? null,
|
|
183
|
+
timed_out_case_ids: [...new Set(timedOutCaseIds)].sort(),
|
|
184
|
+
interrupted_case_ids: [...new Set(interruptedCaseIds)].sort(),
|
|
185
|
+
finding_codes: result.findings.map((finding) => finding.code),
|
|
186
|
+
rejection_reasons: rejectionReasons,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function counterfactualIntegrityFinding(entry, actual) {
|
|
190
|
+
return {
|
|
191
|
+
code: "counterfactual_integrity_failed",
|
|
192
|
+
outcome_key: entry.findingOutcomeKey,
|
|
193
|
+
check_key: entry.check.key,
|
|
194
|
+
...(entry.control.expected_assertion_failures.length === 1
|
|
195
|
+
? { assertion_key: entry.control.expected_assertion_failures[0] }
|
|
196
|
+
: {}),
|
|
197
|
+
claim_keys: entry.control.claims,
|
|
198
|
+
binding_ref: entry.bindingRef,
|
|
199
|
+
owning_outcome_key: entry.owningOutcome.key,
|
|
200
|
+
owner_paths: entry.owningOutcome.product.owner.path_globs,
|
|
201
|
+
message: `Counterfactual ${entry.control.key} did not fail exactly the designated Assertions.`,
|
|
202
|
+
expected: [...entry.control.expected_assertion_failures].sort(),
|
|
203
|
+
actual,
|
|
204
|
+
next_action: "Repair the referenced implementation carrier or proof so only the designated Assertion value mismatches demonstrate sensitivity.",
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export function isValidCounterfactualCheckResult(result, expectedAssertionFailures) {
|
|
208
|
+
const expected = [...expectedAssertionFailures].sort();
|
|
209
|
+
const failedAssertions = result.assertion_results
|
|
210
|
+
.filter((assertion) => !assertion.passed)
|
|
211
|
+
.map((assertion) => assertion.key)
|
|
212
|
+
.sort();
|
|
213
|
+
return (result.status === "assertion_failed" &&
|
|
214
|
+
result.findings.length === expected.length &&
|
|
215
|
+
result.findings.filter((finding) => finding.assertion_key).length ===
|
|
216
|
+
expected.length &&
|
|
217
|
+
result.findings
|
|
218
|
+
.filter((finding) => finding.assertion_key)
|
|
219
|
+
.every((finding) => expected.some((key) => finding.assertion_key === key)) &&
|
|
220
|
+
result.findings.every((finding) => finding.code === "assertion_value_mismatch") &&
|
|
221
|
+
result.assertion_results
|
|
222
|
+
.filter((assertion) => !assertion.passed)
|
|
223
|
+
.every((assertion) => assertion.status === "assertion_value_mismatch") &&
|
|
224
|
+
failedAssertions.length === expected.length &&
|
|
225
|
+
failedAssertions.every((item, index) => item === expected[index]));
|
|
226
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClaimCoverageSummaryV2, DeliveryContractV2, SourceClaimV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
type AcceptanceDisposition = Extract<SourceClaimV2["disposition"], {
|
|
3
|
+
type: "acceptance";
|
|
4
|
+
}>;
|
|
5
|
+
export declare function explainAcceptanceLinks(contract: DeliveryContractV2, coverage: ClaimCoverageSummaryV2, disposition: AcceptanceDisposition): ({
|
|
6
|
+
type: "acceptance";
|
|
7
|
+
reference: string;
|
|
8
|
+
scope: "global" | "outcome";
|
|
9
|
+
outcome_key: string | null;
|
|
10
|
+
criterion: string | null;
|
|
11
|
+
claims: string[];
|
|
12
|
+
source_backed_claims: string[];
|
|
13
|
+
required_proof_surfaces: Record<string, string[]>;
|
|
14
|
+
covered_proof_surfaces: Record<string, string[]>;
|
|
15
|
+
proof_surface: import("./long-task-contract-types.js").ProofSurface;
|
|
16
|
+
evidence_adapter: import("./long-task-evidence-adapter-types.js").EvidenceAdapter;
|
|
17
|
+
observation: string;
|
|
18
|
+
counterfactuals: {
|
|
19
|
+
key: string;
|
|
20
|
+
claims: string[];
|
|
21
|
+
binding_ref: string;
|
|
22
|
+
owning_outcome_key: string;
|
|
23
|
+
expected_assertion_failures: string[];
|
|
24
|
+
}[] | {
|
|
25
|
+
key: string;
|
|
26
|
+
claims: string[];
|
|
27
|
+
binding_key: string;
|
|
28
|
+
owning_outcome_key: string | null;
|
|
29
|
+
expected_assertion_failures: string[];
|
|
30
|
+
}[];
|
|
31
|
+
} | {
|
|
32
|
+
type: string;
|
|
33
|
+
reference: string;
|
|
34
|
+
scope: null;
|
|
35
|
+
outcome_key: null;
|
|
36
|
+
criterion: null;
|
|
37
|
+
claims: never[];
|
|
38
|
+
source_backed_claims: never[];
|
|
39
|
+
required_proof_surfaces: {};
|
|
40
|
+
covered_proof_surfaces: {};
|
|
41
|
+
proof_surface: null;
|
|
42
|
+
evidence_adapter: null;
|
|
43
|
+
observation: null;
|
|
44
|
+
counterfactuals: never[];
|
|
45
|
+
})[];
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { resolveAcceptanceAssertion } from "./long-task-acceptance-reference.js";
|
|
2
|
+
import { evidenceAdapterForRunner } from "./long-task-evidence-adapter-policy.js";
|
|
3
|
+
export function explainAcceptanceLinks(contract, coverage, disposition) {
|
|
4
|
+
return disposition.refs.map((reference) => {
|
|
5
|
+
const resolved = resolveAcceptanceAssertion(contract, reference);
|
|
6
|
+
if (!resolved)
|
|
7
|
+
return missingAcceptanceLink(reference);
|
|
8
|
+
const { assertion, check } = resolved;
|
|
9
|
+
const required = {};
|
|
10
|
+
const covered = {};
|
|
11
|
+
for (const claim of assertion.claims) {
|
|
12
|
+
if (resolved.scope === "outcome") {
|
|
13
|
+
const proof = coverage.claims_by_outcome[resolved.outcome_key]?.[claim];
|
|
14
|
+
required[claim] = proof ? proof.required_surfaces : [];
|
|
15
|
+
covered[claim] = proof ? proof.covered_surfaces : [];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const proof = coverage.claims_by_global[claim];
|
|
19
|
+
required[claim] = [];
|
|
20
|
+
covered[claim] = proof
|
|
21
|
+
? [...new Set(proof.proofs.map((item) => item.proof_surface))].sort()
|
|
22
|
+
: [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const counterfactuals = acceptanceCounterfactuals(contract, resolved.scope, resolved.outcome_key, resolved.check_key, resolved.assertion_key);
|
|
26
|
+
return {
|
|
27
|
+
type: disposition.type,
|
|
28
|
+
reference,
|
|
29
|
+
scope: resolved.scope,
|
|
30
|
+
outcome_key: resolved.outcome_key,
|
|
31
|
+
criterion: assertion.criterion ?? null,
|
|
32
|
+
claims: assertion.claims,
|
|
33
|
+
source_backed_claims: assertion.claims.filter((claim) => sourceBacked(contract, resolved.scope, resolved.outcome_key, claim)),
|
|
34
|
+
required_proof_surfaces: required,
|
|
35
|
+
covered_proof_surfaces: covered,
|
|
36
|
+
proof_surface: check.proof_surface,
|
|
37
|
+
evidence_adapter: evidenceAdapterForRunner(check.runner.type),
|
|
38
|
+
observation: assertion.observation,
|
|
39
|
+
counterfactuals,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function missingAcceptanceLink(reference) {
|
|
44
|
+
return {
|
|
45
|
+
type: "acceptance",
|
|
46
|
+
reference,
|
|
47
|
+
scope: null,
|
|
48
|
+
outcome_key: null,
|
|
49
|
+
criterion: null,
|
|
50
|
+
claims: [],
|
|
51
|
+
source_backed_claims: [],
|
|
52
|
+
required_proof_surfaces: {},
|
|
53
|
+
covered_proof_surfaces: {},
|
|
54
|
+
proof_surface: null,
|
|
55
|
+
evidence_adapter: null,
|
|
56
|
+
observation: null,
|
|
57
|
+
counterfactuals: [],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function sourceBacked(contract, scope, outcomeKey, claim) {
|
|
61
|
+
if (scope === "global")
|
|
62
|
+
return contract.source_claims.some((source) => source.disposition.type === "global_constraint" &&
|
|
63
|
+
source.disposition.refs.includes(claim));
|
|
64
|
+
const reference = `${outcomeKey}.${claim}`;
|
|
65
|
+
return contract.source_claims.some((source) => {
|
|
66
|
+
const disposition = source.disposition;
|
|
67
|
+
return ((disposition.type === "claim" || disposition.type === "outcome_result") &&
|
|
68
|
+
(disposition.type === "outcome_result"
|
|
69
|
+
? disposition.ref === reference
|
|
70
|
+
: disposition.refs.includes(reference)));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function acceptanceCounterfactuals(contract, scope, outcomeKey, checkKey, assertionKey) {
|
|
74
|
+
if (scope === "global")
|
|
75
|
+
return contract.global.acceptance.counterfactual_controls
|
|
76
|
+
.filter((control) => control.check_key === checkKey &&
|
|
77
|
+
control.expected_assertion_failures.includes(assertionKey))
|
|
78
|
+
.map((control) => ({
|
|
79
|
+
key: control.key,
|
|
80
|
+
claims: control.claims,
|
|
81
|
+
binding_ref: control.binding_ref,
|
|
82
|
+
owning_outcome_key: control.binding_ref.split(".")[0],
|
|
83
|
+
expected_assertion_failures: control.expected_assertion_failures,
|
|
84
|
+
}));
|
|
85
|
+
const outcome = contract.outcomes.find((item) => item.key === outcomeKey);
|
|
86
|
+
return (outcome?.acceptance.counterfactual_controls ?? [])
|
|
87
|
+
.filter((control) => control.check_key === checkKey &&
|
|
88
|
+
control.expected_assertion_failures.includes(assertionKey))
|
|
89
|
+
.map((control) => ({
|
|
90
|
+
key: control.key,
|
|
91
|
+
claims: control.claims,
|
|
92
|
+
binding_key: control.binding_key,
|
|
93
|
+
owning_outcome_key: outcomeKey,
|
|
94
|
+
expected_assertion_failures: control.expected_assertion_failures,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ClaimCoverageSummaryV2, DeliveryContractV2, SourceClaimV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
type ClaimDisposition = Extract<SourceClaimV2["disposition"], {
|
|
3
|
+
type: "claim";
|
|
4
|
+
}>;
|
|
5
|
+
type GlobalDisposition = Extract<SourceClaimV2["disposition"], {
|
|
6
|
+
type: "global_constraint";
|
|
7
|
+
}>;
|
|
8
|
+
type ResultDisposition = Extract<SourceClaimV2["disposition"], {
|
|
9
|
+
type: "outcome_result";
|
|
10
|
+
}>;
|
|
11
|
+
export declare function explainOutcomeClaimLinks(contract: DeliveryContractV2, coverage: ClaimCoverageSummaryV2, disposition: ClaimDisposition): {
|
|
12
|
+
type: "claim";
|
|
13
|
+
reference: string;
|
|
14
|
+
source_backed: boolean;
|
|
15
|
+
checks: string[];
|
|
16
|
+
assertions: (string | null)[];
|
|
17
|
+
required_proof_surfaces: import("./long-task-contract-types.js").ProofSurface[];
|
|
18
|
+
covered_proof_surfaces: import("./long-task-contract-types.js").ProofSurface[];
|
|
19
|
+
evidence_adapters: (import("./long-task-evidence-adapter-types.js").EvidenceAdapter | null)[];
|
|
20
|
+
}[];
|
|
21
|
+
export declare function explainOutcomeResultLinks(contract: DeliveryContractV2, coverage: ClaimCoverageSummaryV2, disposition: ResultDisposition): {
|
|
22
|
+
type: "outcome_result";
|
|
23
|
+
reference: string;
|
|
24
|
+
source_backed: boolean;
|
|
25
|
+
checks: string[];
|
|
26
|
+
}[];
|
|
27
|
+
export declare function explainGlobalClaimLinks(contract: DeliveryContractV2, coverage: ClaimCoverageSummaryV2, disposition: GlobalDisposition): {
|
|
28
|
+
type: "global_constraint";
|
|
29
|
+
reference: string;
|
|
30
|
+
source_backed: boolean;
|
|
31
|
+
checks: string[];
|
|
32
|
+
assertions: (string | null)[];
|
|
33
|
+
evidence_adapters: (import("./long-task-evidence-adapter-types.js").EvidenceAdapter | null)[];
|
|
34
|
+
counterfactuals: {
|
|
35
|
+
key: string;
|
|
36
|
+
check_key: string;
|
|
37
|
+
binding_ref: string;
|
|
38
|
+
owning_outcome: string;
|
|
39
|
+
owner_paths: string[];
|
|
40
|
+
carrier_paths: string[];
|
|
41
|
+
expected_assertion_failures: string[];
|
|
42
|
+
mutation: import("./long-task-counterfactual-types.js").CounterfactualMutationV2;
|
|
43
|
+
}[];
|
|
44
|
+
}[];
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { evidenceAdapterForRunner } from "./long-task-evidence-adapter-policy.js";
|
|
2
|
+
export function explainOutcomeClaimLinks(contract, coverage, disposition) {
|
|
3
|
+
return disposition.refs.map((reference) => {
|
|
4
|
+
const [outcomeKey, ...parts] = reference.split(".");
|
|
5
|
+
const proof = coverage.claims_by_outcome[outcomeKey]?.[parts.join(".")];
|
|
6
|
+
return {
|
|
7
|
+
type: disposition.type,
|
|
8
|
+
reference,
|
|
9
|
+
source_backed: sourceBacked(contract, reference),
|
|
10
|
+
checks: proof ? unique(proof.proofs.map((item) => item.check_key)) : [],
|
|
11
|
+
assertions: proof
|
|
12
|
+
? unique(proof.proofs.map((item) => item.assertion_key))
|
|
13
|
+
: [],
|
|
14
|
+
required_proof_surfaces: proof ? proof.required_surfaces : [],
|
|
15
|
+
covered_proof_surfaces: proof ? proof.covered_surfaces : [],
|
|
16
|
+
evidence_adapters: proof
|
|
17
|
+
? unique(proof.proofs.map((item) => outcomeAdapter(contract, outcomeKey, item.check_key)))
|
|
18
|
+
: [],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function explainOutcomeResultLinks(contract, coverage, disposition) {
|
|
23
|
+
const proof = coverage.claims_by_outcome[disposition.ref.split(".")[0]]?.result;
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
type: disposition.type,
|
|
27
|
+
reference: disposition.ref,
|
|
28
|
+
source_backed: sourceBacked(contract, disposition.ref),
|
|
29
|
+
checks: proof ? unique(proof.proofs.map((item) => item.check_key)) : [],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
export function explainGlobalClaimLinks(contract, coverage, disposition) {
|
|
34
|
+
return disposition.refs.map((reference) => {
|
|
35
|
+
const proof = coverage.claims_by_global[reference];
|
|
36
|
+
return {
|
|
37
|
+
type: disposition.type,
|
|
38
|
+
reference,
|
|
39
|
+
source_backed: sourceBacked(contract, reference),
|
|
40
|
+
checks: proof ? unique(proof.proofs.map((item) => item.check_key)) : [],
|
|
41
|
+
assertions: proof
|
|
42
|
+
? unique(proof.proofs.map((item) => item.assertion_key))
|
|
43
|
+
: [],
|
|
44
|
+
evidence_adapters: proof
|
|
45
|
+
? unique(proof.proofs.map((item) => globalAdapter(contract, item.check_key)))
|
|
46
|
+
: [],
|
|
47
|
+
counterfactuals: contract.global.acceptance.counterfactual_controls
|
|
48
|
+
.filter((control) => control.claims.includes(reference))
|
|
49
|
+
.map((control) => {
|
|
50
|
+
const [outcomeKey, bindingKey] = control.binding_ref.split(".");
|
|
51
|
+
const outcome = contract.outcomes.find((item) => item.key === outcomeKey);
|
|
52
|
+
const binding = outcome?.technical.bindings.find((item) => item.key === bindingKey);
|
|
53
|
+
return {
|
|
54
|
+
key: control.key,
|
|
55
|
+
check_key: control.check_key,
|
|
56
|
+
binding_ref: control.binding_ref,
|
|
57
|
+
owning_outcome: outcomeKey,
|
|
58
|
+
owner_paths: outcome?.product.owner.path_globs ?? [],
|
|
59
|
+
carrier_paths: binding?.carrier_paths ?? [],
|
|
60
|
+
expected_assertion_failures: control.expected_assertion_failures,
|
|
61
|
+
mutation: control.mutation,
|
|
62
|
+
};
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function unique(values) {
|
|
68
|
+
return values.filter((value, index) => values.indexOf(value) === index);
|
|
69
|
+
}
|
|
70
|
+
function sourceBacked(contract, reference) {
|
|
71
|
+
return contract.source_claims.some((source) => {
|
|
72
|
+
const disposition = source.disposition;
|
|
73
|
+
if (disposition.type === "outcome_result")
|
|
74
|
+
return disposition.ref === reference;
|
|
75
|
+
return ((disposition.type === "claim" ||
|
|
76
|
+
disposition.type === "global_constraint") &&
|
|
77
|
+
disposition.refs.includes(reference));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function outcomeAdapter(contract, outcomeKey, checkKey) {
|
|
81
|
+
const outcome = contract.outcomes.find((item) => item.key === outcomeKey);
|
|
82
|
+
const check = outcome?.acceptance.checks.find((candidate) => candidate.key === checkKey);
|
|
83
|
+
return check ? evidenceAdapterForRunner(check.runner.type) : null;
|
|
84
|
+
}
|
|
85
|
+
function globalAdapter(contract, checkKey) {
|
|
86
|
+
const check = contract.global.acceptance.checks.find((candidate) => candidate.key === checkKey);
|
|
87
|
+
return check ? evidenceAdapterForRunner(check.runner.type) : null;
|
|
88
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ClaimCoverageSummaryV2, DeliveryContractV2, SourceClaimV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function explainSourceLinks(contract: DeliveryContractV2, coverage: ClaimCoverageSummaryV2, source: SourceClaimV2): ({
|
|
3
|
+
type: "acceptance" | "claim" | "decision_required" | "external_confirmation" | "global_constraint" | "outcome_result" | "risk_fact";
|
|
4
|
+
reason: string | null;
|
|
5
|
+
} | {
|
|
6
|
+
type: "acceptance";
|
|
7
|
+
reference: string;
|
|
8
|
+
scope: "global" | "outcome";
|
|
9
|
+
outcome_key: string | null;
|
|
10
|
+
criterion: string | null;
|
|
11
|
+
claims: string[];
|
|
12
|
+
source_backed_claims: string[];
|
|
13
|
+
required_proof_surfaces: Record<string, string[]>;
|
|
14
|
+
covered_proof_surfaces: Record<string, string[]>;
|
|
15
|
+
proof_surface: import("./long-task-contract-types.js").ProofSurface;
|
|
16
|
+
evidence_adapter: import("./long-task-evidence-adapter-types.js").EvidenceAdapter;
|
|
17
|
+
observation: string;
|
|
18
|
+
counterfactuals: {
|
|
19
|
+
key: string;
|
|
20
|
+
claims: string[];
|
|
21
|
+
binding_ref: string;
|
|
22
|
+
owning_outcome_key: string;
|
|
23
|
+
expected_assertion_failures: string[];
|
|
24
|
+
}[] | {
|
|
25
|
+
key: string;
|
|
26
|
+
claims: string[];
|
|
27
|
+
binding_key: string;
|
|
28
|
+
owning_outcome_key: string | null;
|
|
29
|
+
expected_assertion_failures: string[];
|
|
30
|
+
}[];
|
|
31
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
32
|
+
} | {
|
|
33
|
+
type: string;
|
|
34
|
+
reference: string;
|
|
35
|
+
scope: null;
|
|
36
|
+
outcome_key: null;
|
|
37
|
+
criterion: null;
|
|
38
|
+
claims: never[];
|
|
39
|
+
source_backed_claims: never[];
|
|
40
|
+
required_proof_surfaces: {};
|
|
41
|
+
covered_proof_surfaces: {};
|
|
42
|
+
proof_surface: null;
|
|
43
|
+
evidence_adapter: null;
|
|
44
|
+
observation: null;
|
|
45
|
+
counterfactuals: never[];
|
|
46
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
47
|
+
} | {
|
|
48
|
+
type: "claim";
|
|
49
|
+
reference: string;
|
|
50
|
+
source_backed: boolean;
|
|
51
|
+
checks: string[];
|
|
52
|
+
assertions: (string | null)[];
|
|
53
|
+
required_proof_surfaces: import("./long-task-contract-types.js").ProofSurface[];
|
|
54
|
+
covered_proof_surfaces: import("./long-task-contract-types.js").ProofSurface[];
|
|
55
|
+
evidence_adapters: (import("./long-task-evidence-adapter-types.js").EvidenceAdapter | null)[];
|
|
56
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
57
|
+
} | {
|
|
58
|
+
type: "outcome_result";
|
|
59
|
+
reference: string;
|
|
60
|
+
source_backed: boolean;
|
|
61
|
+
checks: string[];
|
|
62
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
63
|
+
} | {
|
|
64
|
+
type: "global_constraint";
|
|
65
|
+
reference: string;
|
|
66
|
+
source_backed: boolean;
|
|
67
|
+
checks: string[];
|
|
68
|
+
assertions: (string | null)[];
|
|
69
|
+
evidence_adapters: (import("./long-task-evidence-adapter-types.js").EvidenceAdapter | null)[];
|
|
70
|
+
counterfactuals: {
|
|
71
|
+
key: string;
|
|
72
|
+
check_key: string;
|
|
73
|
+
binding_ref: string;
|
|
74
|
+
owning_outcome: string;
|
|
75
|
+
owner_paths: string[];
|
|
76
|
+
carrier_paths: string[];
|
|
77
|
+
expected_assertion_failures: string[];
|
|
78
|
+
mutation: import("./long-task-counterfactual-types.js").CounterfactualMutationV2;
|
|
79
|
+
}[];
|
|
80
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
81
|
+
} | {
|
|
82
|
+
type: "external_confirmation";
|
|
83
|
+
reference: string;
|
|
84
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
85
|
+
} | {
|
|
86
|
+
type: "risk_fact";
|
|
87
|
+
reference: string;
|
|
88
|
+
risk_fact: string;
|
|
89
|
+
affected_outcome: string;
|
|
90
|
+
effective_risk: import("./long-task-risk-types.js").EffectiveRiskLevel;
|
|
91
|
+
risk_reasons: ("critical_user_path" | "data_migration" | "full_population_operation" | "irreversible_external_effect" | "multi_repository_change" | "permission_boundary_change" | "persistent_data_change" | "public_api_or_schema_change" | "security_boundary_change" | "weak_observability")[];
|
|
92
|
+
canonical_target: import("./long-task-source-target-index.js").CanonicalSourceTarget | null;
|
|
93
|
+
})[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { explainAcceptanceLinks } from "./long-task-explain-acceptance-link.js";
|
|
2
|
+
import { explainGlobalClaimLinks, explainOutcomeClaimLinks, explainOutcomeResultLinks, } from "./long-task-explain-claim-links.js";
|
|
3
|
+
import { buildCanonicalSourceTargetIndex } from "./long-task-source-target-index.js";
|
|
4
|
+
import { classifyLongTaskRisk } from "./long-task-risk.js";
|
|
5
|
+
export function explainSourceLinks(contract, coverage, source) {
|
|
6
|
+
const disposition = source.disposition;
|
|
7
|
+
const targets = buildCanonicalSourceTargetIndex(contract);
|
|
8
|
+
let links;
|
|
9
|
+
if (disposition.type === "acceptance")
|
|
10
|
+
links = explainAcceptanceLinks(contract, coverage, disposition);
|
|
11
|
+
if (disposition.type === "claim")
|
|
12
|
+
links = explainOutcomeClaimLinks(contract, coverage, disposition);
|
|
13
|
+
if (disposition.type === "outcome_result")
|
|
14
|
+
links = explainOutcomeResultLinks(contract, coverage, disposition);
|
|
15
|
+
if (disposition.type === "global_constraint")
|
|
16
|
+
links = explainGlobalClaimLinks(contract, coverage, disposition);
|
|
17
|
+
if (disposition.type === "external_confirmation")
|
|
18
|
+
links = disposition.refs.map((reference) => ({
|
|
19
|
+
type: disposition.type,
|
|
20
|
+
reference,
|
|
21
|
+
}));
|
|
22
|
+
if (disposition.type === "risk_fact") {
|
|
23
|
+
const risk = classifyLongTaskRisk(contract);
|
|
24
|
+
links = disposition.refs.map((reference) => {
|
|
25
|
+
const [fact, affectedOutcome] = reference.split(":");
|
|
26
|
+
return {
|
|
27
|
+
type: disposition.type,
|
|
28
|
+
reference,
|
|
29
|
+
risk_fact: fact,
|
|
30
|
+
affected_outcome: affectedOutcome,
|
|
31
|
+
effective_risk: risk.effective_level,
|
|
32
|
+
risk_reasons: risk.reasons_by_outcome[affectedOutcome] ?? [],
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
links ??= [
|
|
37
|
+
{
|
|
38
|
+
type: disposition.type,
|
|
39
|
+
reason: "reason" in disposition ? disposition.reason : null,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
return links.map((link) => {
|
|
43
|
+
if (!("reference" in link))
|
|
44
|
+
return link;
|
|
45
|
+
const target = targets.get(link.reference);
|
|
46
|
+
return {
|
|
47
|
+
...link,
|
|
48
|
+
canonical_target: target ?? null,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|