project-tiny-context-harness 0.2.81 → 0.2.83

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.
Files changed (52) hide show
  1. package/README.md +11 -3
  2. package/assets/README.md +11 -3
  3. package/assets/README.zh-CN.md +9 -1
  4. package/assets/protected-harness-baseline.json +18 -0
  5. package/assets/skills/composite-long-task-workflow/SKILL.md +21 -1
  6. package/assets/skills/composite-long-task-workflow/assets/execution-binding.template.md +10 -0
  7. package/assets/skills/composite-long-task-workflow/assets/goal-objective.template.md +6 -15
  8. package/assets/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md +32 -15
  9. package/dist/commands/composite-long-task.js +45 -2
  10. package/dist/lib/superpowers-task-ac010.d.ts +6 -0
  11. package/dist/lib/superpowers-task-ac010.js +26 -0
  12. package/dist/lib/superpowers-task-assertion-normalizers.js +8 -1
  13. package/dist/lib/superpowers-task-assertions.js +35 -20
  14. package/dist/lib/superpowers-task-attempt.d.ts +4 -0
  15. package/dist/lib/superpowers-task-attempt.js +102 -0
  16. package/dist/lib/superpowers-task-command-specs.d.ts +3 -0
  17. package/dist/lib/superpowers-task-command-specs.js +52 -0
  18. package/dist/lib/superpowers-task-compile.d.ts +4 -1
  19. package/dist/lib/superpowers-task-compile.js +7 -1
  20. package/dist/lib/superpowers-task-contradictions.d.ts +6 -0
  21. package/dist/lib/superpowers-task-contradictions.js +126 -0
  22. package/dist/lib/superpowers-task-current-evidence.d.ts +3 -0
  23. package/dist/lib/superpowers-task-current-evidence.js +154 -0
  24. package/dist/lib/superpowers-task-delivery.js +30 -18
  25. package/dist/lib/superpowers-task-derive.d.ts +1 -0
  26. package/dist/lib/superpowers-task-derive.js +76 -1
  27. package/dist/lib/superpowers-task-evidence-kernel.d.ts +12 -0
  28. package/dist/lib/superpowers-task-evidence-kernel.js +351 -0
  29. package/dist/lib/superpowers-task-evidence-records.d.ts +2 -0
  30. package/dist/lib/superpowers-task-evidence-records.js +55 -0
  31. package/dist/lib/superpowers-task-evidence.d.ts +10 -0
  32. package/dist/lib/superpowers-task-evidence.js +141 -0
  33. package/dist/lib/superpowers-task-fields.d.ts +22 -0
  34. package/dist/lib/superpowers-task-fields.js +276 -0
  35. package/dist/lib/superpowers-task-gates.js +36 -24
  36. package/dist/lib/superpowers-task-harness-drift.d.ts +11 -0
  37. package/dist/lib/superpowers-task-harness-drift.js +86 -0
  38. package/dist/lib/superpowers-task-protected-baseline.d.ts +10 -0
  39. package/dist/lib/superpowers-task-protected-baseline.js +47 -0
  40. package/dist/lib/superpowers-task-source-compile.js +93 -95
  41. package/dist/lib/superpowers-task-source-parser.js +1 -3
  42. package/dist/lib/superpowers-task-state-schema.d.ts +158 -3
  43. package/dist/lib/superpowers-task-state-schema.js +23 -1
  44. package/dist/lib/superpowers-task-state-shape.d.ts +3 -0
  45. package/dist/lib/superpowers-task-state-shape.js +50 -0
  46. package/dist/lib/superpowers-task-state.js +19 -39
  47. package/dist/lib/superpowers-task-status.js +11 -1
  48. package/dist/lib/superpowers-task-under-specified.d.ts +7 -0
  49. package/dist/lib/superpowers-task-under-specified.js +61 -0
  50. package/dist/lib/superpowers-task-validator.js +11 -37
  51. package/package.json +69 -69
  52. package/source-mappings.yaml +3 -0
package/README.md CHANGED
@@ -96,15 +96,23 @@ The ordinary long-task path uses `/normal-long-task`. It is the non-Superpowers
96
96
 
97
97
  The Composite Long-Task Workflow path uses `/composite-long-task-workflow` when three inputs already exist: `Product / Architecture Source`, `Technical Realization Plan` and `Acceptance Checklist`. The product/architecture source preserves original intent and scope; the technical realization plan is the execution blueprint and plan-conformance source; the checklist is the acceptance authority. The Skill does not perform complexity routing: invocation means Superpowers-backed composite execution was already selected. Two-document compatibility is allowed only when the first document clearly contains both product/architecture source and technical realization plan sections. If only a product/architecture source and checklist exist, the Skill stops with a Missing Fields Report for a missing `Technical Realization Plan` instead of generating one. The technical realization plan must already satisfy the required Superpowers-ready Markdown implementation plan fields. When it does, the Skill freezes the package-managed workflow into `workflow-protocol.md`, writes task-local `execution-binding.md`, and renders `goal-objective.txt` as a thin Codex Goal objective instead of packing the full workflow into goal text. This is intentional: the Goal objective stays small enough to preserve the persistent completion contract, while the complete executable workflow lives in the protocol snapshot and the task-specific binding. The expected runtime effect is explicit fusion rather than agent improvisation: Tiny Context Workflow Contract first, then three-input authority, state compilation, Superpowers implementation slices, canonical evidence/state updates, generated views, slice/epoch gates and final-gate completion. The workflow is Tiny Context's composite adapter layer, aligned to the official Superpowers skills while remaining a Tiny Context-owned adapter rather than an upstream-owned schema; it is not the Tiny Context Workflow Contract itself, not a business fact source, not a generic prompt generator and not a Superpowers fork. It may wrap Superpowers with Tiny Context authority, conformance and acceptance gates, but it must not redefine or fork Superpowers execution mechanics. It requires parent-level `Product Context Delta` and `Technical Context Delta` checks before implementation and uses a canonical state kernel under `tmp/ty-context/plan-acceptance/<plan-slug>/`: `task-state.json` is the only execution state source, `events.ndjson` is append-only and `derived/**` contains generated local audit, plan-conformance matrix, final acceptance verdict, progress ledger, evidence index, context alignment and final summary views. Complete acceptance rows are externally reviewable evidence claims derived from `task-state.evidence[]`: the checklist supplies the proof chain, fresh reviewable evidence must satisfy every required layer, and machine-verifiable layers such as UI/browser/runtime/API/data/integration/test require passed assertion results, zero command/assertion exit codes, target AC/layer coverage, passed positive and negative assertions and no negative evidence contradiction. Screenshot-only proof, component screenshots, viewmodels, diagnostic pages, API-only proof for a UI Path AC, final cards, matrix/verdict rows, validator passes and prose summaries are invalid as completion proof for those layers. Material drift, missing layers, failed/stale assertion reports, failed negative evidence scans or unapproved sibling substitution prevent `complete`. Goal-mode wording separates `audit_task_complete`, `acceptance_target_status` and computed `product_goal_complete`: implementation / execution goals complete only when `ty-context composite-long-task final-gate` computes `product_goal_complete=true`; read-only audit goals may end at `audit_task_complete`, but a non-accepted verdict says `Audit workflow completed; acceptance target not complete.` and does not use unqualified `Goal achieved` or `update_goal(status="complete")` as acceptance of the user target.
98
98
 
99
+ Strict completion is current-attempt-only and runs through one Trusted Evidence Kernel. `compile` derives required command specs from each machine-blocking AC's `assertion_command`, `assertion_artifacts`, proof layers, required tests, positive/negative assertions, invalid completion signals and expected final evidence; `start-attempt --mode product_task|harness_task` records the current execution identity; `run-assertion` records assertion command runs; `record-evidence` registers artifacts as canonical EvidenceRecordV2; and `final-gate` recomputes from current records. EvidenceRecordV2 must carry attempt/source/product/plan/checklist hashes, git head, worktree fingerprint, command spec/run ids, command line and exit code, artifact path/SHA/mtime, target AC ids, target PI ids, target proof layers, assertion status/exit code, positive assertions, negative assertions, invalid completion signals, negative evidence scan and required test ids. Legacy v1 evidence, historical `events.ndjson` complete events, stale `derived/**` views, validator passes, final cards, auditor prose, AC summary-only proof and unregistered temporary JSON cannot complete machine-blocking ACs. Newer failed command runs, Playwright/JUnit/test result failures, owner DOM forbidden states, source/worktree drift, task-state false/partial status and derived/state mismatches invalidate older passed evidence for the same AC/layer.
100
+
101
+ The final-gate order is fixed inside the kernel: load the three inputs, recompute source hashes, load task state, load current attempt, load command-run records, load registered EvidenceRecords, discard stale evidence, scan contradictions, recompute every AC, recompute every PI, recompute `acceptance_target_status`, recompute `product_goal_complete`, regenerate `derived/**` and append an event. A machine-blocking AC with missing assertion command/artifacts/assertions/invalid signals, UI proof without browser/e2e/smoke/trace evidence, generated-only final evidence, manual-only test cases or no possible `assertion_result` is `under_specified`; its PI is blocked and `product_goal_complete=false`. AC-010/final-gate summary evidence cannot bootstrap other ACs: if a summary AC passes while another required AC is missing, failed or stale, the summary AC is invalidated with `final_gate_cannot_bootstrap_from_summary_only`.
102
+
103
+ Harness Drift Lock separates product proof from harness proof. A `product_task` that changes Playwright specs, tests, assertion generators, AC010 helpers, evidence writers, final-gate, validator, derive, task-state reducer, composite workflow Skill/protocol or related Makefile/package test targets is blocked with `harness_drift_detected`, `acceptance_target_status=blocked`, `product_goal_complete=false` and the message "本轮修改了验收工具链或测试本身,不能用被修改后的验收证明同一轮产品完成。请拆成独立 harness_task。" A `harness_task` may change harness files only with adversarial fixtures whose expected final-gate outcomes include stale evidence, historical complete, derived contradiction, AC010 summary-only, target mismatch, API-only-for-UI, negative evidence after pass, source hash mismatch, dirty worktree mismatch, missing assertion_result, test weakening and a happy path; it proves the harness, not product completion. `protected-harness-baseline.json` protects the final gate, validator, derive, evidence registration, assertion schema, fixture expectations, workflow protocol, Skill markdown and test runner scripts; product tasks changing that baseline are blocked, and harness tasks need a baseline reason plus fixture verification.
104
+
99
105
  The three inputs also carry capability-first delivery boundaries. Product / Architecture Source declares `delivery_scope`, `full_population_required`, samples that validate the claim, samples that do not validate it and out-of-scope backlog. Each Technical Realization Plan item declares delivery scope, capability target, representative samples, full-population boundary and non-required population. Each Acceptance Checklist item declares acceptance scope, what it validates and does not validate, sample boundary and full-population requirement. `scope_conflict_requires_decision` blocks completion when source, plan and checklist disagree between system capability build, representative sample validation and full-population operation. Sample evidence or framework-only implementation cannot prove all-provider, all-interface, all-platform or full-population completion unless the AC explicitly allows it; when full population is not explicitly required, generated views report it as `not_in_scope`.
