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,116 @@
|
|
|
1
|
+
import { progressRecordFresh } from "./long-task-progress.js";
|
|
2
|
+
export function projectDeliveryStatus(input) {
|
|
3
|
+
const outcomes = projectOutcomes(input);
|
|
4
|
+
return {
|
|
5
|
+
finalResult: projectFinalResult(input),
|
|
6
|
+
finalWorkflowStatus: receiptFresh(input)
|
|
7
|
+
? input.receipt.workflow_status
|
|
8
|
+
: null,
|
|
9
|
+
outcomes,
|
|
10
|
+
readyOutcomes: readyOutcomes(input.compiled, outcomes),
|
|
11
|
+
needsReverify: Object.entries(outcomes)
|
|
12
|
+
.filter(([, status]) => ["unverified", "progress_stale", "progress_failing"].includes(status))
|
|
13
|
+
.map(([key]) => key),
|
|
14
|
+
progressPassing: Object.entries(outcomes)
|
|
15
|
+
.filter(([, status]) => status === "progress_passing")
|
|
16
|
+
.map(([key]) => key),
|
|
17
|
+
progressFailing: Object.entries(outcomes)
|
|
18
|
+
.filter(([, status]) => status === "progress_failing")
|
|
19
|
+
.map(([key]) => key),
|
|
20
|
+
findings: projectFindings(input),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function projectOutcomes(input) {
|
|
24
|
+
const outcomes = {};
|
|
25
|
+
for (const outcome of input.compiled.outcomes) {
|
|
26
|
+
const states = outcome.acceptance.checks.map((check) => {
|
|
27
|
+
const record = input.progress[check.internal_id];
|
|
28
|
+
if (!record)
|
|
29
|
+
return "unverified";
|
|
30
|
+
if (input.stale.length ||
|
|
31
|
+
!progressRecordFresh(record, input.compiled, input.manifest, check))
|
|
32
|
+
return "progress_stale";
|
|
33
|
+
if (record.result === "passed")
|
|
34
|
+
return "progress_passing";
|
|
35
|
+
if (record.result === "blocked_external")
|
|
36
|
+
return "blocked_external";
|
|
37
|
+
return "progress_failing";
|
|
38
|
+
});
|
|
39
|
+
outcomes[outcome.key] = states.includes("progress_failing")
|
|
40
|
+
? "progress_failing"
|
|
41
|
+
: states.includes("blocked_external")
|
|
42
|
+
? "blocked_external"
|
|
43
|
+
: states.includes("progress_stale")
|
|
44
|
+
? "progress_stale"
|
|
45
|
+
: states.length > 0 &&
|
|
46
|
+
states.every((state) => state === "progress_passing")
|
|
47
|
+
? "progress_passing"
|
|
48
|
+
: "unverified";
|
|
49
|
+
}
|
|
50
|
+
return outcomes;
|
|
51
|
+
}
|
|
52
|
+
function projectFindings(input) {
|
|
53
|
+
const findings = input.stale.map((code) => ({
|
|
54
|
+
code,
|
|
55
|
+
outcome_key: null,
|
|
56
|
+
check_key: null,
|
|
57
|
+
message: "A compiled authority input changed.",
|
|
58
|
+
next_action: "Review the change and recompile the Delivery Contract.",
|
|
59
|
+
}));
|
|
60
|
+
if (input.receiptError)
|
|
61
|
+
findings.push({
|
|
62
|
+
code: input.receiptError,
|
|
63
|
+
outcome_key: null,
|
|
64
|
+
check_key: null,
|
|
65
|
+
message: "The last audit Receipt is invalid; it has no acceptance authority.",
|
|
66
|
+
next_action: "Run a new Live Final Gate.",
|
|
67
|
+
});
|
|
68
|
+
const checks = [
|
|
69
|
+
...input.compiled.global.acceptance.checks,
|
|
70
|
+
...input.compiled.outcomes.flatMap((outcome) => outcome.acceptance.checks),
|
|
71
|
+
];
|
|
72
|
+
for (const record of Object.values(input.progress)) {
|
|
73
|
+
const check = checks.find((candidate) => candidate.internal_id === record.check_internal_id);
|
|
74
|
+
if (!check)
|
|
75
|
+
continue;
|
|
76
|
+
if (progressRecordFresh(record, input.compiled, input.manifest, check)) {
|
|
77
|
+
findings.push(...record.findings);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (check.outcome_key === null)
|
|
81
|
+
findings.push({
|
|
82
|
+
code: "global_progress_stale",
|
|
83
|
+
outcome_key: null,
|
|
84
|
+
check_key: check.key,
|
|
85
|
+
message: `Targeted progress for Global Check ${check.key} is stale.`,
|
|
86
|
+
next_action: "Rerun the Global Check against the current carrier snapshot.",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return findings;
|
|
90
|
+
}
|
|
91
|
+
function readyOutcomes(compiled, outcomes) {
|
|
92
|
+
return compiled.outcomes
|
|
93
|
+
.filter((outcome) => outcomes[outcome.key] !== "progress_passing" &&
|
|
94
|
+
outcome.depends_on.every((dependency) => outcomes[dependency] === "progress_passing"))
|
|
95
|
+
.map((outcome) => outcome.key);
|
|
96
|
+
}
|
|
97
|
+
function projectFinalResult(input) {
|
|
98
|
+
if (!input.receipt)
|
|
99
|
+
return "no_final_gate";
|
|
100
|
+
if (!receiptFresh(input))
|
|
101
|
+
return "last_gate_inputs_stale";
|
|
102
|
+
if (input.receipt.workflow_status === "blocked_external")
|
|
103
|
+
return "last_gate_blocked";
|
|
104
|
+
if (input.receipt.workflow_status === "needs_work")
|
|
105
|
+
return "last_gate_failed";
|
|
106
|
+
return "last_gate_passed";
|
|
107
|
+
}
|
|
108
|
+
function receiptFresh(input) {
|
|
109
|
+
return Boolean(input.receipt &&
|
|
110
|
+
!input.receiptError &&
|
|
111
|
+
!input.stale.length &&
|
|
112
|
+
input.receipt.compiled_identity === input.compiled.compiled_identity &&
|
|
113
|
+
input.receipt.snapshot_sha256 === input.manifest.snapshot_sha256 &&
|
|
114
|
+
input.receipt.git_head === input.manifest.git_head &&
|
|
115
|
+
input.receipt.git_tree === input.manifest.fingerprint.head_tree);
|
|
116
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ExternalConfirmationV2, FinalReceiptV2, LongTaskFindingV2, OutcomeStatusV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { type AuditGateStatusV2 } from "./long-task-status-projection.js";
|
|
3
|
+
export interface DeliveryStatusV2 {
|
|
4
|
+
schema_version: "long-task-status-v2";
|
|
5
|
+
task_id: string;
|
|
6
|
+
compiled_identity: string;
|
|
7
|
+
effective_risk: "standard" | "strict";
|
|
8
|
+
workspace_snapshot_sha256: string;
|
|
9
|
+
acceptance_authority: "live_final_gate_required";
|
|
10
|
+
final_result: AuditGateStatusV2;
|
|
11
|
+
final_workflow_status: FinalReceiptV2["workflow_status"] | null;
|
|
12
|
+
external_confirmations: ExternalConfirmationV2[];
|
|
13
|
+
outcomes: Record<string, OutcomeStatusV2>;
|
|
14
|
+
ready_outcomes: string[];
|
|
15
|
+
ready_for_implementation: string[];
|
|
16
|
+
needs_reverify: string[];
|
|
17
|
+
progress_passing: string[];
|
|
18
|
+
progress_failing: string[];
|
|
19
|
+
findings: LongTaskFindingV2[];
|
|
20
|
+
}
|
|
21
|
+
export declare function readDeliveryStatus(workdir: string): Promise<DeliveryStatusV2>;
|
|
22
|
+
export declare function resumeDeliveryTask(workdir: string): Promise<Record<string, unknown>>;
|
|
23
|
+
export declare function doctorDeliveryTask(workdirInput: string): Promise<Record<string, unknown>>;
|
|
24
|
+
export declare function stopCheckDeliveryTask(workdirInput: string, messageText?: string): Promise<StopCheckDeliveryResultV2>;
|
|
25
|
+
export interface StopCheckDeliveryResultV2 {
|
|
26
|
+
continue: boolean;
|
|
27
|
+
reason: string;
|
|
28
|
+
workflow_status?: FinalReceiptV2["workflow_status"];
|
|
29
|
+
external_confirmations?: ExternalConfirmationV2[];
|
|
30
|
+
message?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CloseDeliveryResultV2 {
|
|
33
|
+
status: "closed";
|
|
34
|
+
workflow_status: Extract<FinalReceiptV2["workflow_status"], "machine_accepted" | "machine_accepted_external_pending">;
|
|
35
|
+
external_confirmations: ExternalConfirmationV2[];
|
|
36
|
+
}
|
|
37
|
+
export declare function closeDeliveryTask(workdir: string): Promise<CloseDeliveryResultV2>;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { compileDeliveryContract } from "./long-task-delivery-compiler.js";
|
|
3
|
+
import { runDeliveryFinalGate } from "./long-task-final-v2.js";
|
|
4
|
+
import { deliveryCompileFreshness } from "./long-task-freshness.js";
|
|
5
|
+
import { activeAuthorityLockExists, clearActiveBindingCas, inspectCompiledCache, loadActiveLongTaskAuthority, readActiveLongTaskBinding, readFinalReceipt, readProgressRecords, } from "./long-task-state.js";
|
|
6
|
+
import { projectDeliveryStatus, } from "./long-task-status-projection.js";
|
|
7
|
+
import { captureWorkspaceManifest, currentGitState, repositoryRoot, } from "./long-task-workspace.js";
|
|
8
|
+
export async function readDeliveryStatus(workdir) {
|
|
9
|
+
const root = await repositoryRoot(process.cwd());
|
|
10
|
+
const loaded = await loadActiveLongTaskAuthority(root);
|
|
11
|
+
const active = loaded.authority;
|
|
12
|
+
if (!active)
|
|
13
|
+
throw new Error("active_task_missing");
|
|
14
|
+
if (active.workdir !== path.resolve(workdir))
|
|
15
|
+
throw new Error("active_task_workdir_mismatch");
|
|
16
|
+
return readDeliveryStatusForAuthority(active);
|
|
17
|
+
}
|
|
18
|
+
async function readDeliveryStatusForAuthority(active) {
|
|
19
|
+
const compiled = active.authority_snapshot;
|
|
20
|
+
const cacheStatus = await inspectCompiledCache(active);
|
|
21
|
+
const current = await captureWorkspaceManifest(compiled.repository_root, compiled.workdir);
|
|
22
|
+
const stale = await deliveryCompileFreshness(compiled);
|
|
23
|
+
const progress = await readProgressRecords(active.workdir);
|
|
24
|
+
let receipt = null;
|
|
25
|
+
let receiptError = null;
|
|
26
|
+
try {
|
|
27
|
+
receipt = await readFinalReceipt(compiled.repository_root, compiled.workdir);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
receiptError = message(error);
|
|
31
|
+
}
|
|
32
|
+
const projection = projectDeliveryStatus({
|
|
33
|
+
compiled,
|
|
34
|
+
manifest: current,
|
|
35
|
+
stale,
|
|
36
|
+
progress,
|
|
37
|
+
receipt,
|
|
38
|
+
receiptError,
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
schema_version: "long-task-status-v2",
|
|
42
|
+
task_id: compiled.task.id,
|
|
43
|
+
compiled_identity: compiled.compiled_identity,
|
|
44
|
+
effective_risk: compiled.effective_risk,
|
|
45
|
+
workspace_snapshot_sha256: current.snapshot_sha256,
|
|
46
|
+
acceptance_authority: "live_final_gate_required",
|
|
47
|
+
final_result: projection.finalResult,
|
|
48
|
+
final_workflow_status: projection.finalWorkflowStatus,
|
|
49
|
+
external_confirmations: compiled.global.acceptance.external_confirmations,
|
|
50
|
+
outcomes: projection.outcomes,
|
|
51
|
+
ready_outcomes: projection.readyOutcomes,
|
|
52
|
+
ready_for_implementation: projection.readyOutcomes,
|
|
53
|
+
needs_reverify: projection.needsReverify,
|
|
54
|
+
progress_passing: projection.progressPassing,
|
|
55
|
+
progress_failing: projection.progressFailing,
|
|
56
|
+
findings: [
|
|
57
|
+
...projection.findings,
|
|
58
|
+
...(cacheStatus === "compiled_cache_matching"
|
|
59
|
+
? []
|
|
60
|
+
: [cacheDiagnostic(cacheStatus)]),
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export async function resumeDeliveryTask(workdir) {
|
|
65
|
+
const root = await repositoryRoot(process.cwd());
|
|
66
|
+
const loaded = await loadActiveLongTaskAuthority(root);
|
|
67
|
+
const active = loaded.authority;
|
|
68
|
+
if (!active)
|
|
69
|
+
throw new Error("active_task_missing");
|
|
70
|
+
if (active.workdir !== path.resolve(workdir))
|
|
71
|
+
throw new Error("active_task_workdir_mismatch");
|
|
72
|
+
const compiled = active.authority_snapshot;
|
|
73
|
+
const [status, git] = await Promise.all([
|
|
74
|
+
readDeliveryStatusForAuthority(active),
|
|
75
|
+
currentGitState(compiled.repository_root),
|
|
76
|
+
]);
|
|
77
|
+
return {
|
|
78
|
+
schema_version: "long-task-resume-v2",
|
|
79
|
+
task: {
|
|
80
|
+
id: compiled.task.id,
|
|
81
|
+
title: compiled.task.title,
|
|
82
|
+
goal: compiled.task.goal,
|
|
83
|
+
},
|
|
84
|
+
contract_identity: compiled.compiled_identity,
|
|
85
|
+
authority_revision: compiled.authority_revision,
|
|
86
|
+
effective_risk: compiled.effective_risk,
|
|
87
|
+
context_refs: compiled.task.context_refs,
|
|
88
|
+
git,
|
|
89
|
+
acceptance_authority: "live_final_gate_required",
|
|
90
|
+
last_gate: status.final_result,
|
|
91
|
+
final_workflow_status: status.final_workflow_status,
|
|
92
|
+
external_confirmations: status.external_confirmations,
|
|
93
|
+
outcomes: status.outcomes,
|
|
94
|
+
ready_outcomes: status.ready_outcomes,
|
|
95
|
+
ready_for_implementation: status.ready_for_implementation,
|
|
96
|
+
needs_reverify: status.needs_reverify,
|
|
97
|
+
progress_passing: status.progress_passing,
|
|
98
|
+
progress_failing: status.progress_failing,
|
|
99
|
+
recent_findings: status.findings,
|
|
100
|
+
next_safe_action: nextAction(status),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export async function doctorDeliveryTask(workdirInput) {
|
|
104
|
+
const root = await repositoryRoot(process.cwd());
|
|
105
|
+
let loaded;
|
|
106
|
+
try {
|
|
107
|
+
loaded = await loadActiveLongTaskAuthority(root);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
const finding = doctorAuthorityFinding(message(error));
|
|
111
|
+
return {
|
|
112
|
+
schema_version: "long-task-doctor-v2",
|
|
113
|
+
status: finding,
|
|
114
|
+
healthy: false,
|
|
115
|
+
findings: [finding],
|
|
116
|
+
next_action: `ty-context long-task abandon ${path.resolve(workdirInput)} --force-corrupt-state`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const active = loaded.authority;
|
|
120
|
+
if (!active)
|
|
121
|
+
return { status: "no_active_task", healthy: true };
|
|
122
|
+
if (active.workdir !== path.resolve(workdirInput))
|
|
123
|
+
throw new Error("active_task_workdir_mismatch");
|
|
124
|
+
const findings = [
|
|
125
|
+
"active_authority_valid",
|
|
126
|
+
await inspectCompiledCache(active),
|
|
127
|
+
];
|
|
128
|
+
if (await activeAuthorityLockExists(root))
|
|
129
|
+
findings.push("active_authority_lock_present");
|
|
130
|
+
let currentAuthorityIdentity = null;
|
|
131
|
+
try {
|
|
132
|
+
const compiled = await compileDeliveryContract(active.workdir, root, {
|
|
133
|
+
live_gate: true,
|
|
134
|
+
initial_task_base: active.initial_task_base,
|
|
135
|
+
authority_revision: active.authority_revision,
|
|
136
|
+
require_completion_gate: true,
|
|
137
|
+
});
|
|
138
|
+
currentAuthorityIdentity = compiled.compiled_identity;
|
|
139
|
+
if (compiled.compiled_identity !== active.active_authority_identity)
|
|
140
|
+
findings.push("active_authority_source_mismatch");
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
findings.push(`active_authority_source_invalid:${message(error)}`);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
schema_version: "long-task-doctor-v2",
|
|
147
|
+
status: findings[0],
|
|
148
|
+
healthy: !findings.some((finding) => finding === "active_authority_lock_present" ||
|
|
149
|
+
finding === "active_authority_source_mismatch" ||
|
|
150
|
+
finding.startsWith("active_authority_source_invalid:")),
|
|
151
|
+
task_id: active.task_id,
|
|
152
|
+
authority_revision: active.authority_revision,
|
|
153
|
+
marker_and_record: "matched",
|
|
154
|
+
contract: "available",
|
|
155
|
+
current_authority_identity: currentAuthorityIdentity,
|
|
156
|
+
active_authority_identity: active.active_authority_identity,
|
|
157
|
+
verifier_identity: active.verifier_identity.bundle_sha256,
|
|
158
|
+
hook: "available",
|
|
159
|
+
source_context_fresh: !findings.some((finding) => finding.startsWith("active_authority_source_")),
|
|
160
|
+
compiled_cache: findings.find((finding) => finding.startsWith("compiled_cache_")),
|
|
161
|
+
findings,
|
|
162
|
+
...(findings.includes("active_authority_lock_present")
|
|
163
|
+
? {
|
|
164
|
+
next_action: `ty-context long-task abandon ${path.resolve(workdirInput)} --force-corrupt-state`,
|
|
165
|
+
}
|
|
166
|
+
: {}),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export async function stopCheckDeliveryTask(workdirInput, messageText = "") {
|
|
170
|
+
const root = await repositoryRoot(process.cwd());
|
|
171
|
+
let active;
|
|
172
|
+
try {
|
|
173
|
+
active = await readActiveLongTaskBinding(root);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return {
|
|
177
|
+
continue: false,
|
|
178
|
+
reason: "long_task_state_invalid",
|
|
179
|
+
message: message(error),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (!active)
|
|
183
|
+
return { continue: true, reason: "no_active_task" };
|
|
184
|
+
if (active.workdir !== path.resolve(workdirInput))
|
|
185
|
+
return { continue: false, reason: "active_task_workdir_mismatch" };
|
|
186
|
+
try {
|
|
187
|
+
const result = await runDeliveryFinalGate(active.workdir);
|
|
188
|
+
if (result.workflow_status === "machine_accepted" ||
|
|
189
|
+
result.workflow_status === "machine_accepted_external_pending") {
|
|
190
|
+
try {
|
|
191
|
+
await clearActiveBindingCas({
|
|
192
|
+
repository_root: root,
|
|
193
|
+
workdir: active.workdir,
|
|
194
|
+
task_id: active.task_id,
|
|
195
|
+
authority_revision: active.authority_revision,
|
|
196
|
+
compiled_identity: active.active_authority_identity,
|
|
197
|
+
worktree_identity: active.worktree_identity,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
if (message(error).includes("active_authority_clear_compare_and_swap_failed"))
|
|
202
|
+
return {
|
|
203
|
+
continue: false,
|
|
204
|
+
reason: "active_authority_changed_after_final_gate",
|
|
205
|
+
workflow_status: result.workflow_status,
|
|
206
|
+
external_confirmations: result.external_confirmations,
|
|
207
|
+
message: "Active Authority changed after the Live Final Gate; the accepted identity was not cleared.",
|
|
208
|
+
};
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
continue: true,
|
|
213
|
+
reason: result.workflow_status,
|
|
214
|
+
workflow_status: result.workflow_status,
|
|
215
|
+
external_confirmations: result.external_confirmations,
|
|
216
|
+
...(result.workflow_status === "machine_accepted_external_pending"
|
|
217
|
+
? {
|
|
218
|
+
message: externalPendingMessage(result.external_confirmations),
|
|
219
|
+
}
|
|
220
|
+
: {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
continue: false,
|
|
225
|
+
reason: `live_final_gate_${result.workflow_status}`,
|
|
226
|
+
workflow_status: result.workflow_status,
|
|
227
|
+
external_confirmations: result.external_confirmations,
|
|
228
|
+
message: messageText ||
|
|
229
|
+
result.findings.at(-1)?.next_action ||
|
|
230
|
+
"Repair the failing Check and rerun Stop.",
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (message(error).includes("verifier_authority_migration_required"))
|
|
235
|
+
return {
|
|
236
|
+
continue: false,
|
|
237
|
+
reason: "verifier_authority_migration_required",
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
continue: false,
|
|
241
|
+
reason: "live_final_gate_error",
|
|
242
|
+
message: message(error),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
export async function closeDeliveryTask(workdir) {
|
|
247
|
+
const root = await repositoryRoot(process.cwd());
|
|
248
|
+
const active = await readActiveLongTaskBinding(root);
|
|
249
|
+
if (!active || active.workdir !== path.resolve(workdir))
|
|
250
|
+
throw new Error("active_task_missing_or_mismatched");
|
|
251
|
+
const result = await runDeliveryFinalGate(active.workdir);
|
|
252
|
+
if (result.workflow_status !== "machine_accepted" &&
|
|
253
|
+
result.workflow_status !== "machine_accepted_external_pending")
|
|
254
|
+
throw new Error(`close_live_final_gate_failed:${result.workflow_status}`);
|
|
255
|
+
await clearActiveBindingCas({
|
|
256
|
+
repository_root: root,
|
|
257
|
+
workdir: active.workdir,
|
|
258
|
+
task_id: active.task_id,
|
|
259
|
+
authority_revision: active.authority_revision,
|
|
260
|
+
compiled_identity: active.active_authority_identity,
|
|
261
|
+
worktree_identity: active.worktree_identity,
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
status: "closed",
|
|
265
|
+
workflow_status: result.workflow_status,
|
|
266
|
+
external_confirmations: result.external_confirmations,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function externalPendingMessage(confirmations) {
|
|
270
|
+
const pending = confirmations
|
|
271
|
+
.map((confirmation) => `${confirmation.key} (${confirmation.owner})`)
|
|
272
|
+
.join(", ");
|
|
273
|
+
return `Machine-verifiable scope accepted. Complete external delivery remains pending: ${pending}. Do not report complete external delivery.`;
|
|
274
|
+
}
|
|
275
|
+
function nextAction(status) {
|
|
276
|
+
if (status.findings.length)
|
|
277
|
+
return status.findings.at(-1).next_action;
|
|
278
|
+
if (status.ready_outcomes.length)
|
|
279
|
+
return `Implement and verify ready Outcome: ${status.ready_outcomes[0]}.`;
|
|
280
|
+
return "Create a clean candidate commit; Stop will run the authoritative Live Final Gate.";
|
|
281
|
+
}
|
|
282
|
+
function message(error) {
|
|
283
|
+
return error instanceof Error ? error.message : String(error);
|
|
284
|
+
}
|
|
285
|
+
function cacheDiagnostic(code) {
|
|
286
|
+
return {
|
|
287
|
+
code,
|
|
288
|
+
outcome_key: null,
|
|
289
|
+
check_key: null,
|
|
290
|
+
message: code === "compiled_cache_missing_repairable"
|
|
291
|
+
? "The compiled cache projection is missing; active authority remains valid."
|
|
292
|
+
: "The compiled cache projection does not match active authority and was ignored.",
|
|
293
|
+
next_action: "Run ty-context long-task compile to rebuild the cache projection from active authority.",
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function doctorAuthorityFinding(error) {
|
|
297
|
+
if (error.includes("legacy_v2_active_authority_manual_required"))
|
|
298
|
+
return "legacy_v2_active_authority_manual_required";
|
|
299
|
+
if (error.includes("active_authority_continuity_unrecoverable"))
|
|
300
|
+
return "active_authority_continuity_unrecoverable";
|
|
301
|
+
if (error.includes("marker") ||
|
|
302
|
+
error.includes("active_binding_marker") ||
|
|
303
|
+
error.includes("active_binding_record_missing"))
|
|
304
|
+
return "marker_record_mismatch";
|
|
305
|
+
return "active_authority_invalid";
|
|
306
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DeliveryBindingV2, RollbackRecoveryV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export declare function parseBindings(value: unknown, label: string): DeliveryBindingV2[];
|
|
3
|
+
export declare function parseRollback(value: unknown, label: string): RollbackRecoveryV2;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { array, fail, key, literal, object, repositoryFile, repositoryPattern, repositoryPatterns, string, strings, } from "./long-task-shape-primitives.js";
|
|
2
|
+
export function parseBindings(value, label) {
|
|
3
|
+
return array(value, label).map((item, index) => {
|
|
4
|
+
const itemLabel = `${label}[${index}]`;
|
|
5
|
+
const row = object(item, itemLabel, ["key", "kind", "target", "carrier_paths"], ["existence", "verification_check_key"]);
|
|
6
|
+
const kindValue = literal(row.kind, ["path_glob", "file", "verified"], `${itemLabel}.kind`);
|
|
7
|
+
const verificationCheckKey = Object.hasOwn(row, "verification_check_key")
|
|
8
|
+
? key(row.verification_check_key, `${itemLabel}.verification_check_key`)
|
|
9
|
+
: undefined;
|
|
10
|
+
if (kindValue === "verified" && !verificationCheckKey)
|
|
11
|
+
fail(`${itemLabel}.verification_check_key`, "is required for verified");
|
|
12
|
+
if (kindValue !== "verified" && verificationCheckKey)
|
|
13
|
+
fail(`${itemLabel}.verification_check_key`, "is only allowed for verified");
|
|
14
|
+
const target = kindValue === "file"
|
|
15
|
+
? repositoryFile(row.target, `${itemLabel}.target`)
|
|
16
|
+
: kindValue === "path_glob"
|
|
17
|
+
? repositoryPattern(row.target, `${itemLabel}.target`)
|
|
18
|
+
: string(row.target, `${itemLabel}.target`);
|
|
19
|
+
return {
|
|
20
|
+
key: key(row.key, `${itemLabel}.key`),
|
|
21
|
+
kind: kindValue,
|
|
22
|
+
target,
|
|
23
|
+
carrier_paths: repositoryPatterns(row.carrier_paths, `${itemLabel}.carrier_paths`),
|
|
24
|
+
existence: Object.hasOwn(row, "existence")
|
|
25
|
+
? literal(row.existence, ["existing", "planned"], `${itemLabel}.existence`)
|
|
26
|
+
: "existing",
|
|
27
|
+
...(verificationCheckKey
|
|
28
|
+
? { verification_check_key: verificationCheckKey }
|
|
29
|
+
: {}),
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function parseRollback(value, label) {
|
|
34
|
+
const row = object(value, label, [
|
|
35
|
+
"rollback",
|
|
36
|
+
"recovery",
|
|
37
|
+
"verification_check_keys",
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
rollback: string(row.rollback, `${label}.rollback`),
|
|
41
|
+
recovery: string(row.recovery, `${label}.recovery`),
|
|
42
|
+
verification_check_keys: strings(row.verification_check_keys, `${label}.verification_check_keys`),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VerifierContentAuthority, VerifierIdentityV2, VerifierRuntimeLocator } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface VerifierAuthorityDiffV2 {
|
|
3
|
+
verifier_content_changed: boolean;
|
|
4
|
+
verifier_runtime_locator_changed: boolean;
|
|
5
|
+
verifier_files_changed: string[];
|
|
6
|
+
previous_verifier: VerifierIdentityV2;
|
|
7
|
+
next_verifier: VerifierIdentityV2;
|
|
8
|
+
}
|
|
9
|
+
export declare function verifierContentAuthority(identity: VerifierIdentityV2): VerifierContentAuthority;
|
|
10
|
+
export declare function verifierRuntimeLocator(identity: VerifierIdentityV2): VerifierRuntimeLocator;
|
|
11
|
+
export declare function verifierAuthorityDiff(previous: VerifierIdentityV2, next: VerifierIdentityV2): VerifierAuthorityDiffV2;
|
|
12
|
+
export declare function verifierIdentityMatches(previous: VerifierIdentityV2, next: VerifierIdentityV2): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
2
|
+
export function verifierContentAuthority(identity) {
|
|
3
|
+
return {
|
|
4
|
+
package_name: identity.package_name,
|
|
5
|
+
bundle_sha256: identity.bundle_sha256,
|
|
6
|
+
schema_sha256: identity.schema_sha256,
|
|
7
|
+
hook_sha256: identity.hook_sha256,
|
|
8
|
+
bundle_files: identity.bundle_files,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function verifierRuntimeLocator(identity) {
|
|
12
|
+
return {
|
|
13
|
+
package_version: identity.package_version,
|
|
14
|
+
package_root: identity.package_root,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function verifierAuthorityDiff(previous, next) {
|
|
18
|
+
const contentChanged = canonicalValueJson(verifierContentAuthority(previous)) !==
|
|
19
|
+
canonicalValueJson(verifierContentAuthority(next));
|
|
20
|
+
const locatorChanged = canonicalValueJson(verifierRuntimeLocator(previous)) !==
|
|
21
|
+
canonicalValueJson(verifierRuntimeLocator(next));
|
|
22
|
+
return {
|
|
23
|
+
verifier_content_changed: contentChanged,
|
|
24
|
+
verifier_runtime_locator_changed: locatorChanged,
|
|
25
|
+
verifier_files_changed: changedVerifierFiles(previous, next),
|
|
26
|
+
previous_verifier: previous,
|
|
27
|
+
next_verifier: next,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function verifierIdentityMatches(previous, next) {
|
|
31
|
+
const diff = verifierAuthorityDiff(previous, next);
|
|
32
|
+
return (!diff.verifier_content_changed && !diff.verifier_runtime_locator_changed);
|
|
33
|
+
}
|
|
34
|
+
function changedVerifierFiles(previous, next) {
|
|
35
|
+
const files = new Set([
|
|
36
|
+
...Object.keys(previous.bundle_files),
|
|
37
|
+
...Object.keys(next.bundle_files),
|
|
38
|
+
]);
|
|
39
|
+
const changed = [...files].filter((file) => previous.bundle_files[file] !== next.bundle_files[file]);
|
|
40
|
+
if (previous.schema_sha256 !== next.schema_sha256)
|
|
41
|
+
changed.push("<schema>");
|
|
42
|
+
if (previous.hook_sha256 !== next.hook_sha256)
|
|
43
|
+
changed.push("<hook>");
|
|
44
|
+
if (previous.package_name !== next.package_name)
|
|
45
|
+
changed.push("<package-name>");
|
|
46
|
+
return [...new Set(changed)].sort();
|
|
47
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import DELIVERY_SCHEMA from "../schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json" with { type: "json" };
|
|
5
|
+
import OUTCOMES_SCHEMA from "../schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json" with { type: "json" };
|
|
6
|
+
import { checkLongTaskCompletionGate } from "./long-task-hook-preflight.js";
|
|
7
|
+
import { assertProtectedRepositoryFile } from "./long-task-protected-files.js";
|
|
8
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
9
|
+
const REQUIRED_ENTRYPOINTS = [
|
|
10
|
+
"cli.js",
|
|
11
|
+
"long-task-hook.js",
|
|
12
|
+
"commands/long-task.js",
|
|
13
|
+
"commands/delivery-set.js",
|
|
14
|
+
"lib/context-graph-snapshot.js",
|
|
15
|
+
"lib/strict-codec.js",
|
|
16
|
+
];
|
|
17
|
+
export async function captureVerifierIdentity(repositoryRoot, requireHook) {
|
|
18
|
+
const packageRoot = fileURLToPath(new URL("../../", import.meta.url));
|
|
19
|
+
const packageFile = await assertProtectedRepositoryFile(packageRoot, path.join(packageRoot, "package.json"), "package_owned_verifier_package");
|
|
20
|
+
const packageJson = JSON.parse(await readFile(packageFile, "utf8"));
|
|
21
|
+
const files = await verifierBundleFiles(packageRoot);
|
|
22
|
+
const hook = requireHook
|
|
23
|
+
? await checkLongTaskCompletionGate(repositoryRoot, packageRoot)
|
|
24
|
+
: null;
|
|
25
|
+
if (hook && hook.status !== "available")
|
|
26
|
+
throw new Error(`completion_gate_unavailable:${hook.findings.join(",")}`);
|
|
27
|
+
return {
|
|
28
|
+
package_name: "project-tiny-context-harness",
|
|
29
|
+
package_version: packageJson.version,
|
|
30
|
+
package_root: packageRoot,
|
|
31
|
+
bundle_sha256: sha256Hex(canonicalValueJson(files)),
|
|
32
|
+
bundle_files: files,
|
|
33
|
+
schema_sha256: sha256Hex(canonicalValueJson({
|
|
34
|
+
delivery: DELIVERY_SCHEMA,
|
|
35
|
+
outcomes: OUTCOMES_SCHEMA,
|
|
36
|
+
})),
|
|
37
|
+
hook_sha256: hook?.hook_sha256 ?? "not-required",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function verifierBundleFiles(packageRoot) {
|
|
41
|
+
const distRoot = path.join(packageRoot, "dist");
|
|
42
|
+
const relativeFiles = new Set(REQUIRED_ENTRYPOINTS);
|
|
43
|
+
for (const file of await readdir(path.join(distRoot, "lib")))
|
|
44
|
+
if (/^long-task-.*\.js$/u.test(file))
|
|
45
|
+
relativeFiles.add(`lib/${file}`);
|
|
46
|
+
relativeFiles.add("schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json");
|
|
47
|
+
relativeFiles.add("schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json");
|
|
48
|
+
const rows = await Promise.all([...relativeFiles]
|
|
49
|
+
.sort()
|
|
50
|
+
.map(async (relative) => [
|
|
51
|
+
relative,
|
|
52
|
+
sha256Hex(await readFile(await assertProtectedRepositoryFile(packageRoot, path.join(distRoot, ...relative.split("/")), `package_owned_verifier:${relative}`))),
|
|
53
|
+
]));
|
|
54
|
+
return Object.fromEntries(rows);
|
|
55
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CheckExecutionResultV2, CompiledCheckV2, CompiledDeliveryContractV2, LongTaskFindingV2, TargetedVerificationResultV2, WorkspaceManifestV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import { type WorkspaceSnapshotV2 } from "./long-task-workspace.js";
|
|
3
|
+
export interface DeliveryRunV2 {
|
|
4
|
+
snapshot: WorkspaceManifestV2;
|
|
5
|
+
check_results: CheckExecutionResultV2[];
|
|
6
|
+
findings: LongTaskFindingV2[];
|
|
7
|
+
}
|
|
8
|
+
export declare function verifyDeliveryContract(workdir: string, selection?: {
|
|
9
|
+
outcome?: string;
|
|
10
|
+
check?: string;
|
|
11
|
+
}): Promise<TargetedVerificationResultV2>;
|
|
12
|
+
export declare function runDeliveryChecks(compiled: CompiledDeliveryContractV2, snapshot: WorkspaceSnapshotV2, checks: CompiledCheckV2[], includeCounterfactuals: boolean, finalGate?: boolean): Promise<DeliveryRunV2>;
|
|
13
|
+
export declare function allCompiledChecks(compiled: CompiledDeliveryContractV2): CompiledCheckV2[];
|