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,203 @@
|
|
|
1
|
+
import type { LongTaskRiskFacts, RequestedRiskLevel } from "./long-task-risk-types.js";
|
|
2
|
+
import type { CounterfactualControlV2, GlobalCounterfactualControlV2 } from "./long-task-counterfactual-types.js";
|
|
3
|
+
export type SourceClaimDispositionV2 = {
|
|
4
|
+
type: "claim";
|
|
5
|
+
refs: string[];
|
|
6
|
+
} | {
|
|
7
|
+
type: "acceptance";
|
|
8
|
+
refs: [string];
|
|
9
|
+
} | {
|
|
10
|
+
type: "outcome_result";
|
|
11
|
+
ref: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "global_constraint";
|
|
14
|
+
refs: string[];
|
|
15
|
+
} | {
|
|
16
|
+
type: "risk_fact";
|
|
17
|
+
refs: string[];
|
|
18
|
+
} | {
|
|
19
|
+
type: "external_confirmation";
|
|
20
|
+
refs: string[];
|
|
21
|
+
} | {
|
|
22
|
+
type: "decision_required";
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
|
25
|
+
export interface SourceClaimV2 {
|
|
26
|
+
key: string;
|
|
27
|
+
source_ref: string;
|
|
28
|
+
statement: string;
|
|
29
|
+
disposition: SourceClaimDispositionV2;
|
|
30
|
+
}
|
|
31
|
+
export interface KeyedStatementV2 {
|
|
32
|
+
key: string;
|
|
33
|
+
statement: string;
|
|
34
|
+
}
|
|
35
|
+
export interface KeyedPathV2 {
|
|
36
|
+
key: string;
|
|
37
|
+
path: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ExternalConfirmationV2 {
|
|
40
|
+
key: string;
|
|
41
|
+
description: string;
|
|
42
|
+
owner: string;
|
|
43
|
+
}
|
|
44
|
+
export type ProofSurface = "ui_browser" | "runtime_behavior" | "api_contract" | "data_state" | "security_boundary" | "population_coverage" | "implementation_structure";
|
|
45
|
+
export type RunnerType = "package_script" | "project_binary" | "node_oracle" | "playwright_test";
|
|
46
|
+
export type PresenceOrUnaryAssertionOperator = "exists" | "truthy" | "falsy";
|
|
47
|
+
export type BinaryAssertionOperator = "equals" | "not_equals" | "contains" | "not_contains" | "matches" | "not_matches" | "greater_than" | "greater_or_equal" | "less_than" | "less_or_equal" | "set_equals" | "subset_of" | "superset_of";
|
|
48
|
+
export type AssertionOperator = PresenceOrUnaryAssertionOperator | BinaryAssertionOperator;
|
|
49
|
+
interface DeliveryAssertionBaseV2 {
|
|
50
|
+
key: string;
|
|
51
|
+
criterion?: string;
|
|
52
|
+
claims: string[];
|
|
53
|
+
observation: string;
|
|
54
|
+
}
|
|
55
|
+
export type DeliveryAssertionV2 = (DeliveryAssertionBaseV2 & {
|
|
56
|
+
operator: PresenceOrUnaryAssertionOperator;
|
|
57
|
+
expected?: never;
|
|
58
|
+
}) | (DeliveryAssertionBaseV2 & {
|
|
59
|
+
operator: BinaryAssertionOperator;
|
|
60
|
+
expected: unknown;
|
|
61
|
+
});
|
|
62
|
+
export interface DeliveryRunnerV2 {
|
|
63
|
+
type: RunnerType;
|
|
64
|
+
target: string;
|
|
65
|
+
argv: string[];
|
|
66
|
+
cwd: string;
|
|
67
|
+
timeout_ms: number;
|
|
68
|
+
effect: "read_only" | "test_sandbox";
|
|
69
|
+
retry_policy: "none" | "transient_once";
|
|
70
|
+
idempotent: boolean;
|
|
71
|
+
}
|
|
72
|
+
export type EnvironmentRequirementV2 = {
|
|
73
|
+
key: string;
|
|
74
|
+
kind: "executable" | "env_var";
|
|
75
|
+
target: string;
|
|
76
|
+
} | {
|
|
77
|
+
key: string;
|
|
78
|
+
kind: "file" | "directory";
|
|
79
|
+
target: string;
|
|
80
|
+
} | {
|
|
81
|
+
key: string;
|
|
82
|
+
kind: "loopback_tcp";
|
|
83
|
+
host: "127.0.0.1" | "::1" | "localhost";
|
|
84
|
+
port: number;
|
|
85
|
+
timeout_ms: number;
|
|
86
|
+
};
|
|
87
|
+
export interface DeliveryCheckV2 {
|
|
88
|
+
key: string;
|
|
89
|
+
proof_surface: ProofSurface;
|
|
90
|
+
runner: DeliveryRunnerV2;
|
|
91
|
+
verification_inputs: string[];
|
|
92
|
+
input_paths: string[];
|
|
93
|
+
expected_output_paths: string[];
|
|
94
|
+
artifact_globs: string[];
|
|
95
|
+
positive_assertions: DeliveryAssertionV2[];
|
|
96
|
+
negative_assertions: DeliveryAssertionV2[];
|
|
97
|
+
environment_requirements: EnvironmentRequirementV2[];
|
|
98
|
+
}
|
|
99
|
+
export interface DeliveryControlV2 {
|
|
100
|
+
key: string;
|
|
101
|
+
location: string;
|
|
102
|
+
trigger: string;
|
|
103
|
+
input: string;
|
|
104
|
+
loading_state: string;
|
|
105
|
+
empty_state: string;
|
|
106
|
+
success_state: string;
|
|
107
|
+
failure_state: string;
|
|
108
|
+
feedback: string;
|
|
109
|
+
}
|
|
110
|
+
interface DeliveryRequirementV2 extends KeyedStatementV2 {
|
|
111
|
+
required_proof_surfaces: ProofSurface[];
|
|
112
|
+
}
|
|
113
|
+
export interface DeliveryOwnerV2 {
|
|
114
|
+
label: string;
|
|
115
|
+
context_refs: string[];
|
|
116
|
+
path_globs: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface DeliveryObligationV2 extends KeyedStatementV2 {
|
|
119
|
+
required_proof_surfaces: ProofSurface[];
|
|
120
|
+
}
|
|
121
|
+
export interface DeliveryBindingV2 {
|
|
122
|
+
key: string;
|
|
123
|
+
kind: "path_glob" | "file" | "verified";
|
|
124
|
+
target: string;
|
|
125
|
+
carrier_paths: string[];
|
|
126
|
+
existence: "existing" | "planned";
|
|
127
|
+
verification_check_key?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface RollbackRecoveryV2 {
|
|
130
|
+
rollback: string;
|
|
131
|
+
recovery: string;
|
|
132
|
+
verification_check_keys: string[];
|
|
133
|
+
}
|
|
134
|
+
export interface PopulationRequirementV2 {
|
|
135
|
+
check_key: string;
|
|
136
|
+
claims: string[];
|
|
137
|
+
observations: {
|
|
138
|
+
eligible_ids: string;
|
|
139
|
+
observed_ids: string;
|
|
140
|
+
excluded_items: string;
|
|
141
|
+
};
|
|
142
|
+
exclusion_rules: KeyedStatementV2[];
|
|
143
|
+
}
|
|
144
|
+
export interface DeliveryOutcomeV2 {
|
|
145
|
+
key: string;
|
|
146
|
+
title: string;
|
|
147
|
+
depends_on: string[];
|
|
148
|
+
product: {
|
|
149
|
+
observable_result: string;
|
|
150
|
+
owner: DeliveryOwnerV2;
|
|
151
|
+
requirements: DeliveryRequirementV2[];
|
|
152
|
+
owner_surfaces: string[];
|
|
153
|
+
controls: DeliveryControlV2[];
|
|
154
|
+
non_completing_outcomes: KeyedStatementV2[];
|
|
155
|
+
};
|
|
156
|
+
technical: {
|
|
157
|
+
obligations: DeliveryObligationV2[];
|
|
158
|
+
expected_change_paths: string[];
|
|
159
|
+
allowed_support_paths: string[];
|
|
160
|
+
forbidden_paths: string[];
|
|
161
|
+
bindings: DeliveryBindingV2[];
|
|
162
|
+
forbidden_shortcuts: KeyedStatementV2[];
|
|
163
|
+
rollback_and_recovery: RollbackRecoveryV2 | null;
|
|
164
|
+
};
|
|
165
|
+
acceptance: {
|
|
166
|
+
checks: DeliveryCheckV2[];
|
|
167
|
+
population: PopulationRequirementV2 | null;
|
|
168
|
+
counterfactual_controls: CounterfactualControlV2[];
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export interface DeliveryContractV2 {
|
|
172
|
+
schema_version: "long-task-delivery-v2";
|
|
173
|
+
task: {
|
|
174
|
+
id: string;
|
|
175
|
+
title: string;
|
|
176
|
+
goal: string;
|
|
177
|
+
source_paths: string[];
|
|
178
|
+
context_refs: string[];
|
|
179
|
+
context_snapshot_mode: "referenced" | "full";
|
|
180
|
+
};
|
|
181
|
+
source_claims: SourceClaimV2[];
|
|
182
|
+
risk: {
|
|
183
|
+
requested_level: RequestedRiskLevel;
|
|
184
|
+
facts: LongTaskRiskFacts;
|
|
185
|
+
};
|
|
186
|
+
global: {
|
|
187
|
+
product: {
|
|
188
|
+
non_goals: KeyedStatementV2[];
|
|
189
|
+
};
|
|
190
|
+
technical: {
|
|
191
|
+
constraints: KeyedStatementV2[];
|
|
192
|
+
forbidden_paths: KeyedPathV2[];
|
|
193
|
+
forbidden_shortcuts: KeyedStatementV2[];
|
|
194
|
+
};
|
|
195
|
+
acceptance: {
|
|
196
|
+
checks: DeliveryCheckV2[];
|
|
197
|
+
counterfactual_controls: GlobalCounterfactualControlV2[];
|
|
198
|
+
external_confirmations: ExternalConfirmationV2[];
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
outcomes: DeliveryOutcomeV2[];
|
|
202
|
+
}
|
|
203
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CounterfactualControlV2, DeliveryContractV2, DeliveryBindingV2, DeliveryOutcomeV2, GlobalCounterfactualControlV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function validateCounterfactualBindingClaims(outcome: DeliveryOutcomeV2, control: CounterfactualControlV2, binding: DeliveryBindingV2): void;
|
|
3
|
+
export declare function resolveGlobalCounterfactualBinding(contract: DeliveryContractV2, control: GlobalCounterfactualControlV2): {
|
|
4
|
+
outcome: DeliveryOutcomeV2;
|
|
5
|
+
binding: DeliveryBindingV2;
|
|
6
|
+
};
|
|
7
|
+
export declare function validateGlobalCounterfactualBindingClaims(contract: DeliveryContractV2, control: GlobalCounterfactualControlV2): {
|
|
8
|
+
outcome: DeliveryOutcomeV2;
|
|
9
|
+
binding: DeliveryBindingV2;
|
|
10
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export function validateCounterfactualBindingClaims(outcome, control, binding) {
|
|
2
|
+
if (binding.verification_check_key &&
|
|
3
|
+
binding.verification_check_key !== control.check_key)
|
|
4
|
+
throw new Error(`counterfactual_binding_check_mismatch:${outcome.key}:${control.key}:${binding.key}:${control.check_key}`);
|
|
5
|
+
const check = outcome.acceptance.checks.find((item) => item.key === control.check_key);
|
|
6
|
+
if (!check)
|
|
7
|
+
throw new Error(`counterfactual_check_unknown:${outcome.key}:${control.key}:${control.check_key}`);
|
|
8
|
+
validateExpectedAssertions(control, check, `counterfactual_assertion_unknown:${outcome.key}:${control.key}`);
|
|
9
|
+
const expectedAssertions = new Set(control.expected_assertion_failures);
|
|
10
|
+
const expectedClaims = new Set([
|
|
11
|
+
...(check?.positive_assertions ?? []),
|
|
12
|
+
...(check?.negative_assertions ?? []),
|
|
13
|
+
]
|
|
14
|
+
.filter((assertion) => expectedAssertions.has(assertion.key))
|
|
15
|
+
.flatMap((assertion) => assertion.claims));
|
|
16
|
+
if (control.claims.some((claim) => !expectedClaims.has(claim)))
|
|
17
|
+
throw new Error(`counterfactual_binding_claim_unrelated:${outcome.key}:${control.key}`);
|
|
18
|
+
}
|
|
19
|
+
export function resolveGlobalCounterfactualBinding(contract, control) {
|
|
20
|
+
const [outcomeKey, bindingKey] = control.binding_ref.split(".");
|
|
21
|
+
const outcome = contract.outcomes.find((item) => item.key === outcomeKey);
|
|
22
|
+
if (!outcome)
|
|
23
|
+
throw new Error(`global_counterfactual_binding_ref_invalid:${control.key}:${control.binding_ref}`);
|
|
24
|
+
const binding = outcome.technical.bindings.find((item) => item.key === bindingKey);
|
|
25
|
+
if (!binding)
|
|
26
|
+
throw new Error(`global_counterfactual_binding_unknown:${control.key}:${control.binding_ref}`);
|
|
27
|
+
return { outcome, binding };
|
|
28
|
+
}
|
|
29
|
+
export function validateGlobalCounterfactualBindingClaims(contract, control) {
|
|
30
|
+
const resolved = resolveGlobalCounterfactualBinding(contract, control);
|
|
31
|
+
const check = contract.global.acceptance.checks.find((item) => item.key === control.check_key);
|
|
32
|
+
if (!check)
|
|
33
|
+
throw new Error(`global_counterfactual_check_unknown:${control.key}:${control.check_key}`);
|
|
34
|
+
validateExpectedAssertions(control, check, `global_counterfactual_assertion_unknown:${control.key}`);
|
|
35
|
+
const allowedClaims = new Set([
|
|
36
|
+
...contract.global.product.non_goals.map((item) => `non_goal.${item.key}`),
|
|
37
|
+
...contract.global.technical.constraints.map((item) => `constraint.${item.key}`),
|
|
38
|
+
...contract.global.technical.forbidden_shortcuts.map((item) => `forbidden_shortcut.${item.key}`),
|
|
39
|
+
]);
|
|
40
|
+
if (control.claims.some((claim) => !allowedClaims.has(claim)))
|
|
41
|
+
throw new Error(`global_counterfactual_claim_invalid:${control.key}:${control.claims.filter((claim) => !allowedClaims.has(claim)).join(",")}`);
|
|
42
|
+
const expectedAssertions = new Set(control.expected_assertion_failures);
|
|
43
|
+
const expectedClaims = new Set([...check.positive_assertions, ...check.negative_assertions]
|
|
44
|
+
.filter((assertion) => expectedAssertions.has(assertion.key))
|
|
45
|
+
.flatMap((assertion) => assertion.claims));
|
|
46
|
+
if (control.claims.some((claim) => !expectedClaims.has(claim)))
|
|
47
|
+
throw new Error(`global_counterfactual_claim_unrelated:${control.key}`);
|
|
48
|
+
return resolved;
|
|
49
|
+
}
|
|
50
|
+
function validateExpectedAssertions(control, check, unknownPrefix) {
|
|
51
|
+
if (!control.expected_assertion_failures.length)
|
|
52
|
+
throw new Error(`${unknownPrefix}:required`);
|
|
53
|
+
const assertions = new Set([...check.positive_assertions, ...check.negative_assertions].map((assertion) => assertion.key));
|
|
54
|
+
for (const key of control.expected_assertion_failures)
|
|
55
|
+
if (!assertions.has(key))
|
|
56
|
+
throw new Error(`${unknownPrefix}:${key}`);
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CompiledCheckV2, CounterfactualControlV2, GlobalCounterfactualControlV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface CounterfactualSandboxV2 {
|
|
3
|
+
root: string;
|
|
4
|
+
dispose(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createCounterfactualSandbox(snapshotRoot: string, check: CompiledCheckV2, control: CounterfactualControlV2 | GlobalCounterfactualControlV2, bindingCarrierPaths: string[], manifest?: WorkspaceManifestV2): Promise<CounterfactualSandboxV2>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { copyFile, cp, lstat, mkdir, mkdtemp, readlink, realpath, rm, symlink, } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { matchesRepoPattern } from "./long-task-paths.js";
|
|
5
|
+
export async function createCounterfactualSandbox(snapshotRoot, check, control, bindingCarrierPaths, manifest) {
|
|
6
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "ty-context-counterfactual-"));
|
|
7
|
+
if (!manifest) {
|
|
8
|
+
await cp(snapshotRoot, root, {
|
|
9
|
+
recursive: true,
|
|
10
|
+
force: true,
|
|
11
|
+
dereference: false,
|
|
12
|
+
});
|
|
13
|
+
return disposable(root);
|
|
14
|
+
}
|
|
15
|
+
const exactPaths = new Set([
|
|
16
|
+
...Object.keys(check.runner.frozen_files),
|
|
17
|
+
...Object.keys(check.verification_input_hashes),
|
|
18
|
+
check.runner.resolved_target,
|
|
19
|
+
...(control.mutation.type === "replace_file"
|
|
20
|
+
? [control.mutation.fixture_path]
|
|
21
|
+
: []),
|
|
22
|
+
]);
|
|
23
|
+
const patterns = [
|
|
24
|
+
...check.input_paths,
|
|
25
|
+
...check.expected_output_paths,
|
|
26
|
+
...check.artifact_globs,
|
|
27
|
+
...bindingCarrierPaths,
|
|
28
|
+
...(control.mutation.type === "remove_paths"
|
|
29
|
+
? control.mutation.paths
|
|
30
|
+
: [control.mutation.path]),
|
|
31
|
+
];
|
|
32
|
+
for (const requirement of check.environment_requirements) {
|
|
33
|
+
if (requirement.kind === "file")
|
|
34
|
+
exactPaths.add(requirement.target);
|
|
35
|
+
if (requirement.kind === "directory")
|
|
36
|
+
patterns.push(`${requirement.target}/**`);
|
|
37
|
+
}
|
|
38
|
+
const selected = manifest.files
|
|
39
|
+
.map((file) => file.path)
|
|
40
|
+
.filter((relative) => exactPaths.has(relative) ||
|
|
41
|
+
patterns.some((pattern) => matchesRepoPattern(relative, pattern)));
|
|
42
|
+
await copyInBatches(snapshotRoot, root, selected);
|
|
43
|
+
await mkdir(path.join(root, check.runner.resolved_cwd), { recursive: true });
|
|
44
|
+
await linkDependencyRoots(snapshotRoot, root, check.runner.resolved_cwd);
|
|
45
|
+
return disposable(root);
|
|
46
|
+
}
|
|
47
|
+
async function copyInBatches(sourceRoot, targetRoot, paths) {
|
|
48
|
+
const concurrency = 32;
|
|
49
|
+
for (let index = 0; index < paths.length; index += concurrency)
|
|
50
|
+
await Promise.all(paths
|
|
51
|
+
.slice(index, index + concurrency)
|
|
52
|
+
.map((relative) => copyEntry(path.join(sourceRoot, relative), path.join(targetRoot, relative))));
|
|
53
|
+
}
|
|
54
|
+
async function copyEntry(source, target) {
|
|
55
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
56
|
+
const info = await lstat(source);
|
|
57
|
+
if (!info.isSymbolicLink()) {
|
|
58
|
+
await copyFile(source, target);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const link = await readlink(source);
|
|
62
|
+
if (process.platform === "win32")
|
|
63
|
+
await symlink(link, target, "junction");
|
|
64
|
+
else
|
|
65
|
+
await symlink(link, target);
|
|
66
|
+
}
|
|
67
|
+
async function linkDependencyRoots(sourceRoot, targetRoot, resolvedCwd) {
|
|
68
|
+
const segments = resolvedCwd === "." ? [] : resolvedCwd.split("/");
|
|
69
|
+
for (let length = 0; length <= segments.length; length += 1) {
|
|
70
|
+
const relative = path.join(...segments.slice(0, length), "node_modules");
|
|
71
|
+
const source = path.join(sourceRoot, relative);
|
|
72
|
+
if (!(await lstat(source).catch(() => null)))
|
|
73
|
+
continue;
|
|
74
|
+
const target = path.join(targetRoot, relative);
|
|
75
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
76
|
+
await rm(target, { recursive: true, force: true });
|
|
77
|
+
await symlink(await realpath(source), target, process.platform === "win32" ? "junction" : "dir");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function disposable(root) {
|
|
81
|
+
return {
|
|
82
|
+
root,
|
|
83
|
+
async dispose() {
|
|
84
|
+
await rm(root, { recursive: true, force: true });
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type CounterfactualMutationV2 = {
|
|
2
|
+
type: "remove_paths";
|
|
3
|
+
paths: string[];
|
|
4
|
+
} | {
|
|
5
|
+
type: "replace_file";
|
|
6
|
+
path: string;
|
|
7
|
+
fixture_path: string;
|
|
8
|
+
};
|
|
9
|
+
export interface CounterfactualControlV2 {
|
|
10
|
+
key: string;
|
|
11
|
+
binding_key: string;
|
|
12
|
+
claims: string[];
|
|
13
|
+
check_key: string;
|
|
14
|
+
mutation: CounterfactualMutationV2;
|
|
15
|
+
expected_assertion_failures: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface GlobalCounterfactualControlV2 {
|
|
18
|
+
key: string;
|
|
19
|
+
binding_ref: string;
|
|
20
|
+
claims: string[];
|
|
21
|
+
check_key: string;
|
|
22
|
+
mutation: CounterfactualMutationV2;
|
|
23
|
+
expected_assertion_failures: string[];
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompiledDeliveryContractV2, InitialTaskBaseV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface CompileDeliveryOptionsV2 {
|
|
3
|
+
require_completion_gate?: boolean;
|
|
4
|
+
revise?: boolean;
|
|
5
|
+
live_gate?: boolean;
|
|
6
|
+
initial_task_base?: InitialTaskBaseV2;
|
|
7
|
+
authority_revision?: number;
|
|
8
|
+
previous_authority?: CompiledDeliveryContractV2 | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function compileDeliveryContract(workdirInput: string, projectRootInput?: string, options?: CompileDeliveryOptionsV2): Promise<CompiledDeliveryContractV2>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { validateContractForActivation } from "./long-task-activation-validation.js";
|
|
3
|
+
import { DELIVERY_CONTRACT_FILE, parseDeliveryContractBundle, } from "./long-task-delivery-parser.js";
|
|
4
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
5
|
+
import { changedAuthoritySections, computeAuthorityHashes, } from "./long-task-authority.js";
|
|
6
|
+
import { authorityMaterialsChanged, compiledAuthorityMaterials, computeAuthorityMaterials, } from "./long-task-authority-materials.js";
|
|
7
|
+
import { normalizeContextAuthoritySnapshot } from "./long-task-context-authority.js";
|
|
8
|
+
import { assertRiskNotDowngraded, enforceAuthorityRevision, } from "./long-task-authority-revision-enforcement.js";
|
|
9
|
+
import { validateActualRiskSurfaces } from "./long-task-risk-surfaces.js";
|
|
10
|
+
import { captureVerifierIdentity } from "./long-task-verifier-identity.js";
|
|
11
|
+
import { verifierAuthorityDiff } from "./long-task-verifier-authority.js";
|
|
12
|
+
import { changedWorkspacePaths, currentGitTree, repoRelative, repositoryRoot, } from "./long-task-workspace.js";
|
|
13
|
+
export async function compileDeliveryContract(workdirInput, projectRootInput = process.cwd(), options = {}) {
|
|
14
|
+
const repository = await repositoryRoot(projectRootInput);
|
|
15
|
+
const workdir = path.resolve(workdirInput);
|
|
16
|
+
const workdirRelative = repoRelative(repository, workdir);
|
|
17
|
+
if (!workdirRelative)
|
|
18
|
+
throw new Error("long_task_workdir_must_not_be_repository_root");
|
|
19
|
+
const contractFile = path.join(workdir, DELIVERY_CONTRACT_FILE);
|
|
20
|
+
const parsed = await parseDeliveryContractBundle(workdir, repository, {
|
|
21
|
+
validate_structure: false,
|
|
22
|
+
});
|
|
23
|
+
const contract = parsed.contract;
|
|
24
|
+
const validation = await validateContractForActivation({
|
|
25
|
+
contract,
|
|
26
|
+
repository,
|
|
27
|
+
workdir,
|
|
28
|
+
mode: "fail_fast",
|
|
29
|
+
});
|
|
30
|
+
const claims = validation.claims;
|
|
31
|
+
const risk = validation.risk;
|
|
32
|
+
const sourceHashes = validation.source_hashes;
|
|
33
|
+
const sourceItems = validation.source_items;
|
|
34
|
+
const context = validation.context_snapshot;
|
|
35
|
+
const current = validation.workspace;
|
|
36
|
+
const globalChecks = validation.global_checks;
|
|
37
|
+
const outcomes = validation.outcomes;
|
|
38
|
+
const contractHash = sha256Hex(canonicalValueJson(contract));
|
|
39
|
+
const authorityMaterials = computeAuthorityMaterials(contract, sourceHashes, sourceItems, context);
|
|
40
|
+
const previous = options.live_gate
|
|
41
|
+
? null
|
|
42
|
+
: (options.previous_authority ?? null);
|
|
43
|
+
const initialTaskBase = options.initial_task_base ??
|
|
44
|
+
previous?.initial_task_base ?? {
|
|
45
|
+
git_commit: current.git_head,
|
|
46
|
+
git_tree: await currentGitTree(repository),
|
|
47
|
+
workspace_manifest: current,
|
|
48
|
+
};
|
|
49
|
+
await validateActualRiskSurfaces(repository, changedWorkspacePaths(initialTaskBase.workspace_manifest, current), contract);
|
|
50
|
+
const verifier = await captureVerifierIdentity(repository, options.require_completion_gate !== false);
|
|
51
|
+
const allChecks = [
|
|
52
|
+
...globalChecks,
|
|
53
|
+
...outcomes.flatMap((outcome) => outcome.acceptance.checks),
|
|
54
|
+
];
|
|
55
|
+
const authorityHashes = computeAuthorityHashes(contract);
|
|
56
|
+
authorityHashes.acceptance_authority_hash = sha256Hex(canonicalValueJson({
|
|
57
|
+
declared: authorityHashes.acceptance_authority_hash,
|
|
58
|
+
claim_coverage: claims.summary,
|
|
59
|
+
frozen_checks: allChecks.map((check) => ({
|
|
60
|
+
internal_id: check.internal_id,
|
|
61
|
+
runner_definition: check.runner.definition_sha256,
|
|
62
|
+
resolved_cwd: check.runner.resolved_cwd,
|
|
63
|
+
resolved_target: check.runner.resolved_target,
|
|
64
|
+
package_script: check.runner.package_script,
|
|
65
|
+
verification_inputs: check.verification_input_hashes,
|
|
66
|
+
raw_execution_identity: check.raw_execution_identity,
|
|
67
|
+
evidence_adapter: check.evidence_adapter,
|
|
68
|
+
})),
|
|
69
|
+
}));
|
|
70
|
+
let authorityRevision = options.authority_revision ?? previous?.authority_revision ?? 1;
|
|
71
|
+
if (previous) {
|
|
72
|
+
const changes = changedAuthoritySections(previous.authority_hashes, authorityHashes);
|
|
73
|
+
const contractChanged = previous.contract_sha256 !== contractHash;
|
|
74
|
+
const materialsChanged = authorityMaterialsChanged(compiledAuthorityMaterials(previous), authorityMaterials);
|
|
75
|
+
const verifierChanged = verifierAuthorityDiff(previous.verifier_identity, verifier);
|
|
76
|
+
const authorityChanged = changes.length > 0 ||
|
|
77
|
+
contractChanged ||
|
|
78
|
+
materialsChanged ||
|
|
79
|
+
verifierChanged.verifier_content_changed ||
|
|
80
|
+
verifierChanged.verifier_runtime_locator_changed;
|
|
81
|
+
if (authorityChanged && !options.revise)
|
|
82
|
+
throw new Error("authority_revision_requires_revise_flag");
|
|
83
|
+
if (options.revise && authorityChanged) {
|
|
84
|
+
assertRiskNotDowngraded(previous, risk.effective_level, risk.reasons);
|
|
85
|
+
authorityRevision = previous.authority_revision + 1;
|
|
86
|
+
await enforceAuthorityRevision(previous, contract, authorityHashes, authorityMaterials, globalChecks, outcomes, verifier, workdir, risk.minimum_level);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const unsigned = {
|
|
90
|
+
schema_version: "compiled-long-task-delivery-v2",
|
|
91
|
+
repository_root: repository,
|
|
92
|
+
workdir,
|
|
93
|
+
contract_file: repoRelative(repository, contractFile),
|
|
94
|
+
contract_sha256: contractHash,
|
|
95
|
+
contract_files: Object.fromEntries(Object.entries(parsed.contract_files).map(([relative, hash]) => [
|
|
96
|
+
repoRelative(repository, path.join(workdir, ...relative.split("/"))),
|
|
97
|
+
hash,
|
|
98
|
+
])),
|
|
99
|
+
source_hashes: sourceHashes,
|
|
100
|
+
source_items: sourceItems,
|
|
101
|
+
context_snapshot: normalizeContextAuthoritySnapshot(context),
|
|
102
|
+
verifier_identity: verifier,
|
|
103
|
+
effective_risk: risk.effective_level,
|
|
104
|
+
risk_reasons: risk.reasons,
|
|
105
|
+
baseline_workspace: initialTaskBase.workspace_manifest,
|
|
106
|
+
initial_task_base: initialTaskBase,
|
|
107
|
+
authority_hashes: authorityHashes,
|
|
108
|
+
authority_materials: authorityMaterials,
|
|
109
|
+
authority_revision: authorityRevision,
|
|
110
|
+
claim_coverage: claims.summary,
|
|
111
|
+
task: contract.task,
|
|
112
|
+
risk: contract.risk,
|
|
113
|
+
source_claims: contract.source_claims,
|
|
114
|
+
global: {
|
|
115
|
+
product: contract.global.product,
|
|
116
|
+
technical: contract.global.technical,
|
|
117
|
+
acceptance: {
|
|
118
|
+
checks: globalChecks,
|
|
119
|
+
counterfactual_controls: contract.global.acceptance.counterfactual_controls,
|
|
120
|
+
external_confirmations: contract.global.acceptance.external_confirmations,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
outcomes,
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
...unsigned,
|
|
127
|
+
compiled_identity: sha256Hex(canonicalValueJson(unsigned)),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare const DELIVERY_CONTRACT_FILE = "delivery-contract.yaml";
|
|
3
|
+
export interface ParsedDeliveryContractV2 {
|
|
4
|
+
contract: DeliveryContractV2;
|
|
5
|
+
contract_files: Record<string, string>;
|
|
6
|
+
outcome_files: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ParseDeliveryContractOptions {
|
|
9
|
+
validate_structure?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseDeliveryContract(workdir: string): Promise<DeliveryContractV2>;
|
|
12
|
+
export declare function parseDeliveryContractBundle(workdirInput: string, repositoryInput?: string, options?: ParseDeliveryContractOptions): Promise<ParsedDeliveryContractV2>;
|
|
13
|
+
export declare function parseDeliveryContractText(raw: string): DeliveryContractV2;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseStrictYaml, sha256Hex } from "./strict-codec.js";
|
|
4
|
+
import { validateDeliveryContractStructure } from "./long-task-delivery-validation.js";
|
|
5
|
+
import { parseOutcome, parseOutcomeFragment, safeFragmentPath, } from "./long-task-outcome-parser.js";
|
|
6
|
+
import { assertProtectedRepositoryFile } from "./long-task-protected-files.js";
|
|
7
|
+
import { array, literal, object, parseSourceClaims, strings, } from "./long-task-delivery-shape.js";
|
|
8
|
+
import { parseGlobal, parseRisk, parseTask } from "./long-task-root-shape.js";
|
|
9
|
+
import { repositoryRoot } from "./long-task-workspace.js";
|
|
10
|
+
export const DELIVERY_CONTRACT_FILE = "delivery-contract.yaml";
|
|
11
|
+
export async function parseDeliveryContract(workdir) {
|
|
12
|
+
return (await parseDeliveryContractBundle(workdir)).contract;
|
|
13
|
+
}
|
|
14
|
+
export async function parseDeliveryContractBundle(workdirInput, repositoryInput, options = {}) {
|
|
15
|
+
const workdir = path.resolve(workdirInput);
|
|
16
|
+
const file = path.join(workdir, DELIVERY_CONTRACT_FILE);
|
|
17
|
+
const repository = repositoryInput
|
|
18
|
+
? path.resolve(repositoryInput)
|
|
19
|
+
: await repositoryRoot(workdir);
|
|
20
|
+
const raw = await readFile(await assertProtectedRepositoryFile(repository, file, "delivery_contract"), "utf8");
|
|
21
|
+
const root = parseRoot(raw, true);
|
|
22
|
+
const hasInline = Object.hasOwn(root, "outcomes");
|
|
23
|
+
const hasFiles = Object.hasOwn(root, "outcome_files");
|
|
24
|
+
if (hasInline === hasFiles)
|
|
25
|
+
throw new Error("delivery_contract_invalid:$:exactly one of outcomes or outcome_files is required");
|
|
26
|
+
const files = {};
|
|
27
|
+
let outcomes;
|
|
28
|
+
let outcomeFiles = [];
|
|
29
|
+
if (hasInline) {
|
|
30
|
+
outcomes = array(root.outcomes, "outcomes").map((item, index) => parseOutcome(item, `outcomes[${index}]`));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
outcomeFiles = strings(root.outcome_files, "outcome_files")
|
|
34
|
+
.map((item, index) => safeFragmentPath(item, index))
|
|
35
|
+
.sort();
|
|
36
|
+
if (new Set(outcomeFiles).size !== outcomeFiles.length)
|
|
37
|
+
throw new Error("delivery_contract_invalid:outcome_files:duplicate path");
|
|
38
|
+
outcomes = [];
|
|
39
|
+
for (const relative of outcomeFiles) {
|
|
40
|
+
const target = path.resolve(workdir, ...relative.split("/"));
|
|
41
|
+
if (!target.startsWith(`${workdir}${path.sep}`))
|
|
42
|
+
throw new Error(`unsafe_path:outcome_files:${relative}`);
|
|
43
|
+
const protectedFragment = await assertProtectedRepositoryFile(repository, target, `outcome_fragment:${relative}`).catch((error) => {
|
|
44
|
+
if (error instanceof Error &&
|
|
45
|
+
error.message.startsWith("protected_input_not_found:"))
|
|
46
|
+
throw new Error(`outcome_fragment_not_found:${relative}`);
|
|
47
|
+
throw error;
|
|
48
|
+
});
|
|
49
|
+
const fragmentRaw = await readFile(protectedFragment, "utf8");
|
|
50
|
+
files[relative] = sha256Hex(fragmentRaw);
|
|
51
|
+
outcomes.push(...parseOutcomeFragment(fragmentRaw, relative));
|
|
52
|
+
}
|
|
53
|
+
outcomes.sort((left, right) => left.key.localeCompare(right.key));
|
|
54
|
+
}
|
|
55
|
+
const contract = parseContractRoot(root, outcomes);
|
|
56
|
+
if (options.validate_structure !== false)
|
|
57
|
+
validateDeliveryContractStructure(contract);
|
|
58
|
+
return {
|
|
59
|
+
contract,
|
|
60
|
+
contract_files: Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b))),
|
|
61
|
+
outcome_files: outcomeFiles,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function parseDeliveryContractText(raw) {
|
|
65
|
+
const root = parseRoot(raw, false);
|
|
66
|
+
const contract = parseContractRoot(root, array(root.outcomes, "outcomes").map((item, index) => parseOutcome(item, `outcomes[${index}]`)));
|
|
67
|
+
validateDeliveryContractStructure(contract);
|
|
68
|
+
return contract;
|
|
69
|
+
}
|
|
70
|
+
function parseRoot(raw, bundle) {
|
|
71
|
+
const decoded = parseStrictYaml(raw);
|
|
72
|
+
if (decoded &&
|
|
73
|
+
typeof decoded === "object" &&
|
|
74
|
+
!Array.isArray(decoded) &&
|
|
75
|
+
decoded.schema_version ===
|
|
76
|
+
"long-task-delivery-v1")
|
|
77
|
+
throw new Error("long_task_delivery_v1_retired_use_v2");
|
|
78
|
+
return object(decoded, "$", ["schema_version", "task", "source_claims", "risk", "global"], bundle ? ["outcomes", "outcome_files"] : ["outcomes"]);
|
|
79
|
+
}
|
|
80
|
+
function parseContractRoot(root, outcomes) {
|
|
81
|
+
literal(root.schema_version, ["long-task-delivery-v2"], "schema_version");
|
|
82
|
+
return {
|
|
83
|
+
schema_version: "long-task-delivery-v2",
|
|
84
|
+
task: parseTask(root.task),
|
|
85
|
+
source_claims: parseSourceClaims(root.source_claims, "source_claims"),
|
|
86
|
+
risk: parseRisk(root.risk),
|
|
87
|
+
global: parseGlobal(root.global),
|
|
88
|
+
outcomes,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CompiledCheckV2, CompiledDeliveryContractV2, CompiledOutcomeV2, DeliveryContractV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function validateVerificationInputSeparation(contract: DeliveryContractV2, checks: CompiledDeliveryContractV2["outcomes"][number]["acceptance"]["checks"], workdirRelative: string): void;
|
|
3
|
+
export declare function validateTechnicalPaths(contract: DeliveryContractV2, repository: string, workdirRelative: string, baseline: WorkspaceManifestV2): void;
|
|
4
|
+
export declare function validateCounterfactualPaths(contract: DeliveryContractV2, compiledGlobalChecks: CompiledCheckV2[], compiledOutcomes: CompiledOutcomeV2[], repository: string, workdirRelative: string, protectedAuthorityPaths: string[]): Promise<void>;
|
|
5
|
+
export declare function hashDeclaredFiles(repository: string, files: string[], label: string): Promise<Record<string, string>>;
|