project-tiny-context-harness 0.2.84 → 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 -157
- 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 +15 -3
- 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 -244
- package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -57
- 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 -675
- 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 -52
- package/dist/lib/superpowers-task-completion-output.js +0 -228
- 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 -382
- 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 -24
- package/dist/lib/superpowers-task-gates.d.ts +0 -12
- package/dist/lib/superpowers-task-gates.js +0 -155
- 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 -440
- 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 -290
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export function classifyPlaywrightCounterfactual(raw, result, control) {
|
|
2
|
+
const reasons = [];
|
|
3
|
+
const expected = [...new Set(control.expected_assertion_failures)].sort();
|
|
4
|
+
if (expected.length !== control.expected_assertion_failures.length)
|
|
5
|
+
reasons.push("expected_assertion_failures_duplicate");
|
|
6
|
+
if (result.evidence_adapter !== "playwright_json_v1")
|
|
7
|
+
reasons.push("evidence_adapter_not_playwright_json_v1");
|
|
8
|
+
if (raw.execution_status !== "completed")
|
|
9
|
+
reasons.push(`execution_status_${raw.execution_status}`);
|
|
10
|
+
if (raw.exit_code === 0)
|
|
11
|
+
reasons.push("exit_code_zero_with_test_failure");
|
|
12
|
+
else if (raw.exit_code !== 1)
|
|
13
|
+
reasons.push(`exit_code_not_expected_test_failure:${raw.exit_code}`);
|
|
14
|
+
const reportErrorCount = count(raw.observations, "playwright.report_error_count", reasons);
|
|
15
|
+
const declaredUnexpectedInstances = count(raw.observations, "playwright.declared_unexpected_instances", reasons);
|
|
16
|
+
const unboundUnexpectedInstances = count(raw.observations, "playwright.unbound_unexpected_instances", reasons);
|
|
17
|
+
const reportUnexpectedInstances = count(raw.observations, "playwright.unexpected", reasons);
|
|
18
|
+
if (reportErrorCount !== null && reportErrorCount !== 0)
|
|
19
|
+
reasons.push(`playwright_report_errors:${reportErrorCount}`);
|
|
20
|
+
if (unboundUnexpectedInstances !== null && unboundUnexpectedInstances !== 0)
|
|
21
|
+
reasons.push(`playwright_unbound_unexpected_instances:${unboundUnexpectedInstances}`);
|
|
22
|
+
const expectedCaseIds = new Set();
|
|
23
|
+
let expectedUnexpectedInstances = 0;
|
|
24
|
+
for (const assertionKey of expected) {
|
|
25
|
+
const assertion = result.assertion_results.find((item) => item.key === assertionKey);
|
|
26
|
+
if (!assertion) {
|
|
27
|
+
reasons.push(`expected_assertion_missing:${assertionKey}`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const caseId = playwrightCaseId(assertion.observation);
|
|
31
|
+
if (!caseId) {
|
|
32
|
+
reasons.push(`expected_assertion_not_playwright_ac:${assertionKey}`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (expectedCaseIds.has(caseId))
|
|
36
|
+
reasons.push(`expected_playwright_ac_duplicate:${caseId}`);
|
|
37
|
+
expectedCaseIds.add(caseId);
|
|
38
|
+
const prefix = `playwright.case.${caseId}`;
|
|
39
|
+
if (boolean(raw.observations, `${prefix}.executed`) !== true)
|
|
40
|
+
reasons.push(`expected_playwright_ac_not_executed:${caseId}`);
|
|
41
|
+
if (boolean(raw.observations, `${prefix}.unexpected`) !== true)
|
|
42
|
+
reasons.push(`expected_playwright_ac_not_unexpected:${caseId}`);
|
|
43
|
+
if (boolean(raw.observations, `${prefix}.skipped`) !== false)
|
|
44
|
+
reasons.push(`expected_playwright_ac_skipped:${caseId}`);
|
|
45
|
+
if (boolean(raw.observations, `${prefix}.flaky`) !== false)
|
|
46
|
+
reasons.push(`expected_playwright_ac_flaky:${caseId}`);
|
|
47
|
+
const unexpectedInstances = count(raw.observations, `${prefix}.unexpected_instances`, reasons);
|
|
48
|
+
const timedOutInstances = count(raw.observations, `${prefix}.timed_out_instances`, reasons);
|
|
49
|
+
const interruptedInstances = count(raw.observations, `${prefix}.interrupted_instances`, reasons);
|
|
50
|
+
if (unexpectedInstances !== null) {
|
|
51
|
+
expectedUnexpectedInstances += unexpectedInstances;
|
|
52
|
+
if (unexpectedInstances === 0)
|
|
53
|
+
reasons.push(`expected_playwright_ac_has_no_unexpected_instance:${caseId}`);
|
|
54
|
+
}
|
|
55
|
+
if (timedOutInstances !== null && timedOutInstances !== 0)
|
|
56
|
+
reasons.push(`expected_playwright_ac_timed_out:${caseId}`);
|
|
57
|
+
if (interruptedInstances !== null && interruptedInstances !== 0)
|
|
58
|
+
reasons.push(`expected_playwright_ac_interrupted:${caseId}`);
|
|
59
|
+
if (assertion.passed || assertion.status !== "assertion_value_mismatch")
|
|
60
|
+
reasons.push(`expected_assertion_not_value_mismatch:${assertionKey}`);
|
|
61
|
+
}
|
|
62
|
+
for (const assertion of result.assertion_results)
|
|
63
|
+
if (!expected.includes(assertion.key) && !assertion.passed)
|
|
64
|
+
reasons.push(`unspecified_assertion_failed:${assertion.key}`);
|
|
65
|
+
if (declaredUnexpectedInstances !== null &&
|
|
66
|
+
declaredUnexpectedInstances !== expectedUnexpectedInstances)
|
|
67
|
+
reasons.push(`declared_unexpected_instance_mismatch:${declaredUnexpectedInstances}:${expectedUnexpectedInstances}`);
|
|
68
|
+
if (reportUnexpectedInstances !== null &&
|
|
69
|
+
reportUnexpectedInstances !== expectedUnexpectedInstances)
|
|
70
|
+
reasons.push(`report_unexpected_instance_mismatch:${reportUnexpectedInstances}:${expectedUnexpectedInstances}`);
|
|
71
|
+
const genericTestFailures = result.findings.filter((finding) => finding.code === "test_failed" && !finding.assertion_key);
|
|
72
|
+
if (genericTestFailures.length !== 1)
|
|
73
|
+
reasons.push(`generic_test_failure_count_unexpected:${genericTestFailures.length}`);
|
|
74
|
+
for (const finding of result.findings) {
|
|
75
|
+
const expectedAcceptanceFailure = finding.code === "acceptance_case_unexpected" &&
|
|
76
|
+
Boolean(finding.assertion_key) &&
|
|
77
|
+
expected.includes(finding.assertion_key);
|
|
78
|
+
const genericTestFailure = finding.code === "test_failed" && !finding.assertion_key;
|
|
79
|
+
if (!expectedAcceptanceFailure && !genericTestFailure)
|
|
80
|
+
reasons.push(`unexplained_finding:${finding.code}:${finding.assertion_key ?? "none"}`);
|
|
81
|
+
}
|
|
82
|
+
for (const assertionKey of expected)
|
|
83
|
+
if (!result.findings.some((finding) => finding.code === "acceptance_case_unexpected" &&
|
|
84
|
+
finding.assertion_key === assertionKey))
|
|
85
|
+
reasons.push(`expected_acceptance_failure_missing:${assertionKey}`);
|
|
86
|
+
const rejectionReasons = [...new Set(reasons)].sort();
|
|
87
|
+
if (rejectionReasons.length)
|
|
88
|
+
return {
|
|
89
|
+
accepted_test_failure_exit: false,
|
|
90
|
+
normalized_result: result,
|
|
91
|
+
rejection_reasons: rejectionReasons,
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
accepted_test_failure_exit: true,
|
|
95
|
+
normalized_result: {
|
|
96
|
+
...result,
|
|
97
|
+
status: "assertion_failed",
|
|
98
|
+
claim_proofs: [],
|
|
99
|
+
findings: result.findings
|
|
100
|
+
.filter((finding) => !(finding.code === "test_failed" && !finding.assertion_key))
|
|
101
|
+
.map((finding) => finding.code === "acceptance_case_unexpected" &&
|
|
102
|
+
finding.assertion_key &&
|
|
103
|
+
expected.includes(finding.assertion_key)
|
|
104
|
+
? { ...finding, code: "assertion_value_mismatch" }
|
|
105
|
+
: finding),
|
|
106
|
+
},
|
|
107
|
+
rejection_reasons: [],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function playwrightCaseId(observation) {
|
|
111
|
+
return (/^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(observation)?.[1] ?? null);
|
|
112
|
+
}
|
|
113
|
+
function count(observations, key, reasons) {
|
|
114
|
+
const value = observations[key];
|
|
115
|
+
if (!Number.isInteger(value) || Number(value) < 0) {
|
|
116
|
+
reasons.push(`playwright_diagnostic_count_invalid:${key}`);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return Number(value);
|
|
120
|
+
}
|
|
121
|
+
function boolean(observations, key) {
|
|
122
|
+
return typeof observations[key] === "boolean"
|
|
123
|
+
? observations[key]
|
|
124
|
+
: null;
|
|
125
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CompiledCheckV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface PlaywrightEvidence {
|
|
3
|
+
observations: Record<string, unknown>;
|
|
4
|
+
error: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function extractPlaywrightEvidence(check: CompiledCheckV2, report: Record<string, unknown>, exitCode: number): PlaywrightEvidence;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
export function extractPlaywrightEvidence(check, report, exitCode) {
|
|
2
|
+
const stats = record(report.stats);
|
|
3
|
+
if (!stats)
|
|
4
|
+
return invalid("playwright_report_invalid:stats");
|
|
5
|
+
const expected = integer(stats.expected);
|
|
6
|
+
const unexpected = integer(stats.unexpected);
|
|
7
|
+
const skipped = integer(stats.skipped);
|
|
8
|
+
const flaky = integer(stats.flaky);
|
|
9
|
+
if ([expected, unexpected, skipped, flaky].some((value) => value === null))
|
|
10
|
+
return invalid("playwright_report_invalid:counts");
|
|
11
|
+
const total = expected + unexpected + skipped + flaky;
|
|
12
|
+
const reportErrors = report.errors;
|
|
13
|
+
if (reportErrors !== undefined && !Array.isArray(reportErrors))
|
|
14
|
+
return invalid("playwright_report_invalid:errors");
|
|
15
|
+
const observations = {
|
|
16
|
+
"playwright.passed": exitCode === 0,
|
|
17
|
+
"playwright.expected": expected,
|
|
18
|
+
"playwright.unexpected": unexpected,
|
|
19
|
+
"playwright.skipped": skipped,
|
|
20
|
+
"playwright.flaky": flaky,
|
|
21
|
+
"playwright.total": total,
|
|
22
|
+
"playwright.zero_or_all_skipped": total === 0 || skipped === total,
|
|
23
|
+
"playwright.report_error_count": Array.isArray(reportErrors)
|
|
24
|
+
? reportErrors.length
|
|
25
|
+
: 0,
|
|
26
|
+
};
|
|
27
|
+
const collected = collectCases(report, declaredCaseIds(check));
|
|
28
|
+
if (collected.error)
|
|
29
|
+
return invalid(collected.error);
|
|
30
|
+
const instances = collected.cases;
|
|
31
|
+
observations["playwright.declared_unexpected_instances"] = instances.filter((item) => item.unexpected).length;
|
|
32
|
+
observations["playwright.unbound_unexpected_instances"] =
|
|
33
|
+
collected.unbound_unexpected_instances;
|
|
34
|
+
const duplicate = duplicateCaseInstance(instances);
|
|
35
|
+
if (duplicate)
|
|
36
|
+
return invalid(`playwright_ac_id_duplicate:${duplicate.id}:${duplicate.project_id}`);
|
|
37
|
+
const cases = aggregateCases(instances);
|
|
38
|
+
for (const item of cases) {
|
|
39
|
+
const prefix = `playwright.case.${item.id}`;
|
|
40
|
+
observations[`${prefix}.executed`] = item.executed;
|
|
41
|
+
observations[`${prefix}.passed`] = item.passed;
|
|
42
|
+
observations[`${prefix}.skipped`] = item.skipped;
|
|
43
|
+
observations[`${prefix}.flaky`] = item.flaky;
|
|
44
|
+
observations[`${prefix}.unexpected`] = item.unexpected;
|
|
45
|
+
observations[`${prefix}.status`] = item.status;
|
|
46
|
+
observations[`${prefix}.project_ids`] = item.project_ids;
|
|
47
|
+
observations[`${prefix}.executed_instances`] = item.executed_instances;
|
|
48
|
+
observations[`${prefix}.failed_instances`] = item.failed_instances;
|
|
49
|
+
observations[`${prefix}.skipped_instances`] = item.skipped_instances;
|
|
50
|
+
observations[`${prefix}.flaky_instances`] = item.flaky_instances;
|
|
51
|
+
observations[`${prefix}.unexpected_instances`] = item.unexpected_instances;
|
|
52
|
+
observations[`${prefix}.timed_out_instances`] = item.timed_out_instances;
|
|
53
|
+
observations[`${prefix}.interrupted_instances`] =
|
|
54
|
+
item.interrupted_instances;
|
|
55
|
+
}
|
|
56
|
+
for (const id of declaredCaseIds(check)) {
|
|
57
|
+
const prefix = `playwright.case.${id}`;
|
|
58
|
+
if (!Object.hasOwn(observations, `${prefix}.status`)) {
|
|
59
|
+
observations[`${prefix}.executed`] = false;
|
|
60
|
+
observations[`${prefix}.status`] = "missing";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
observations["playwright.case_ids"] = cases.map((item) => item.id).sort();
|
|
64
|
+
return { observations, error: null };
|
|
65
|
+
}
|
|
66
|
+
function collectCases(report, declaredIds) {
|
|
67
|
+
const cases = [];
|
|
68
|
+
const collection = { unbound_unexpected_instances: 0 };
|
|
69
|
+
const error = visitSuites(report.suites, cases, declaredIds, collection);
|
|
70
|
+
return { cases, error, ...collection };
|
|
71
|
+
}
|
|
72
|
+
function visitSuites(value, cases, declaredIds, collection) {
|
|
73
|
+
if (!Array.isArray(value))
|
|
74
|
+
return null;
|
|
75
|
+
for (const suiteValue of value) {
|
|
76
|
+
const suite = record(suiteValue);
|
|
77
|
+
if (!suite)
|
|
78
|
+
continue;
|
|
79
|
+
const nestedError = visitSuites(suite.suites, cases, declaredIds, collection);
|
|
80
|
+
if (nestedError)
|
|
81
|
+
return nestedError;
|
|
82
|
+
if (!Array.isArray(suite.specs))
|
|
83
|
+
continue;
|
|
84
|
+
for (const specValue of suite.specs) {
|
|
85
|
+
const spec = record(specValue);
|
|
86
|
+
if (!spec || !Array.isArray(spec.tests))
|
|
87
|
+
continue;
|
|
88
|
+
for (const testValue of spec.tests) {
|
|
89
|
+
const test = record(testValue);
|
|
90
|
+
if (!test)
|
|
91
|
+
continue;
|
|
92
|
+
const title = [spec.title, test.title]
|
|
93
|
+
.filter((item) => typeof item === "string")
|
|
94
|
+
.join(" ");
|
|
95
|
+
const ids = declaredIdsInTitle(title, declaredIds);
|
|
96
|
+
if (ids.length > 1)
|
|
97
|
+
return `playwright_test_multiple_ac_ids:${ids.join(",")}`;
|
|
98
|
+
const instance = playwrightCase(ids[0] ?? "unbound", test);
|
|
99
|
+
if (ids.length === 1)
|
|
100
|
+
cases.push(instance);
|
|
101
|
+
else if (instance.unexpected)
|
|
102
|
+
collection.unbound_unexpected_instances += 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function declaredIdsInTitle(title, declared) {
|
|
109
|
+
const explicit = [...title.matchAll(/\[ac:([a-z0-9][a-z0-9-]*)\]/gu)].map((match) => match[1]);
|
|
110
|
+
const legacy = [...title.matchAll(/\[([a-z0-9][a-z0-9-]*)\]/gu)].map((match) => match[1]);
|
|
111
|
+
return [
|
|
112
|
+
...new Set([...explicit, ...legacy].filter((id) => declared.has(id))),
|
|
113
|
+
].sort();
|
|
114
|
+
}
|
|
115
|
+
function playwrightCase(id, test) {
|
|
116
|
+
const status = typeof test.status === "string" ? test.status : "invalid";
|
|
117
|
+
const projectId = typeof test.projectId === "string"
|
|
118
|
+
? test.projectId
|
|
119
|
+
: typeof test.projectName === "string"
|
|
120
|
+
? test.projectName
|
|
121
|
+
: "default";
|
|
122
|
+
const results = Array.isArray(test.results)
|
|
123
|
+
? test.results.map(record).filter(Boolean)
|
|
124
|
+
: [];
|
|
125
|
+
const resultStatuses = results
|
|
126
|
+
.map((result) => result.status)
|
|
127
|
+
.filter((value) => typeof value === "string");
|
|
128
|
+
const skipped = status === "skipped" ||
|
|
129
|
+
(resultStatuses.length > 0 &&
|
|
130
|
+
resultStatuses.every((value) => value === "skipped"));
|
|
131
|
+
const executed = !skipped && resultStatuses.length > 0;
|
|
132
|
+
const flaky = status === "flaky";
|
|
133
|
+
const unexpected = status === "unexpected";
|
|
134
|
+
const timedOut = resultStatuses.includes("timedOut");
|
|
135
|
+
const interrupted = resultStatuses.includes("interrupted");
|
|
136
|
+
const passed = executed &&
|
|
137
|
+
!flaky &&
|
|
138
|
+
!unexpected &&
|
|
139
|
+
status === "expected" &&
|
|
140
|
+
resultStatuses.length > 0 &&
|
|
141
|
+
resultStatuses.at(-1) === "passed";
|
|
142
|
+
return {
|
|
143
|
+
id,
|
|
144
|
+
project_id: projectId,
|
|
145
|
+
executed,
|
|
146
|
+
passed,
|
|
147
|
+
skipped,
|
|
148
|
+
flaky,
|
|
149
|
+
unexpected,
|
|
150
|
+
timed_out: timedOut,
|
|
151
|
+
interrupted,
|
|
152
|
+
status,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function declaredCaseIds(check) {
|
|
156
|
+
const result = new Set();
|
|
157
|
+
for (const assertion of [
|
|
158
|
+
...check.positive_assertions,
|
|
159
|
+
...check.negative_assertions,
|
|
160
|
+
]) {
|
|
161
|
+
if (!assertion.claims.length)
|
|
162
|
+
continue;
|
|
163
|
+
const match = /^playwright\.case\.([a-z0-9][a-z0-9-]*)\.passed$/u.exec(assertion.observation);
|
|
164
|
+
if (match)
|
|
165
|
+
result.add(assertion.key);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
function duplicateCaseInstance(values) {
|
|
170
|
+
const seen = new Set();
|
|
171
|
+
for (const value of values) {
|
|
172
|
+
const identity = `${value.id}\0${value.project_id}`;
|
|
173
|
+
if (seen.has(identity))
|
|
174
|
+
return value;
|
|
175
|
+
seen.add(identity);
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
function aggregateCases(instances) {
|
|
180
|
+
const grouped = new Map();
|
|
181
|
+
for (const instance of instances) {
|
|
182
|
+
const rows = grouped.get(instance.id) ?? [];
|
|
183
|
+
rows.push(instance);
|
|
184
|
+
grouped.set(instance.id, rows);
|
|
185
|
+
}
|
|
186
|
+
return [...grouped.entries()]
|
|
187
|
+
.map(([id, rows]) => {
|
|
188
|
+
const executedInstances = rows.filter((item) => item.executed).length;
|
|
189
|
+
const skippedInstances = rows.filter((item) => item.skipped).length;
|
|
190
|
+
const flakyInstances = rows.filter((item) => item.flaky).length;
|
|
191
|
+
const unexpectedInstances = rows.filter((item) => item.unexpected).length;
|
|
192
|
+
const timedOutInstances = rows.filter((item) => item.timed_out).length;
|
|
193
|
+
const interruptedInstances = rows.filter((item) => item.interrupted).length;
|
|
194
|
+
const failedInstances = rows.filter((item) => !item.passed && !item.skipped).length;
|
|
195
|
+
const executed = rows.length > 0 && rows.every((item) => item.executed);
|
|
196
|
+
const passed = executed &&
|
|
197
|
+
skippedInstances === 0 &&
|
|
198
|
+
flakyInstances === 0 &&
|
|
199
|
+
unexpectedInstances === 0 &&
|
|
200
|
+
rows.every((item) => item.passed);
|
|
201
|
+
const status = passed
|
|
202
|
+
? "passed"
|
|
203
|
+
: skippedInstances
|
|
204
|
+
? "skipped"
|
|
205
|
+
: flakyInstances
|
|
206
|
+
? "flaky"
|
|
207
|
+
: timedOutInstances
|
|
208
|
+
? "timed_out"
|
|
209
|
+
: interruptedInstances
|
|
210
|
+
? "interrupted"
|
|
211
|
+
: unexpectedInstances
|
|
212
|
+
? "unexpected"
|
|
213
|
+
: "failed";
|
|
214
|
+
return {
|
|
215
|
+
id,
|
|
216
|
+
executed,
|
|
217
|
+
passed,
|
|
218
|
+
skipped: skippedInstances > 0,
|
|
219
|
+
flaky: flakyInstances > 0,
|
|
220
|
+
unexpected: unexpectedInstances > 0,
|
|
221
|
+
status,
|
|
222
|
+
project_ids: rows.map((item) => item.project_id).sort(),
|
|
223
|
+
executed_instances: executedInstances,
|
|
224
|
+
failed_instances: failedInstances,
|
|
225
|
+
skipped_instances: skippedInstances,
|
|
226
|
+
flaky_instances: flakyInstances,
|
|
227
|
+
unexpected_instances: unexpectedInstances,
|
|
228
|
+
timed_out_instances: timedOutInstances,
|
|
229
|
+
interrupted_instances: interruptedInstances,
|
|
230
|
+
};
|
|
231
|
+
})
|
|
232
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
233
|
+
}
|
|
234
|
+
function record(value) {
|
|
235
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
236
|
+
? value
|
|
237
|
+
: null;
|
|
238
|
+
}
|
|
239
|
+
function integer(value) {
|
|
240
|
+
return Number.isInteger(value) && Number(value) >= 0 ? Number(value) : null;
|
|
241
|
+
}
|
|
242
|
+
function invalid(error) {
|
|
243
|
+
return { observations: {}, error };
|
|
244
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DeliveryControlV2, DeliveryObligationV2, DeliveryOwnerV2, KeyedPathV2, KeyedStatementV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function parseKeyedStatements(value: unknown, label: string): KeyedStatementV2[];
|
|
3
|
+
export declare function parseKeyedPaths(value: unknown, label: string): KeyedPathV2[];
|
|
4
|
+
export declare function parseControls(value: unknown, label: string): DeliveryControlV2[];
|
|
5
|
+
export declare function parseOwner(value: unknown, label: string): DeliveryOwnerV2;
|
|
6
|
+
export declare function parseObligations(value: unknown, label: string): DeliveryObligationV2[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { parseRequiredProofSurfaces } from "./long-task-required-proof-surfaces.js";
|
|
2
|
+
import { array, key, object, repositoryFiles, repositoryPattern, repositoryPatterns, string, text, } from "./long-task-shape-primitives.js";
|
|
3
|
+
export function parseKeyedStatements(value, label) {
|
|
4
|
+
return array(value, label).map((item, index) => {
|
|
5
|
+
const itemLabel = `${label}[${index}]`;
|
|
6
|
+
const row = object(item, itemLabel, ["key", "statement"]);
|
|
7
|
+
return {
|
|
8
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
9
|
+
statement: string(row.statement, `${itemLabel}.statement`),
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function parseKeyedPaths(value, label) {
|
|
14
|
+
return array(value, label).map((item, index) => {
|
|
15
|
+
const itemLabel = `${label}[${index}]`;
|
|
16
|
+
const row = object(item, itemLabel, ["key", "path"]);
|
|
17
|
+
return {
|
|
18
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
19
|
+
path: repositoryPattern(row.path, `${itemLabel}.path`),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function parseControls(value, label) {
|
|
24
|
+
return array(value, label).map((item, index) => {
|
|
25
|
+
const itemLabel = `${label}[${index}]`;
|
|
26
|
+
const row = object(item, itemLabel, ["key", "location"], [
|
|
27
|
+
"trigger",
|
|
28
|
+
"input",
|
|
29
|
+
"loading_state",
|
|
30
|
+
"empty_state",
|
|
31
|
+
"success_state",
|
|
32
|
+
"failure_state",
|
|
33
|
+
"feedback",
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
37
|
+
location: string(row.location, `${itemLabel}.location`),
|
|
38
|
+
trigger: optionalText(row, "trigger", itemLabel),
|
|
39
|
+
input: optionalText(row, "input", itemLabel),
|
|
40
|
+
loading_state: optionalText(row, "loading_state", itemLabel),
|
|
41
|
+
empty_state: optionalText(row, "empty_state", itemLabel),
|
|
42
|
+
success_state: optionalText(row, "success_state", itemLabel),
|
|
43
|
+
failure_state: optionalText(row, "failure_state", itemLabel),
|
|
44
|
+
feedback: optionalText(row, "feedback", itemLabel),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function parseOwner(value, label) {
|
|
49
|
+
const row = object(value, label, ["label", "context_refs", "path_globs"]);
|
|
50
|
+
return {
|
|
51
|
+
label: string(row.label, `${label}.label`),
|
|
52
|
+
context_refs: repositoryFiles(row.context_refs, `${label}.context_refs`),
|
|
53
|
+
path_globs: repositoryPatterns(row.path_globs, `${label}.path_globs`),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function parseObligations(value, label) {
|
|
57
|
+
return array(value, label).map((item, index) => {
|
|
58
|
+
const itemLabel = `${label}[${index}]`;
|
|
59
|
+
const row = object(item, itemLabel, [
|
|
60
|
+
"key",
|
|
61
|
+
"statement",
|
|
62
|
+
"required_proof_surfaces",
|
|
63
|
+
]);
|
|
64
|
+
return {
|
|
65
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
66
|
+
statement: string(row.statement, `${itemLabel}.statement`),
|
|
67
|
+
required_proof_surfaces: parseRequiredProofSurfaces(row.required_proof_surfaces, `${itemLabel}.required_proof_surfaces`),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function optionalText(row, field, label) {
|
|
72
|
+
return Object.hasOwn(row, field) ? text(row[field], `${label}.${field}`) : "";
|
|
73
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CheckExecutionResultV2, CompiledCheckV2, CompiledDeliveryContractV2, ProgressRecordV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function createProgressRecord(compiled: CompiledDeliveryContractV2, manifest: WorkspaceManifestV2, check: CompiledCheckV2, result: CheckExecutionResultV2): ProgressRecordV2;
|
|
3
|
+
export declare function progressRecordFresh(record: ProgressRecordV2, compiled: CompiledDeliveryContractV2, manifest: WorkspaceManifestV2, check: CompiledCheckV2): boolean;
|
|
4
|
+
export declare function checkIdentity(check: CompiledCheckV2): string;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { outcomeAuthorityHash } from "./long-task-authority.js";
|
|
2
|
+
import { contextAuthorityProjection } from "./long-task-context-authority.js";
|
|
3
|
+
import { matchesRepoPattern } from "./long-task-paths.js";
|
|
4
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
5
|
+
export function createProgressRecord(compiled, manifest, check, result) {
|
|
6
|
+
const outcome = check.outcome_key
|
|
7
|
+
? (compiled.outcomes.find((item) => item.key === check.outcome_key) ?? null)
|
|
8
|
+
: null;
|
|
9
|
+
return {
|
|
10
|
+
schema_version: "long-task-progress-record-v2",
|
|
11
|
+
compiled_identity: compiled.compiled_identity,
|
|
12
|
+
outcome_authority_hash: progressAuthorityHash(compiled, outcome ?? null),
|
|
13
|
+
check_identity: checkIdentity(check),
|
|
14
|
+
check_internal_id: check.internal_id,
|
|
15
|
+
outcome_key: check.outcome_key,
|
|
16
|
+
check_key: check.key,
|
|
17
|
+
runner_verifier_identity: runnerVerifierIdentity(compiled, check),
|
|
18
|
+
relevant_context_identity: contextIdentity(compiled),
|
|
19
|
+
resolved_input_path_hashes: hashPatterns(manifest, check.input_paths),
|
|
20
|
+
binding_carrier_path_hashes: hashPatterns(manifest, progressBindingCarrierPatterns(compiled, check, outcome)),
|
|
21
|
+
dependency_interface_identities: dependencyInterfaceIdentities(compiled, manifest, outcome?.depends_on ?? []),
|
|
22
|
+
result: result.status,
|
|
23
|
+
check_result: result,
|
|
24
|
+
findings: result.findings,
|
|
25
|
+
completed_at: new Date().toISOString(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function progressRecordFresh(record, compiled, manifest, check) {
|
|
29
|
+
const outcome = check.outcome_key
|
|
30
|
+
? (compiled.outcomes.find((item) => item.key === check.outcome_key) ?? null)
|
|
31
|
+
: null;
|
|
32
|
+
const expectedOutcomeAuthority = progressAuthorityHash(compiled, outcome ?? null);
|
|
33
|
+
return (record.check_internal_id === check.internal_id &&
|
|
34
|
+
record.check_identity === checkIdentity(check) &&
|
|
35
|
+
record.outcome_authority_hash === expectedOutcomeAuthority &&
|
|
36
|
+
record.runner_verifier_identity ===
|
|
37
|
+
runnerVerifierIdentity(compiled, check) &&
|
|
38
|
+
record.relevant_context_identity === contextIdentity(compiled) &&
|
|
39
|
+
same(record.resolved_input_path_hashes, hashPatterns(manifest, check.input_paths)) &&
|
|
40
|
+
same(record.binding_carrier_path_hashes, hashPatterns(manifest, progressBindingCarrierPatterns(compiled, check, outcome))) &&
|
|
41
|
+
same(record.dependency_interface_identities, dependencyInterfaceIdentities(compiled, manifest, outcome?.depends_on ?? [])));
|
|
42
|
+
}
|
|
43
|
+
function progressBindingCarrierPatterns(compiled, check, outcome) {
|
|
44
|
+
if (outcome)
|
|
45
|
+
return outcome.technical.bindings.flatMap((binding) => binding.carrier_paths);
|
|
46
|
+
const references = (compiled.global.acceptance.counterfactual_controls ?? [])
|
|
47
|
+
.filter((control) => control.check_key === check.key)
|
|
48
|
+
.map((control) => control.binding_ref);
|
|
49
|
+
return references.flatMap((reference) => {
|
|
50
|
+
const [outcomeKey, bindingKey] = reference.split(".");
|
|
51
|
+
return (compiled.outcomes
|
|
52
|
+
.find((item) => item.key === outcomeKey)
|
|
53
|
+
?.technical.bindings.find((binding) => binding.key === bindingKey)
|
|
54
|
+
?.carrier_paths ?? []);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function progressAuthorityHash(compiled, outcome) {
|
|
58
|
+
return sha256Hex(canonicalValueJson({
|
|
59
|
+
source: compiled.authority_hashes.source_authority_hash,
|
|
60
|
+
product: compiled.authority_hashes.product_authority_hash,
|
|
61
|
+
acceptance: compiled.authority_hashes.acceptance_authority_hash,
|
|
62
|
+
risk: compiled.authority_hashes.risk_authority_hash,
|
|
63
|
+
outcome: outcome ? outcomeAuthorityHash(outcome) : null,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
export function checkIdentity(check) {
|
|
67
|
+
return sha256Hex(canonicalValueJson({
|
|
68
|
+
internal_id: check.internal_id,
|
|
69
|
+
proof_surface: check.proof_surface,
|
|
70
|
+
evidence_adapter: check.evidence_adapter,
|
|
71
|
+
runner: check.runner.execution_identity,
|
|
72
|
+
raw_execution: check.raw_execution_identity,
|
|
73
|
+
verification_input_hashes: check.verification_input_hashes,
|
|
74
|
+
input_paths: check.input_paths,
|
|
75
|
+
expected_output_paths: check.expected_output_paths,
|
|
76
|
+
artifact_globs: check.artifact_globs,
|
|
77
|
+
positive_assertions: check.positive_assertions,
|
|
78
|
+
negative_assertions: check.negative_assertions,
|
|
79
|
+
environment_requirements: check.environment_requirements,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
function runnerVerifierIdentity(compiled, check) {
|
|
83
|
+
return sha256Hex(canonicalValueJson({
|
|
84
|
+
runner: check.raw_execution_identity,
|
|
85
|
+
verifier: compiled.verifier_identity.bundle_sha256,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
function contextIdentity(compiled) {
|
|
89
|
+
return sha256Hex(canonicalValueJson(contextAuthorityProjection(compiled.context_snapshot)));
|
|
90
|
+
}
|
|
91
|
+
function dependencyInterfaceIdentities(compiled, manifest, dependencies) {
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const key of dependencies) {
|
|
94
|
+
const dependency = compiled.outcomes.find((outcome) => outcome.key === key);
|
|
95
|
+
if (!dependency)
|
|
96
|
+
continue;
|
|
97
|
+
result[key] = sha256Hex(canonicalValueJson({
|
|
98
|
+
authority: outcomeAuthorityHash(dependency),
|
|
99
|
+
carriers: hashPatterns(manifest, dependency.technical.bindings.flatMap((binding) => binding.carrier_paths)),
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
return Object.fromEntries(Object.entries(result).sort(([a], [b]) => a.localeCompare(b)));
|
|
103
|
+
}
|
|
104
|
+
function hashPatterns(manifest, patterns) {
|
|
105
|
+
const result = {};
|
|
106
|
+
for (const pattern of patterns)
|
|
107
|
+
for (const file of manifest.files)
|
|
108
|
+
if (matchesRepoPattern(file.path, pattern))
|
|
109
|
+
result[file.path] = file.sha256;
|
|
110
|
+
return Object.fromEntries(Object.entries(result).sort(([a], [b]) => a.localeCompare(b)));
|
|
111
|
+
}
|
|
112
|
+
function same(left, right) {
|
|
113
|
+
return canonicalValueJson(left) === canonicalValueJson(right);
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertProtectedRepositoryFile(repositoryInput: string, fileInput: string, label: string): Promise<string>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { lstat, realpath } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export async function assertProtectedRepositoryFile(repositoryInput, fileInput, label) {
|
|
4
|
+
const repositoryPath = path.resolve(repositoryInput);
|
|
5
|
+
const repository = await realpath(repositoryPath);
|
|
6
|
+
const candidate = path.resolve(fileInput);
|
|
7
|
+
assertInside(repositoryPath, candidate, label, fileInput);
|
|
8
|
+
const info = await lstat(candidate).catch(() => null);
|
|
9
|
+
if (!info)
|
|
10
|
+
throw new Error(`protected_input_not_found:${label}:${display(fileInput)}`);
|
|
11
|
+
if (info.isSymbolicLink())
|
|
12
|
+
throw new Error(`protected_input_symlink_not_allowed:${label}:${display(fileInput)}`);
|
|
13
|
+
if (!info.isFile())
|
|
14
|
+
throw new Error(`protected_input_not_regular_file:${label}:${display(fileInput)}`);
|
|
15
|
+
const resolved = await realpath(candidate);
|
|
16
|
+
assertInside(repository, resolved, label, fileInput);
|
|
17
|
+
if (typeof info.nlink === "number" && info.nlink > 1)
|
|
18
|
+
throw new Error(`protected_input_hardlink_not_allowed:${label}:${display(fileInput)}`);
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
function assertInside(repository, candidate, label, original) {
|
|
22
|
+
const relative = path.relative(repository, candidate);
|
|
23
|
+
if (relative === ".." ||
|
|
24
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
25
|
+
path.isAbsolute(relative))
|
|
26
|
+
throw new Error(`protected_input_realpath_outside_repository:${label}:${display(original)}`);
|
|
27
|
+
}
|
|
28
|
+
function display(file) {
|
|
29
|
+
return file.replace(/\\/gu, "/");
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { array, fail, literal, PROOF_SURFACES, } from "./long-task-shape-primitives.js";
|
|
2
|
+
export function parseRequiredProofSurfaces(value, label) {
|
|
3
|
+
const surfaces = array(value, label).map((surface, index) => literal(surface, PROOF_SURFACES, `${label}[${index}]`));
|
|
4
|
+
if (!surfaces.length)
|
|
5
|
+
fail("required_proof_surfaces_empty", label);
|
|
6
|
+
const seen = new Set();
|
|
7
|
+
for (const surface of surfaces) {
|
|
8
|
+
if (seen.has(surface))
|
|
9
|
+
fail("required_proof_surface_duplicate", `${label}:${surface}`);
|
|
10
|
+
seen.add(surface);
|
|
11
|
+
}
|
|
12
|
+
return surfaces;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parseRequiredProofSurfaces } from "./long-task-required-proof-surfaces.js";
|
|
2
|
+
import { array, key, object, string } from "./long-task-shape-primitives.js";
|
|
3
|
+
export function parseRequirements(value, label) {
|
|
4
|
+
return array(value, label).map((item, index) => {
|
|
5
|
+
const itemLabel = `${label}[${index}]`;
|
|
6
|
+
const row = object(item, itemLabel, [
|
|
7
|
+
"key",
|
|
8
|
+
"statement",
|
|
9
|
+
"required_proof_surfaces",
|
|
10
|
+
]);
|
|
11
|
+
const surfaces = parseRequiredProofSurfaces(row.required_proof_surfaces, `${itemLabel}.required_proof_surfaces`);
|
|
12
|
+
return {
|
|
13
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
14
|
+
statement: string(row.statement, `${itemLabel}.statement`),
|
|
15
|
+
required_proof_surfaces: surfaces,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|