100
106
 
101
107
  `ty-context composite-long-task compile` uses a strict heading-based grammar for that packet. Product / Architecture Source is one document-level object with fixed fields. Technical Realization Plan items are definitions only when written as Markdown headings such as `## PI-001: ...`; Acceptance Checklist items are definitions only when written as headings such as `## AC-001: ...`. Fields inside those sections must use fixed `key: value`, indented-list or `key: |` syntax. Plain prose, tables, mapping previews and ordinary lists that mention `PI-001` or `AC-001` are references, not definitions; old list-style definitions such as `- PI-001: ...` followed by delivery fields now fail at compile time with file and line guidance.
102
108
 
109
+ Strict V2 packets also require canonical Product / PI / AC field groups. Product Source carries Scope Fit and owner-boundary fields such as `scope_fit_decision`, `selected_scope_fit_slice`, `owner_boundary`, `primary_capability_path`, `non_completing_outcomes` and `assertion_policy`; PI items carry owner, trigger, state-transition, observable-result and assertion-support fields; ACs carry `assertion_command`, `assertion_artifacts`, `positive_assertions`, `negative_assertions`, `machine_blocking`, `invalid_completion_signals` and `assertion_result_required`. Unknown, duplicate, table or missing canonical fields fail compile. Canonical proof layers are `code`, `api_schema`, `worker_runtime`, `data_artifact`, `integration`, `ui_browser`, `security_redaction`, `all_provider_all_runner`, `cleanup_stale_scan` and `test`; aliases such as `runtime`, `browser`, `api`, `data` and `security` compile to the canonical names, and `code` cannot complete a machine-backed AC by itself. The generated evidence index is available as both `derived/evidence-index.md` and `derived/evidence-index.json`.
110
+
103
111
  For non-trivial Superpowers-backed slices, the workflow protocol requires a structured `slice-delta.json`. The executor applies it with `ty-context composite-long-task apply-slice-delta <workdir> <slice-delta.json>`, then runs `ty-context composite-long-task derive` and `ty-context composite-long-task slice-gate`. Each delta records touched plan items/ACs, code changes, closed and remaining proof layers, blockers, cleanup assertions, `progress_value` and canonical evidence records with `proves`, `does_not_prove`, freshness, redaction, reviewability, command exit code when applicable, assertion result and negative evidence scan. Default slice guidance is to group 2-4 strongly related missing layers that share an AC, runtime scenario, proof environment or verification path, while single-gap slices are reserved for blockers, contradictions or small metadata cleanup. The protocol also asks executors to classify missing layers, reuse DB/API/Browser environments only with unique proof prefixes and cleanup assertions, and run a stale/overclaim scan after deriving artifacts.
104
112
 
105
113
  The generated Superpowers prompt uses Slice Gate / Epoch Gate / Final Gate cadence instead of running a full final gate after every slice. Progress Accounting tracks AC acceptance completion, engineering implementation progress, runtime/proof progress, system capability progress, representative sample progress, real object coverage, full population operation progress, artifact budget, proof-layer milestone status and workflow overhead in state and generated `derived/progress-ledger.*`. Workflow overhead backpressure asks executors to batch shared provider/browser/runtime/security epoch proof environments, prune stale artifacts and choose the Next 3-5 high-value clusters that close the most blocking AC/proof-layer gaps.
106
114
 
