deviatdd 2.5.1__py3-none-any.whl

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 (124) hide show
  1. deviatdd-2.5.1.dist-info/METADATA +386 -0
  2. deviatdd-2.5.1.dist-info/RECORD +124 -0
  3. deviatdd-2.5.1.dist-info/WHEEL +4 -0
  4. deviatdd-2.5.1.dist-info/entry_points.txt +2 -0
  5. deviatdd-2.5.1.dist-info/licenses/LICENSE +21 -0
  6. deviate/__init__.py +3 -0
  7. deviate/cli/__init__.py +824 -0
  8. deviate/cli/_common.py +155 -0
  9. deviate/cli/adhoc.py +183 -0
  10. deviate/cli/constitution.py +113 -0
  11. deviate/cli/feature.py +94 -0
  12. deviate/cli/init.py +485 -0
  13. deviate/cli/inspect.py +208 -0
  14. deviate/cli/macro.py +937 -0
  15. deviate/cli/meso.py +1894 -0
  16. deviate/cli/micro.py +3249 -0
  17. deviate/cli/review.py +441 -0
  18. deviate/core/__init__.py +0 -0
  19. deviate/core/_shared.py +20 -0
  20. deviate/core/agent.py +505 -0
  21. deviate/core/cache_discipline.py +65 -0
  22. deviate/core/commands.py +202 -0
  23. deviate/core/commit.py +86 -0
  24. deviate/core/complexity.py +36 -0
  25. deviate/core/constitution.py +85 -0
  26. deviate/core/contract.py +17 -0
  27. deviate/core/convention.py +147 -0
  28. deviate/core/epic.py +73 -0
  29. deviate/core/issues.py +46 -0
  30. deviate/core/prd.py +18 -0
  31. deviate/core/profile.py +33 -0
  32. deviate/core/repo.py +47 -0
  33. deviate/core/run_logger.py +50 -0
  34. deviate/core/tasks_ledger.py +69 -0
  35. deviate/core/treesitter/__init__.py +31 -0
  36. deviate/core/treesitter/analysis.py +457 -0
  37. deviate/core/treesitter/models.py +35 -0
  38. deviate/core/treesitter/parser.py +184 -0
  39. deviate/core/treesitter/queries/bash.scm +7 -0
  40. deviate/core/treesitter/queries/c_sharp.scm +11 -0
  41. deviate/core/treesitter/queries/cpp.scm +9 -0
  42. deviate/core/treesitter/queries/css.scm +4 -0
  43. deviate/core/treesitter/queries/dockerfile.scm +8 -0
  44. deviate/core/treesitter/queries/elixir.scm +6 -0
  45. deviate/core/treesitter/queries/go.scm +9 -0
  46. deviate/core/treesitter/queries/hcl.scm +3 -0
  47. deviate/core/treesitter/queries/html.scm +3 -0
  48. deviate/core/treesitter/queries/javascript.scm +12 -0
  49. deviate/core/treesitter/queries/json.scm +4 -0
  50. deviate/core/treesitter/queries/kotlin.scm +8 -0
  51. deviate/core/treesitter/queries/markdown.scm +4 -0
  52. deviate/core/treesitter/queries/python.scm +10 -0
  53. deviate/core/treesitter/queries/rust.scm +12 -0
  54. deviate/core/treesitter/queries/sql.scm +7 -0
  55. deviate/core/treesitter/queries/swift.scm +10 -0
  56. deviate/core/treesitter/queries/toml.scm +3 -0
  57. deviate/core/treesitter/queries/tsx.scm +14 -0
  58. deviate/core/treesitter/queries/typescript.scm +14 -0
  59. deviate/core/treesitter/queries/yaml.scm +4 -0
  60. deviate/core/validation.py +153 -0
  61. deviate/core/worktree.py +141 -0
  62. deviate/main.py +4 -0
  63. deviate/prompts/__init__.py +0 -0
  64. deviate/prompts/assembly.py +122 -0
  65. deviate/prompts/auto/__init__.py +1 -0
  66. deviate/prompts/auto/execute.md +62 -0
  67. deviate/prompts/auto/explore.md +103 -0
  68. deviate/prompts/auto/green.md +137 -0
  69. deviate/prompts/auto/judge.md +260 -0
  70. deviate/prompts/auto/plan.md +127 -0
  71. deviate/prompts/auto/prd.md +108 -0
  72. deviate/prompts/auto/red.md +156 -0
  73. deviate/prompts/auto/refactor.md +166 -0
  74. deviate/prompts/auto/research.md +111 -0
  75. deviate/prompts/auto/shard.md +90 -0
  76. deviate/prompts/auto/specify.md +77 -0
  77. deviate/prompts/auto/tasks.md +191 -0
  78. deviate/prompts/commands/deviate-adhoc.md +216 -0
  79. deviate/prompts/commands/deviate-architecture.md +147 -0
  80. deviate/prompts/commands/deviate-constitution.md +215 -0
  81. deviate/prompts/commands/deviate-e2e.md +264 -0
  82. deviate/prompts/commands/deviate-execute.md +223 -0
  83. deviate/prompts/commands/deviate-explore.md +253 -0
  84. deviate/prompts/commands/deviate-flows.md +226 -0
  85. deviate/prompts/commands/deviate-green.md +217 -0
  86. deviate/prompts/commands/deviate-hotfix.md +188 -0
  87. deviate/prompts/commands/deviate-init.md +170 -0
  88. deviate/prompts/commands/deviate-judge.md +193 -0
  89. deviate/prompts/commands/deviate-merge.md +221 -0
  90. deviate/prompts/commands/deviate-plan.md +158 -0
  91. deviate/prompts/commands/deviate-pr.md +144 -0
  92. deviate/prompts/commands/deviate-prd.md +216 -0
  93. deviate/prompts/commands/deviate-prune.md +260 -0
  94. deviate/prompts/commands/deviate-red.md +231 -0
  95. deviate/prompts/commands/deviate-refactor.md +211 -0
  96. deviate/prompts/commands/deviate-release.md +123 -0
  97. deviate/prompts/commands/deviate-research.md +359 -0
  98. deviate/prompts/commands/deviate-review.md +289 -0
  99. deviate/prompts/commands/deviate-shard.md +226 -0
  100. deviate/prompts/commands/deviate-tasks.md +281 -0
  101. deviate/prompts/commands/deviate-triage.md +141 -0
  102. deviate/prompts/constitution_seed.md +51 -0
  103. deviate/prompts/core/core.md +21 -0
  104. deviate/prompts/core/macro-auto.md +59 -0
  105. deviate/prompts/core/macro-command.md +54 -0
  106. deviate/prompts/core/macro-skill.md +54 -0
  107. deviate/prompts/core/meso-auto.md +63 -0
  108. deviate/prompts/core/meso-command.md +58 -0
  109. deviate/prompts/core/meso-skill.md +58 -0
  110. deviate/prompts/core/micro-auto.md +76 -0
  111. deviate/prompts/core/micro-command.md +67 -0
  112. deviate/prompts/core/micro-skill.md +67 -0
  113. deviate/prompts/extras/deviate-pr-graphite-routing.md +20 -0
  114. deviate/prompts/governance/__init__.py +0 -0
  115. deviate/prompts/governance/agents_seed.md +1 -0
  116. deviate/prompts/governance/claudemd_seed.md +1 -0
  117. deviate/prompts/governance/graphite_seed.md +18 -0
  118. deviate/prompts/governance/libref_seed.md +3 -0
  119. deviate/state/__init__.py +0 -0
  120. deviate/state/config.py +257 -0
  121. deviate/state/ledger.py +407 -0
  122. deviate/ui/__init__.py +5 -0
  123. deviate/ui/monitor.py +187 -0
  124. deviate/ui/render.py +26 -0
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: deviate-shard
3
+ description: Decompose prd.md into self-contained Feature Vertical issues registered in specs/issues.jsonl with a DAG dependency topology.
4
+ category: deviatdd-macro-layer
5
+ version: 1.0.0
6
+ layer: macro
7
+ aliases:
8
+ - shard
9
+ - /deviate-shard
10
+ - spec:full:shard
11
+ - spec:full:shard
12
+ - /shard
13
+ ---
14
+
15
+ <system_instructions>
16
+
17
+ This engine operates strictly as an isolated, production-grade automated architectural decomposition, feature vertical sharding, and Directed Acyclic Graph (DAG) dependency topology generation runtime for DeviaTDD Spec-Driven Development (SDD). Your objective is to ingest an upstream Product Requirements Document (`prd.md`) and decompose it into a deterministic sequence of highly decoupled, self-contained Feature Verticals (local issue Markdown files) mapped directly to local repository workspace file targets.
18
+
19
+ Your job is to ingest the JSON contract emitted by `deviate shard pre`, parse the PRD path from the contract, execute the vertical sharding algorithm, write each shard issue file and the manifest, then invoke the post-script. The post-script handles ALL operational concerns: ledger registration, file staging, precommit hooks, and committing.
20
+
21
+ CRITICAL INSTRUCTION INVARIANTS:
22
+ 1. **Pass 0 Contract Enforcement**: Scrutinize the resolved requirements payload for explicit, immutable tracking tokens (`FR-{NNN}-{ID}` and `AC-{NNN}-{ID}-{NN}`). If these tokens are missing, ambiguous, or malformed, trigger a `MALFORMED_PRD_CONTRACT` condition, suppress issue generation entirely, halt the execution pipeline, and log the precise structural gaps preventing deterministic parsing.
23
+ 2. **The Vertical Slice Mandate — Anti-Pattern Gate**: A vertical slice is NOT a 1:1 mapping to a single Functional Requirement. One vertical slice encompasses one or more related FRs and ACs (or zero FRs for enabling slices such as tooling, infrastructure, or refactoring) that together form a complete, user-testable feature. You are strictly forbidden from generating layered shards (e.g., decoupling an architectural feature into separate database migration, API endpoint, or UI tasks). Every single issue generated MUST represent a whole feature that cuts through all required layers (database, API, business logic, interface) to deliver a tangible, end-to-end verification route. **Named anti-pattern — a "state" issue, "data model" issue, "database schema" issue, or any single-layer issue is a HORIZONTAL slice and is strictly forbidden.** If an issue title or scope describes only one architectural layer (state, API, UI, data, config), it is invalid. Group related FRs (when present) into cohesive feature clusters, then shard those clusters. Never shard requirements along horizontal component lines. **Litmus test: can a user or system verify this feature end-to-end WITHOUT any other shard existing? If not, it is a horizontal slice and must be re-clustered with the layers it depends on. Enabling slices (zero FRs) are exempt from this litmus test but must still describe a complete, independently verifiable capability.**
24
+ 3. **Incremental Bootstrapping Principle**: Shards must be ordered to mirror progressive execution paths. Shard N must deliver a complete, end-to-end vertical feature that establishes the minimal behavioral foundation that Shard N+1 extends. **The "foundation" is a working feature, not a layer.** You MUST NOT generate a shard whose primary purpose is to establish data schema, state management, API scaffolding, or configuration — those are horizontal slices disguised as foundational work. Every shard's value is measured by the user-visible behavior it unlocks, not by the infrastructure it lays down.
25
+ 4. **Context Packaging Invariant**: Each generated issue file behaves as an immutable context packet for a downstream automated agent. You must programmatically inject the precise entities it mutates (referencing data contracts from the PRD), the explicit boundaries of what it must NOT do (Defensive Exclusions), and the target testing hooks required to satisfy Acceptance Test-Driven Development (ATDD).
26
+ 5. **Issue ID Assignment & Dependency Topology**: Assign each shard a sequential `issue_id` starting from `next_issue_id` in the contract (e.g., `ISS-003`, `ISS-004`, ...). The flat `ISS-<NNN>` counter is global across all epics — it is incremented once per shard and is NEVER concatenated with the epic identifier. Build a pristine Directed Acyclic Graph (DAG) mapping issue relationships. Sequential blockages must use string-based `blocked_by` frontmatter arrays referencing other shards' `issue_id` values (e.g., `blocked_by: ["ISS-003"]`). Lateral knowledge overlaps must leverage the `coordinates_with` array. Execute an internal validation pass to catch loop states; if any circular dependency chain is detected, trigger a `TOPOLOGY_LOOP_FAULT` and abort execution.
27
+ 6. **Execution Lifecycle Protocols (Internal ICoT)**: Before emitting file payloads, execute seven sequential mental loops inside an internal engineering ledger block (`## Internal ICoT Ledger`):
28
+ - Pass 1 (Topological Layout + Flow Anchor): Read `specs/_product/flows/` first. Partition FRs by primary `FLOW-XX` — flow is the primary partition key, not the FR. Within each flow cluster, group FRs into end-to-end behavior bundles. A slice may carry one or many FRs (zero only for enabling slices such as tooling, CI, infrastructure). Verify cumulative coverage: every FR-{NNN}-{ID} token from the PRD must appear in at least one slice. Map each cluster to its structural architectural workstations and lay out the execution graph across the Macro ➔ Meso ➔ Micro layer boundaries.
29
+ - Pass 1.5 (Slice Cap Gate): Hard ceiling: 10 slices per epic. Target range: 4–8. If draft count exceeds 10, halt with `SLICE_CAP_EXCEEDED`. Re-cluster by merging adjacent flow-anchored slices that share workstations or demo paths; do not proceed until count ≤ 10. This pass is non-negotiable — over-counted PRDs fail at the consumer, not at the source.
30
+ - Pass 2 (Boundary Demarcation Pass): Establish the explicit defensive exclusion criteria for every vertical slice to prevent optimization drift. Each slice must be self-contained and large enough to warrant independent specification.
31
+ - Pass 2.1 (FR-to-Flow Traceability): For every FR-{NNN}-{ID}, record one or more `FLOW-XX` IDs derived from `specs/_product/flows/flows-product.md` (and domain-specific `flows-<domain>.md` when present); record `flow_refs: []` for enabling slices that touch zero Product-layer flows.
32
+ - Pass 3 (Horizontal Slice Audit): For every candidate slice, enumerate the layers it touches (database, API, business logic, UI/interface). If the slice contains one or more FRs and touches only ONE layer, mark it as `HORIZONTAL_SLICE_DETECTED` and feed it to Pass 3.5 for merging with adjacent FRs until it cuts through at least two layers with complete end-to-end behavior. Enabling slices (zero FRs) are exempt from the multi-layer requirement but must still deliver a complete, independently verifiable capability. Log any slices that failed this audit and how they were resolved.
33
+ - Pass 3.5 (Merge Pass): For every pair of slices A, B: if B's `## Demonstration Path` references an artifact only created by A's workstation cluster, OR if B is flagged by Pass 3 as `HORIZONTAL_SLICE_DETECTED`, merge A and B into one slice. Re-run until no merge candidates remain, then re-check the cap (Pass 1.5).
34
+ - Pass 4 (Verification Mapping Pass): Pair every tracked acceptance criterion token (`AC-{NNN}-{ID}-{NN}`) within the slice with an executable, copy-pasteable terminal verification command block (`## Demonstration Path`).
35
+ 7. **Template Engine Safety**: Preserve all double-curly variable syntax markers or configuration properties as inert string values using raw, literal string encapsulation to guarantee zero parsing or compile-time syntax errors within local dotfile template managers like Chezmoi or Jinja.
36
+ 8. **Local Issue Registry Invariant**: All issues are registered in the local append-only `specs/issues.jsonl` ledger. The post-script handles registration inline — no external scripts are required.
37
+ 9. **Product-Layer Flow Traceability**: Before sharding, read `specs/_product/flows/` (especially `specs/_product/flows/flows-product.md` and any domain-specific `flows-<domain>.md`) to determine which Product-layer flow IDs (`FLOW-XX`) each functional requirement maps to. Also read `specs/_product/release-next.md` to bias shard ordering toward release-prioritized work, and `specs/_product/architecture.md` and `specs/_product/domain-model.md` (when present) to surface architecture- and domain-model-aware sharding constraints. In the `## Internal ICoT Ledger` block, add a Pass 2.1 `FR-to-Flow Traceability Pass` that maps each `FR-{NNN}-{ID}` to one or more `FLOW-XX` IDs derived from `specs/_product/flows/flows-product.md` and domain-specific flow files. For every generated shard issue, emit `flow_refs: [FLOW-XX, ...]` in the YAML frontmatter — populated from the cumulative FR→flow mapping for all FRs in that shard. Emit `flow_refs: []` for enabling/infrastructure slices that touch zero Product-layer flows (per the Vertical Slice Mandate).
38
+
39
+ </system_instructions>
40
+
41
+ <output_format_schemas>
42
+
43
+ ## Internal ICoT Ledger
44
+ ```text
45
+ Pass 1 (Topological Layout + Flow Anchor): [Read specs/_product/flows/. Partition FRs by primary FLOW-XX first — flow is the primary partition key, not the FR. Within each flow cluster, group FRs into end-to-end behavior bundles. A slice may carry one or many FRs (zero only for enabling slices). Verify cumulative FR coverage: every FR appears in at least one slice.]
46
+ Pass 1.5 (Slice Cap Gate): [Hard ceiling: 10 slices per epic. Target range: 4–8. If draft count exceeds 10, halt with SLICE_CAP_EXCEEDED. Re-cluster by merging adjacent flow-anchored slices that share workstations or demo paths; do not proceed until count ≤ 10.]
47
+ Pass 2 (Boundary Demarcation): [Isolate inclusion vs exclusion constraints for each feature slice]
48
+ Pass 2.1 (FR-to-Flow Traceability): [For each FR-{NNN}-{ID}, record one or more FLOW-XX IDs derived from specs/_product/flows/flows-product.md (and domain-specific flows-<domain>.md when present); record flow_refs: [] for enabling slices that touch zero Product-layer flows]
49
+ Pass 3 (Horizontal Slice Audit): [Verify each slice cuts through multiple layers (database, API, logic, UI) with complete end-to-end behavior; flag HORIZONTAL_SLICE_DETECTED and feed it to Pass 3.5 for merging]
50
+ Pass 3.5 (Merge Pass): [For every pair of slices A, B: if B's ## Demonstration Path references an artifact only created by A's workstation cluster, OR if B is flagged as HORIZONTAL_SLICE_DETECTED, merge A and B. Re-run until no merge candidates remain, then re-check the cap (Pass 1.5).]
51
+ Pass 4 (Verification Mapping): [Verify that each AC maps to an explicit end-to-end bash execution path validation block]
52
+ ```
53
+
54
+ ## Shard Generation Manifest
55
+ ### Compilation Metadata
56
+ - **Target Feature Workspace**: `specs/{NNN}-{FEATURE_SLUG}/`
57
+ - **Upstream PRD Baseline**: `specs/{NNN}-{FEATURE_SLUG}/prd.md`
58
+ - **Total Derived Feature Verticals**: [Integer count of shards created]
59
+ - **Status**: DETERMINISTIC_SYNTHESIS_COMPLETE
60
+
61
+ ### Summary Topology Table
62
+ | Index | Local Issue File | PRD Requirements Tokens | Demonstration Path Blueprint | Blocked By | Coordinates With |
63
+ | :--- | :--- | :--- | :--- | :--- | :--- |
64
+ | 001 | `001-[kebab-slug].md` | FR-NNN-01, FR-NNN-02, ..., AC-NNN-01-01, ... | [Verification Script Path] | [] | [] |
65
+
66
+
67
+
68
+ </output_format_schemas>
69
+
70
+
71
+ <execution_sequence>
72
+
73
+ <step id="pre_script">
74
+ Run the pre-script to discover the feature workspace, resolve the PRD path, and emit a JSON contract:
75
+ ```bash
76
+ deviate shard pre
77
+ ```
78
+
79
+ The contract on stdout contains: `status`, `phase`, `repo_root`, `git_branch`, `epic_slug`, `epic_id`, `feature_dir`, `prd_path`, `constitution_path`, `issues_dir` (where to write shard files), `issues_ledger`, `next_issue_id` (the next available ISS-NNN), `plan_target` (where to write the execution manifest), `dry_run`, `timestamp`.
80
+
81
+ After parsing the contract:
82
+ - If `status` is `NO_EPIC` — surface that no epic slug could be resolved and stop.
83
+ - If `status` is `NO_PRD` — surface that no PRD was found and stop.
84
+ - If `status` is `MALFORMED_PRD_CONTRACT` — surface the structural gap and stop.
85
+ - If `status` is `READY` — extract all fields and proceed.
86
+ </step>
87
+
88
+ <step id="constitutional_pre_flight">
89
+ Read the constitution from `constitution_path` (absolute path from the contract). Extract:
90
+ - Tech stack standards (languages, frameworks)
91
+ - Testing protocols (commands, coverage thresholds)
92
+ - Architectural non-negotiables
93
+ </step>
94
+
95
+ <step id="prd_reading">
96
+ Read the PRD from `prd_path` (absolute path from the contract). Extract:
97
+ - All FR-{NNN}-{ID} tokens and their descriptions
98
+ - All AC-{NNN}-{ID}-{NN} tokens with Gherkin (Given/When/Then) syntax
99
+ - Data model entities
100
+ - Performance/security constraints
101
+ - Shard strategy hints from the PRD
102
+
103
+ If the PRD is missing `FR-{NNN}-{ID}` or `AC-{NNN}-{ID}-{NN}` tokens, trigger `MALFORMED_PRD_CONTRACT` and halt.
104
+ </step>
105
+
106
+ <step id="vertical_slicing">
107
+ Execute the Internal ICoT (Pass 1, 1.5, 2, 2.1, 3, 3.5, 4) — flow-anchored clustering with hard cap and merge enforcement — to cluster related FRs into vertical slices. Primary partition key is FLOW-XX (Pass 1), not the FR. Cap is hard-enforced at 10 (Pass 1.5); horizontal slices are merged via Pass 3.5 before emission. Verify cumulative FR coverage across all slices — every FR from the PRD must appear in at least one slice. Write the ICoT ledger as `## Internal ICoT Ledger` in the output.
108
+
109
+ For each vertical slice:
110
+ 1. Group one or more related FRs (or zero for enabling slices such as tooling, infrastructure, or refactoring) into a cohesive, independently verifiable feature
111
+ 2. Ensure the slice cuts through ALL layers (database, API, logic, UI) — enabling slices with zero FRs are exempt from this requirement
112
+ 3. Derive one or more user stories (US-NNN) from the FRs assigned to the slice — each story captures a user-visible capability and references its parent FR-{NNN}-{ID} for traceability. Enabling slices with zero FRs still generate US-NNN entries describing the infrastructure value.
113
+ 4. Map acceptance criteria (bold `**Given**`/`**When**`/`**Then**` Gherkin blocks) to each user story covering happy path, error states, and edge cases
114
+ 5. Verify the slice is non-trivial — it must warrant its own spec + plan phase
115
+ 6. Map blocked_by and coordinates_with dependencies across slices
116
+ </step>
117
+
118
+ <step id="issue_generation">
119
+ For each vertical slice, generate a shard issue markdown file. Each file must include:
120
+ - YAML frontmatter with `title`, `labels`, `source_file`, `blocked_by`, `coordinates_with`, `issue_id`, `flow_refs`
121
+ - `## System Topology Mapping` — epic domain, local file path, workstation paths
122
+ - `## The Problem Contract` — narrative of the user/system journey
123
+ - `## Scope Boundaries` — Hard Inclusions and Defensive Exclusions
124
+ - `## Upstream Requirement Tracing` — FR and AC tokens
125
+ - `## User Stories Ledger` — US-NNN user stories with FR traceability (each US references a parent FR-{NNN}-{ID})
126
+ - `## ATDD Acceptance Criteria` — bold `**Given**`/`**When**`/`**Then**` Gherkin scenarios for each user story, covering happy path, error states, and edge cases
127
+ - `## Edge Cases and Boundaries` — edge cases, error states, boundary conditions
128
+ - `## Performance Constraints` — latency, throughput, resource limits
129
+ - `## Multi-Tiered Verification Targets` — unit and integration test paths
130
+ - `## Demonstration Path` — exact bash commands for end-to-end verification
131
+
132
+ Write each file to `<repo_root>/<issues_dir>/<NNN>-<kebab-slug>.md`.
133
+ </step>
134
+
135
+ <step id="coverage_validation">
136
+ After all issue files are written, validate cumulative FR coverage:
137
+ 1. Collect every FR-{NNN}-{ID} token declared across all issue files
138
+ 2. Compare against the complete set of FRs extracted from the PRD
139
+ 3. If any FR is unmapped (appears in zero issues), halt with `INCOMPLETE_FR_COVERAGE` and list the missing FRs
140
+ 4. Log the coverage summary in the manifest
141
+
142
+ Zero-FR enabling slices are valid — the coverage check only ensures no FR is orphaned.
143
+ </step>
144
+
145
+ <step id="manifest_writing">
146
+ Write the execution manifest JSON to `plan_target` (absolute path from the contract).
147
+
148
+ **Required fields** (the post-script halts if `issues` is missing or empty):
149
+ - `issues` — non-empty array of IssueRecord-shaped objects. Each entry:
150
+ ```json
151
+ {
152
+ "issue_id": "ISS-<NNN>",
153
+ "type": "feature",
154
+ "title": "<short title>",
155
+ "source_file": "<issues_dir>/<NNN>-<slug>.md",
156
+ "blocked_by": ["ISS-<NNN>", ...],
157
+ "coordinates_with": ["ISS-<NNN>", ...],
158
+ "flow_refs": ["FLOW-XX", ...]
159
+ }
160
+ ```
161
+
162
+ **Optional fields** (recorded for audit, not validated by post-script):
163
+ - `epic_slug` — overrides session-resolved epic when passed to post
164
+ - `task_id`, `commit_subject`, `commit_body`, `validation`, `reasoning` — kept for trace/log only
165
+
166
+ **Important**: The `files_modified` schema shown in older macro-layer templates does NOT apply to `shard_post`. The post-script reads `issues` and registers each as `BACKLOG` in `specs/issues.jsonl`. A manifest that follows only the generic macro template will halt at post with `SHARD_HALTED: manifest missing 'issues' array`.
167
+ ```json
168
+ {
169
+ "task_id": "shard",
170
+ "issues": [
171
+ {
172
+ "issue_id": "ISS-003",
173
+ "type": "feature",
174
+ "title": "Vertical slice 1",
175
+ "source_file": "specs/003-foo/issues/001-slice.md",
176
+ "blocked_by": [],
177
+ "coordinates_with": ["ISS-004"],
178
+ "flow_refs": ["FLOW-01"]
179
+ }
180
+ ],
181
+ "commit_subject": "docs(003): shard vertical slices",
182
+ "commit_body": "Generated <N> vertical shards from PRD with DAG dependency topology"
183
+ }
184
+ ```
185
+ </step>
186
+
187
+ <step id="post_script">
188
+ Run the post-script to register issues in the ledger, stage files, and commit:
189
+ ```bash
190
+ deviate shard post "$PLAN_TARGET"
191
+ ```
192
+ **IMPORTANT**: The post-script runs precommit hooks which include the full test suite — allocate a timeout of at least 180s (3 minutes) when running this command.
193
+
194
+ The post-script:
195
+ 1. Reads the manifest from `$PLAN_TARGET`
196
+ 2. Validates that all shard files exist at the expected paths
197
+ 3. Registers each shard in the issues ledger via inline registration (appends to `specs/issues.jsonl`)
198
+ 4. Stages and commits the shard files + ledger updates
199
+ 5. Emits status JSON on stdout
200
+
201
+ If the post-script exits with `status: FAILURE`, surface the `reason` to the user and stop.
202
+ </step>
203
+
204
+ </execution_sequence>
205
+
206
+ <edge_case_handling>
207
+
208
+ | Condition | Action |
209
+ |---|---|---|
210
+ | Pre-script returns `NO_EPIC` | Surface error; no feature workspace found in specs/ |
211
+ | Pre-script returns `NO_PRD` | Surface error; user must run /deviate-prd first |
212
+ | PRD has no FR-{NNN}-{ID} or AC-{NNN}-{ID}-{NN} tokens | Halt with MALFORMED_PRD_CONTRACT |
213
+ | Cumulative FR coverage fails — one or more FRs unmapped | Halt with INCOMPLETE_FR_COVERAGE; list missing FRs |
214
+ | Circular dependency detected in DAG | Halt with TOPOLOGY_LOOP_FAULT |
215
+ | Post-script returns MANIFEST_NOT_FOUND | LLM forgot to write manifest — write it, then re-run post |
216
+ | `--dry-run` mode | Write preview manifest, post-script emits preview without mutations |
217
+ | `specs/_product/` directory missing | Emit `flow_refs: []` for all shards and note gap in manifest; do not halt |
218
+
219
+ </edge_case_handling>
220
+
221
+ <context>
222
+ <user_input>
223
+ $ARGUMENTS
224
+ </user_input>
225
+ </context>
226
+
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: deviate-tasks
3
+ description: Decompose a spec-enriched issue into tasks.md — autonomous Red-Green-Refactor units (vertical, 30-90 min each).
4
+ category: deviatdd-meso-layer
5
+ version: 1.0.0
6
+ layer: meso
7
+ aliases:
8
+ - tasks
9
+ - /deviate-tasks
10
+ - spec:core:tasks
11
+ - spec.core.tasks
12
+ - /tasks
13
+ ---
14
+
15
+ <system_instructions>
16
+
17
+ This system operates strictly as an isolated, deterministic execution compilation pipeline for software implementation strategies and structured technical task decomposition. Your objective is to ingest a JSON contract emitted by the orchestrator script `deviate tasks pre` (which detects the existing worktree claim, locates the spec source, validates its required sections, and validates the plan.md prerequisite) and produce a granular task decomposition (`tasks.md`) consisting of autonomous Red-Green-Refactor units (vertical tasks, 30-90 min each). Each task is a deterministic instruction for an agent to perform a complete R-G-R cycle.
18
+
19
+ **Embedded-First Spec Consumption**: The tasks pipeline reads spec content from the issue file itself when embedded sections are present — the issue file carries `## User Stories Ledger`, `## ATDD Acceptance Criteria`, and other spec sections directly. When these embedded sections are absent, tasks falls back to reading the adjacent `spec.md` file in the same issue directory. Embedded sections take precedence when both exist.
20
+
21
+ **The "Autonomous R-G-R" Mandate** (applies only to TDD-mode tasks):
22
+ - **Red**: Every TDD task starts by writing a failing test (Sociable/Integration).
23
+ - **Green**: Every TDD task implements the minimum code to pass the test.
24
+ - **Refactor**: Every task (TDD or IMMEDIATE) cleans up code to match idioms and `specs/constitution.md` invariants.
25
+ - **Verification-is-Done**: A task is ONLY finished when its `Verification` command passes. No "vibe" confirmation.
26
+ - **IMMEDIATE tasks**: Skip the Red/Green cycle. Execute directly then verify.
27
+
28
+ **The "Workstation" Mandate**:
29
+ - **Context Consolidation**: Files that share a logical capability MUST be in the same task.
30
+ - **Maximize Signal-to-Noise**: Group files so the agent has full "Workstation" context in a single Turn.
31
+
32
+ **Meso Workflow Position**: Shard+Specify → [HITL Gate 2] → Plan → Tasks → TDD (red-green-refactor)
33
+ - **Shard+Specify**: Precedes this phase. Produces spec-enriched issue files with embedded `[USER_STORIES_LEDGER]`, `[ATDD_ACCEPTANCE_CRITERIA]`, `[EDGE_CASES_AND_BOUNDARIES]`, and `[PERFORMANCE_CONSTRAINTS]` sections.
34
+ - **Plan** (HITL Gate 2 → Plan): Per-issue localized research phase producing `plan.md`. The pre-script enforces that plan.md exists before tasks can proceed — plan is a mandatory prerequisite.
35
+ - **Tasks** (this phase): Write `tasks.md` only. Commit it. STOP.
36
+ - **TDD**: Begins after the tasks artifact is committed.
37
+
38
+ Research artifacts (`design.md`, `data-model.md`) produced by the `deviate-research` skill may exist alongside the spec source and serve as supplementary input for workstation mapping and architectural context.
39
+
40
+ CRITICAL INFERENCE PHYSICS INVARIANTS:
41
+ 1. **Context Reuse Rule**: This phase follows `/deviate-plan` in the same conversation — plan.md has already been written. Reuse `BRANCH_NAME`, `WORKTREE_PATH`, `ISSUE_ID`, `EPIC_SLUG`, `ISSUE_SLUG` from the plan contract in your context. Do NOT re-run the plan or shard pre-script.
42
+ 2. **Cohesive Scope Invariant**: Every task line-item, target verification asset, or file node declared in this ledger must map directly onto a named entity or functional acceptance rule within the codebase repository tree.
43
+
44
+ </system_instructions>
45
+
46
+
47
+ <execution_sequence>
48
+ 1. `cd` into the worktree (using the `worktree_full` path from your context) and run the pre-script to detect the worktree and emit a JSON contract:
49
+ ```
50
+ deviate tasks pre
51
+ ```
52
+ The pre-script detects the worktree via `Path.cwd()` — it must run from inside the worktree. It accepts the session in PLAN or TASKS phase (plan must have completed). Use `--force` to bypass the plan.md prerequisite. The contract on stdout contains: `branch_name`, `worktree_full`, `spec_path` (the primary spec source — either the issue file with embedded sections, or the spec.md fallback, resolved from the active issue ID), `plan_path` (path to the required plan.md), `tasks_target` (where to write tasks.md), `design_path` (optional), `data_model_path` (optional), `constitution_test_command`, `constitution_lint_command`.
53
+ - If the pre-script emits `STATUS: PLAN_NOT_FOUND`, the `/deviate-plan` phase must complete and produce `plan.md` before tasks can proceed (use `--force` to bypass).
54
+ - If the pre-script emits `STATUS: SPEC_NOT_FOUND` or `STATUS: NO_ACTIVE_ISSUE`, surface the status. The spec-enriched issue file must exist first.
55
+
56
+ 2. Read the plan artifact from `plan_path` (the plan.md produced by `/deviate-plan`) for implementation strategy, workstation mapping, risk assessment, and integration point analysis. Then read the spec source from `spec_path` — this is the issue file itself when it contains embedded `## User Stories Ledger` and `## ATDD Acceptance Criteria` sections (primary path). If those embedded sections are absent, fall back to reading the adjacent `spec.md` file in the same issue directory (legacy path). If `design_path` or `data_model_path` are present in the contract, read those too for architectural context and data schema definitions. Embedded sections take precedence when both exist.
57
+
58
+ 3. **Workstation Mapping**: Map all files touched by each user story from the spec source's `SYSTEM_TOPOLOGY_MAPPING` and `PROJECT_STRUCTURE` sections (whether from embedded `[USER_STORIES_LEDGER]` in the issue file or from `spec.md`). Group related files (e.g., a service and its test file, a handler and its route registration) into workstation clusters. Derive phases from logical groupings of related user stories.
59
+
60
+ 4. **Task Construction**:
61
+ - **4a. Group Items**: Group workstation clusters into **Batched Logical Units** (vertical slices), each delivering one or more related acceptance criteria.
62
+ - **4b. Assign Execution_Mode**: Decide **per task** using this decision tree. Run it fresh for every task:
63
+
64
+ 1. Does this task modify **only config, docs, constants, schemas, or trivial boilerplate**? → **IMMEDIATE**
65
+ 2. Does this task **refactor existing code without changing behavior** and have **existing test coverage**? → **IMMEDIATE**
66
+ 3. Does this task introduce **new business logic, state mutations, API endpoints, or integration boundaries**? → **TDD**
67
+ 4. Does this task fix a **bug**? → **TDD** (write regression test first)
68
+ 5. Does this task have **non-trivial acceptance criteria** that aren't trivially verifiable? → **TDD**
69
+ 6. Otherwise → **IMMEDIATE** (when in doubt, prefer IMMEDIATE over speculative TDD)
70
+ 7. Does this task **connect/wire already-tested components** via subprocess, API, or message passing? → **TDD** with system-edge mock boundary (mock `subprocess.Popen`, assert CLI args/env/stdin)
71
+
72
+ A single phase can contain both modes. Do NOT default to TDD — TDD carries cost; use it where it earns its keep.
73
+ - **4c. Assign Verification**: Assign each slice a `Verification` command based on the test strategy implied by the acceptance criteria.
74
+ - **4d. Validate Structure**: Ensure no "Testing-only" tasks — tests are the mandatory **Red** phase of every TDD task.
75
+ - **4e. File Rationale Assignment**: For each task, add `[File_Rationale]` explaining WHY each file is touched.
76
+
77
+ 5. **Traceability Audit**:
78
+ - Read the spec source's `SCOPE_BOUNDARIES > Defensive Exclusions` section and verify no task touches files related to anti-goals
79
+ - Read `design.md` `RISK_REGISTER` or `CONSTRAINTS` sections (if available) and incorporate into task generation
80
+ - Verify phase-to-story mapping
81
+ - Flag orphaned files
82
+
83
+ 6. Apply granularity rules:
84
+ - **Slice over Step**: Tasks are defined by **What they add to the feature**, not the technical step.
85
+ - **30-90 Minute Rule**: If a task takes < 30 min, merge it. If > 90 min, split it only while maintaining verticality.
86
+ - **Ambiguity Resolution**: If a plan item spans multiple capabilities, create separate tasks per capability with explicit `Dependency` links.
87
+
88
+ 7. Transpile the final task decomposition into format-compliant Markdown per `<output_format_schemas>` and write it directly to `<tasks_target>` (the relative path from the contract). Write exactly the tasks content — no preamble, no postamble, no XML wrapper tags.
89
+
90
+ 8. Run the post-script to validate and commit (still inside the worktree from step 1):
91
+ ```
92
+ deviate tasks post
93
+ ```
94
+ The post-script validates required sections and task ID format (`T{NNN}`), then commits and advances the session to IDLE. The post-script runs precommit hooks which include the full test suite — allocate a timeout of at least 180s (3 minutes) when running this command. If validation fails, it prints a diagnostic. Fix the file and re-run. Use `--force` only with documented justification.
95
+
96
+ **TERMINATE HERE. Do NOT proceed to implementation. Hand off to the TDD phase.**
97
+ </execution_sequence>
98
+
99
+ <output_format_schemas>
100
+ <format_contract>
101
+ Render output to `<tasks_target>` using the following format. No XML wrapper tags — the file content is the ledger body.
102
+
103
+ **CRITICAL FORMAT RULES:**
104
+ - `**Files**` MUST be followed by indented file paths on separate lines (not inline)
105
+ - `**Details**` MUST be followed by indented bullet points on separate lines (not inline)
106
+ - `**Dependency**` MUST be inline: `TSK-001-01` not on separate line
107
+
108
+ **CRITICAL TASK ID CONSTRAINT:**
109
+ - Task IDs MUST follow the format `TSK-{NNN}-{NN}:` where `NNN` is the 3-digit issue number and `NN` is the 2-digit task index within the issue, starting from `TSK-001-01:`.
110
+ - Examples of VALID task IDs: `TSK-001-01:`, `TSK-001-02:`, `TSK-002-01:`, `TSK-010-01:`, `TSK-099-01:`
111
+ - Examples of INVALID task IDs (DO NOT use): `T001:`, `TASK_1:`, `T1:`, `T-001:`, `Task1:`, `TSK001:`
112
+ - The post-script validator enforces this exact pattern: `TSK-` followed by exactly 3 digits, `-`, exactly 2 digits, and a colon.
113
+
114
+ **TASK STRUCTURE CONSTRAINTS** — every task MUST contain:
115
+ - **Type**: `Feature_Batch | Infra_Batch | Domain_Batch | Bugfix | Migration | Config`
116
+ - **Mode**: `TDD | IMMEDIATE` (no default — apply the decision tree at step 4b)
117
+ - `TDD`: Full Red-Green-Refactor cycle. **Use for**: New business logic, state mutations, integration boundaries, or non-trivial acceptance criteria.
118
+ - `IMMEDIATE`: Execute directly without test-first. **Use for**: Trivial updates (config, docs, constants), pure refactoring with existing test coverage, or low-risk boilerplate where testing cost outweighs regression risk.
119
+ - **Test Strategy**: `Sociable_Unit | Integration | Solitary_Unit` (required if Mode is TDD)
120
+ - **Verification**: A **Deterministic CLI Command** (e.g., `pytest tests/unit/test_s3.py`).
121
+ - **Estimated Time**: Time estimate in format `30-90 minutes` or `60 minutes`.
122
+ - **Files**: List of absolute or project-relative paths (multi-line, indented, minimum 2 files).
123
+ - **Details**: **CRITICAL** — Must contain 4-8 detailed bullet points with explicit R-G-R breakdown:
124
+ - **Red**: Specific test file, test cases to write, and assertions
125
+ - **Green**: Exact functions/methods to implement, signatures, and logic
126
+ - **Refactor**: Code quality improvements, pattern alignment
127
+ - **Edge Cases**: Error handling, boundary conditions
128
+ - **Acceptance**: Concrete "done" criteria beyond test passing
129
+ - **Dependency**: (Optional) `T{NNN}` if this task requires another task to complete first (inline value).
130
+
131
+ **DETAILS QUALITY RULES:**
132
+ - Minimum 4 bullet points, maximum 8
133
+ - For TDD tasks: MUST include at least one **Red** bullet with specific test case name and assertion
134
+ - For TDD tasks: MUST include at least one **Green** bullet with function signature and logic
135
+ - For IMMEDIATE tasks: Use **Implementation** instead of **Red**/**Green**
136
+ - SHOULD include **Edge Cases** for error handling scenarios
137
+ - SHOULD include **Acceptance** with concrete "done" criteria
138
+
139
+ **FILE TRACEABILITY RULES:**
140
+ - **Rationale** is REQUIRED on every task (prevents misaligned scope)
141
+ - Must explain WHY each file in **Files** is being modified
142
+ - Must tie each file to specific story identifiers and acceptance criteria from spec.md
143
+ - Every file in **Files** MUST be justified in **Rationale**
144
+ - Files without justification are flagged as potential scope creep
145
+
146
+ **DETERMINISM RULES:**
147
+ - **No Vibe Coding**: Any task without a `Verification` command is invalid.
148
+ - **No Layered Tasks**: Reject any task that doesn't produce a testable outcome.
149
+ - **No Vague Details**: Reject any task with fewer than 4 `Details` bullets. TDD tasks must have **Red**/**Green** markers; IMMEDIATE tasks must have **Implementation** markers.
150
+ - **Path Integrity**: Use absolute paths for all cross-references.
151
+ - **Test-First Enforcement**: Every TDD task's **Green** bullet MUST have a corresponding **Red** bullet that defines the test it passes. IMMEDIATE tasks are exempt (use **Implementation** instead).
152
+
153
+ **OUTPUT TEMPLATE** — the complete file should follow this structure:
154
+ ```markdown
155
+ # Implementation Tasks: {BRANCH_NAME}
156
+
157
+ ## Phase 1: <Feature Slice Name>
158
+ **Goal**: <what capability this slice delivers>
159
+
160
+ ### Tasks
161
+
162
+ - T001: <Description of Vertical Slice>
163
+ - **Type**: Feature_Batch
164
+ - **Mode**: TDD
165
+ - **Test Strategy**: Sociable_Unit
166
+ - **Verification**: `pytest tests/unit/test_s3.py`
167
+ - **Estimated Time**: 60 minutes
168
+ - **Files**:
169
+ - `path/to/file1.ts`
170
+ - `path/to/file2.ts`
171
+ - **Rationale**: <Why these files? Tie to specific story US_### and AC>
172
+ - **Details**:
173
+ - **Red**: Write failing test: `<test_name>()` with assertion that <expected>
174
+ - **Green**: Implement `<function>(<params>): <return>` with <logic>
175
+ - **Refactor**: <code quality improvement>
176
+ - **Edge Cases**: Handle <error scenario> by <action>
177
+ - **Acceptance**: <concrete done criteria>
178
+
179
+ - T002: <Description>
180
+ - **Type**: Feature_Batch
181
+ - **Mode**: IMMEDIATE
182
+ - **Verification**: `npm run lint`
183
+ - **Estimated Time**: 30 minutes
184
+ - **Dependency**: T001
185
+ - **Files**:
186
+ - `path/to/file3.ts`
187
+ - **Rationale**: <Why these files?>
188
+ - **Details**:
189
+ - **Implementation**: Implement `<function>()` with <logic>
190
+ - **Refactor**: <improvement>
191
+ - **Acceptance**: <criteria>
192
+
193
+ ---
194
+
195
+ ## Implementation Strategy
196
+ **Execution Order**:
197
+ 1. Phase 1 -> Phase 2 (Logical dependency order)
198
+
199
+ **Critical Dependency Chains**:
200
+ - T001 (Schema) must precede T002 (API)
201
+
202
+ **Risk Hotspots**:
203
+ - High coupling in `user.service.ts`
204
+
205
+ **Merge Conflict Boundaries**:
206
+ - Files touched by multiple phases: [list_files]
207
+
208
+ ---
209
+
210
+ ## Universal Test Constraints (ALL TASKS)
211
+
212
+ - **Git Isolation Mandatory**: Any test that invokes git operations (init, add, commit, branch, worktree, checkout, log, status, push) MUST operate on a temporary directory initialized as a fresh git repo via `tmp_path` (pytest) or `tempfile.TemporaryDirectory`. Tests MUST NOT run git commands within the real repository's working tree.
213
+ - **Implementation Pattern**: Use a shared `tmp_git_repo` fixture from `tests/conftest.py` (which calls `git init` inside `tmp_path` and configures a test user). Pass `repo=tmp_git_repo` to all git-interacting functions. Never reference `Path.cwd()` or the real repo root.
214
+ - **Rationale**: Prevent accidental commits, branch creation, or state mutation in the actual project repo during test execution. All tests are TDD and run repeatedly; accidental mutations corrupt the development workflow.
215
+
216
+ ## Universal API Design Constraint (ALL CORE MODULES)
217
+
218
+ Every git-interacting function in core modules MUST accept an optional `repo_path: Path | None = None` parameter. When `None`, default to `Path.cwd()`. This is the **sole enabler** of test isolation — without it, tests must use fragile `chdir` tricks or operate on the real repo.
219
+
220
+ ```python
221
+ # DO: accept repo_path, default to cwd
222
+ def find_repo_root(start_at: Path | None = None) -> Path:
223
+ start_at = start_at or Path.cwd()
224
+
225
+ def stage_and_commit(message: str, files: list[Path], repo: Path | None = None) -> str:
226
+ repo = repo or Path.cwd()
227
+ subprocess.run(["git", "add", ...], cwd=repo, check=True)
228
+
229
+ # DON'T: hard-code Path.cwd() or rely on ambient working directory
230
+ def find_repo_root() -> Path: # BAD — untestable
231
+ ...
232
+ ```
233
+
234
+ **Consequence**: Every per-task Git Isolation block below is a specific instance of this universal constraint. If a task's `Green` section says to implement a function that runs git commands, that function **must** accept `repo_path`.
235
+ ```
236
+
237
+ **Write the entire content directly to `<tasks_target>`** as the file's full content. No wrapping tags, no preamble, no postamble. The post-script reads the file and commits it.
238
+ </format_contract>
239
+
240
+
241
+ </output_format_schemas>
242
+
243
+ <edge_case_handling>
244
+ <case condition="Pre-script emits STATUS: NOT_IN_WORKTREE or STATUS: SPEC_NOT_FOUND">
245
+ <action>Stop. The /deviate-shard phase must produce a valid spec-enriched issue file (or a spec.md must exist as fallback) before tasks can run. Surface the status to the human operator.</action>
246
+ </case>
247
+ <case condition="Pre-script emits STATUS: PLAN_NOT_FOUND">
248
+ <action>Halt. The /deviate-plan phase must complete and produce plan.md before tasks can run. Surface the missing plan.md path to the human operator. Use `deviate tasks pre --force` only if you have a documented reason to bypass the prerequisite.</action>
249
+ </case>
250
+ <case condition="Issue file contains embedded ## User Stories Ledger and ## ATDD Acceptance Criteria sections">
251
+ <action>Read spec from the issue file directly — this is the primary path. Do NOT look for a separate spec.md. Per spec AC-ADHOC-003-07, embedded sections take precedence over spec.md when both exist.</action>
252
+ </case>
253
+ <case condition="Issue file lacks embedded spec sections (no USER_STORIES_LEDGER or ATDD_ACCEPTANCE_CRITERIA)">
254
+ <action>Fall back to reading the adjacent spec.md file in the same issue directory. This is the legacy path — log a notice that the issue file lacks embedded spec sections, then proceed with spec.md as the spec source.</action>
255
+ </case>
256
+ <case condition="Both issue file embedded sections AND spec.md exist">
257
+ <action>Embedded sections take precedence per spec AC-ADHOC-003-07. Read from the issue file; ignore spec.md. Document the precedence decision in a note.</action>
258
+ </case>
259
+ <case condition="spec.md is empty or missing required sections (fallback path only)">
260
+ <action>Halt with Failure_State: "Invalid spec source — missing required sections". Require human to run /deviate-shard first to produce a valid spec-enriched issue.</action>
261
+ </case>
262
+ <case condition="spec.md is missing or incomplete (fallback path only)">
263
+ <action>Continue with available spec sections. Add `[WARNING]` to tasks touching undefined areas.</action>
264
+ </case>
265
+ <case condition="No test command available from spec source or constitution">
266
+ <action>Generate Verification commands using repository conventions (pytest, npm test) as defaults. Document inferred commands in a note.</action>
267
+ </case>
268
+ <case condition="Circular dependencies detected between tasks">
269
+ <action>Detect and reject; require human to resolve dependency graph before task generation.</action>
270
+ </case>
271
+ <case condition="Post-script rejects output">
272
+ <action>Halt, fix the violations, and re-run the post-script.</action>
273
+ </case>
274
+ </edge_case_handling>
275
+
276
+ <context>
277
+ <user_input>
278
+ $ARGUMENTS
279
+ </user_input>
280
+ </context>
281
+