project-tiny-context-harness 0.2.84 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -428
- package/assets/README.md +283 -455
- package/assets/README.zh-CN.md +199 -123
- package/assets/agents/AGENTS_CORE.md +54 -67
- package/assets/context_templates/context.toml +3 -0
- package/assets/context_templates/global.md +6 -6
- package/assets/github/harness.yml +2 -2
- package/assets/skills/context_development_engineer/SKILL.md +91 -107
- package/assets/skills/context_product_plan/SKILL.md +18 -28
- package/assets/skills/context_surface_contract/SKILL.md +35 -38
- package/assets/skills/context_uiux_design/SKILL.md +31 -30
- package/assets/skills/long-task-workflow/SKILL.md +76 -0
- package/assets/skills/long-task-workflow/agents/openai.yaml +4 -0
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +41 -0
- package/assets/skills/long-task-workflow/references/contract-authoring.md +62 -0
- package/assets/skills/long-task-workflow/references/evidence-design.md +45 -0
- package/assets/skills/normal-long-task/SKILL.md +12 -489
- package/assets/skills/source-plan-authoring/SKILL.md +379 -0
- package/assets/tools/validate_context.py +293 -127
- package/dist/cli.js +3 -1
- package/dist/commands/check-modularity.js +33 -10
- package/dist/commands/composite-campaign.d.ts +1 -0
- package/dist/commands/composite-campaign.js +8 -0
- package/dist/commands/composite-long-task.d.ts +1 -6
- package/dist/commands/composite-long-task.js +7 -157
- package/dist/commands/delivery-set.d.ts +1 -0
- package/dist/commands/delivery-set.js +8 -0
- package/dist/commands/disable.d.ts +1 -0
- package/dist/commands/disable.js +15 -0
- package/dist/commands/enable.d.ts +1 -0
- package/dist/commands/enable.js +14 -0
- package/dist/commands/export-context-args.js +13 -4
- package/dist/commands/export-context.js +18 -7
- package/dist/commands/index.js +42 -30
- package/dist/commands/init.js +12 -6
- package/dist/commands/long-task-authoring.d.ts +3 -0
- package/dist/commands/long-task-authoring.js +92 -0
- package/dist/commands/long-task-explain.d.ts +1 -0
- package/dist/commands/long-task-explain.js +52 -0
- package/dist/commands/long-task.d.ts +1 -0
- package/dist/commands/long-task.js +226 -0
- package/dist/commands/package-source.js +2 -2
- package/dist/commands/upgrade.js +10 -10
- package/dist/index.d.ts +11 -1
- package/dist/index.js +8 -0
- package/dist/lib/config.js +34 -8
- package/dist/lib/context-default-footprint.d.ts +16 -0
- package/dist/lib/context-default-footprint.js +107 -0
- package/dist/lib/context-export.js +105 -41
- package/dist/lib/context-graph-snapshot.d.ts +18 -0
- package/dist/lib/context-graph-snapshot.js +171 -0
- package/dist/lib/context-manifest-schema.d.ts +28 -0
- package/dist/lib/context-manifest-schema.js +150 -0
- package/dist/lib/context-manifest.js +28 -20
- package/dist/lib/context-templates.js +5 -5
- package/dist/lib/design-md.js +1 -1
- package/dist/lib/doctor.js +54 -1
- package/dist/lib/harness-root.js +25 -8
- package/dist/lib/init.js +6 -3
- package/dist/lib/legacy-managed-scan.js +23 -7
- package/dist/lib/legacy-sdlc-migration.js +21 -11
- package/dist/lib/long-task-acceptance-reference.d.ts +22 -0
- package/dist/lib/long-task-acceptance-reference.js +46 -0
- package/dist/lib/long-task-acceptance-shape.d.ts +5 -0
- package/dist/lib/long-task-acceptance-shape.js +131 -0
- package/dist/lib/long-task-activation-validation.d.ts +21 -0
- package/dist/lib/long-task-activation-validation.js +136 -0
- package/dist/lib/long-task-artifacts.d.ts +5 -0
- package/dist/lib/long-task-artifacts.js +34 -0
- package/dist/lib/long-task-assertions-v2.d.ts +22 -0
- package/dist/lib/long-task-assertions-v2.js +212 -0
- package/dist/lib/long-task-authoring-authority-preview.d.ts +5 -0
- package/dist/lib/long-task-authoring-authority-preview.js +85 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.d.ts +8 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.js +179 -0
- package/dist/lib/long-task-authoring-preflight-repair-order.d.ts +8 -0
- package/dist/lib/long-task-authoring-preflight-repair-order.js +95 -0
- package/dist/lib/long-task-authoring-preflight-types.d.ts +46 -0
- package/dist/lib/long-task-authoring-preflight-types.js +38 -0
- package/dist/lib/long-task-authoring-preflight.d.ts +3 -0
- package/dist/lib/long-task-authoring-preflight.js +44 -0
- package/dist/lib/long-task-authority-material-diff.d.ts +17 -0
- package/dist/lib/long-task-authority-material-diff.js +152 -0
- package/dist/lib/long-task-authority-materials.d.ts +7 -0
- package/dist/lib/long-task-authority-materials.js +83 -0
- package/dist/lib/long-task-authority-policy.d.ts +168 -0
- package/dist/lib/long-task-authority-policy.js +181 -0
- package/dist/lib/long-task-authority-revision-details.d.ts +19 -0
- package/dist/lib/long-task-authority-revision-details.js +192 -0
- package/dist/lib/long-task-authority-revision-enforcement.d.ts +3 -0
- package/dist/lib/long-task-authority-revision-enforcement.js +41 -0
- package/dist/lib/long-task-authority-revision-types.d.ts +50 -0
- package/dist/lib/long-task-authority-revision-types.js +1 -0
- package/dist/lib/long-task-authority-revision.d.ts +4 -0
- package/dist/lib/long-task-authority-revision.js +188 -0
- package/dist/lib/long-task-authority-transition-policy.d.ts +62 -0
- package/dist/lib/long-task-authority-transition-policy.js +62 -0
- package/dist/lib/long-task-authority-types.d.ts +96 -0
- package/dist/lib/long-task-authority-types.js +1 -0
- package/dist/lib/long-task-authority.d.ts +7 -0
- package/dist/lib/long-task-authority.js +142 -0
- package/dist/lib/long-task-boundary-check.d.ts +15 -0
- package/dist/lib/long-task-boundary-check.js +9 -0
- package/dist/lib/long-task-check-evidence-decoder.d.ts +3 -0
- package/dist/lib/long-task-check-evidence-decoder.js +74 -0
- package/dist/lib/long-task-check-execution-policy.d.ts +18 -0
- package/dist/lib/long-task-check-execution-policy.js +36 -0
- package/dist/lib/long-task-check-runner.d.ts +2 -0
- package/dist/lib/long-task-check-runner.js +181 -0
- package/dist/lib/long-task-check-shape.d.ts +2 -0
- package/dist/lib/long-task-check-shape.js +136 -0
- package/dist/lib/long-task-claim-definitions.d.ts +7 -0
- package/dist/lib/long-task-claim-definitions.js +78 -0
- package/dist/lib/long-task-claim-proof-policy.d.ts +4 -0
- package/dist/lib/long-task-claim-proof-policy.js +57 -0
- package/dist/lib/long-task-claims.d.ts +10 -0
- package/dist/lib/long-task-claims.js +187 -0
- package/dist/lib/long-task-context-authority-topology.d.ts +7 -0
- package/dist/lib/long-task-context-authority-topology.js +37 -0
- package/dist/lib/long-task-context-authority.d.ts +14 -0
- package/dist/lib/long-task-context-authority.js +66 -0
- package/dist/lib/long-task-contract-types.d.ts +203 -0
- package/dist/lib/long-task-contract-types.js +1 -0
- package/dist/lib/long-task-counterfactual-claim-policy.d.ts +10 -0
- package/dist/lib/long-task-counterfactual-claim-policy.js +57 -0
- package/dist/lib/long-task-counterfactual-sandbox.d.ts +6 -0
- package/dist/lib/long-task-counterfactual-sandbox.js +87 -0
- package/dist/lib/long-task-counterfactual-types.d.ts +24 -0
- package/dist/lib/long-task-counterfactual-types.js +1 -0
- package/dist/lib/long-task-delivery-compiler.d.ts +10 -0
- package/dist/lib/long-task-delivery-compiler.js +129 -0
- package/dist/lib/long-task-delivery-parser.d.ts +13 -0
- package/dist/lib/long-task-delivery-parser.js +90 -0
- package/dist/lib/long-task-delivery-preflight.d.ts +5 -0
- package/dist/lib/long-task-delivery-preflight.js +151 -0
- package/dist/lib/long-task-delivery-shape.d.ts +5 -0
- package/dist/lib/long-task-delivery-shape.js +5 -0
- package/dist/lib/long-task-delivery-types.d.ts +8 -0
- package/dist/lib/long-task-delivery-types.js +8 -0
- package/dist/lib/long-task-delivery-validation.d.ts +3 -0
- package/dist/lib/long-task-delivery-validation.js +175 -0
- package/dist/lib/long-task-evidence-adapter-policy.d.ts +4 -0
- package/dist/lib/long-task-evidence-adapter-policy.js +15 -0
- package/dist/lib/long-task-evidence-adapter-types.d.ts +1 -0
- package/dist/lib/long-task-evidence-adapter-types.js +1 -0
- package/dist/lib/long-task-evidence-findings.d.ts +5 -0
- package/dist/lib/long-task-evidence-findings.js +113 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +4 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.js +98 -0
- package/dist/lib/long-task-evidence-v2.d.ts +5 -0
- package/dist/lib/long-task-evidence-v2.js +226 -0
- package/dist/lib/long-task-explain-acceptance-link.d.ts +46 -0
- package/dist/lib/long-task-explain-acceptance-link.js +96 -0
- package/dist/lib/long-task-explain-claim-links.d.ts +45 -0
- package/dist/lib/long-task-explain-claim-links.js +88 -0
- package/dist/lib/long-task-explain-source-links.d.ts +93 -0
- package/dist/lib/long-task-explain-source-links.js +51 -0
- package/dist/lib/long-task-final-v2.d.ts +2 -0
- package/dist/lib/long-task-final-v2.js +124 -0
- package/dist/lib/long-task-finding-context.d.ts +3 -0
- package/dist/lib/long-task-finding-context.js +63 -0
- package/dist/lib/long-task-freshness.d.ts +3 -0
- package/dist/lib/long-task-freshness.js +80 -0
- package/dist/lib/long-task-hook-install.d.ts +9 -0
- package/dist/lib/long-task-hook-install.js +184 -0
- package/dist/lib/long-task-hook-preflight.d.ts +7 -0
- package/dist/lib/long-task-hook-preflight.js +58 -0
- package/dist/lib/long-task-observation-ownership.d.ts +2 -0
- package/dist/lib/long-task-observation-ownership.js +22 -0
- package/dist/lib/long-task-outcome-parser.d.ts +4 -0
- package/dist/lib/long-task-outcome-parser.js +100 -0
- package/dist/lib/long-task-paths.d.ts +49 -0
- package/dist/lib/long-task-paths.js +418 -0
- package/dist/lib/long-task-playwright-counterfactual-policy.d.ts +7 -0
- package/dist/lib/long-task-playwright-counterfactual-policy.js +125 -0
- package/dist/lib/long-task-playwright-evidence.d.ts +6 -0
- package/dist/lib/long-task-playwright-evidence.js +244 -0
- package/dist/lib/long-task-product-shape.d.ts +6 -0
- package/dist/lib/long-task-product-shape.js +73 -0
- package/dist/lib/long-task-progress.d.ts +4 -0
- package/dist/lib/long-task-progress.js +114 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -0
- package/dist/lib/long-task-protected-files.js +30 -0
- package/dist/lib/long-task-required-proof-surfaces.d.ts +2 -0
- package/dist/lib/long-task-required-proof-surfaces.js +13 -0
- package/dist/lib/long-task-requirement-shape.d.ts +2 -0
- package/dist/lib/long-task-requirement-shape.js +18 -0
- package/dist/lib/long-task-risk-surfaces.d.ts +2 -0
- package/dist/lib/long-task-risk-surfaces.js +60 -0
- package/dist/lib/long-task-risk-types.d.ts +5 -0
- package/dist/lib/long-task-risk-types.js +12 -0
- package/dist/lib/long-task-risk.d.ts +9 -0
- package/dist/lib/long-task-risk.js +132 -0
- package/dist/lib/long-task-root-shape.d.ts +4 -0
- package/dist/lib/long-task-root-shape.js +86 -0
- package/dist/lib/long-task-runner-environment.d.ts +7 -0
- package/dist/lib/long-task-runner-environment.js +57 -0
- package/dist/lib/long-task-runner-files.d.ts +3 -0
- package/dist/lib/long-task-runner-files.js +39 -0
- package/dist/lib/long-task-runner-freeze.d.ts +2 -0
- package/dist/lib/long-task-runner-freeze.js +168 -0
- package/dist/lib/long-task-runtime-types.d.ts +214 -0
- package/dist/lib/long-task-runtime-types.js +1 -0
- package/dist/lib/long-task-shape-primitives.d.ts +17 -0
- package/dist/lib/long-task-shape-primitives.js +81 -0
- package/dist/lib/long-task-source-authority-types.d.ts +13 -0
- package/dist/lib/long-task-source-authority-types.js +1 -0
- package/dist/lib/long-task-source-claim-validation.d.ts +5 -0
- package/dist/lib/long-task-source-claim-validation.js +96 -0
- package/dist/lib/long-task-source-continuity.d.ts +4 -0
- package/dist/lib/long-task-source-continuity.js +57 -0
- package/dist/lib/long-task-source-inventory.d.ts +2 -0
- package/dist/lib/long-task-source-inventory.js +21 -0
- package/dist/lib/long-task-source-item-parser.d.ts +3 -0
- package/dist/lib/long-task-source-item-parser.js +112 -0
- package/dist/lib/long-task-source-shape.d.ts +2 -0
- package/dist/lib/long-task-source-shape.js +56 -0
- package/dist/lib/long-task-source-target-continuity.d.ts +4 -0
- package/dist/lib/long-task-source-target-continuity.js +80 -0
- package/dist/lib/long-task-source-target-index.d.ts +12 -0
- package/dist/lib/long-task-source-target-index.js +76 -0
- package/dist/lib/long-task-source-validation.d.ts +3 -0
- package/dist/lib/long-task-source-validation.js +46 -0
- package/dist/lib/long-task-state.d.ts +91 -0
- package/dist/lib/long-task-state.js +611 -0
- package/dist/lib/long-task-status-projection.d.ts +21 -0
- package/dist/lib/long-task-status-projection.js +116 -0
- package/dist/lib/long-task-status-v2.d.ts +37 -0
- package/dist/lib/long-task-status-v2.js +306 -0
- package/dist/lib/long-task-technical-shape.d.ts +3 -0
- package/dist/lib/long-task-technical-shape.js +44 -0
- package/dist/lib/long-task-verifier-authority.d.ts +12 -0
- package/dist/lib/long-task-verifier-authority.js +47 -0
- package/dist/lib/long-task-verifier-identity.d.ts +2 -0
- package/dist/lib/long-task-verifier-identity.js +55 -0
- package/dist/lib/long-task-verifier-v2.d.ts +13 -0
- package/dist/lib/long-task-verifier-v2.js +266 -0
- package/dist/lib/long-task-workspace-runtime-types.d.ts +23 -0
- package/dist/lib/long-task-workspace-runtime-types.js +1 -0
- package/dist/lib/long-task-workspace.d.ts +25 -0
- package/dist/lib/long-task-workspace.js +366 -0
- package/dist/lib/managed-file.js +20 -5
- package/dist/lib/migrations.js +156 -32
- package/dist/lib/modularity.d.ts +27 -1
- package/dist/lib/modularity.js +499 -23
- package/dist/lib/package-json-config.js +14 -5
- package/dist/lib/package-source.js +15 -3
- package/dist/lib/profiles.d.ts +13 -0
- package/dist/lib/profiles.js +66 -0
- package/dist/lib/schema-guard.js +4 -2
- package/dist/lib/source-files.js +14 -7
- package/dist/lib/source-pack-classify.js +91 -19
- package/dist/lib/source-pack-config.js +25 -8
- package/dist/lib/source-pack-export.js +84 -25
- package/dist/lib/source-pack-manifest.js +18 -6
- package/dist/lib/source-pack-records.js +35 -11
- package/dist/lib/source-pack-render.js +47 -18
- package/dist/lib/stable-json.d.ts +2 -0
- package/dist/lib/stable-json.js +21 -0
- package/dist/lib/strict-codec.d.ts +4 -0
- package/dist/lib/strict-codec.js +65 -0
- package/dist/lib/sync-engine.js +76 -24
- package/dist/lib/types.d.ts +8 -1
- package/dist/lib/upgrade.js +4 -3
- package/dist/lib/validators.js +218 -191
- package/dist/long-task-hook.d.ts +2 -0
- package/dist/long-task-hook.js +55 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +340 -0
- package/dist/schemas/long-task-delivery-v2/long-task-outcomes-v2.schema.json +18 -0
- package/migrations/README.md +8 -3
- package/package.json +17 -6
- package/source-mappings.yaml +0 -3
- package/assets/protected-harness-baseline.json +0 -20
- package/assets/skills/composite-long-task-workflow/SKILL.md +0 -244
- package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +0 -57
- package/assets/skills/composite-long-task-workflow/assets/goal-objective.template.md +0 -17
- package/assets/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md +0 -675
- package/dist/commands/superpowers.d.ts +0 -1
- package/dist/commands/superpowers.js +0 -8
- package/dist/lib/composite-long-task-renderer.d.ts +0 -12
- package/dist/lib/composite-long-task-renderer.js +0 -109
- package/dist/lib/plan-acceptance-artifacts.d.ts +0 -1
- package/dist/lib/plan-acceptance-artifacts.js +0 -220
- package/dist/lib/plan-acceptance-evidence.d.ts +0 -2
- package/dist/lib/plan-acceptance-evidence.js +0 -108
- package/dist/lib/plan-acceptance-json.d.ts +0 -15
- package/dist/lib/plan-acceptance-json.js +0 -133
- package/dist/lib/plan-acceptance-validator.d.ts +0 -2
- package/dist/lib/plan-acceptance-validator.js +0 -209
- package/dist/lib/plan-contract-validator.d.ts +0 -2
- package/dist/lib/plan-contract-validator.js +0 -127
- package/dist/lib/plan-validator-common.d.ts +0 -24
- package/dist/lib/plan-validator-common.js +0 -196
- package/dist/lib/superpowers-task-ac010.d.ts +0 -6
- package/dist/lib/superpowers-task-ac010.js +0 -26
- package/dist/lib/superpowers-task-assertion-normalizers.d.ts +0 -3
- package/dist/lib/superpowers-task-assertion-normalizers.js +0 -74
- package/dist/lib/superpowers-task-assertions.d.ts +0 -20
- package/dist/lib/superpowers-task-assertions.js +0 -257
- package/dist/lib/superpowers-task-attempt.d.ts +0 -4
- package/dist/lib/superpowers-task-attempt.js +0 -102
- package/dist/lib/superpowers-task-command-run-correlation.d.ts +0 -8
- package/dist/lib/superpowers-task-command-run-correlation.js +0 -103
- package/dist/lib/superpowers-task-command-specs.d.ts +0 -3
- package/dist/lib/superpowers-task-command-specs.js +0 -52
- package/dist/lib/superpowers-task-compile-diagnostics.d.ts +0 -5
- package/dist/lib/superpowers-task-compile-diagnostics.js +0 -20
- package/dist/lib/superpowers-task-compile-guards.d.ts +0 -2
- package/dist/lib/superpowers-task-compile-guards.js +0 -66
- package/dist/lib/superpowers-task-compile.d.ts +0 -6
- package/dist/lib/superpowers-task-compile.js +0 -133
- package/dist/lib/superpowers-task-completion-output.d.ts +0 -52
- package/dist/lib/superpowers-task-completion-output.js +0 -228
- package/dist/lib/superpowers-task-conformance.d.ts +0 -2
- package/dist/lib/superpowers-task-conformance.js +0 -24
- package/dist/lib/superpowers-task-contradictions.d.ts +0 -6
- package/dist/lib/superpowers-task-contradictions.js +0 -126
- package/dist/lib/superpowers-task-current-evidence.d.ts +0 -3
- package/dist/lib/superpowers-task-current-evidence.js +0 -176
- package/dist/lib/superpowers-task-delivery.d.ts +0 -4
- package/dist/lib/superpowers-task-delivery.js +0 -96
- package/dist/lib/superpowers-task-derive.d.ts +0 -14
- package/dist/lib/superpowers-task-derive.js +0 -382
- package/dist/lib/superpowers-task-events.d.ts +0 -1
- package/dist/lib/superpowers-task-events.js +0 -13
- package/dist/lib/superpowers-task-evidence-kernel.d.ts +0 -19
- package/dist/lib/superpowers-task-evidence-kernel.js +0 -347
- package/dist/lib/superpowers-task-evidence-records.d.ts +0 -2
- package/dist/lib/superpowers-task-evidence-records.js +0 -55
- package/dist/lib/superpowers-task-evidence.d.ts +0 -10
- package/dist/lib/superpowers-task-evidence.js +0 -147
- package/dist/lib/superpowers-task-fields.d.ts +0 -22
- package/dist/lib/superpowers-task-fields.js +0 -276
- package/dist/lib/superpowers-task-final-card.d.ts +0 -3
- package/dist/lib/superpowers-task-final-card.js +0 -24
- package/dist/lib/superpowers-task-gates.d.ts +0 -12
- package/dist/lib/superpowers-task-gates.js +0 -155
- package/dist/lib/superpowers-task-harness-drift.d.ts +0 -11
- package/dist/lib/superpowers-task-harness-drift.js +0 -90
- package/dist/lib/superpowers-task-next-slices.d.ts +0 -1
- package/dist/lib/superpowers-task-next-slices.js +0 -12
- package/dist/lib/superpowers-task-protected-baseline.d.ts +0 -10
- package/dist/lib/superpowers-task-protected-baseline.js +0 -66
- package/dist/lib/superpowers-task-source-compile.d.ts +0 -5
- package/dist/lib/superpowers-task-source-compile.js +0 -226
- package/dist/lib/superpowers-task-source-parser.d.ts +0 -23
- package/dist/lib/superpowers-task-source-parser.js +0 -218
- package/dist/lib/superpowers-task-state-schema.d.ts +0 -440
- package/dist/lib/superpowers-task-state-schema.js +0 -66
- package/dist/lib/superpowers-task-state-shape.d.ts +0 -3
- package/dist/lib/superpowers-task-state-shape.js +0 -50
- package/dist/lib/superpowers-task-state.d.ts +0 -16
- package/dist/lib/superpowers-task-state.js +0 -246
- package/dist/lib/superpowers-task-status.d.ts +0 -2
- package/dist/lib/superpowers-task-status.js +0 -24
- package/dist/lib/superpowers-task-under-specified.d.ts +0 -7
- package/dist/lib/superpowers-task-under-specified.js +0 -61
- package/dist/lib/superpowers-task-unregistered-evidence.d.ts +0 -11
- package/dist/lib/superpowers-task-unregistered-evidence.js +0 -72
- package/dist/lib/superpowers-task-validator.d.ts +0 -5
- package/dist/lib/superpowers-task-validator.js +0 -290
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { computeAuthorityHashes } from "./long-task-authority.js";
|
|
2
|
+
import { computeAuthorityMaterials, compiledAuthorityMaterials, } from "./long-task-authority-materials.js";
|
|
3
|
+
import { addDiagnosticError } from "./long-task-authoring-preflight-diagnostics.js";
|
|
4
|
+
import { loadActiveLongTaskAuthority, } from "./long-task-state.js";
|
|
5
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
6
|
+
export async function loadAuthoringActiveAuthority(repository, workdir, diagnostics) {
|
|
7
|
+
try {
|
|
8
|
+
const active = (await loadActiveLongTaskAuthority(repository)).authority;
|
|
9
|
+
if (active && active.workdir !== workdir)
|
|
10
|
+
diagnostics.push({
|
|
11
|
+
level: "error",
|
|
12
|
+
code: "active_task_exists",
|
|
13
|
+
message: `Another workdir owns Active Authority: ${active.workdir}`,
|
|
14
|
+
});
|
|
15
|
+
return active;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
addDiagnosticError(diagnostics, error);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function authoringRevisionPreview(contract, sourceHashes, sourceItems, context, active) {
|
|
23
|
+
if (!active)
|
|
24
|
+
return {
|
|
25
|
+
active: false,
|
|
26
|
+
authority_revision: null,
|
|
27
|
+
contract_changed: false,
|
|
28
|
+
source_or_context_changed: false,
|
|
29
|
+
declared_authority_sections_changed: [],
|
|
30
|
+
};
|
|
31
|
+
const hashes = computeAuthorityHashes(contract);
|
|
32
|
+
const previousDeclaredHashes = computeAuthorityHashes({
|
|
33
|
+
schema_version: "long-task-delivery-v2",
|
|
34
|
+
task: active.authority_snapshot.task,
|
|
35
|
+
source_claims: active.authority_snapshot.source_claims,
|
|
36
|
+
risk: active.authority_snapshot.risk,
|
|
37
|
+
global: active.authority_snapshot.global,
|
|
38
|
+
outcomes: active.authority_snapshot.outcomes,
|
|
39
|
+
});
|
|
40
|
+
const declaredChanged = new Set(Object.keys(hashes)
|
|
41
|
+
.filter((key) => hashes[key] !== previousDeclaredHashes[key])
|
|
42
|
+
.map((key) => key.replace(/_authority_hash$/u, "")));
|
|
43
|
+
let sourceChanged = false;
|
|
44
|
+
let contextChanged = false;
|
|
45
|
+
if (sourceHashes && sourceItems && context) {
|
|
46
|
+
const next = computeAuthorityMaterials(contract, sourceHashes, sourceItems, context);
|
|
47
|
+
const previous = compiledAuthorityMaterials(active.authority_snapshot);
|
|
48
|
+
sourceChanged =
|
|
49
|
+
canonicalValueJson({
|
|
50
|
+
source_hashes: next.source_hashes,
|
|
51
|
+
source_items: next.source_items,
|
|
52
|
+
}) !==
|
|
53
|
+
canonicalValueJson({
|
|
54
|
+
source_hashes: previous.source_hashes,
|
|
55
|
+
source_items: previous.source_items,
|
|
56
|
+
});
|
|
57
|
+
contextChanged =
|
|
58
|
+
canonicalValueJson({
|
|
59
|
+
context_snapshot: next.context_snapshot,
|
|
60
|
+
}) !==
|
|
61
|
+
canonicalValueJson({
|
|
62
|
+
context_snapshot: previous.context_snapshot,
|
|
63
|
+
});
|
|
64
|
+
if (sourceChanged)
|
|
65
|
+
declaredChanged.add("source");
|
|
66
|
+
if (contextChanged)
|
|
67
|
+
declaredChanged.add("context");
|
|
68
|
+
}
|
|
69
|
+
const sectionOrder = [
|
|
70
|
+
"source",
|
|
71
|
+
"product",
|
|
72
|
+
"technical",
|
|
73
|
+
"acceptance",
|
|
74
|
+
"risk",
|
|
75
|
+
"context",
|
|
76
|
+
];
|
|
77
|
+
return {
|
|
78
|
+
active: true,
|
|
79
|
+
authority_revision: active.authority_revision,
|
|
80
|
+
contract_changed: sha256Hex(canonicalValueJson(contract)) !==
|
|
81
|
+
active.authority_snapshot.contract_sha256,
|
|
82
|
+
source_or_context_changed: sourceChanged || contextChanged,
|
|
83
|
+
declared_authority_sections_changed: sectionOrder.filter((section) => declaredChanged.has(section)),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ParsedDeliveryContractV2 } from "./long-task-delivery-parser.js";
|
|
2
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
3
|
+
import type { AuthoringPreflightDiagnosticV1, SourceCoverageV1 } from "./long-task-authoring-preflight-types.js";
|
|
4
|
+
export declare function addAuthoringDiagnostics(contract: DeliveryContractV2, parsed: ParsedDeliveryContractV2, diagnostics: AuthoringPreflightDiagnosticV1[]): void;
|
|
5
|
+
export declare function sourceCoverage(contract: DeliveryContractV2): SourceCoverageV1;
|
|
6
|
+
export declare function captureDiagnostic(diagnostics: AuthoringPreflightDiagnosticV1[], action: () => Promise<unknown>): Promise<void>;
|
|
7
|
+
export declare function addDiagnosticError(diagnostics: AuthoringPreflightDiagnosticV1[], error: unknown, outcomeKey?: string | null, checkKey?: string): void;
|
|
8
|
+
export declare function normalizeAuthoringDiagnostics(diagnostics: AuthoringPreflightDiagnosticV1[]): AuthoringPreflightDiagnosticV1[];
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { applyDiagnosticRepairOrder } from "./long-task-authoring-preflight-repair-order.js";
|
|
2
|
+
export function addAuthoringDiagnostics(contract, parsed, diagnostics) {
|
|
3
|
+
if (parsed.outcome_files.length)
|
|
4
|
+
diagnostics.push({
|
|
5
|
+
level: "warning",
|
|
6
|
+
code: "outcome_files_compatibility_only",
|
|
7
|
+
message: "outcome_files is supported only as physical compatibility; new authoring should use inline Outcomes.",
|
|
8
|
+
repair_hint: "Keep compatibility files only when required; use inline Outcomes for new authoring.",
|
|
9
|
+
});
|
|
10
|
+
for (const claim of contract.source_claims)
|
|
11
|
+
if (claim.disposition.type === "decision_required")
|
|
12
|
+
diagnostics.push({
|
|
13
|
+
level: "decision_required",
|
|
14
|
+
code: "source_claim_decision_required",
|
|
15
|
+
message: `${claim.key}: ${claim.disposition.reason}`,
|
|
16
|
+
refs: [claim.key],
|
|
17
|
+
repair_hint: "Resolve this product decision from the user or an authoritative Source before Compile; do not infer it from implementation convenience.",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function sourceCoverage(contract) {
|
|
21
|
+
const counts = {
|
|
22
|
+
claim: 0,
|
|
23
|
+
acceptance: 0,
|
|
24
|
+
outcome_result: 0,
|
|
25
|
+
global_constraint: 0,
|
|
26
|
+
risk_fact: 0,
|
|
27
|
+
external_confirmation: 0,
|
|
28
|
+
decision_required: 0,
|
|
29
|
+
};
|
|
30
|
+
for (const item of contract.source_claims)
|
|
31
|
+
counts[item.disposition.type] += 1;
|
|
32
|
+
return {
|
|
33
|
+
total: contract.source_claims.length,
|
|
34
|
+
resolved: contract.source_claims.length - counts.decision_required,
|
|
35
|
+
mapped_to_product_claims: counts.claim,
|
|
36
|
+
mapped_to_acceptance: counts.acceptance,
|
|
37
|
+
mapped_to_outcome_results: counts.outcome_result,
|
|
38
|
+
mapped_to_global_constraints: counts.global_constraint,
|
|
39
|
+
mapped_to_risk_facts: counts.risk_fact,
|
|
40
|
+
mapped_to_external_confirmations: counts.external_confirmation,
|
|
41
|
+
decision_required: counts.decision_required,
|
|
42
|
+
unresolved: contract.source_claims
|
|
43
|
+
.filter((item) => item.disposition.type === "decision_required")
|
|
44
|
+
.map((item) => item.key),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export async function captureDiagnostic(diagnostics, action) {
|
|
48
|
+
try {
|
|
49
|
+
await action();
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
addDiagnosticError(diagnostics, error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function addDiagnosticError(diagnostics, error, outcomeKey, checkKey) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
const rows = message.startsWith("delivery_contract_preflight_failed:\n")
|
|
58
|
+
? message.split(/\r?\n/u).slice(1)
|
|
59
|
+
: [message];
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
const code = diagnosticCode(row);
|
|
62
|
+
const refs = diagnosticRefs(code, row);
|
|
63
|
+
const repairHint = diagnosticRepairHint(code);
|
|
64
|
+
diagnostics.push({
|
|
65
|
+
level: "error",
|
|
66
|
+
code,
|
|
67
|
+
message: row,
|
|
68
|
+
...(outcomeKey ? { outcome_key: outcomeKey } : {}),
|
|
69
|
+
...(checkKey ? { check_key: checkKey } : {}),
|
|
70
|
+
...(refs.length ? { refs } : {}),
|
|
71
|
+
...(repairHint ? { repair_hint: repairHint } : {}),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function normalizeAuthoringDiagnostics(diagnostics) {
|
|
76
|
+
const normalized = [];
|
|
77
|
+
const positions = new Map();
|
|
78
|
+
for (const diagnostic of diagnostics) {
|
|
79
|
+
const refs = diagnostic.refs?.length
|
|
80
|
+
? [...new Set(diagnostic.refs)].sort()
|
|
81
|
+
: undefined;
|
|
82
|
+
const next = {
|
|
83
|
+
...diagnostic,
|
|
84
|
+
...(refs ? { refs } : {}),
|
|
85
|
+
};
|
|
86
|
+
delete next.occurrences;
|
|
87
|
+
delete next.diagnostic_id;
|
|
88
|
+
delete next.repair_group;
|
|
89
|
+
delete next.repair_priority;
|
|
90
|
+
delete next.blocked_by;
|
|
91
|
+
const key = JSON.stringify([
|
|
92
|
+
next.level,
|
|
93
|
+
next.code,
|
|
94
|
+
next.message,
|
|
95
|
+
next.outcome_key ?? null,
|
|
96
|
+
next.check_key ?? null,
|
|
97
|
+
next.refs ?? [],
|
|
98
|
+
next.repair_hint ?? null,
|
|
99
|
+
]);
|
|
100
|
+
const position = positions.get(key);
|
|
101
|
+
if (position === undefined) {
|
|
102
|
+
positions.set(key, normalized.length);
|
|
103
|
+
normalized.push(next);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const existing = normalized[position];
|
|
107
|
+
existing.occurrences = (existing.occurrences ?? 1) + 1;
|
|
108
|
+
}
|
|
109
|
+
return applyDiagnosticRepairOrder(normalized);
|
|
110
|
+
}
|
|
111
|
+
function diagnosticCode(message) {
|
|
112
|
+
if (message.startsWith("delivery_contract_invalid:"))
|
|
113
|
+
return message.split(":")[1] || "delivery_contract_invalid";
|
|
114
|
+
return message.split(":")[0] || "authoring_preflight_error";
|
|
115
|
+
}
|
|
116
|
+
function diagnosticPayload(code, message) {
|
|
117
|
+
const parts = message.split(":");
|
|
118
|
+
if (message.startsWith("delivery_contract_invalid:"))
|
|
119
|
+
return parts.slice(2);
|
|
120
|
+
if (parts[0] === code)
|
|
121
|
+
return parts.slice(1);
|
|
122
|
+
return parts.slice(1);
|
|
123
|
+
}
|
|
124
|
+
function diagnosticRefs(code, message) {
|
|
125
|
+
const payload = diagnosticPayload(code, message).filter(Boolean);
|
|
126
|
+
switch (code) {
|
|
127
|
+
case "owner_context_ref_unknown":
|
|
128
|
+
case "path_outside_owner_boundary":
|
|
129
|
+
case "source_claim_anchor_not_found":
|
|
130
|
+
case "binding_carrier_path_not_found":
|
|
131
|
+
case "binding_carrier_outside_change_paths":
|
|
132
|
+
case "binding_target_not_found":
|
|
133
|
+
case "binding_target_outside_carrier":
|
|
134
|
+
return payload.slice(0, 2);
|
|
135
|
+
case "requirement_key_duplicate":
|
|
136
|
+
case "binding_key_duplicate":
|
|
137
|
+
case "control_key_duplicate":
|
|
138
|
+
case "obligation_key_duplicate":
|
|
139
|
+
case "forbidden_shortcut_key_duplicate":
|
|
140
|
+
return payload.slice(0, 2);
|
|
141
|
+
case "owner_path_globs_empty":
|
|
142
|
+
return payload.slice(0, 1);
|
|
143
|
+
case "product_claim_uncovered":
|
|
144
|
+
case "global_claim_uncovered":
|
|
145
|
+
case "source_claim_decision_required":
|
|
146
|
+
return payload.flatMap((value) => value.split(",")).filter(Boolean);
|
|
147
|
+
case "assertion_criterion_required":
|
|
148
|
+
return payload.length ? [payload.join(":")] : [];
|
|
149
|
+
default:
|
|
150
|
+
if (code.endsWith("_path_not_found"))
|
|
151
|
+
return payload.slice(0, 2);
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function diagnosticRepairHint(code) {
|
|
156
|
+
switch (code) {
|
|
157
|
+
case "owner_context_ref_unknown":
|
|
158
|
+
return "Add the existing Context path to task.context_refs or correct owner.context_refs; do not invent a Context owner.";
|
|
159
|
+
case "requirement_key_duplicate":
|
|
160
|
+
case "binding_key_duplicate":
|
|
161
|
+
case "control_key_duplicate":
|
|
162
|
+
case "obligation_key_duplicate":
|
|
163
|
+
case "forbidden_shortcut_key_duplicate":
|
|
164
|
+
return "Remove an accidental duplicate or assign distinct stable keys while preserving each distinct semantic item.";
|
|
165
|
+
case "product_claim_uncovered":
|
|
166
|
+
case "global_claim_uncovered":
|
|
167
|
+
return "Add claim-bearing Assertion coverage for every required proof surface or correct the Claim mapping; do not weaken or delete the uncovered Claim.";
|
|
168
|
+
case "assertion_criterion_required":
|
|
169
|
+
return "Add a named falsifiable criterion that states what the Assertion accepts.";
|
|
170
|
+
case "source_claim_anchor_not_found":
|
|
171
|
+
return "Correct source_ref or add the matching non-rendering Source marker/anchor without rewriting the Source statement.";
|
|
172
|
+
case "source_claim_decision_required":
|
|
173
|
+
return "Resolve the stated product decision from the user or authoritative Source before Compile.";
|
|
174
|
+
default:
|
|
175
|
+
if (code.endsWith("_path_not_found"))
|
|
176
|
+
return "Create or correct the declared repository path, runner target or Binding carrier, then rerun Preflight.";
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AuthoringPreflightDiagnosticV1 } from "./long-task-authoring-preflight-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adds repair-order metadata only when a structural duplicate makes the
|
|
4
|
+
* identity of an uncovered Claim ambiguous. The structural diagnostic must be
|
|
5
|
+
* reviewed first, but the coverage finding is never treated as automatically
|
|
6
|
+
* resolved. No diagnostic is hidden, merged, reclassified or removed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyDiagnosticRepairOrder(diagnostics: AuthoringPreflightDiagnosticV1[]): AuthoringPreflightDiagnosticV1[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { canonicalJson, sha256Hex } from "./strict-codec.js";
|
|
2
|
+
const STRUCTURAL_BLOCKERS = new Set([
|
|
3
|
+
"requirement_key_duplicate",
|
|
4
|
+
"control_key_duplicate",
|
|
5
|
+
"obligation_key_duplicate",
|
|
6
|
+
"forbidden_shortcut_key_duplicate",
|
|
7
|
+
]);
|
|
8
|
+
const COVERAGE_FOLLOW_UPS = new Set([
|
|
9
|
+
"product_claim_uncovered",
|
|
10
|
+
"global_claim_uncovered",
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Adds repair-order metadata only when a structural duplicate makes the
|
|
14
|
+
* identity of an uncovered Claim ambiguous. The structural diagnostic must be
|
|
15
|
+
* reviewed first, but the coverage finding is never treated as automatically
|
|
16
|
+
* resolved. No diagnostic is hidden, merged, reclassified or removed.
|
|
17
|
+
*/
|
|
18
|
+
export function applyDiagnosticRepairOrder(diagnostics) {
|
|
19
|
+
const groups = diagnostics.map((diagnostic) => ({
|
|
20
|
+
diagnostic,
|
|
21
|
+
entity: repairEntity(diagnostic),
|
|
22
|
+
}));
|
|
23
|
+
const blockersByEntity = new Map();
|
|
24
|
+
for (const [index, item] of groups.entries()) {
|
|
25
|
+
if (!item.entity || !STRUCTURAL_BLOCKERS.has(item.diagnostic.code))
|
|
26
|
+
continue;
|
|
27
|
+
const blockers = blockersByEntity.get(item.entity) ?? [];
|
|
28
|
+
blockers.push({ index, id: stableDiagnosticId(item.diagnostic) });
|
|
29
|
+
blockersByEntity.set(item.entity, blockers);
|
|
30
|
+
}
|
|
31
|
+
const linkedBlockerIndexes = new Set();
|
|
32
|
+
const dependencies = new Map();
|
|
33
|
+
for (const [index, item] of groups.entries()) {
|
|
34
|
+
if (!item.entity || !COVERAGE_FOLLOW_UPS.has(item.diagnostic.code))
|
|
35
|
+
continue;
|
|
36
|
+
const blockers = blockersByEntity.get(item.entity);
|
|
37
|
+
if (!blockers?.length)
|
|
38
|
+
continue;
|
|
39
|
+
blockers.forEach((blocker) => linkedBlockerIndexes.add(blocker.index));
|
|
40
|
+
dependencies.set(index, [...new Set(blockers.map((blocker) => blocker.id))].sort());
|
|
41
|
+
}
|
|
42
|
+
return diagnostics.map((diagnostic, index) => {
|
|
43
|
+
const blockedBy = dependencies.get(index);
|
|
44
|
+
if (blockedBy)
|
|
45
|
+
return {
|
|
46
|
+
...diagnostic,
|
|
47
|
+
diagnostic_id: stableDiagnosticId(diagnostic),
|
|
48
|
+
repair_group: groups[index].entity,
|
|
49
|
+
repair_priority: "dependent",
|
|
50
|
+
blocked_by: blockedBy,
|
|
51
|
+
};
|
|
52
|
+
if (linkedBlockerIndexes.has(index))
|
|
53
|
+
return {
|
|
54
|
+
...diagnostic,
|
|
55
|
+
diagnostic_id: stableDiagnosticId(diagnostic),
|
|
56
|
+
repair_group: groups[index].entity,
|
|
57
|
+
repair_priority: "primary",
|
|
58
|
+
};
|
|
59
|
+
return diagnostic;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function stableDiagnosticId(diagnostic) {
|
|
63
|
+
return `diag-${sha256Hex(canonicalJson({
|
|
64
|
+
level: diagnostic.level,
|
|
65
|
+
code: diagnostic.code,
|
|
66
|
+
message: diagnostic.message,
|
|
67
|
+
outcome_key: diagnostic.outcome_key ?? null,
|
|
68
|
+
check_key: diagnostic.check_key ?? null,
|
|
69
|
+
refs: diagnostic.refs ?? [],
|
|
70
|
+
repair_hint: diagnostic.repair_hint ?? null,
|
|
71
|
+
})).slice(0, 16)}`;
|
|
72
|
+
}
|
|
73
|
+
function repairEntity(diagnostic) {
|
|
74
|
+
const refs = diagnostic.refs ?? [];
|
|
75
|
+
switch (diagnostic.code) {
|
|
76
|
+
case "requirement_key_duplicate":
|
|
77
|
+
return scopedClaim(refs, "requirement");
|
|
78
|
+
case "control_key_duplicate":
|
|
79
|
+
return scopedClaim(refs, "control");
|
|
80
|
+
case "obligation_key_duplicate":
|
|
81
|
+
return scopedClaim(refs, "obligation");
|
|
82
|
+
case "forbidden_shortcut_key_duplicate":
|
|
83
|
+
return scopedClaim(refs, "forbidden_shortcut");
|
|
84
|
+
case "product_claim_uncovered":
|
|
85
|
+
return refs.length === 1 ? refs[0] : null;
|
|
86
|
+
case "global_claim_uncovered":
|
|
87
|
+
return refs.length === 1 ? refs[0] : null;
|
|
88
|
+
default:
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function scopedClaim(refs, kind) {
|
|
93
|
+
const [scope, key] = refs;
|
|
94
|
+
return scope && key ? `${scope}.${kind}.${key}` : null;
|
|
95
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClaimCoverageSummaryV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface AuthoringPreflightDiagnosticV1 {
|
|
3
|
+
level: "error" | "decision_required" | "warning" | "info";
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
outcome_key?: string;
|
|
7
|
+
check_key?: string;
|
|
8
|
+
refs?: string[];
|
|
9
|
+
repair_hint?: string;
|
|
10
|
+
occurrences?: number;
|
|
11
|
+
diagnostic_id?: string;
|
|
12
|
+
repair_group?: string;
|
|
13
|
+
repair_priority?: "primary" | "dependent";
|
|
14
|
+
blocked_by?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface SourceCoverageV1 {
|
|
17
|
+
total: number;
|
|
18
|
+
resolved: number;
|
|
19
|
+
mapped_to_product_claims: number;
|
|
20
|
+
mapped_to_acceptance: number;
|
|
21
|
+
mapped_to_outcome_results: number;
|
|
22
|
+
mapped_to_global_constraints: number;
|
|
23
|
+
mapped_to_risk_facts: number;
|
|
24
|
+
mapped_to_external_confirmations: number;
|
|
25
|
+
decision_required: number;
|
|
26
|
+
unresolved: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface AuthoringRevisionPreviewV1 {
|
|
29
|
+
active: boolean;
|
|
30
|
+
authority_revision: number | null;
|
|
31
|
+
contract_changed: boolean;
|
|
32
|
+
source_or_context_changed: boolean;
|
|
33
|
+
declared_authority_sections_changed: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface AuthoringPreflightResultV1 {
|
|
36
|
+
schema_version: "long-task-authoring-preflight-v1";
|
|
37
|
+
status: "ready" | "not_ready";
|
|
38
|
+
would_create_authority_lock: boolean;
|
|
39
|
+
outcomes: string[];
|
|
40
|
+
source_coverage: SourceCoverageV1;
|
|
41
|
+
claim_coverage: ClaimCoverageSummaryV2;
|
|
42
|
+
revision_preview: AuthoringRevisionPreviewV1;
|
|
43
|
+
diagnostics: AuthoringPreflightDiagnosticV1[];
|
|
44
|
+
}
|
|
45
|
+
export declare function emptyClaimCoverage(): ClaimCoverageSummaryV2;
|
|
46
|
+
export declare function emptyPreflightResult(diagnostics: AuthoringPreflightDiagnosticV1[]): AuthoringPreflightResultV1;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function emptyClaimCoverage() {
|
|
2
|
+
return {
|
|
3
|
+
claims_total: 0,
|
|
4
|
+
claims_covered: 0,
|
|
5
|
+
uncovered_claims: [],
|
|
6
|
+
claims_by_global: {},
|
|
7
|
+
claims_by_outcome: {},
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function emptyPreflightResult(diagnostics) {
|
|
11
|
+
return {
|
|
12
|
+
schema_version: "long-task-authoring-preflight-v1",
|
|
13
|
+
status: "not_ready",
|
|
14
|
+
would_create_authority_lock: false,
|
|
15
|
+
outcomes: [],
|
|
16
|
+
source_coverage: {
|
|
17
|
+
total: 0,
|
|
18
|
+
resolved: 0,
|
|
19
|
+
mapped_to_product_claims: 0,
|
|
20
|
+
mapped_to_acceptance: 0,
|
|
21
|
+
mapped_to_outcome_results: 0,
|
|
22
|
+
mapped_to_global_constraints: 0,
|
|
23
|
+
mapped_to_risk_facts: 0,
|
|
24
|
+
mapped_to_external_confirmations: 0,
|
|
25
|
+
decision_required: 0,
|
|
26
|
+
unresolved: [],
|
|
27
|
+
},
|
|
28
|
+
claim_coverage: emptyClaimCoverage(),
|
|
29
|
+
revision_preview: {
|
|
30
|
+
active: false,
|
|
31
|
+
authority_revision: null,
|
|
32
|
+
contract_changed: false,
|
|
33
|
+
source_or_context_changed: false,
|
|
34
|
+
declared_authority_sections_changed: [],
|
|
35
|
+
},
|
|
36
|
+
diagnostics,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type AuthoringPreflightResultV1 } from "./long-task-authoring-preflight-types.js";
|
|
2
|
+
export type { AuthoringPreflightDiagnosticV1, AuthoringPreflightResultV1, SourceCoverageV1, } from "./long-task-authoring-preflight-types.js";
|
|
3
|
+
export declare function preflightDeliveryContract(workdirInput: string, projectRootInput?: string): Promise<AuthoringPreflightResultV1>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { authoringRevisionPreview, loadAuthoringActiveAuthority, } from "./long-task-authoring-authority-preview.js";
|
|
3
|
+
import { addAuthoringDiagnostics, addDiagnosticError, normalizeAuthoringDiagnostics, sourceCoverage, } from "./long-task-authoring-preflight-diagnostics.js";
|
|
4
|
+
import { emptyClaimCoverage, emptyPreflightResult, } from "./long-task-authoring-preflight-types.js";
|
|
5
|
+
import { validateContractForActivation } from "./long-task-activation-validation.js";
|
|
6
|
+
import { parseDeliveryContractBundle } from "./long-task-delivery-parser.js";
|
|
7
|
+
import { repositoryRoot } from "./long-task-workspace.js";
|
|
8
|
+
export async function preflightDeliveryContract(workdirInput, projectRootInput = process.cwd()) {
|
|
9
|
+
const diagnostics = [];
|
|
10
|
+
const repository = await repositoryRoot(projectRootInput);
|
|
11
|
+
const workdir = path.resolve(workdirInput);
|
|
12
|
+
let parsed;
|
|
13
|
+
try {
|
|
14
|
+
parsed = await parseDeliveryContractBundle(workdir, repository, {
|
|
15
|
+
validate_structure: false,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
addDiagnosticError(diagnostics, error);
|
|
20
|
+
return emptyPreflightResult(normalizeAuthoringDiagnostics(diagnostics));
|
|
21
|
+
}
|
|
22
|
+
const contract = parsed.contract;
|
|
23
|
+
addAuthoringDiagnostics(contract, parsed, diagnostics);
|
|
24
|
+
const validation = await validateContractForActivation({
|
|
25
|
+
repository,
|
|
26
|
+
workdir,
|
|
27
|
+
contract,
|
|
28
|
+
mode: "collect",
|
|
29
|
+
diagnostics,
|
|
30
|
+
});
|
|
31
|
+
const active = await loadAuthoringActiveAuthority(repository, workdir, diagnostics);
|
|
32
|
+
const normalizedDiagnostics = normalizeAuthoringDiagnostics(diagnostics);
|
|
33
|
+
const ready = !normalizedDiagnostics.some((item) => item.level === "error" || item.level === "decision_required");
|
|
34
|
+
return {
|
|
35
|
+
schema_version: "long-task-authoring-preflight-v1",
|
|
36
|
+
status: ready ? "ready" : "not_ready",
|
|
37
|
+
would_create_authority_lock: active === null,
|
|
38
|
+
outcomes: contract.outcomes.map((outcome) => outcome.key),
|
|
39
|
+
source_coverage: sourceCoverage(contract),
|
|
40
|
+
claim_coverage: validation.claims?.summary ?? emptyClaimCoverage(),
|
|
41
|
+
revision_preview: authoringRevisionPreview(contract, validation.source_hashes, validation.source_items, validation.context_snapshot, active),
|
|
42
|
+
diagnostics: normalizedDiagnostics,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CompiledDeliveryContractV2, DeliveryContractV2, NextAuthorityMaterialsV2, SourceClaimV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
export interface AuthorityMaterialRevisionDiffV2 {
|
|
3
|
+
product_semantics_changed: string[];
|
|
4
|
+
global_semantics_changed: string[];
|
|
5
|
+
source_files_added: string[];
|
|
6
|
+
source_files_removed: string[];
|
|
7
|
+
source_files_changed: string[];
|
|
8
|
+
context_snapshot_mode_changed: boolean;
|
|
9
|
+
context_topology_changed: boolean;
|
|
10
|
+
context_files_added: string[];
|
|
11
|
+
context_files_removed: string[];
|
|
12
|
+
context_files_changed: string[];
|
|
13
|
+
reduction_reasons: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function authorityMaterialRevisionDiff(previous: CompiledDeliveryContractV2, nextMaterials: NextAuthorityMaterialsV2): AuthorityMaterialRevisionDiffV2;
|
|
16
|
+
export declare function sourceClaimAdditions(beforeClaims: SourceClaimV2[], afterClaims: SourceClaimV2[]): string[];
|
|
17
|
+
export declare function changedProductClaimSemantics(previous: CompiledDeliveryContractV2, next: DeliveryContractV2): string[];
|