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,100 @@
|
|
|
1
|
+
import { parseCheck } from "./long-task-check-shape.js";
|
|
2
|
+
import { normalizeRepositoryFile } from "./long-task-paths.js";
|
|
3
|
+
import { parseRequirements } from "./long-task-requirement-shape.js";
|
|
4
|
+
import { array, key, literal, nullable, object, parseBindings, parseControls, parseCounterfactuals, parseKeyedStatements, parseObligations, parseOwner, parsePopulation, parseRollback, repositoryPatterns, string, strings, } from "./long-task-delivery-shape.js";
|
|
5
|
+
import { parseStrictYaml } from "./strict-codec.js";
|
|
6
|
+
export function parseOutcome(value, label) {
|
|
7
|
+
const row = object(value, label, ["key", "title", "product", "technical", "acceptance"], ["depends_on"]);
|
|
8
|
+
const product = object(row.product, `${label}.product`, ["observable_result", "owner"], ["requirements", "owner_surfaces", "controls", "non_completing_outcomes"]);
|
|
9
|
+
const technical = object(row.technical, `${label}.technical`, ["expected_change_paths"], [
|
|
10
|
+
"obligations",
|
|
11
|
+
"allowed_support_paths",
|
|
12
|
+
"forbidden_paths",
|
|
13
|
+
"forbidden_shortcuts",
|
|
14
|
+
"bindings",
|
|
15
|
+
"rollback_and_recovery",
|
|
16
|
+
]);
|
|
17
|
+
const acceptance = object(row.acceptance, `${label}.acceptance`, ["checks"], ["population", "counterfactual_controls"]);
|
|
18
|
+
return {
|
|
19
|
+
key: key(row.key, `${label}.key`),
|
|
20
|
+
title: string(row.title, `${label}.title`),
|
|
21
|
+
depends_on: Object.hasOwn(row, "depends_on")
|
|
22
|
+
? strings(row.depends_on, `${label}.depends_on`).map((item, index) => key(item, `${label}.depends_on[${index}]`))
|
|
23
|
+
: [],
|
|
24
|
+
product: {
|
|
25
|
+
observable_result: string(product.observable_result, `${label}.product.observable_result`),
|
|
26
|
+
owner: parseOwner(product.owner, `${label}.product.owner`),
|
|
27
|
+
requirements: Object.hasOwn(product, "requirements")
|
|
28
|
+
? parseRequirements(product.requirements, `${label}.product.requirements`)
|
|
29
|
+
: [],
|
|
30
|
+
owner_surfaces: Object.hasOwn(product, "owner_surfaces")
|
|
31
|
+
? strings(product.owner_surfaces, `${label}.product.owner_surfaces`)
|
|
32
|
+
: [],
|
|
33
|
+
controls: Object.hasOwn(product, "controls")
|
|
34
|
+
? parseControls(product.controls, `${label}.product.controls`)
|
|
35
|
+
: [],
|
|
36
|
+
non_completing_outcomes: Object.hasOwn(product, "non_completing_outcomes")
|
|
37
|
+
? parseKeyedStatements(product.non_completing_outcomes, `${label}.product.non_completing_outcomes`)
|
|
38
|
+
: [],
|
|
39
|
+
},
|
|
40
|
+
technical: {
|
|
41
|
+
obligations: Object.hasOwn(technical, "obligations")
|
|
42
|
+
? parseObligations(technical.obligations, `${label}.technical.obligations`)
|
|
43
|
+
: [],
|
|
44
|
+
expected_change_paths: repositoryPatterns(technical.expected_change_paths, `${label}.technical.expected_change_paths`),
|
|
45
|
+
allowed_support_paths: Object.hasOwn(technical, "allowed_support_paths")
|
|
46
|
+
? repositoryPatterns(technical.allowed_support_paths, `${label}.technical.allowed_support_paths`)
|
|
47
|
+
: [],
|
|
48
|
+
forbidden_paths: Object.hasOwn(technical, "forbidden_paths")
|
|
49
|
+
? repositoryPatterns(technical.forbidden_paths, `${label}.technical.forbidden_paths`)
|
|
50
|
+
: [],
|
|
51
|
+
forbidden_shortcuts: Object.hasOwn(technical, "forbidden_shortcuts")
|
|
52
|
+
? parseKeyedStatements(technical.forbidden_shortcuts, `${label}.technical.forbidden_shortcuts`)
|
|
53
|
+
: [],
|
|
54
|
+
bindings: Object.hasOwn(technical, "bindings")
|
|
55
|
+
? parseBindings(technical.bindings, `${label}.technical.bindings`)
|
|
56
|
+
: [],
|
|
57
|
+
rollback_and_recovery: Object.hasOwn(technical, "rollback_and_recovery")
|
|
58
|
+
? nullable(technical.rollback_and_recovery, (item) => parseRollback(item, `${label}.technical.rollback_and_recovery`))
|
|
59
|
+
: null,
|
|
60
|
+
},
|
|
61
|
+
acceptance: {
|
|
62
|
+
checks: array(acceptance.checks, `${label}.acceptance.checks`).map((item, index) => parseCheck(item, `${label}.acceptance.checks[${index}]`)),
|
|
63
|
+
population: Object.hasOwn(acceptance, "population")
|
|
64
|
+
? nullable(acceptance.population, (item) => parsePopulation(item, `${label}.acceptance.population`))
|
|
65
|
+
: null,
|
|
66
|
+
counterfactual_controls: Object.hasOwn(acceptance, "counterfactual_controls")
|
|
67
|
+
? parseCounterfactuals(acceptance.counterfactual_controls, `${label}.acceptance.counterfactual_controls`)
|
|
68
|
+
: [],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function parseOutcomeFragment(raw, relative) {
|
|
73
|
+
const value = parseStrictYaml(raw);
|
|
74
|
+
if (Array.isArray(value))
|
|
75
|
+
return value.map((item, index) => parseOutcome(item, `${relative}[${index}]`));
|
|
76
|
+
const row = object(value, relative, [], [
|
|
77
|
+
"schema_version",
|
|
78
|
+
"outcomes",
|
|
79
|
+
"key",
|
|
80
|
+
"title",
|
|
81
|
+
"depends_on",
|
|
82
|
+
"product",
|
|
83
|
+
"technical",
|
|
84
|
+
"acceptance",
|
|
85
|
+
]);
|
|
86
|
+
if (Object.hasOwn(row, "outcomes")) {
|
|
87
|
+
if (Object.keys(row).some((name) => !["schema_version", "outcomes"].includes(name)))
|
|
88
|
+
throw new Error(`delivery_contract_invalid:${relative}:fragment cannot mix root or Outcome keys`);
|
|
89
|
+
if (Object.hasOwn(row, "schema_version"))
|
|
90
|
+
literal(row.schema_version, ["long-task-outcomes-v2"], `${relative}.schema_version`);
|
|
91
|
+
return array(row.outcomes, `${relative}.outcomes`).map((item, index) => parseOutcome(item, `${relative}.outcomes[${index}]`));
|
|
92
|
+
}
|
|
93
|
+
return [parseOutcome(value, relative)];
|
|
94
|
+
}
|
|
95
|
+
export function safeFragmentPath(value, index) {
|
|
96
|
+
const normalized = normalizeRepositoryFile(value, `outcome_files[${index}]`);
|
|
97
|
+
if (!normalized.endsWith(".yaml"))
|
|
98
|
+
throw new Error(`unsafe_path:outcome_files[${index}]:${value}`);
|
|
99
|
+
return normalized;
|
|
100
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type PatternContainment = {
|
|
2
|
+
status: "proven_subset";
|
|
3
|
+
reason: string;
|
|
4
|
+
} | {
|
|
5
|
+
status: "not_subset";
|
|
6
|
+
reason: string;
|
|
7
|
+
} | {
|
|
8
|
+
status: "unknown";
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
export type PatternOverlap = {
|
|
12
|
+
status: "proven_overlap";
|
|
13
|
+
reason: string;
|
|
14
|
+
} | {
|
|
15
|
+
status: "proven_disjoint";
|
|
16
|
+
reason: string;
|
|
17
|
+
} | {
|
|
18
|
+
status: "unknown";
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
export interface RepositoryPatternAst {
|
|
22
|
+
normalized: string;
|
|
23
|
+
segments: RepositoryPatternSegmentAst[];
|
|
24
|
+
}
|
|
25
|
+
export type RepositoryPatternSegmentAst = {
|
|
26
|
+
kind: "recursive";
|
|
27
|
+
raw: "**";
|
|
28
|
+
} | {
|
|
29
|
+
kind: "segment";
|
|
30
|
+
raw: string;
|
|
31
|
+
tokens: RepositoryPatternTokenAst[];
|
|
32
|
+
};
|
|
33
|
+
export type RepositoryPatternTokenAst = {
|
|
34
|
+
kind: "literal";
|
|
35
|
+
value: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "star";
|
|
38
|
+
} | {
|
|
39
|
+
kind: "question";
|
|
40
|
+
};
|
|
41
|
+
export declare function parseRepositoryPattern(value: string, label?: string): RepositoryPatternAst;
|
|
42
|
+
export declare function normalizeRepositoryFile(value: string, label?: string): string;
|
|
43
|
+
export declare function normalizeRepositoryCwd(value: string, label?: string): string;
|
|
44
|
+
export declare function assertRepositoryPattern(repositoryRoot: string, value: string, label: string): string;
|
|
45
|
+
export declare function matchesRepoPattern(fileInput: string, patternInput: string): boolean;
|
|
46
|
+
export declare function proveRepositoryPatternSubset(candidateInput: string, ownerInput: string): PatternContainment;
|
|
47
|
+
export declare function classifyRepositoryPatternOverlap(leftInput: string, rightInput: string): PatternOverlap;
|
|
48
|
+
export declare function repositoryPatternsMayOverlap(left: string, right: string): boolean;
|
|
49
|
+
export declare function findScopeEscapes(changedPaths: string[], allowedPatterns: string[], forbiddenPatterns: string[]): string[];
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { resolveInsideRepository } from "./long-task-workspace.js";
|
|
3
|
+
export function parseRepositoryPattern(value, label = "repository_pattern") {
|
|
4
|
+
const normalized = canonicalRepositoryPath(value, label, "pattern");
|
|
5
|
+
if (/[\[\]{}()]/u.test(normalized))
|
|
6
|
+
throw new Error(`unsupported_repository_pattern_syntax:${label}:${value}`);
|
|
7
|
+
const segments = normalized.split("/").map((segment) => {
|
|
8
|
+
if (segment === "**")
|
|
9
|
+
return { kind: "recursive", raw: "**" };
|
|
10
|
+
if (segment.includes("**"))
|
|
11
|
+
throw new Error(`unsupported_repository_pattern_syntax:${label}:${value}`);
|
|
12
|
+
const tokens = [];
|
|
13
|
+
let literal = "";
|
|
14
|
+
const flush = () => {
|
|
15
|
+
if (!literal)
|
|
16
|
+
return;
|
|
17
|
+
tokens.push({ kind: "literal", value: literal });
|
|
18
|
+
literal = "";
|
|
19
|
+
};
|
|
20
|
+
for (const character of segment) {
|
|
21
|
+
if (character === "*") {
|
|
22
|
+
flush();
|
|
23
|
+
tokens.push({ kind: "star" });
|
|
24
|
+
}
|
|
25
|
+
else if (character === "?") {
|
|
26
|
+
flush();
|
|
27
|
+
tokens.push({ kind: "question" });
|
|
28
|
+
}
|
|
29
|
+
else
|
|
30
|
+
literal += character;
|
|
31
|
+
}
|
|
32
|
+
flush();
|
|
33
|
+
return { kind: "segment", raw: segment, tokens };
|
|
34
|
+
});
|
|
35
|
+
return { normalized, segments };
|
|
36
|
+
}
|
|
37
|
+
export function normalizeRepositoryFile(value, label = "repository_file") {
|
|
38
|
+
return canonicalRepositoryPath(value, label, "file");
|
|
39
|
+
}
|
|
40
|
+
export function normalizeRepositoryCwd(value, label = "runner.cwd") {
|
|
41
|
+
return canonicalRepositoryPath(value, label, "cwd");
|
|
42
|
+
}
|
|
43
|
+
export function assertRepositoryPattern(repositoryRoot, value, label) {
|
|
44
|
+
const pattern = parseRepositoryPattern(value, label);
|
|
45
|
+
const prefix = [];
|
|
46
|
+
for (const segment of pattern.segments) {
|
|
47
|
+
if (segment.kind === "recursive" ||
|
|
48
|
+
segment.tokens.some((token) => token.kind !== "literal"))
|
|
49
|
+
break;
|
|
50
|
+
prefix.push(segment.raw);
|
|
51
|
+
}
|
|
52
|
+
if (prefix.length)
|
|
53
|
+
resolveInsideRepository(repositoryRoot, prefix.join("/"), label);
|
|
54
|
+
return pattern.normalized;
|
|
55
|
+
}
|
|
56
|
+
export function matchesRepoPattern(fileInput, patternInput) {
|
|
57
|
+
const file = normalizeRepositoryFile(fileInput);
|
|
58
|
+
const pattern = parseRepositoryPattern(patternInput);
|
|
59
|
+
const fileSegments = file.split("/");
|
|
60
|
+
const memo = new Map();
|
|
61
|
+
const match = (patternIndex, fileIndex) => {
|
|
62
|
+
const key = `${patternIndex}:${fileIndex}`;
|
|
63
|
+
const cached = memo.get(key);
|
|
64
|
+
if (cached !== undefined)
|
|
65
|
+
return cached;
|
|
66
|
+
const segment = pattern.segments[patternIndex];
|
|
67
|
+
let result;
|
|
68
|
+
if (!segment)
|
|
69
|
+
result = fileIndex === fileSegments.length;
|
|
70
|
+
else if (segment.kind === "recursive")
|
|
71
|
+
result =
|
|
72
|
+
match(patternIndex + 1, fileIndex) ||
|
|
73
|
+
(fileIndex < fileSegments.length && match(patternIndex, fileIndex + 1));
|
|
74
|
+
else
|
|
75
|
+
result =
|
|
76
|
+
fileIndex < fileSegments.length &&
|
|
77
|
+
segmentMatches(fileSegments[fileIndex], segment) &&
|
|
78
|
+
match(patternIndex + 1, fileIndex + 1);
|
|
79
|
+
memo.set(key, result);
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
return match(0, 0);
|
|
83
|
+
}
|
|
84
|
+
export function proveRepositoryPatternSubset(candidateInput, ownerInput) {
|
|
85
|
+
const candidate = parseRepositoryPattern(candidateInput, "candidate");
|
|
86
|
+
const owner = parseRepositoryPattern(ownerInput, "owner");
|
|
87
|
+
if (candidate.normalized === owner.normalized)
|
|
88
|
+
return { status: "proven_subset", reason: "patterns_are_equal" };
|
|
89
|
+
if (isGlobalRecursive(owner))
|
|
90
|
+
return {
|
|
91
|
+
status: "proven_subset",
|
|
92
|
+
reason: "owner_is_global_recursive_pattern",
|
|
93
|
+
};
|
|
94
|
+
if (isExactPattern(candidate))
|
|
95
|
+
return matchesAst(candidate.normalized, owner)
|
|
96
|
+
? {
|
|
97
|
+
status: "proven_subset",
|
|
98
|
+
reason: "exact_candidate_matches_owner_pattern",
|
|
99
|
+
}
|
|
100
|
+
: {
|
|
101
|
+
status: "not_subset",
|
|
102
|
+
reason: "exact_candidate_does_not_match_owner_pattern",
|
|
103
|
+
};
|
|
104
|
+
const ownerRecursiveTail = recursiveTailPrefix(owner);
|
|
105
|
+
if (ownerRecursiveTail) {
|
|
106
|
+
const candidatePrefix = requiredLeadingSegments(candidate);
|
|
107
|
+
if (candidatePrefix.length < ownerRecursiveTail.length)
|
|
108
|
+
return {
|
|
109
|
+
status: "unknown",
|
|
110
|
+
reason: "candidate_may_match_before_owner_recursive_prefix",
|
|
111
|
+
};
|
|
112
|
+
for (let index = 0; index < ownerRecursiveTail.length; index += 1) {
|
|
113
|
+
const relation = segmentSubset(candidatePrefix[index], ownerRecursiveTail[index]);
|
|
114
|
+
if (relation.status === "not_subset")
|
|
115
|
+
return {
|
|
116
|
+
status: "not_subset",
|
|
117
|
+
reason: "candidate_prefix_is_not_within_owner_recursive_prefix",
|
|
118
|
+
};
|
|
119
|
+
if (relation.status === "unknown")
|
|
120
|
+
return {
|
|
121
|
+
status: "unknown",
|
|
122
|
+
reason: "candidate_prefix_containment_is_unknown",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
status: "proven_subset",
|
|
127
|
+
reason: "candidate_is_within_owner_recursive_subtree",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const candidateRecursive = candidate.segments.some((segment) => segment.kind === "recursive");
|
|
131
|
+
const ownerRecursive = owner.segments.some((segment) => segment.kind === "recursive");
|
|
132
|
+
if (candidateRecursive && !ownerRecursive)
|
|
133
|
+
return owner.segments.some((segment) => segment.kind === "segment" &&
|
|
134
|
+
segment.tokens.some((token) => token.kind === "question"))
|
|
135
|
+
? {
|
|
136
|
+
status: "unknown",
|
|
137
|
+
reason: "recursive_candidate_vs_question_owner_not_proven",
|
|
138
|
+
}
|
|
139
|
+
: {
|
|
140
|
+
status: "not_subset",
|
|
141
|
+
reason: "recursive_candidate_exceeds_non_recursive_owner",
|
|
142
|
+
};
|
|
143
|
+
if (candidateRecursive || ownerRecursive)
|
|
144
|
+
return {
|
|
145
|
+
status: "unknown",
|
|
146
|
+
reason: "recursive_pattern_relation_not_proven",
|
|
147
|
+
};
|
|
148
|
+
if (candidate.segments.length !== owner.segments.length)
|
|
149
|
+
return {
|
|
150
|
+
status: "not_subset",
|
|
151
|
+
reason: "candidate_and_owner_match_different_path_depths",
|
|
152
|
+
};
|
|
153
|
+
let unknown = false;
|
|
154
|
+
for (let index = 0; index < owner.segments.length; index += 1) {
|
|
155
|
+
const relation = segmentSubset(candidate.segments[index], owner.segments[index]);
|
|
156
|
+
if (relation.status === "not_subset")
|
|
157
|
+
return {
|
|
158
|
+
status: "not_subset",
|
|
159
|
+
reason: "candidate_segment_language_exceeds_owner_segment",
|
|
160
|
+
};
|
|
161
|
+
if (relation.status === "unknown")
|
|
162
|
+
unknown = true;
|
|
163
|
+
}
|
|
164
|
+
return unknown
|
|
165
|
+
? {
|
|
166
|
+
status: "unknown",
|
|
167
|
+
reason: "segment_language_containment_not_proven",
|
|
168
|
+
}
|
|
169
|
+
: {
|
|
170
|
+
status: "proven_subset",
|
|
171
|
+
reason: "segment_languages_are_contained",
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function classifyRepositoryPatternOverlap(leftInput, rightInput) {
|
|
175
|
+
const left = parseRepositoryPattern(leftInput, "left");
|
|
176
|
+
const right = parseRepositoryPattern(rightInput, "right");
|
|
177
|
+
const queue = [
|
|
178
|
+
{ left: 0, right: 0, unknown: false },
|
|
179
|
+
];
|
|
180
|
+
const visited = new Set();
|
|
181
|
+
let unknownAcceptance = false;
|
|
182
|
+
while (queue.length) {
|
|
183
|
+
const state = queue.shift();
|
|
184
|
+
const key = `${state.left}:${state.right}:${state.unknown ? 1 : 0}`;
|
|
185
|
+
if (visited.has(key))
|
|
186
|
+
continue;
|
|
187
|
+
visited.add(key);
|
|
188
|
+
if (state.left === left.segments.length &&
|
|
189
|
+
state.right === right.segments.length) {
|
|
190
|
+
if (!state.unknown)
|
|
191
|
+
return {
|
|
192
|
+
status: "proven_overlap",
|
|
193
|
+
reason: "pattern_languages_have_a_proven_common_path",
|
|
194
|
+
};
|
|
195
|
+
unknownAcceptance = true;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const leftSegment = left.segments[state.left];
|
|
199
|
+
const rightSegment = right.segments[state.right];
|
|
200
|
+
if (leftSegment?.kind === "recursive")
|
|
201
|
+
queue.push({
|
|
202
|
+
left: state.left + 1,
|
|
203
|
+
right: state.right,
|
|
204
|
+
unknown: state.unknown,
|
|
205
|
+
});
|
|
206
|
+
if (rightSegment?.kind === "recursive")
|
|
207
|
+
queue.push({
|
|
208
|
+
left: state.left,
|
|
209
|
+
right: state.right + 1,
|
|
210
|
+
unknown: state.unknown,
|
|
211
|
+
});
|
|
212
|
+
if (!leftSegment || !rightSegment)
|
|
213
|
+
continue;
|
|
214
|
+
if (leftSegment.kind === "recursive" && rightSegment.kind === "recursive")
|
|
215
|
+
continue;
|
|
216
|
+
if (leftSegment.kind === "recursive") {
|
|
217
|
+
queue.push({
|
|
218
|
+
left: state.left,
|
|
219
|
+
right: state.right + 1,
|
|
220
|
+
unknown: state.unknown,
|
|
221
|
+
});
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (rightSegment.kind === "recursive") {
|
|
225
|
+
queue.push({
|
|
226
|
+
left: state.left + 1,
|
|
227
|
+
right: state.right,
|
|
228
|
+
unknown: state.unknown,
|
|
229
|
+
});
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const overlap = segmentOverlap(leftSegment, rightSegment);
|
|
233
|
+
if (overlap.status !== "proven_disjoint")
|
|
234
|
+
queue.push({
|
|
235
|
+
left: state.left + 1,
|
|
236
|
+
right: state.right + 1,
|
|
237
|
+
unknown: state.unknown || overlap.status === "unknown",
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return unknownAcceptance
|
|
241
|
+
? {
|
|
242
|
+
status: "unknown",
|
|
243
|
+
reason: "pattern_overlap_depends_on_unproven_segment_relation",
|
|
244
|
+
}
|
|
245
|
+
: {
|
|
246
|
+
status: "proven_disjoint",
|
|
247
|
+
reason: "pattern_languages_have_no_common_path",
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export function repositoryPatternsMayOverlap(left, right) {
|
|
251
|
+
return (classifyRepositoryPatternOverlap(left, right).status !== "proven_disjoint");
|
|
252
|
+
}
|
|
253
|
+
export function findScopeEscapes(changedPaths, allowedPatterns, forbiddenPatterns) {
|
|
254
|
+
return changedPaths.filter((file) => forbiddenPatterns.some((pattern) => matchesRepoPattern(file, pattern)) ||
|
|
255
|
+
!allowedPatterns.some((pattern) => matchesRepoPattern(file, pattern)));
|
|
256
|
+
}
|
|
257
|
+
function segmentSubset(candidate, owner) {
|
|
258
|
+
if (candidate.raw === owner.raw)
|
|
259
|
+
return { status: "proven_subset" };
|
|
260
|
+
if (isUniversalSegment(owner))
|
|
261
|
+
return { status: "proven_subset" };
|
|
262
|
+
if (isLiteralSegment(candidate))
|
|
263
|
+
return segmentMatches(candidate.raw, owner)
|
|
264
|
+
? { status: "proven_subset" }
|
|
265
|
+
: { status: "not_subset" };
|
|
266
|
+
if (isLiteralSegment(owner) || isUniversalSegment(candidate))
|
|
267
|
+
return { status: "not_subset" };
|
|
268
|
+
const candidateSuffix = simpleSuffix(candidate);
|
|
269
|
+
const ownerSuffix = simpleSuffix(owner);
|
|
270
|
+
if (candidateSuffix !== null && ownerSuffix !== null)
|
|
271
|
+
return candidateSuffix.endsWith(ownerSuffix)
|
|
272
|
+
? { status: "proven_subset" }
|
|
273
|
+
: { status: "not_subset" };
|
|
274
|
+
return { status: "unknown" };
|
|
275
|
+
}
|
|
276
|
+
function segmentOverlap(left, right) {
|
|
277
|
+
if (left.raw === right.raw)
|
|
278
|
+
return { status: "proven_overlap", reason: "segments_are_equal" };
|
|
279
|
+
if (isLiteralSegment(left))
|
|
280
|
+
return segmentMatches(left.raw, right)
|
|
281
|
+
? { status: "proven_overlap", reason: "left_literal_matches_right" }
|
|
282
|
+
: { status: "proven_disjoint", reason: "left_literal_rejected" };
|
|
283
|
+
if (isLiteralSegment(right))
|
|
284
|
+
return segmentMatches(right.raw, left)
|
|
285
|
+
? { status: "proven_overlap", reason: "right_literal_matches_left" }
|
|
286
|
+
: { status: "proven_disjoint", reason: "right_literal_rejected" };
|
|
287
|
+
if (isUniversalSegment(left) || isUniversalSegment(right))
|
|
288
|
+
return {
|
|
289
|
+
status: "proven_overlap",
|
|
290
|
+
reason: "universal_segment_has_nonempty_intersection",
|
|
291
|
+
};
|
|
292
|
+
const leftSuffix = simpleSuffix(left);
|
|
293
|
+
const rightSuffix = simpleSuffix(right);
|
|
294
|
+
if (leftSuffix !== null && rightSuffix !== null)
|
|
295
|
+
return leftSuffix.endsWith(rightSuffix) || rightSuffix.endsWith(leftSuffix)
|
|
296
|
+
? {
|
|
297
|
+
status: "proven_overlap",
|
|
298
|
+
reason: "suffix_languages_have_a_common_value",
|
|
299
|
+
}
|
|
300
|
+
: {
|
|
301
|
+
status: "proven_disjoint",
|
|
302
|
+
reason: "suffix_languages_are_disjoint",
|
|
303
|
+
};
|
|
304
|
+
const leftFixed = fixedWidthTokens(left);
|
|
305
|
+
const rightFixed = fixedWidthTokens(right);
|
|
306
|
+
if (leftFixed && rightFixed) {
|
|
307
|
+
if (leftFixed.length !== rightFixed.length)
|
|
308
|
+
return {
|
|
309
|
+
status: "proven_disjoint",
|
|
310
|
+
reason: "fixed_width_segments_have_different_lengths",
|
|
311
|
+
};
|
|
312
|
+
for (let index = 0; index < leftFixed.length; index += 1)
|
|
313
|
+
if (leftFixed[index] !== null &&
|
|
314
|
+
rightFixed[index] !== null &&
|
|
315
|
+
leftFixed[index] !== rightFixed[index])
|
|
316
|
+
return {
|
|
317
|
+
status: "proven_disjoint",
|
|
318
|
+
reason: "fixed_width_literal_positions_conflict",
|
|
319
|
+
};
|
|
320
|
+
return {
|
|
321
|
+
status: "proven_overlap",
|
|
322
|
+
reason: "fixed_width_segments_have_a_common_value",
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
status: "unknown",
|
|
327
|
+
reason: "segment_overlap_not_proven",
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function matchesAst(file, pattern) {
|
|
331
|
+
return matchesRepoPattern(file, pattern.normalized);
|
|
332
|
+
}
|
|
333
|
+
function segmentMatches(fileSegment, pattern) {
|
|
334
|
+
return segmentExpression(pattern).test(fileSegment);
|
|
335
|
+
}
|
|
336
|
+
function segmentExpression(pattern) {
|
|
337
|
+
const expression = pattern.tokens
|
|
338
|
+
.map((token) => {
|
|
339
|
+
if (token.kind === "star")
|
|
340
|
+
return ".*";
|
|
341
|
+
if (token.kind === "question")
|
|
342
|
+
return ".";
|
|
343
|
+
return escapeRegex(token.value);
|
|
344
|
+
})
|
|
345
|
+
.join("");
|
|
346
|
+
return new RegExp(`^${expression}$`, "u");
|
|
347
|
+
}
|
|
348
|
+
function isExactPattern(pattern) {
|
|
349
|
+
return pattern.segments.every((segment) => segment.kind === "segment" && isLiteralSegment(segment));
|
|
350
|
+
}
|
|
351
|
+
function isGlobalRecursive(pattern) {
|
|
352
|
+
return (pattern.segments.length === 1 && pattern.segments[0].kind === "recursive");
|
|
353
|
+
}
|
|
354
|
+
function recursiveTailPrefix(pattern) {
|
|
355
|
+
if (pattern.segments.at(-1)?.kind !== "recursive" ||
|
|
356
|
+
pattern.segments
|
|
357
|
+
.slice(0, -1)
|
|
358
|
+
.some((segment) => segment.kind === "recursive"))
|
|
359
|
+
return null;
|
|
360
|
+
return pattern.segments.slice(0, -1);
|
|
361
|
+
}
|
|
362
|
+
function requiredLeadingSegments(pattern) {
|
|
363
|
+
const result = [];
|
|
364
|
+
for (const segment of pattern.segments) {
|
|
365
|
+
if (segment.kind === "recursive")
|
|
366
|
+
break;
|
|
367
|
+
result.push(segment);
|
|
368
|
+
}
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
function isLiteralSegment(segment) {
|
|
372
|
+
return segment.tokens.every((token) => token.kind === "literal");
|
|
373
|
+
}
|
|
374
|
+
function isUniversalSegment(segment) {
|
|
375
|
+
return segment.tokens.length === 1 && segment.tokens[0].kind === "star";
|
|
376
|
+
}
|
|
377
|
+
function simpleSuffix(segment) {
|
|
378
|
+
if (segment.tokens.length !== 2 ||
|
|
379
|
+
segment.tokens[0].kind !== "star" ||
|
|
380
|
+
segment.tokens[1].kind !== "literal")
|
|
381
|
+
return null;
|
|
382
|
+
return segment.tokens[1].value;
|
|
383
|
+
}
|
|
384
|
+
function fixedWidthTokens(segment) {
|
|
385
|
+
if (segment.tokens.some((token) => token.kind === "star"))
|
|
386
|
+
return null;
|
|
387
|
+
return segment.tokens.flatMap((token) => token.kind === "question"
|
|
388
|
+
? [null]
|
|
389
|
+
: token.kind === "literal"
|
|
390
|
+
? [...token.value].map((character) => character)
|
|
391
|
+
: []);
|
|
392
|
+
}
|
|
393
|
+
function canonicalRepositoryPath(value, label, kind) {
|
|
394
|
+
if (/[\0\r\n\t]/u.test(value))
|
|
395
|
+
throw new Error(`unsafe_path:${label}:control_character`);
|
|
396
|
+
const slashed = value.replace(/\\/gu, "/");
|
|
397
|
+
if (kind === "cwd" && slashed === ".")
|
|
398
|
+
return ".";
|
|
399
|
+
const normalized = slashed.startsWith("./") ? slashed.slice(2) : slashed;
|
|
400
|
+
if (!normalized ||
|
|
401
|
+
path.posix.isAbsolute(normalized) ||
|
|
402
|
+
normalized.startsWith("//") ||
|
|
403
|
+
/^[A-Za-z]:/u.test(normalized))
|
|
404
|
+
throw new Error(`unsafe_path:${label}:${value}`);
|
|
405
|
+
const segments = normalized.split("/");
|
|
406
|
+
if (segments.some((segment) => !segment))
|
|
407
|
+
throw new Error(`unsafe_path:${label}:${value}`);
|
|
408
|
+
if (segments.includes("."))
|
|
409
|
+
throw new Error(`non_canonical_repository_path_dot_segment:${label}:${value}`);
|
|
410
|
+
if (segments.includes(".."))
|
|
411
|
+
throw new Error(`unsafe_path:${label}:${value}`);
|
|
412
|
+
if (kind !== "pattern" && /[*?\[\]{}()]/u.test(normalized))
|
|
413
|
+
throw new Error(`unsupported_repository_path_syntax:${label}:${value}`);
|
|
414
|
+
return normalized;
|
|
415
|
+
}
|
|
416
|
+
function escapeRegex(value) {
|
|
417
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
418
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CheckExecutionResultV2, CounterfactualControlV2, GlobalCounterfactualControlV2, RawCommandExecutionV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface PlaywrightCounterfactualClassification {
|
|
3
|
+
accepted_test_failure_exit: boolean;
|
|
4
|
+
normalized_result: CheckExecutionResultV2;
|
|
5
|
+
rejection_reasons: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function classifyPlaywrightCounterfactual(raw: RawCommandExecutionV2, result: CheckExecutionResultV2, control: CounterfactualControlV2 | GlobalCounterfactualControlV2): PlaywrightCounterfactualClassification;
|