107
- The recommended Superpowers layer is the specific [obra/Superpowers](https://github.com/obra/superpowers) plugin/workflow, not a generic planning substitute. After `/composite-long-task-workflow` accepts the input packet, prefer `superpowers:subagent-driven-development` when subagents are available and `superpowers:executing-plans` otherwise. Behavior changes should use `superpowers:test-driven-development`. Final gate order is derive all views, `superpowers:verification-before-completion`, `ty-context validate-superpowers-state <dir>`, `ty-context validate-plan-acceptance <dir>`, read-only auditor when available, rederive/revalidate if auditor fixes changed state or evidence, final stale/overclaim scan, AC Evidence Assertion Gate, Negative Evidence Scan Gate, then `ty-context composite-long-task final-gate <dir>` computes completion. The auditor reconstructs AC proof chains with a fixed auditor checklist and finds gaps, but does not become proof. Superpowers review and verification remain useful execution checks, but they cannot override Tiny Context gates: passing Superpowers review does not by itself prove plan conformance or checklist acceptance.
115
+ The recommended Superpowers layer is the specific [obra/Superpowers](https://github.com/obra/superpowers) plugin/workflow, not a generic planning substitute. After `/composite-long-task-workflow` accepts the input packet, prefer `superpowers:subagent-driven-development` when subagents are available and `superpowers:executing-plans` otherwise. Behavior changes should use `superpowers:test-driven-development`; behavior proof still enters the Trusted Evidence Kernel through current-attempt command runs and EvidenceRecordV2 entries. Superpowers verification, state validators, plan-acceptance validators, auditor checks and generated views remain useful execution checks, but they cannot override Tiny Context gates or become product proof: passing Superpowers review, validators or final-summary prose does not by itself prove plan conformance or checklist acceptance.
108
116
 
109
117
  Hallucination guard: do not register `workflow-protocol.md` in `project_context/context.toml`, treat it as business Context, let `derived/**` rewrite Product / Plan / Checklist, use local audit or Superpowers review as quality proof, use screenshots/final cards/matrix/verdict/validator pass/prose as machine-verifiable proof, use sample evidence as full-population proof, claim full alignment while Source-to-Context Coverage or Context-to-Implementation Binding has unresolved required gaps, handwrite `product_goal_complete`, or complete an implementation Goal before final-gate passes.
110
118
 
@@ -163,7 +171,7 @@ npm ci
163
171
  npm run smoke:quickstart
164
172
  npm run preview:pack
165
173
  cd /path/to/your/test-repo
166
- npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.2.81.tgz
174
+ npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.2.83.tgz
167
175
  npx --no-install ty-context init --adopt
168
176
  make validate-context
169
177
  ```
@@ -296,7 +304,7 @@ Use `npx --no-install ty-context ...` only when you explicitly want the already
296
304
  | Plan contract validation | `npx --yes --package project-tiny-context-harness@latest ty-context validate-plan-contract <plan.md\|dir>` | Checks Source-to-Context Coverage and Context-to-Implementation Binding for structural consistency, referenced path existence and weak-proof complete/bound contradictions. |
297
305
  | Superpowers state validation | `npx --yes --package project-tiny-context-harness@latest ty-context validate-superpowers-state <dir>` | Checks canonical Superpowers-backed `task-state.json`, source hashes, graph references, delivery scope fields/conflicts, evidence/proof-layer consistency, assertion-backed machine-verifiable evidence, negative evidence contradictions, stale evidence, sibling substitution, auditor blockers, derived drift and final completion rules. |
298
306
  | Plan acceptance validation | `npx --yes --package project-tiny-context-harness@latest ty-context validate-plan-acceptance <dir>` | Checks legacy matrix/verdict artifacts when no state exists; when `task-state.json` exists, validates state-backed derived artifacts. It rejects contradictory complete claims, dangling evidence references, weak-proof complete rows, missing proof layers, missing/failed assertion-backed evidence for machine-verifiable layers, negative evidence contradictions, material/critical drift, unapproved sibling substitution, blocking auditor findings, raw secrets/tokens/cookies, generated active-count drift, missing plan/AC cross-references and declared surface/architecture binding gaps. `errors` block; `warnings` / `hygiene` report cleanup. |
299
- | Composite long-task state helpers | `npx --yes --package project-tiny-context-harness@latest ty-context composite-long-task <subcommand>` | Explicit `/composite-long-task-workflow` state helper for `init`, `compile`, `apply-slice-delta`, `derive`, `slice-gate`, `epoch-gate`, `final-gate`, `next-slices` and `render-goal` under `tmp/ty-context/plan-acceptance/**`. |
307
+ | Composite long-task state helpers | `npx --yes --package project-tiny-context-harness@latest ty-context composite-long-task <subcommand>` | Explicit `/composite-long-task-workflow` state helper for `init`, `compile`, `start-attempt`, `run-assertion`, `record-evidence`, `apply-slice-delta`, `derive`, `slice-gate`, `epoch-gate`, `final-gate`, `next-slices` and `render-goal` under `tmp/ty-context/plan-acceptance/**`. |
300
308
  | Diagnostics | `make ty-context-doctor` or `npx --yes --package project-tiny-context-harness@latest ty-context doctor` | Reports Harness root, package version, schema version and required Minimal Context paths. |
301
309
  | Package source checks | `ty-context package sync-source`, `ty-context package check-source` | Maintainer-only commands for keeping package canonical assets aligned with the source workspace. |
302
310
 
package/assets/README.md CHANGED
@@ -94,7 +94,7 @@ That smoke packs the local workspace, installs it into a disposable repo, runs `
94
94
  ```sh
95
95
  npm run preview:pack
96
96
  cd /path/to/your/test-repo
97
- npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.2.81.tgz
97
+ npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.2.83.tgz
98
98
  npx --no-install ty-context init --adopt
99
99
  make validate-context
100
100
  ```
@@ -140,15 +140,23 @@ The ordinary long-task path uses `/normal-long-task`. It is the non-Superpowers
140
140
 
141
141
  The Composite Long-Task Workflow path uses `/composite-long-task-workflow` when three inputs already exist: `Product / Architecture Source`, `Technical Realization Plan` and `Acceptance Checklist`. The product/architecture source preserves original intent and scope; the technical realization plan is the execution blueprint and plan-conformance source; the checklist is the acceptance authority. The Skill does not perform complexity routing: invocation means Superpowers-backed composite execution was already selected. Two-document compatibility is allowed only when the first document clearly contains both product/architecture source and technical realization plan sections. If only a product/architecture source and checklist exist, the Skill stops with a Missing Fields Report for a missing `Technical Realization Plan` instead of generating one. The technical realization plan must already satisfy the required Superpowers-ready Markdown implementation plan fields. When it does, the Skill freezes the package-managed workflow into `workflow-protocol.md`, writes task-local `execution-binding.md`, and renders `goal-objective.txt` as a thin Codex Goal objective instead of packing the full workflow into goal text. This is intentional: the Goal objective stays small enough to preserve the persistent completion contract, while the complete executable workflow lives in the protocol snapshot and the task-specific binding. The expected runtime effect is explicit fusion rather than agent improvisation: Tiny Context Workflow Contract first, then three-input authority, state compilation, Superpowers implementation slices, canonical evidence/state updates, generated views, slice/epoch gates and final-gate completion. The workflow is Tiny Context's composite adapter layer, aligned to the official Superpowers skills while remaining a Tiny Context-owned adapter rather than an upstream-owned schema; it is not the Tiny Context Workflow Contract itself, not a business fact source, not a generic prompt generator and not a Superpowers fork. It may wrap Superpowers with Tiny Context authority, conformance and acceptance gates, but it must not redefine or fork Superpowers execution mechanics. It requires parent-level `Product Context Delta` and `Technical Context Delta` checks before implementation and uses a canonical state kernel under `tmp/ty-context/plan-acceptance/<plan-slug>/`: `task-state.json` is the only execution state source, `events.ndjson` is append-only and `derived/**` contains generated local audit, plan-conformance matrix, final acceptance verdict, progress ledger, evidence index, context alignment and final summary views. Complete acceptance rows are externally reviewable evidence claims derived from `task-state.evidence[]`: the checklist supplies the proof chain, fresh reviewable evidence must satisfy every required layer, and machine-verifiable layers such as UI/browser/runtime/API/data/integration/test require passed assertion results, zero command/assertion exit codes, target AC/layer coverage, passed positive and negative assertions and no negative evidence contradiction. Screenshot-only proof, component screenshots, viewmodels, diagnostic pages, API-only proof for a UI Path AC, final cards, matrix/verdict rows, validator passes and prose summaries are invalid as completion proof for those layers. Material drift, missing layers, failed/stale assertion reports, failed negative evidence scans or unapproved sibling substitution prevent `complete`. Goal-mode wording separates `audit_task_complete`, `acceptance_target_status` and computed `product_goal_complete`: implementation / execution goals complete only when `ty-context composite-long-task final-gate` computes `product_goal_complete=true`; read-only audit goals may end at `audit_task_complete`, but a non-accepted verdict says `Audit workflow completed; acceptance target not complete.` and does not use unqualified `Goal achieved` or `update_goal(status="complete")` as acceptance of the user target.
142
142
 
143
+ Strict completion is current-attempt-only and runs through one Trusted Evidence Kernel. `compile` derives required command specs from each machine-blocking AC's `assertion_command`, `assertion_artifacts`, proof layers, required tests, positive/negative assertions, invalid completion signals and expected final evidence; `start-attempt --mode product_task|harness_task` records the current execution identity; `run-assertion` records assertion command runs; `record-evidence` registers artifacts as canonical EvidenceRecordV2; and `final-gate` recomputes from current records. EvidenceRecordV2 must carry attempt/source/product/plan/checklist hashes, git head, worktree fingerprint, command spec/run ids, command line and exit code, artifact path/SHA/mtime, target AC ids, target PI ids, target proof layers, assertion status/exit code, positive assertions, negative assertions, invalid completion signals, negative evidence scan and required test ids. Legacy v1 evidence, historical `events.ndjson` complete events, stale `derived/**` views, validator passes, final cards, auditor prose, AC summary-only proof and unregistered temporary JSON cannot complete machine-blocking ACs. Newer failed command runs, Playwright/JUnit/test result failures, owner DOM forbidden states, source/worktree drift, task-state false/partial status and derived/state mismatches invalidate older passed evidence for the same AC/layer.
144
+
145
+ The final-gate order is fixed inside the kernel: load the three inputs, recompute source hashes, load task state, load current attempt, load command-run records, load registered EvidenceRecords, discard stale evidence, scan contradictions, recompute every AC, recompute every PI, recompute `acceptance_target_status`, recompute `product_goal_complete`, regenerate `derived/**` and append an event. A machine-blocking AC with missing assertion command/artifacts/assertions/invalid signals, UI proof without browser/e2e/smoke/trace evidence, generated-only final evidence, manual-only test cases or no possible `assertion_result` is `under_specified`; its PI is blocked and `product_goal_complete=false`. AC-010/final-gate summary evidence cannot bootstrap other ACs: if a summary AC passes while another required AC is missing, failed or stale, the summary AC is invalidated with `final_gate_cannot_bootstrap_from_summary_only`.
146
+
147
+ Harness Drift Lock separates product proof from harness proof. A `product_task` that changes Playwright specs, tests, assertion generators, AC010 helpers, evidence writers, final-gate, validator, derive, task-state reducer, composite workflow Skill/protocol or related Makefile/package test targets is blocked with `harness_drift_detected`, `acceptance_target_status=blocked`, `product_goal_complete=false` and the message "本轮修改了验收工具链或测试本身,不能用被修改后的验收证明同一轮产品完成。请拆成独立 harness_task。" A `harness_task` may change harness files only with adversarial fixtures whose expected final-gate outcomes include stale evidence, historical complete, derived contradiction, AC010 summary-only, target mismatch, API-only-for-UI, negative evidence after pass, source hash mismatch, dirty worktree mismatch, missing assertion_result, test weakening and a happy path; it proves the harness, not product completion. `protected-harness-baseline.json` protects the final gate, validator, derive, evidence registration, assertion schema, fixture expectations, workflow protocol, Skill markdown and test runner scripts; product tasks changing that baseline are blocked, and harness tasks need a baseline reason plus fixture verification.
148
+
143
149
  The three inputs also carry capability-first delivery boundaries. Product / Architecture Source declares `delivery_scope`, `full_population_required`, samples that validate the claim, samples that do not validate it and out-of-scope backlog. Each Technical Realization Plan item declares delivery scope, capability target, representative samples, full-population boundary and non-required population. Each Acceptance Checklist item declares acceptance scope, what it validates and does not validate, sample boundary and full-population requirement. `scope_conflict_requires_decision` blocks completion when source, plan and checklist disagree between system capability build, representative sample validation and full-population operation. Sample evidence or framework-only implementation cannot prove all-provider, all-interface, all-platform or full-population completion unless the AC explicitly allows it; when full population is not explicitly required, generated views report it as `not_in_scope`.
144
150
 
145
151
  `ty-context composite-long-task compile` uses a strict heading-based grammar for that packet. Product / Architecture Source is one document-level object with fixed fields. Technical Realization Plan items are definitions only when written as Markdown headings such as `## PI-001: ...`; Acceptance Checklist items are definitions only when written as headings such as `## AC-001: ...`. Fields inside those sections must use fixed `key: value`, indented-list or `key: |` syntax. Plain prose, tables, mapping previews and ordinary lists that mention `PI-001` or `AC-001` are references, not definitions; old list-style definitions such as `- PI-001: ...` followed by delivery fields now fail at compile time with file and line guidance.
146
152
 
153
+ Strict V2 packets also require canonical Product / PI / AC field groups. Product Source carries Scope Fit and owner-boundary fields such as `scope_fit_decision`, `selected_scope_fit_slice`, `owner_boundary`, `primary_capability_path`, `non_completing_outcomes` and `assertion_policy`; PI items carry owner, trigger, state-transition, observable-result and assertion-support fields; ACs carry `assertion_command`, `assertion_artifacts`, `positive_assertions`, `negative_assertions`, `machine_blocking`, `invalid_completion_signals` and `assertion_result_required`. Unknown, duplicate, table or missing canonical fields fail compile. Canonical proof layers are `code`, `api_schema`, `worker_runtime`, `data_artifact`, `integration`, `ui_browser`, `security_redaction`, `all_provider_all_runner`, `cleanup_stale_scan` and `test`; aliases such as `runtime`, `browser`, `api`, `data` and `security` compile to the canonical names, and `code` cannot complete a machine-backed AC by itself. The generated evidence index is available as both `derived/evidence-index.md` and `derived/evidence-index.json`.
154
+
147
155
  For non-trivial Superpowers-backed slices, the workflow protocol requires a structured `slice-delta.json`. The executor applies it with `ty-context composite-long-task apply-slice-delta <workdir> <slice-delta.json>`, then runs `ty-context composite-long-task derive` and `ty-context composite-long-task slice-gate`. Each delta records touched plan items/ACs, code changes, closed and remaining proof layers, blockers, cleanup assertions, `progress_value` and canonical evidence records with `proves`, `does_not_prove`, freshness, redaction, reviewability, command exit code when applicable, assertion result and negative evidence scan. Default slice guidance is to group 2-4 strongly related missing layers that share an AC, runtime scenario, proof environment or verification path, while single-gap slices are reserved for blockers, contradictions or small metadata cleanup. The protocol also asks executors to classify missing layers, reuse DB/API/Browser environments only with unique proof prefixes and cleanup assertions, and run a stale/overclaim scan after deriving artifacts.
148
156
 
149
157
  The generated Superpowers prompt uses Slice Gate / Epoch Gate / Final Gate cadence instead of running a full final gate after every slice. Progress Accounting tracks AC acceptance completion, engineering implementation progress, runtime/proof progress, system capability progress, representative sample progress, real object coverage, full population operation progress, artifact budget, proof-layer milestone status and workflow overhead in state and generated `derived/progress-ledger.*`. Workflow overhead backpressure asks executors to batch shared provider/browser/runtime/security epoch proof environments, prune stale artifacts and choose the Next 3-5 high-value clusters that close the most blocking AC/proof-layer gaps.
150
158
 
151
- The recommended Superpowers layer is the specific [obra/Superpowers](https://github.com/obra/superpowers) plugin/workflow, not a generic planning substitute. After `/composite-long-task-workflow` accepts the input packet, prefer `superpowers:subagent-driven-development` when subagents are available and `superpowers:executing-plans` otherwise. Behavior changes should use `superpowers:test-driven-development`. Final gate order is derive all views, `superpowers:verification-before-completion`, `ty-context validate-superpowers-state <dir>`, `ty-context validate-plan-acceptance <dir>`, read-only auditor when available, rederive/revalidate if auditor fixes changed state or evidence, final stale/overclaim scan, AC Evidence Assertion Gate, Negative Evidence Scan Gate, then `ty-context composite-long-task final-gate <dir>` computes completion. The auditor reconstructs AC proof chains with a fixed auditor checklist and finds gaps, but does not become proof. Superpowers review and verification remain useful execution checks, but they cannot override Tiny Context gates: passing Superpowers review does not by itself prove plan conformance or checklist acceptance.
159
+ The recommended Superpowers layer is the specific [obra/Superpowers](https://github.com/obra/superpowers) plugin/workflow, not a generic planning substitute. After `/composite-long-task-workflow` accepts the input packet, prefer `superpowers:subagent-driven-development` when subagents are available and `superpowers:executing-plans` otherwise. Behavior changes should use `superpowers:test-driven-development`; behavior proof still enters the Trusted Evidence Kernel through current-attempt command runs and EvidenceRecordV2 entries. Superpowers verification, state validators, plan-acceptance validators, auditor checks and generated views remain useful execution checks, but they cannot override Tiny Context gates or become product proof: passing Superpowers review, validators or final-summary prose does not by itself prove plan conformance or checklist acceptance.
152
160
 
153
161
  The reason is drift control. The workflow contract plus Context layer is intentionally a soft constraint. It works well for short tasks, and Context can still capture the expected facts for long tasks, but long execution makes the Context-to-code step drift as the context window grows, work is handed off, subagents split scope or validation loops multiply. The extra Tiny Context gates exist because Superpowers alone can still drift under long-running execution pressure: it strengthens execution discipline, but it does not by itself preserve source authority, prevent scope shrinkage, prove full conformance to the Technical Realization Plan or enforce AC-by-AC evidence against the Acceptance Checklist. A product/architecture source, technical realization plan, acceptance checklist, explicit long-task Skill invocation, target-mode prompt, canonical task state, generated derived views and optional Superpowers execution layer make implementation conformance and completion evidence recoverable without restoring a phase-gated workflow.
154
162
 
@@ -407,7 +415,7 @@ Use `npx --no-install ty-context ...` only when you explicitly want the already
407
415
  | `npx --yes --package project-tiny-context-harness@latest ty-context validate-plan-contract <plan.md\|dir>` | Checks Source-to-Context Coverage and Context-to-Implementation Binding for structural consistency, referenced path existence and weak-proof complete/bound contradictions. |
408
416
  | `npx --yes --package project-tiny-context-harness@latest ty-context validate-superpowers-state <dir>` | Checks canonical Superpowers-backed `task-state.json`, source hashes, graph references, delivery scope fields/conflicts, evidence/proof-layer consistency, assertion-backed machine-verifiable evidence, negative evidence contradictions, stale evidence, sibling substitution, auditor blockers, derived drift and final completion rules. |
409
417
  | `npx --yes --package project-tiny-context-harness@latest ty-context validate-plan-acceptance <dir>` | Checks legacy matrix/verdict artifacts when no state exists; when `task-state.json` exists, validates state-backed derived artifacts. It rejects contradictory complete claims, dangling evidence references, weak-proof complete rows, missing proof layers, material/critical drift, unapproved sibling substitution, blocking auditor findings, raw secrets/tokens/cookies, generated active-count drift, missing plan/AC cross-references and declared surface/architecture binding gaps. `errors` block; `warnings` / `hygiene` report cleanup. |
410
- | `npx --yes --package project-tiny-context-harness@latest ty-context composite-long-task <subcommand>` | Explicit `/composite-long-task-workflow` state helper for `init`, `compile`, `apply-slice-delta`, `derive`, `slice-gate`, `epoch-gate`, `final-gate`, `next-slices` and `render-goal` under `tmp/ty-context/plan-acceptance/**`. |
418
+ | `npx --yes --package project-tiny-context-harness@latest ty-context composite-long-task <subcommand>` | Explicit `/composite-long-task-workflow` state helper for `init`, `compile`, `start-attempt`, `run-assertion`, `record-evidence`, `apply-slice-delta`, `derive`, `slice-gate`, `epoch-gate`, `final-gate`, `next-slices` and `render-goal` under `tmp/ty-context/plan-acceptance/**`. |
411
419
  | `make validate-context` | Makefile wrapper for `validate-context`. |
412
420
  | `make validate-code-modularity` | Hard gate for touched handwritten source modularity; CI can set `TY_CONTEXT_MODULARITY_BASE=<ref>` to audit PR/base changes. |
413
421
  | `make validate-harness` | Composite gate for `validate-context` and `validate-code-modularity`. |
@@ -62,13 +62,21 @@ Machine-verifiable proof layer(如 UI/browser、runtime、API/schema、data ar
62
62
 
63
63
  `ty-context composite-long-task compile` 对这三份输入使用严格的 heading-based grammar。Product / Architecture Source 是一个文档级对象,只读固定字段。Technical Realization Plan 里的 PI 只有写成 `## PI-001: ...` 这类 Markdown heading 才是正式定义;Acceptance Checklist 里的 AC 也只有 `## AC-001: ...` 这类 heading 才是正式定义。heading section 内字段必须使用固定 `key: value`、缩进列表或 `key: |` 多行块。正文、表格、mapping preview、`related_acs` / `related_plan_items` 和普通列表里出现的 `PI-001` / `AC-001` 都只是引用;旧式 `- PI-001: ...` 或 `- AC-001: ...` 后面跟字段的写法会在 compile 阶段带文件和行号报错。
64
64
 
65
+ Strict V2 输入还要求 canonical Product / PI / AC 字段组。Product Source 必须包含 `scope_fit_decision`、`selected_scope_fit_slice`、`owner_boundary`、`primary_capability_path`、`non_completing_outcomes`、`assertion_policy` 等 Scope Fit / owner 字段;PI 必须包含 owner、trigger、state transition、observable result 和 assertion support 字段;AC 必须包含 `assertion_command`、`assertion_artifacts`、`positive_assertions`、`negative_assertions`、`machine_blocking`、`invalid_completion_signals` 和 `assertion_result_required`。未知字段、重复字段、表格字段和缺失 canonical 字段都会 compile fail。Canonical proof layers 是 `code`、`api_schema`、`worker_runtime`、`data_artifact`、`integration`、`ui_browser`、`security_redaction`、`all_provider_all_runner`、`cleanup_stale_scan` 和 `test`;`runtime` / `browser` / `api` / `data` / `security` 只是 legacy alias,会编译到 canonical 名称,且 `code` 不能单独完成 machine-backed AC。Evidence index 同时生成 `derived/evidence-index.md` 和 `derived/evidence-index.json`。
66
+
65
67
  对于非平凡 slice,生成的 composite workflow prompt 要求使用结构化 `slice-delta.json`。executor 通过 `ty-context composite-long-task apply-slice-delta <workdir> <slice-delta.json>` 应用 delta,然后运行 `ty-context composite-long-task derive` 和 `ty-context composite-long-task slice-gate`。每个 delta 记录 touched plan items / ACs、code changes、closed / remaining proof layers、blockers、cleanup assertions、`progress_value`,以及带有 `proves`、`does_not_prove`、freshness、redaction 和 reviewability 的 canonical evidence records。默认 slice 策略是把同一 AC、runtime 场景、proof 环境或验证路径下的 2-4 个强相关 missing layers 合并处理;单 gap slice 只留给 blocker、contradiction 或小型 metadata cleanup。prompt 还会要求先分类 missing layer、复用 DB/API/Browser 环境时使用唯一 proof prefix 和 cleanup assertion,并在生成 derived artifacts 后做 stale/overclaim scan。
66
68
 
67
69
  当 slice 声称关闭 machine-verifiable layer 时,`slice-delta.json` 的 evidence record 还应包含 `command_exit_code`、`assertion_result`,UI/browser 等需要时还应包含 `negative_evidence_scan`;derived matrix/verdict 只展示 assertion status 和 blocker,不能替代 assertion 执行。
68
70
 
71
+ 严格完成判定只看 current attempt,并且统一经过 Trusted Evidence Kernel。`compile` 从每个 machine-blocking AC 的 `assertion_command`、`assertion_artifacts`、proof layers、required tests、positive/negative assertions、invalid completion signals 和 final evidence expectation 生成 required command specs;`start-attempt --mode product_task|harness_task` 创建当前执行身份;`run-assertion` 记录 assertion command run;`record-evidence` 把 artifact 注册成 canonical EvidenceRecordV2;`final-gate` 只从当前记录重算。EvidenceRecordV2 必须包含 attempt/source/product/plan/checklist hash、git head、worktree fingerprint、command spec/run id、command line / exit code、artifact path/SHA/mtime、target AC ids、target PI ids、target proof layers、assertion status / exit code、positive assertions、negative assertions、invalid completion signals、negative evidence scan 和 required test ids。legacy v1 evidence、历史 `events.ndjson` complete 事件、旧 `derived/**` complete 视图、validator pass、final card、auditor prose、AC summary-only proof 和未注册临时 JSON 都不能完成 machine-blocking AC;更新的 failed command、Playwright/JUnit/test result 失败、owner DOM forbidden state、source/worktree drift、当前 task-state false/partial 或 derived/state mismatch 会让同 AC/layer 的旧 passed evidence 失效。
72
+
73
+ final-gate 在 kernel 内部固定执行:load 三输入、重算 source hashes、load task-state、load current attempt、load command-run records、load registered EvidenceRecords、discard stale evidence、contradiction scan、重算每个 AC、重算每个 PI、重算 `acceptance_target_status`、重算 `product_goal_complete`、regenerate `derived/**`、append event。machine-blocking AC 缺 assertion command/artifacts/assertions/invalid signals,UI proof 缺 browser/e2e/smoke/trace,final evidence 只指向 generated view,test cases 只有人工查看,或无法产出 `assertion_result` 时,AC 是 `under_specified`,PI blocked,`product_goal_complete=false`。AC-010 / final-gate summary 不能反向证明其它 AC:如果 summary AC passed 但其它 required AC missing / failed / stale,则 summary AC invalidated,reason 是 `final_gate_cannot_bootstrap_from_summary_only`。
74
+
75
+ Harness Drift Lock 把产品证明和验收工具链证明拆开。`product_task` 修改 Playwright spec、测试、assertion generator、AC010 helper、evidence writer、final-gate、validator、derive、task-state reducer、composite workflow Skill/protocol 或相关 Makefile/package test target 时,直接输出 `harness_drift_detected`、`acceptance_target_status=blocked`、`product_goal_complete=false`,并使用文案“本轮修改了验收工具链或测试本身,不能用被修改后的验收证明同一轮产品完成。请拆成独立 harness_task。”`harness_task` 可以修改 harness,但必须有 stale evidence、historical complete、derived contradiction、AC010 summary-only、target mismatch、API-only-for-UI、negative evidence after pass、source hash mismatch、dirty worktree mismatch、missing assertion_result、test weakening 和 happy path fixtures;它只证明 harness 修对,不证明产品任务完成。`protected-harness-baseline.json` 保护 final-gate、validator、derive、evidence registration、assertion schema、fixture expected outcomes、workflow protocol、Skill markdown 和 test runner scripts;product task 改 baseline blocked,harness task 改 baseline 必须写 reason 并跑 fixtures。
76
+
69
77
  生成的 composite workflow prompt 使用 Slice Gate / Epoch Gate / Final Gate 分层节奏,而不是每个 slice 后都跑完整 final gate。Progress Accounting 在 state 和 generated `derived/progress-ledger.*` 中记录 AC acceptance completion、engineering implementation progress、runtime/proof progress、system capability progress、representative sample progress、real object coverage、full population operation progress、artifact budget 和 workflow overhead。每个 slice 需要声明 artifact budget、proof-layer milestone 状态和 cleanup expectation。workflow overhead backpressure 要求 executor 批处理共享的 provider/browser/runtime/security epoch proof environment,清理 stale artifact,并选择 Next 3-5 high-value clusters 来优先关闭最多阻塞 AC / proof-layer gap。
70
78
 
71
- 重要使用提示:Minimal Context 有意把 Context 读取顺序、Context / 代码优先级和漂移检查保持为 agent 级软约束,而不是机器强制 edit-order gate。这个取舍适合短任务,但长任务、大上下文、多次交接或多轮验证时预期会漂移。单靠 Superpowers 在这类压力下仍可能漂移:它能增强执行纪律,但本身不负责保留上游 source authority、防止 scope shrinkage、证明完整符合 Technical Realization Plan,或按 Acceptance Checklist 逐 AC 强制证据成立。普通 checklist 准备需要 `/normal-long-task`;已有产品/架构原始意图源、具体技术实现方案和验收清单且需要 Superpowers-backed execution 时,可直接用 `/composite-long-task-workflow`。`Product Context Delta` 判断产品逻辑、页面职责、信息架构和验收语义是否需要写入 Context;`Technical Context Delta` 判断 API/schema、模块边界、runtime/state、验证/部署路径和稳定技术取舍是否需要写入 Context。`task-state.json` 是唯一执行状态源,`events.ndjson` 追加记录状态变化,`derived/**` 是生成阅读视图,`task-state.evidence[]` 是 canonical evidence ledger;local audit 只是 generated progress/recovery view,不能裁判完成;审计流程完成也不等于被验收目标完成。使用目标模式执行方案时,目标结束条件对齐 computed `product_goal_complete=true`,只读审计目标才可把 `audit_task_complete` 当元任务结束。最终顺序是 derive all views -> verification-before-completion -> `validate-superpowers-state` -> state-backed `validate-plan-acceptance` -> read-only auditor -> stale/overclaim scan -> `ty-context composite-long-task final-gate` 计算 completion;若审计后修改 state/evidence,需 rederive 并重跑两个 validator。`validate-plan-contract`、`validate-superpowers-state` 和 `validate-plan-acceptance` 只检查临时 artifact/state 自洽、引用存在、弱证据 complete 行、缺 required proof layer、material/critical drift、sibling substitution 和已声明的 surface/architecture binding 一致性,不证明产品质量。有 subagent 能力时,composite workflow prompt 会把 subagent 作为只读 auditor 加在主 agent 自证和 validator 之后;auditor 用固定 auditor checklist 找 gap,不是 proof source。Superpowers review 和 verification 仍然有价值,但不能覆盖 Tiny Context gates;通过 Superpowers review 不等于证明 plan conformance 或 checklist acceptance。
79
+ 重要使用提示:Minimal Context 有意把 Context 读取顺序、Context / 代码优先级和漂移检查保持为 agent 级软约束,而不是机器强制 edit-order gate。这个取舍适合短任务,但长任务、大上下文、多次交接或多轮验证时预期会漂移。单靠 Superpowers 在这类压力下仍可能漂移:它能增强执行纪律,但本身不负责保留上游 source authority、防止 scope shrinkage、证明完整符合 Technical Realization Plan,或按 Acceptance Checklist 逐 AC 强制证据成立。普通 checklist 准备需要 `/normal-long-task`;已有产品/架构原始意图源、具体技术实现方案和验收清单且需要 Superpowers-backed execution 时,可直接用 `/composite-long-task-workflow`。`Product Context Delta` 判断产品逻辑、页面职责、信息架构和验收语义是否需要写入 Context;`Technical Context Delta` 判断 API/schema、模块边界、runtime/state、验证/部署路径和稳定技术取舍是否需要写入 Context。`task-state.json` 是唯一执行状态源,`events.ndjson` 追加记录状态变化,`derived/**` 是生成阅读视图,`task-state.evidence[]` 是 canonical evidence ledger;local audit 只是 generated progress/recovery view,不能裁判完成;审计流程完成也不等于被验收目标完成。使用目标模式执行方案时,目标结束条件对齐 computed `product_goal_complete=true`;只读审计目标才可把 `audit_task_complete` 当元任务结束。validators、auditor、Superpowers verification generated views 仍是有用的执行检查,但不能覆盖 Trusted Evidence Kernel,也不能成为 product proof。`validate-plan-contract`、`validate-superpowers-state` 和 `validate-plan-acceptance` 只检查临时 artifact/state 自洽、引用存在、弱证据 complete 行、缺 required proof layer、material/critical drift、sibling substitution 和已声明的 surface/architecture binding 一致性,不证明产品质量。有 subagent 能力时,composite workflow prompt 会把 subagent 作为只读 auditor 加在主 agent 自证和 validator 之后;auditor 用固定 auditor checklist 找 gap,不是 proof source。Superpowers review 和 verification 仍然有价值,但不能覆盖 Tiny Context gates;通过 Superpowers review 不等于证明 plan conformance 或 checklist acceptance。
72
80
 
73
81
  最终顺序中的 final-gate 还包含 AC Evidence Assertion Gate 和 Negative Evidence Scan Gate;`validate-superpowers-state` / state-backed `validate-plan-acceptance` 会拒绝缺少或失败的 assertion-backed machine proof、negative evidence contradiction、target AC/layer 不匹配和 stale assertion evidence。它们仍只验证 assertion report 与 proof layer 的绑定、freshness、reviewability、redaction、negative contradiction 和 state/derived consistency,不执行项目测试本身,也不证明产品质量。
74
82
 
@@ -0,0 +1,18 @@
1
+ {
2
+ "schema_version": "protected-harness-baseline-v1",
3
+ "purpose": "Protect composite-long-task final completion mechanics from product-task self-validation drift.",
4
+ "baseline_reason": "Trusted Evidence Kernel and Harness Drift Lock define the canonical completion proof surface.",
5
+ "protected_categories": {
6
+ "final_gate_implementation": ["packages/ty-context/src/lib/superpowers-task-gates.ts", "packages/ty-context/src/lib/superpowers-task-evidence-kernel.ts"],
7
+ "validator_implementation": ["packages/ty-context/src/lib/superpowers-task-validator.ts"],
8
+ "derive_implementation": ["packages/ty-context/src/lib/superpowers-task-derive.ts"],
9
+ "evidence_registration_implementation": ["packages/ty-context/src/lib/superpowers-task-evidence.ts", "packages/ty-context/src/lib/superpowers-task-current-evidence.ts"],
10
+ "assertion_result_schema": ["packages/ty-context/src/lib/superpowers-task-state-schema.ts", "packages/ty-context/src/lib/superpowers-task-assertion-normalizers.ts"],
11
+ "fixture_expected_outcomes": ["tests/ty-context/superpowers-task-evidence-kernel.test.mjs", "tests/ty-context/composite-long-task-assertion-gate.test.mjs", "tests/ty-context/composite-long-task-expanded-assertion-gate.test.mjs"],
12
+ "workflow_protocol": [".codex/ty-context-managed/skills/composite-long-task-workflow/references/composite-long-task-workflow-protocol.md"],
13
+ "skill_markdown": [".codex/ty-context-managed/skills/composite-long-task-workflow/SKILL.md"],
14
+ "test_runner_scripts": ["packages/ty-context/package.json", "package.json", "Makefile"]
15
+ },
16
+ "product_task_rule": "Changing protected paths in product_task blocks product_goal_complete.",
17
+ "harness_task_rule": "Changing protected paths in harness_task requires a baseline reason, adversarial fixtures, a happy-path fixture and no product completion claim."
18
+ }
@@ -86,6 +86,8 @@ Strict input grammar:
86
86
  - Plain prose, lists, tables, mapping previews and `related_*` fields that mention PI/AC IDs are references, not definitions.
87
87
  - Legacy list-style definitions such as `- PI-001: ...` or `- AC-001: ...` followed by delivery fields are invalid.
88
88
 
89
+ Strict V2 canonical fields are code-owned by `superpowers-task-fields.ts` and must be present in the three sources. Product Source includes Scope Fit fields such as `scope_fit_decision`, `selected_scope_fit_slice`, `owner_boundary`, `primary_capability_path`, `non_completing_outcomes` and `assertion_policy`. PI items include owner/trigger/state/observable/assertion fields such as `owner_boundary`, `primary_capability_path`, `trigger_contract`, `state_transition_contract`, `observable_result_contract`, `assertion_support`, `required_assertion_commands` and `invalid_implementation_shortcuts`. ACs include assertion-gate fields such as `assertion_command`, `assertion_artifacts`, `positive_assertions`, `negative_assertions`, `machine_blocking`, `invalid_completion_signals` and `assertion_result_required`. Unknown fields, duplicate fields, table fields and missing canonical fields fail compile; this Skill must not infer, repair or backfill them.
90
+
89
91
  ## Authority Model
90
92
 
91
93
  - Product / Architecture Source owns intent, scope and boundaries.
@@ -140,6 +142,16 @@ ty-context validate-plan-acceptance <workdir>
140
142
 
141
143
  The validator name `validate-superpowers-state` remains valid because it checks the Superpowers-backed state schema.
142
144
 
145
+ Strict completion also exposes current-attempt evidence commands:
146
+
147
+ ```text
148
+ ty-context composite-long-task start-attempt <workdir> [--mode product_task|harness_task]
149
+ ty-context composite-long-task run-assertion <workdir> --ac AC-001 --proof-layer ui_browser -- <command>
150
+ ty-context composite-long-task record-evidence <workdir> --from <artifact> --command-run-id <id>
151
+ ```
152
+
153
+ `compile [--mode product_task|harness_task]` derives required command specs from AC proof layers, assertion commands, assertion artifacts, required test ids, positive/negative assertions, invalid completion signals and final evidence expectation. `start-attempt` records the current source bundle, git/worktree identity, mode and changed files. `run-assertion` records command runs for the current attempt. `record-evidence` registers artifacts as EvidenceRecordV2 only when attempt/source/product/plan/checklist/worktree/command/artifact/assertion target fields are present.
154
+
143
155
  ## Official Superpowers Binding
144
156
 
145
157
  Bind to official Superpowers skills only after the full checklist and executable Technical Realization Plan exist:
@@ -171,7 +183,15 @@ Superpowers review and verification remain useful execution checks, but they can
171
183
 
172
184
  Agents must not hand-set `product_goal_complete`. Implementation / execution goals complete only when final gate computes `product_goal_complete=true`.
173
185
 
174
- For UI/browser/API/runtime/worker/data/integration/security/test/all-provider/cleanup proof layers, do not mark ACs complete from screenshots, final cards, validator passes, matrix/verdict rows or prose evidence. Required machine-verifiable layers need passed `assertion_result`, zero command/assertion exit codes, target AC/layer coverage, passed positive and negative assertions and no failed/stale `negative_evidence_scan`.
186
+ Final completion is current-attempt-only and owned by the Trusted Evidence Kernel. Legacy v1 evidence, old attempt evidence, stale passed assertion JSON, historical `events.ndjson` completion events, stale `derived/**` views, matrix/verdict/evidence-index/final-summary rows, validator passes, final cards, auditor prose and AC summary-only proof are audit material only. They cannot complete machine-blocking ACs. Current failed command runs, Playwright/JUnit/test-result artifacts, owner DOM forbidden states, source/worktree drift, task-state false/partial status or derived/state mismatch invalidate older positive proof for the same AC/layer.
187
+
188
+ The final gate recomputes in this order: load the three inputs, recompute source hashes, load task state, load current attempt, load command-run records, load registered EvidenceRecords, discard stale evidence, run contradiction scan, recompute every AC, recompute every PI, recompute `acceptance_target_status`, recompute `product_goal_complete`, regenerate `derived/**` and append an event.
189
+
190
+ Canonical proof layers are `code`, `api_schema`, `worker_runtime`, `data_artifact`, `integration`, `ui_browser`, `security_redaction`, `all_provider_all_runner`, `cleanup_stale_scan` and `test`; legacy source aliases map `runtime -> worker_runtime`, `browser -> ui_browser`, `api -> api_schema`, `data -> data_artifact` and `security -> security_redaction`. `code` cannot complete a machine-backed AC by itself. For UI/browser/API/worker/data/integration/security/test/all-provider/cleanup proof layers, do not mark ACs complete from screenshots, final cards, validator passes, matrix/verdict rows or prose evidence. Required machine-verifiable layers need passed `assertion_result`, zero command/assertion exit codes, target AC/PI/layer coverage, passed positive and negative assertions, no invalid completion signal, reviewable artifacts and passed `negative_evidence_scan` with matching target proof layers. Machine-blocking ACs with missing assertion command/artifacts/assertions/invalid signals, manual-only tests, generated-only final evidence, impossible assertion results or UI proof without browser/e2e/smoke/trace evidence are `under_specified`, block the related PI and force `product_goal_complete=false`.
191
+
192
+ AC-010 / final-gate summary ACs can only summarize fresh EvidenceRecordV2 proof for the other ACs. If AC-010 passes while another required AC is missing, failed, stale or under-specified, invalidate AC-010 with `final_gate_cannot_bootstrap_from_summary_only`.
193
+
194
+ Harness Drift Lock: `product_task` cannot complete if it changed Playwright specs, tests, assertion generators, AC010 helpers, evidence writers, final-gate, validator, derive, task-state reducer, this workflow Skill/protocol or related Makefile/package test targets. Report `harness_drift_detected`, `acceptance_target_status=blocked`, `product_goal_complete=false` and exactly: `本轮修改了验收工具链或测试本身,不能用被修改后的验收证明同一轮产品完成。请拆成独立 harness_task。` A `harness_task` must have adversarial fixtures with expected final-gate outcomes and a happy-path fixture; it proves harness behavior only and must not declare product completion. `protected-harness-baseline.json` protects final-gate, validator, derive, evidence registration, assertion schema, fixture expected outcomes, workflow protocol, Skill markdown and test runner scripts; product task baseline changes are blocked, harness task baseline changes require a reason and fixture verification.
175
195
 
176
196
  If `audit_task_complete` is true but `acceptance_target_status` is not complete, report:
177
197
 
@@ -18,6 +18,9 @@ canonical_state:
18
18
  required_commands:
19
19
  init: ty-context composite-long-task init <workdir>
20
20
  compile: ty-context composite-long-task compile <workdir>
21
+ start_attempt: ty-context composite-long-task start-attempt <workdir>
22
+ run_assertion: ty-context composite-long-task run-assertion <workdir> --ac <AC-ID> --proof-layer <layer> -- <command>
23
+ record_evidence: ty-context composite-long-task record-evidence <workdir> --from <artifact> --command-run-id <id>
21
24
  derive: ty-context composite-long-task derive <workdir>
22
25
  apply_slice_delta: ty-context composite-long-task apply-slice-delta <workdir> <slice-delta.json>
23
26
  slice_gate: ty-context composite-long-task slice-gate <workdir> --slice <id>
@@ -31,3 +34,10 @@ completion_gate:
31
34
  cannot_hand_set_product_goal_complete: true
32
35
  includes_ac_evidence_assertion_gate: true
33
36
  includes_negative_evidence_scan_gate: true
37
+ current_attempt_only: true
38
+ trusted_evidence_kernel: true
39
+ harness_drift_lock: true
40
+ protected_harness_baseline: true
41
+ under_specified_machine_ac_blocks_completion: true
42
+ ac010_cannot_bootstrap_summary_only: true
43
+ derived_events_validators_never_proof: true
@@ -1,26 +1,17 @@
1
1
  /goal Execute the composite long-task workflow in {{workdir}}.
2
2
 
3
- First read and obey:
4
- - workflow-protocol.md
5
- - execution-binding.md
6
- - product-architecture-source.md
7
- - technical-realization-plan.md
8
- - acceptance-checklist.md
9
- - task-state.json and generated derived/** views
3
+ Read and obey workflow-protocol.md, execution-binding.md, product-architecture-source.md, technical-realization-plan.md, acceptance-checklist.md, task-state.json and generated derived/** views.
10
4
 
11
5
  Persistent contract:
12
- Product / Architecture Source owns intent, scope and boundaries. Technical Realization Plan owns PI implementation and plan conformance. Acceptance Checklist owns AC completion semantics and proof layers. task-state.json is the only execution state source; events.ndjson is append-only; derived/** is generated and must not be hand-edited as authority.
6
+ Product / Architecture Source owns intent, scope, Scope Fit, owner boundaries and assertion policy. Technical Realization Plan owns PI implementation and plan conformance. Acceptance Checklist owns AC completion semantics and proof layers. task-state.json is the only execution state source; events.ndjson is append-only; derived/** is generated and must not be hand-edited as authority.
13
7
 
14
- Use workflow-protocol.md to combine Tiny Context gates with official Superpowers execution. It is not business Context and must not be registered in project_context/context.toml. Do not redefine, duplicate or fork Superpowers mechanics. Prefer superpowers:subagent-driven-development when subagents are available, otherwise use superpowers:executing-plans. Use TDD for behavior gaps and superpowers:verification-before-completion before completion claims.
15
-
16
- Work in slices. Each slice must update state through slice-delta.json, canonical evidence records, derive, and slice-gate. Run epoch-gate for shared provider/browser/runtime/security proof environments. Preserve Context Delta, plan conformance, acceptance proof layers, redaction, reviewability and sample/full-population boundaries.
8
+ Use workflow-protocol.md to combine Tiny Context gates with official Superpowers execution. It is not business Context and must not be registered in project_context/context.toml. Prefer superpowers:subagent-driven-development when subagents are available; otherwise use superpowers:executing-plans. Use TDD for behavior gaps and superpowers:verification-before-completion before completion claims.
17
9
 
18
10
  Forbidden shortcuts:
19
- Do not mark UI/runtime/API/data/integration/test ACs complete from screenshots, final cards, validator passes, matrix/verdict rows or prose. Required machine-verifiable layers need assertion_result.status=passed, zero command/assertion exit codes, target AC/layer coverage, passed positive and negative assertions, reviewable artifacts and no failed/stale negative_evidence_scan.
20
- Tests alone do not prove plan conformance. Superpowers review does not override Tiny Context gates. Sample evidence does not prove full population unless AC allows. Manual edits under derived/** are not authority. Local audit cannot mark final completion. Do not claim full implementation while Context Delta is required but Context is not updated, or while Source-to-Context Coverage / Context-to-Implementation Binding has unresolved required gaps.
11
+ Do not mark UI/worker/API/data/integration/test ACs complete from screenshots, final cards, validator passes, derived rows, historical complete events, auditor prose, AC summary proof, unregistered JSON or stale attempts. Required machine proof needs current-attempt EvidenceRecordV2, assertion_result.status=passed, zero command/assertion exit codes, target AC/layer coverage, passed positive and negative assertions, reviewable artifacts and no failed/stale negative_evidence_scan with matching target proof layers. Tests alone do not prove plan conformance. Superpowers review does not override Tiny Context gates. Sample evidence does not prove full population unless AC allows. Local audit cannot mark final completion. Do not claim full implementation while Context Delta is required but Context is not updated, or while Source-to-Context Coverage / Context-to-Implementation Binding has unresolved required gaps.
21
12
 
22
13
  Completion:
23
- Do not hand-set product_goal_complete. Only complete after derive, verification-before-completion, validate-superpowers-state, validate-plan-acceptance, auditor/stale-overclaim checks when applicable, AC Evidence Assertion Gate, Negative Evidence Scan Gate, and final-gate compute product_goal_complete=true. If audit_task_complete is true but acceptance_target_status is not complete, report "Audit workflow completed; acceptance target not complete." and continue or stop with blockers; do not say Goal achieved.
14
+ Do not hand-set product_goal_complete. Only final-gate computes it through the Trusted Evidence Kernel after current attempt command runs and EvidenceRecordV2 are registered, stale evidence is discarded, contradictions are scanned and every AC/PI is recomputed. Machine-blocking ACs with missing assertion command/artifacts/assertions/invalid signals, manual-only proof, generated-only final evidence, impossible assertion_result or UI proof without browser/e2e/smoke/trace are under_specified and block completion. AC-010 cannot bootstrap missing, failed or stale ACs. product_task changing tests/harness/final-gate/validator/assertion generators/workflow protocol is harness_drift_detected and must split to harness_task; harness_task proves harness behavior only. Run AC Evidence Assertion Gate, Negative Evidence Scan Gate, then final-gate compute product_goal_complete=true before treating implementation as complete. If audit_task_complete is true but acceptance_target_status is not complete, report "Audit workflow completed; acceptance target not complete." If historical complete conflicts with current recompute, report "Historical stale completion event detected and ignored." and "Current recomputed product_goal_complete=false." Do not say Goal achieved unless current recompute is true.
24
15
 
25
16
  Blocked:
26
- Maximize safe autonomous progress using repo tools, local app/browser sessions, CLI auth and authorized elevation. Stop only for locally unsatisfiable blockers such as MFA, missing permission, external approval or unavailable credentials, and return the minimal user action list plus next agent step.
17
+ Maximize safe autonomous progress with repo tools, local app/browser sessions, CLI auth and authorized elevation. Stop only for MFA, missing permission, external approval or unavailable credentials, then return the minimal user action list plus next agent step.
@@ -35,13 +35,17 @@ Implementation advances through coherent slices. Each slice selects related PI /
35
35
 
36
36
  ## Evidence Protocol
37
37
 
38
- Evidence is canonical state, not prose. Every proof record enters `task-state.evidence[]` with evidence id, slice id, type, command or artifact paths, command exit code when applicable, `proves`, `does_not_prove`, freshness, redaction, reviewability / reproduction data and, for machine-verifiable layers, an `assertion_result`. Evidence must be fresh, reviewable and free of secrets, raw credentials, tokens, cookies and long raw payloads.
38
+ Evidence is canonical state, not prose. Every proof record enters `task-state.evidence[]` with evidence id, slice id, type, command or artifact paths, command exit code when applicable, `proves`, `does_not_prove`, freshness, redaction, reviewability / reproduction data and, for machine-verifiable layers, an `assertion_result`. Strict final completion uses EvidenceRecordV2 records bound to the current attempt, source bundle, product source hash, technical plan hash, acceptance checklist hash, git head, worktree fingerprint, command spec/run id, command line/exit code, artifact path/SHA/mtime, target AC ids, target PI ids, target proof layers, assertion status/exit code, positive assertions, negative assertions, invalid completion signals, negative evidence scan and required test ids. Evidence must be fresh, reviewable and free of secrets, raw credentials, tokens, cookies and long raw payloads.
39
39
 
40
- Machine-verifiable layers such as `ui_browser`, `api_schema`, `runtime`, `worker_runtime`, `data_artifact`, `integration`, `security_redaction`, `test`, `all_provider_all_runner` and `cleanup_stale_scan` are not complete from descriptions, screenshots, final cards, validator passes, matrix rows or verdict rows. They require `assertion_result.schema_version=assertion-result-v1`, `assertion_result.status=passed`, assertion exit code `0`, command exit code `0` when present, target AC/layer coverage, passed positive and negative assertions and reviewable artifacts. UI/browser layers also require owner surface, route/path, user action, browser/playwright/UI assertion evidence and a passed `negative_evidence_scan`.
40
+ Canonical proof layers are `code`, `api_schema`, `worker_runtime`, `data_artifact`, `integration`, `ui_browser`, `security_redaction`, `all_provider_all_runner`, `cleanup_stale_scan` and `test`; legacy aliases map `runtime -> worker_runtime`, `browser -> ui_browser`, `api -> api_schema`, `data -> data_artifact` and `security -> security_redaction`. `code` cannot complete a machine-backed AC by itself. Machine-verifiable layers are not complete from descriptions, screenshots, final cards, validator passes, matrix rows, verdict rows, evidence-index rows, final-summary text, historical `events.ndjson` complete events, auditor prose, summary-only AC proof or unregistered temporary JSON. They require current-attempt EvidenceRecordV2 plus `assertion_result.schema_version=assertion-result-v2`, `assertion_result.status=passed`, assertion exit code `0`, command exit code `0`, target AC/PI/layer coverage, passed positive and negative assertions, no invalid completion signal and reviewable artifacts. UI/browser layers also require owner surface, route/path, user action, browser/playwright/UI assertion evidence and a passed `negative_evidence_scan` with matching target proof layers and checked invalid completion signals.
41
+
42
+ The Trusted Evidence Kernel marks a machine-blocking AC `under_specified` when it lacks an assertion command, assertion artifacts, positive assertions, negative assertions, invalid completion signals, required UI/browser proof, concrete assertion result production or any non-generated final evidence path. Under-specified ACs block related PIs and force `product_goal_complete=false`. AC-010 / final-gate summary proof only summarizes fresh current EvidenceRecordV2 proof for the other ACs; it cannot bootstrap missing, failed, stale or under-specified ACs and is invalidated with `final_gate_cannot_bootstrap_from_summary_only` when it tries.
43
+
44
+ Strict V2 source fields are canonical. Product Source must carry Scope Fit, owner, primary capability and assertion policy fields. PI items must carry owner boundary, primary capability path, trigger/state/observable contracts, assertion support, required assertion commands and invalid implementation shortcuts. ACs must carry assertion command, artifacts, positive/negative assertions, machine-blocking flag, invalid completion signals and assertion-result requirement. Unknown, duplicate, table or missing canonical fields block compile; the workflow must not generate, infer, rewrite or repair the Technical Realization Plan or Acceptance Checklist.
41
45
 
42
46
  ## Derived Views
43
47
 
44
- `derived/**` contains generated reading views only: local audit, plan-conformance matrix, final acceptance verdict, progress ledger, evidence index, context alignment and final summary. Matrix and verdict views may summarize `assertion_status`, blocking assertion failures and negative evidence findings, but they never replace assertion execution and never rewrite Product / Architecture Source, Technical Realization Plan, Acceptance Checklist or `task-state.json`.
48
+ `derived/**` contains generated reading views only: local audit, plan-conformance matrix, final acceptance verdict, progress ledger, evidence index (`md` and `json`), context alignment and final summary. Matrix, verdict and evidence-index views may summarize `assertion_status`, blocking assertion failures and negative evidence findings, but they never replace assertion execution and never rewrite Product / Architecture Source, Technical Realization Plan, Acceptance Checklist or `task-state.json`.
45
49
 
46
50
  ## Gates
47
51
 
@@ -61,7 +65,11 @@ Superpowers remains the execution layer: prefer `superpowers:subagent-driven-dev
61
65
 
62
66
  ## Final Gate Protocol
63
67
 
64
- Final completion always runs in fixed order: derive all views, run `superpowers:verification-before-completion`, validate canonical state, validate plan acceptance artifacts, run auditor and stale-overclaim checks when applicable, rederive/revalidate if fixes changed state or evidence, then let `ty-context composite-long-task final-gate <workdir>` compute `product_goal_complete`.
68
+ Final completion always runs through the Trusted Evidence Kernel. Superpowers verification, validators, auditor checks and generated views are useful execution checks, but they are not proof authority. The AC Evidence Assertion Gate and Negative Evidence Scan Gate are enforced inside the kernel, not by trusting generated matrix or verdict text. The final gate itself runs in fixed order: load the three inputs, recompute source hashes, load task state, load current attempt, load command-run records, load registered EvidenceRecords, discard stale evidence, run contradiction scan, recompute every AC, recompute every PI, recompute `acceptance_target_status`, recompute `product_goal_complete`, regenerate `derived/**` and append an event.
69
+
70
+ The final gate recomputes from current source hashes, current attempt, required command specs/runs, registered EvidenceRecordV2 records, contradiction scan, Harness Drift Lock and protected baseline state. It ignores stale passed artifacts, historical complete events, stale derived complete views, validator passes and AC summary-only proof as proof. Newer failed commands, Playwright `.last-run.json`, `test-results/**/error-context.md`, JUnit/JSON reporter failures, negative evidence artifacts, owner DOM forbidden states, task-state false/partial values and derived/state mismatch block completion for the affected AC/layer. If historical completion conflicts with current recompute, report `Historical stale completion event detected and ignored.` and `Current recomputed product_goal_complete=false.`
71
+
72
+ Harness Drift Lock: `product_task` is blocked when the current attempt changed Playwright specs, tests, assertion generators, AC010 helpers, evidence writers, final-gate, validator, derive, task-state reducer, this workflow Skill/protocol or related Makefile/package test targets. The output must include `harness_drift_detected`, `acceptance_target_status=blocked`, `product_goal_complete=false` and `本轮修改了验收工具链或测试本身,不能用被修改后的验收证明同一轮产品完成。请拆成独立 harness_task。` A `harness_task` must include adversarial fixtures with expected final-gate outcomes for stale evidence, historical complete, derived contradiction, AC010 summary-only, target mismatch, API-only-for-UI, negative evidence after pass, source hash mismatch, dirty worktree mismatch, missing assertion_result, test weakening and one happy path; it never proves product completion. `protected-harness-baseline.json` blocks product-task changes to protected harness surfaces and requires a baseline reason plus fixtures for harness-task changes.
65
73
 
66
74
  ## Completion State Machine
67
75
 
@@ -306,6 +314,8 @@ does_not_prove
306
314
  freshness
307
315
  redaction
308
316
  reviewability / reproduction_steps
317
+ assertion_result for machine-verifiable layers
318
+ negative_evidence_scan with target_proof_layers where invalid completion signals must be ruled out
309
319
  ```
310
320
 
311
321
  `proves` and `does_not_prove` are both required because evidence must say what it proves and what it does not prove. This prevents samples, passing tests, screenshots, mocks or local audit text from being reused as full acceptance.
@@ -331,6 +341,7 @@ derived/local-audit.md
331
341
  derived/plan-conformance-matrix.md
332
342
  derived/final-acceptance-verdict.md
333
343
  derived/progress-ledger.md
344
+ derived/evidence-index.json
334
345
  derived/evidence-index.md
335
346
  derived/context-alignment.md
336
347
  derived/final-summary.md
@@ -493,17 +504,23 @@ Completion is blocked until the source conflict is resolved. Validators inspect
493
504
 
494
505
  ## 13. Phase Twelve: Fixed Final Gate Order
495
506
 
496
- Before final completion, the order is fixed:
497
-
498
- ```text
499
- 1. derive all views
500
- 2. superpowers:verification-before-completion
501
- 3. ty-context validate-superpowers-state <workdir>
502
- 4. ty-context validate-plan-acceptance <workdir>
503
- 5. read-only auditor / stale-overclaim scan when applicable
504
- 6. if auditor findings changed state/evidence, derive and validate again
505
- 7. AC Evidence Assertion Gate and Negative Evidence Scan Gate
506
- 8. ty-context composite-long-task final-gate <workdir>
507
+ Before final completion, the kernel order is fixed:
508
+
509
+ ```text
510
+ 1. load product-architecture-source.md, technical-realization-plan.md, acceptance-checklist.md
511
+ 2. recompute source hashes
512
+ 3. load task-state.json
513
+ 4. load current_attempt
514
+ 5. load command-run records
515
+ 6. load registered EvidenceRecordV2 records
516
+ 7. discard stale evidence
517
+ 8. contradiction scan
518
+ 9. recompute every AC
519
+ 10. recompute every PI
520
+ 11. recompute acceptance_target_status
521
+ 12. recompute product_goal_complete
522
+ 13. regenerate derived/**
523
+ 14. append event
507
524
  ```
508
525
 
509
526
  Legacy/internal compatibility may exist as:
@@ -1,6 +1,8 @@
1
1
  import path from "node:path";
2
2
  import { applySliceDelta, initializeSuperpowersTask } from "../lib/superpowers-task-state.js";
3
3
  import { compileSuperpowersTask } from "../lib/superpowers-task-compile.js";
4
+ import { startAndSaveSuperpowersAttempt } from "../lib/superpowers-task-attempt.js";
5
+ import { recordSuperpowersEvidence, runSuperpowersAssertion } from "../lib/superpowers-task-evidence.js";
4
6
  import { deriveSuperpowersArtifacts } from "../lib/superpowers-task-derive.js";
5
7
  import { runEpochGate, runFinalGate, runSliceGate } from "../lib/superpowers-task-gates.js";
6
8
  import { nextSuperpowersSlices } from "../lib/superpowers-task-next-slices.js";
@@ -26,10 +28,37 @@ export async function runCompositeLongTaskCommand(args, options) {
26
28
  return;
27
29
  }
28
30
  if (subcommand === "compile") {
29
- const state = await compileSuperpowersTask(workdir);
31
+ const state = await compileSuperpowersTask(workdir, { mode: attemptMode(args) });
30
32
  console.log(`compiled ${options.label} graph plan_items=${Object.keys(state.graph.plan_items).length} acs=${Object.keys(state.graph.acceptance_criteria).length}`);
31
33
  return;
32
34
  }
35
+ if (subcommand === "start-attempt") {
36
+ const attempt = await startAndSaveSuperpowersAttempt(workdir, attemptMode(args));
37
+ console.log(`started attempt ${attempt.task_attempt_id}`);
38
+ return;
39
+ }
40
+ if (subcommand === "run-assertion") {
41
+ const separator = args.indexOf("--");
42
+ const commandArgs = separator >= 0 ? args.slice(separator + 1) : [];
43
+ const run = await runSuperpowersAssertion(workdir, {
44
+ acId: optionValue(args, "--ac") ?? "",
45
+ proofLayer: optionValue(args, "--proof-layer") ?? "",
46
+ commandArgs
47
+ });
48
+ console.log(`recorded assertion command_run_id=${run.command_run_id} exit_code=${run.exit_code}`);
49
+ if (run.exit_code !== 0) {
50
+ process.exitCode = 1;
51
+ }
52
+ return;
53
+ }
54
+ if (subcommand === "record-evidence") {
55
+ const evidence = await recordSuperpowersEvidence(workdir, {
56
+ artifactPath: path.resolve(process.cwd(), optionValue(args, "--from") ?? ""),
57
+ commandRunId: optionValue(args, "--command-run-id") ?? ""
58
+ });
59
+ console.log(`registered evidence ${evidence.evidence_id}`);
60
+ return;
61
+ }
33
62
  if (subcommand === "apply-slice-delta") {
34
63
  const delta = args[2];
35
64
  if (!delta) {
@@ -89,7 +118,14 @@ function help(commandName, showRenderGoal) {
89
118
  const renderGoal = showRenderGoal ? "\n render-goal <workdir> Render workflow-protocol.md, execution-binding.md and goal-objective.txt" : "";
90
119
  console.log(`${commandName} commands:
91
120
  init <workdir> Initialize task-state.json and events.ndjson
92
- compile <workdir> Compile sources into task graph
121
+ compile <workdir> [--mode product_task|harness_task]
122
+ Compile sources into task graph
123
+ start-attempt <workdir> [--mode product_task|harness_task]
124
+ Start a fresh current attempt
125
+ run-assertion <workdir> --ac <id> --proof-layer <layer> -- <command>
126
+ Run and record an assertion command
127
+ record-evidence <workdir> --from <artifact> --command-run-id <id>
128
+ Register current-attempt EvidenceRecordV2
93
129
  apply-slice-delta <workdir> <delta> Apply structured slice delta, evidence and derived views
94
130
  derive <workdir> Generate derived/** views
95
131
  slice-gate <workdir> --slice <id> Validate one slice has real progress
@@ -101,3 +137,10 @@ function optionValue(args, name) {
101
137
  const index = args.indexOf(name);
102
138
  return index >= 0 ? args[index + 1] : undefined;
103
139
  }
140
+ function attemptMode(args) {
141
+ const value = optionValue(args, "--mode");
142
+ if (value === "harness_task") {
143
+ return "harness_task";
144
+ }
145
+ return "product_task";
146
+ }
@@ -0,0 +1,6 @@
1
+ import type { SuperpowersTaskState } from "./superpowers-task-state-schema.js";
2
+ export interface Ac010BootstrapResult {
3
+ invalidated_ac_ids: string[];
4
+ errors: string[];
5
+ }
6
+ export declare function evaluateAc010Bootstrap(state: SuperpowersTaskState, acStatuses: Record<string, string>): Ac010BootstrapResult;
@@ -0,0 +1,26 @@
1
+ const SUMMARY_ONLY = /\b(AC[-_ ]?010|final[-_ ]?gate|summary|final[-_ ]?acceptance[-_ ]?verdict|final[-_ ]?summary|matrix|validator)\b/i;
2
+ export function evaluateAc010Bootstrap(state, acStatuses) {
3
+ const invalidated = [];
4
+ const errors = [];
5
+ for (const [acId, ac] of Object.entries(state.graph?.acceptance_criteria ?? {})) {
6
+ if (!isSummaryAc(acId, ac)) {
7
+ continue;
8
+ }
9
+ if (acStatuses[acId] !== "complete" && ac.status !== "complete") {
10
+ continue;
11
+ }
12
+ const incomplete = Object.keys(state.graph.acceptance_criteria).filter((otherId) => otherId !== acId && acIsRequired(otherId) && acStatuses[otherId] !== "complete" && acStatuses[otherId] !== "out_of_scope_NA");
13
+ if (incomplete.length === 0) {
14
+ continue;
15
+ }
16
+ invalidated.push(acId);
17
+ errors.push(`${acId} final_gate_cannot_bootstrap_from_summary_only: summary AC cannot prove incomplete ACs ${incomplete.join(", ")}`);
18
+ }
19
+ return { invalidated_ac_ids: invalidated, errors };
20
+ }
21
+ function isSummaryAc(acId, ac) {
22
+ return /^AC-?0?10$/i.test(acId) || SUMMARY_ONLY.test([ac.scope ?? "", ac.assertion_command ?? "", ...(ac.final_evidence_expected ?? [])].join("\n"));
23
+ }
24
+ function acIsRequired(acId) {
25
+ return !/^AC-?0?10$/i.test(acId);
26
+ }
@@ -1,3 +1,4 @@
1
+ import { normalizeProofLayerId } from "./superpowers-task-fields.js";
1
2
  import { isRecord } from "./superpowers-task-state-schema.js";
2
3
  export function normalizeAssertionResult(value) {
3
4
  if (!isRecord(value)) {
@@ -9,12 +10,16 @@ export function normalizeAssertionResult(value) {
9
10
  runner: String(value.runner ?? ""),
10
11
  exit_code: numberValue(value.exit_code),
11
12
  target_ac_ids: stringArray(value.target_ac_ids),
12
- target_proof_layers: stringArray(value.target_proof_layers),
13
+ target_pi_ids: stringArray(value.target_pi_ids),
14
+ target_proof_layers: stringArray(value.target_proof_layers).map(normalizeProofLayerId),
13
15
  owner_surface: value.owner_surface === undefined ? undefined : String(value.owner_surface),
14
16
  route: value.route === undefined ? undefined : String(value.route),
15
17
  action: value.action === undefined ? undefined : String(value.action),
16
18
  positive_assertions: checkArray(value.positive_assertions),
17
19
  negative_assertions: checkArray(value.negative_assertions),
20
+ invalid_completion_signals: checkArray(value.invalid_completion_signals),
21
+ negative_evidence_scan: normalizeNegativeEvidenceScan(value.negative_evidence_scan),
22
+ required_test_ids: stringArray(value.required_test_ids),
18
23
  artifacts: stringArray(value.artifacts)
19
24
  };
20
25
  }
@@ -26,6 +31,8 @@ export function normalizeNegativeEvidenceScan(value) {
26
31
  schema_version: String(value.schema_version ?? ""),
27
32
  status: String(value.status ?? ""),
28
33
  target_ac_ids: stringArray(value.target_ac_ids),
34
+ target_proof_layers: stringArray(value.target_proof_layers).map(normalizeProofLayerId),
35
+ invalid_completion_signals_checked: stringArray(value.invalid_completion_signals_checked),
29
36
  owner_surface: value.owner_surface === undefined ? undefined : String(value.owner_surface),
30
37
  route: value.route === undefined ? undefined : String(value.route),
31
38
  forbidden_findings: findingArray(value.forbidden_findings),