gennady 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/ai/directives/coding/result-conventions.xml +25 -7
  2. package/ai/directives/sdd/audit.directive.xml +1 -1
  3. package/ai/directives/sdd/critic-protocol.xml +78 -0
  4. package/ai/directives/sdd/critic.directive.xml +158 -0
  5. package/ai/directives/sdd/phase-execution-protocol.xml +11 -9
  6. package/ai/skills/alt-opinion/SKILL.md +79 -0
  7. package/ai/skills/alt-opinion/opinion.prompt.md +11 -0
  8. package/ai/skills/alt-opinion/synth.prompt.md +8 -0
  9. package/ai/skills/sdd-audit/SKILL.md +13 -0
  10. package/ai/skills/sdd-check/SKILL.md +139 -0
  11. package/ai/skills/sdd-continue/SKILL.md +13 -0
  12. package/ai/skills/sdd-critic/SKILL.md +12 -0
  13. package/ai/skills/sdd-discover/SKILL.md +13 -0
  14. package/ai/skills/sdd-execute/SKILL.md +205 -0
  15. package/ai/skills/sdd-execute/scripts/README.md +84 -0
  16. package/ai/skills/sdd-execute/scripts/check-blockers.sh +158 -0
  17. package/ai/skills/sdd-execute/scripts/classify-scripts.js +111 -0
  18. package/ai/skills/sdd-execute/scripts/classify-scripts.ts +133 -0
  19. package/ai/skills/sdd-execute/scripts/extract-section.sh +219 -0
  20. package/ai/skills/sdd-execute/scripts/lint-artifacts.sh +143 -0
  21. package/ai/skills/sdd-execute/scripts/scan.sh +385 -0
  22. package/ai/skills/sdd-execute/scripts/sdd +114 -0
  23. package/ai/skills/sdd-execute/scripts/verify.sh +139 -0
  24. package/ai/skills/sdd-execute-batch/SKILL.md +213 -0
  25. package/ai/skills/sdd-fix/SKILL.md +13 -0
  26. package/ai/skills/sdd-infra/SKILL.md +13 -0
  27. package/ai/skills/sdd-module-decomposition/SKILL.md +13 -0
  28. package/ai/skills/sdd-scaffold/SKILL.md +13 -0
  29. package/ai/skills/sdd-setup/SKILL.md +13 -0
  30. package/dist/ai/directives/coding/result-conventions.xml +25 -7
  31. package/dist/ai/directives/sdd/audit.directive.xml +1 -1
  32. package/dist/ai/directives/sdd/critic-protocol.xml +78 -0
  33. package/dist/ai/directives/sdd/critic.directive.xml +158 -0
  34. package/dist/ai/directives/sdd/phase-execution-protocol.xml +11 -9
  35. package/dist/ai/skills/alt-opinion/SKILL.md +79 -0
  36. package/dist/ai/skills/alt-opinion/opinion.prompt.md +11 -0
  37. package/dist/ai/skills/alt-opinion/synth.prompt.md +8 -0
  38. package/dist/ai/skills/sdd-audit/SKILL.md +13 -0
  39. package/dist/ai/skills/sdd-check/SKILL.md +139 -0
  40. package/dist/ai/skills/sdd-continue/SKILL.md +13 -0
  41. package/dist/ai/skills/sdd-critic/SKILL.md +12 -0
  42. package/dist/ai/skills/sdd-discover/SKILL.md +13 -0
  43. package/dist/ai/skills/sdd-execute/SKILL.md +205 -0
  44. package/dist/ai/skills/sdd-execute/scripts/README.md +84 -0
  45. package/dist/ai/skills/sdd-execute/scripts/check-blockers.sh +158 -0
  46. package/dist/ai/skills/sdd-execute/scripts/classify-scripts.js +111 -0
  47. package/dist/ai/skills/sdd-execute/scripts/classify-scripts.ts +133 -0
  48. package/dist/ai/skills/sdd-execute/scripts/extract-section.sh +219 -0
  49. package/dist/ai/skills/sdd-execute/scripts/lint-artifacts.sh +143 -0
  50. package/dist/ai/skills/sdd-execute/scripts/scan.sh +385 -0
  51. package/dist/ai/skills/sdd-execute/scripts/sdd +114 -0
  52. package/dist/ai/skills/sdd-execute/scripts/verify.sh +139 -0
  53. package/dist/ai/skills/sdd-execute-batch/SKILL.md +213 -0
  54. package/dist/ai/skills/sdd-fix/SKILL.md +13 -0
  55. package/dist/ai/skills/sdd-infra/SKILL.md +13 -0
  56. package/dist/ai/skills/sdd-module-decomposition/SKILL.md +13 -0
  57. package/dist/ai/skills/sdd-scaffold/SKILL.md +13 -0
  58. package/dist/ai/skills/sdd-setup/SKILL.md +13 -0
  59. package/dist/chunks/_commonjsHelpers-DaMA6jEr.js +8 -0
  60. package/dist/chunks/{devtools-B-7ugZhF.js → devtools-CPZ0IUNM.js} +1 -1
  61. package/dist/chunks/help-5qCaicff.js +6 -0
  62. package/dist/chunks/help-B2ETH0j6.js +6 -0
  63. package/dist/chunks/help-BCDURaCQ.js +6 -0
  64. package/dist/chunks/help-BvgYOSyQ.js +6 -0
  65. package/dist/chunks/help-CSPhOoI9.js +8 -0
  66. package/dist/chunks/help-CV1vpwrh.js +6 -0
  67. package/dist/chunks/help-CaBNA6Qr.js +12 -0
  68. package/dist/chunks/help-CjkR6SB9.js +6 -0
  69. package/dist/chunks/help-Coi1l5u9.js +8 -0
  70. package/dist/chunks/help-CsuLpZn-.js +8 -0
  71. package/dist/chunks/help-DL_QBMwy.js +8 -0
  72. package/dist/chunks/help-DqBZ2xcp.js +6 -0
  73. package/dist/chunks/help-_Y_TN4DZ.js +6 -0
  74. package/dist/chunks/{help.cmd-B_G7EWzF.js → help.cmd-BseRtoBF.js} +10 -2
  75. package/dist/chunks/{index-zBnnuvLA.js → index-BU1AXJGA.js} +12 -7
  76. package/dist/chunks/{index-CXuhZzS3.js → index-BXWDYM_9.js} +1 -1
  77. package/dist/chunks/index-BgKyH0dB.js +658 -0
  78. package/dist/chunks/{index-CaahtXiM.js → index-BghL1-Nk.js} +2 -2
  79. package/dist/chunks/{index-BeL1Zcbg.js → index-BlqEQEGy.js} +1 -1
  80. package/dist/chunks/{index-D1qsi0Uc.js → index-CDM74qdR.js} +3 -3
  81. package/dist/chunks/{index-D9ceRUyB.js → index-CGsIRefC.js} +2 -2
  82. package/dist/chunks/{index-CiEM-8nJ.js → index-CIvkaAQ3.js} +2 -2
  83. package/dist/chunks/{index-UbHoePfr.js → index-CkczJ__m.js} +10 -10
  84. package/dist/chunks/index-CtJKSOL0.js +21 -0
  85. package/dist/chunks/index-DEzym4Ae.js +369 -0
  86. package/dist/chunks/{index-CVR66voe.js → index-DoaxOhQ8.js} +401 -393
  87. package/dist/chunks/index-Du1xR-qO.js +752 -0
  88. package/dist/chunks/{index-DU6jD7SS.js → index-OtehG7uM.js} +1 -1
  89. package/dist/chunks/index-ZM_FonZj.js +156 -0
  90. package/dist/chunks/{index-g1LXlp77.js → index-k0nToACp.js} +2 -2
  91. package/dist/chunks/{run-review-command.logic-DpkRoEi8.js → run-review-command.logic-BeYQin-I.js} +9 -9
  92. package/dist/chunks/services-IgZptnTi.js +2732 -0
  93. package/dist/chunks/shared-DL_1LG0K.js +753 -0
  94. package/dist/cli/cmd/agent-mon/help.d.ts +4 -0
  95. package/dist/cli/cmd/agents-rules/agents-rules.cmd.d.ts +8 -0
  96. package/dist/cli/cmd/agents-rules/index.d.ts +1 -0
  97. package/dist/cli/cmd/alt-opinion/help.d.ts +4 -0
  98. package/dist/cli/cmd/cat/help.d.ts +4 -0
  99. package/dist/cli/cmd/commit/help.d.ts +4 -0
  100. package/dist/cli/cmd/lint/checks/anchor-class-body.check.d.ts +11 -0
  101. package/dist/cli/cmd/lint/checks/invariant-count.check.d.ts +11 -0
  102. package/dist/cli/cmd/lint/checks/utils/glob-match.d.ts +15 -0
  103. package/dist/cli/cmd/lint/checks/utils/strip-strings-comments.d.ts +7 -0
  104. package/dist/cli/cmd/lint/help.d.ts +4 -0
  105. package/dist/cli/cmd/lint/lint.cmd.d.ts +1 -1
  106. package/dist/cli/cmd/lint/lint.types.d.ts +6 -0
  107. package/dist/cli/cmd/orient/core/build-index.d.ts +8 -0
  108. package/dist/cli/cmd/orient/core/damerau-levenshtein.d.ts +26 -0
  109. package/dist/cli/cmd/orient/core/extract-header.d.ts +8 -0
  110. package/dist/cli/cmd/orient/core/hints.d.ts +9 -0
  111. package/dist/cli/cmd/orient/core/query-consumer.d.ts +10 -0
  112. package/dist/cli/cmd/orient/core/query-entity.d.ts +11 -0
  113. package/dist/cli/cmd/orient/core/query-graph.d.ts +18 -0
  114. package/dist/cli/cmd/orient/core/query-keyword.d.ts +10 -0
  115. package/dist/cli/cmd/orient/core/query-spec.d.ts +15 -0
  116. package/dist/cli/cmd/orient/core/query-task.d.ts +8 -0
  117. package/dist/cli/cmd/orient/core/scan-files.d.ts +8 -0
  118. package/dist/cli/cmd/orient/help.d.ts +5 -0
  119. package/dist/cli/cmd/orient/index.d.ts +1 -0
  120. package/dist/cli/cmd/orient/orient.cmd.d.ts +7 -0
  121. package/dist/cli/cmd/orient/orient.types.d.ts +136 -0
  122. package/dist/cli/cmd/orient/render/render-detail.d.ts +10 -0
  123. package/dist/cli/cmd/orient/render/render-file-list.d.ts +15 -0
  124. package/dist/cli/cmd/orient/render/render-graph.d.ts +13 -0
  125. package/dist/cli/cmd/orient/render/render-search.d.ts +8 -0
  126. package/dist/cli/cmd/orient/render/render-specs.d.ts +13 -0
  127. package/dist/cli/cmd/orient/render/render-tree.d.ts +13 -0
  128. package/dist/cli/cmd/remote-console/help.d.ts +4 -0
  129. package/dist/cli/cmd/resolve-conflicts/help.d.ts +4 -0
  130. package/dist/cli/cmd/review/help.d.ts +4 -0
  131. package/dist/cli/cmd/review-issues/help.d.ts +4 -0
  132. package/dist/cli/cmd/review-verify/help.d.ts +4 -0
  133. package/dist/cli/cmd/sync/help.d.ts +4 -0
  134. package/dist/cli/cmd/sync/sync-core.d.ts +3 -2
  135. package/dist/cli/cmd/sync/sync-formatter.d.ts +8 -9
  136. package/dist/cli/cmd/sync/sync.cmd.d.ts +2 -21
  137. package/dist/cli/cmd/sync-skills/index.d.ts +1 -0
  138. package/dist/cli/cmd/sync-skills/sync-skills-core.d.ts +50 -0
  139. package/dist/cli/cmd/sync-skills/sync-skills-formatter.d.ts +13 -0
  140. package/dist/cli/cmd/sync-skills/sync-skills.cmd.d.ts +14 -0
  141. package/dist/cli/cmd/sync-skills/sync-skills.types.d.ts +56 -0
  142. package/dist/cli/cmd/vcs-reply/help.d.ts +4 -0
  143. package/dist/gennady.js +73 -18
  144. package/dist/index.js +5 -5
  145. package/dist/services/dbc/linter/implementations/ts/dbc-ts-ast-adapter.d.ts +3 -2
  146. package/dist/shared/common/sync/path-normalizer.d.ts +22 -0
  147. package/dist/shared/common/sync/sync-core.shared.d.ts +14 -0
  148. package/dist/shared/common/sync/sync-deps.type.d.ts +66 -0
  149. package/dist/shared/common/sync/sync-formatter.shared.d.ts +19 -0
  150. package/package.json +6 -5
  151. package/dist/chunks/index-DJpVmyp2.js +0 -176
  152. package/dist/chunks/index-KxSZKmZn.js +0 -540
  153. package/dist/chunks/services-CaLOhuLV.js +0 -2889
  154. package/dist/chunks/shared-Bjy30TeM.js +0 -665
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: sdd-execute-batch
3
+ description: Orchestrate batch task execution. For each task: plan phases from its Phases Overview → dispatch one phase-subagent per phase (sequential within task; parallel across tasks in same sub-batch when file sets disjoint) → close Round → dispatch audit-subagent (fresh-eyes) → optional selective phase re-run on audit FAIL. Use for "выполни всю очередь" / "execute pickable tasks". Optional epic-level audit across batch.
4
+ license: MIT
5
+ compatibility: opencode
6
+ ---
7
+
8
+ <SddExecuteBatchOrchestrator role="orchestrator-only">
9
+ You are the BATCH ORCHESTRATOR. You PLAN the queue, manage layered parallelism, dispatch phase-subagents and audit-subagents in fresh contexts, thread typed Handoff payloads within each task. You do NOT operate under any execution directive yourself.
10
+
11
+ **Environment: macOS.** All bash commands dispatched to subagents must be macOS-compatible. No `grep -P` → use `rg`. No GNU-only flags.
12
+
13
+ You DO read each ticket's PLANNING SURFACE: section 1 Meta, section 2 Phases Overview, current Round of section 7 Execution Log. You do NOT read section 3 Phases bodies, section 4 BDD, section 5 Verification, section 6 Coverage — those are read by phase-subagents.
14
+
15
+ Each subagent runs in a FRESH ISOLATED CONTEXT.
16
+
17
+ <Inputs>
18
+ Args from operator may be:
19
+ - empty / "next" / "все" / "all pickable" → full pickable queue from tasks/README.md.
20
+ - explicit list "TSK-04 TSK-05 TSK-06" → use that exact list (verify each exists).
21
+ - "domain:<name>" → all tickets in tasks/<name>/.
22
+ - "tasks/<scope>/<scope>.task-NN.md" → single task path resolved to ID.
23
+
24
+ Optional flag: `epic-only` → skip per-task audits, run ONE epic-level audit at end. Default = per-task audit + optional epic at end.
25
+ </Inputs>
26
+
27
+ <ProgressReporting>
28
+ Black-box: subagents are opaque. Emit progress at state transitions the orchestrator owns (queue confirmation, layer/sub-batch boundaries, phase dispatch, phase return, audit, retry, batch end).
29
+
30
+ Format: `[<bar>] <pct>% | <done>/<total> | Layer L/Ltotal | <event>`
31
+
32
+ Per-task phase tokens:
33
+
34
+ - `TSK-NN: P<N> (<kind>) 🏃‍♂️‍➡️` — phase actively executing
35
+ - `TSK-NN: P<N> ✅` — phase done; orchestrator threads Handoff to next phase
36
+ - `TSK-NN: ✅ all phases → 🔍 audit`
37
+ - `TSK-NN: ✅ audit PASS`
38
+ - `TSK-NN: ❌ audit FAIL → 🔄 fix phases <list>`
39
+ - `TSK-NN: ❌ FAIL after 2 attempts`
40
+ </ProgressReporting>
41
+
42
+ <Protocol>
43
+ 1. **Collect working set:**
44
+ - Read tasks/README.md Tracker Index.
45
+ - Scan tasks/**/*.task-*.md **planning surface only** — section 1 Meta (up to `## 2.`) + section 2 Phases Overview (up to `## 3.`). Typically first 40-60 lines per ticket. Do NOT read full files.
46
+ - Working set = ALL `[ ] TODO` tickets (regardless of whether deps are DONE yet — future layers must be planned too).
47
+ - Also collect: `[x] DONE` set (for dep-resolution context) and `[~] IN_PROGRESS` / `[!] BLOCKED` set (excluded from batch but reported in summary).
48
+ - Filter by operator args (explicit list / domain scope / etc.).
49
+ - Empty working set → halt: "No TODO tasks in scope. State: <N DONE, M IN_PROGRESS, K BLOCKED>".
50
+
51
+ 2. **Plan execution layers (full forward DAG, not just Layer 0):**
52
+ Build a layered DAG over the WHOLE working set. The orchestrator does this analysis itself reading **planning surface ONLY** (Dependencies + Phases Overview to compute aggregate Target Files for conflict analysis). No subagent for planning.
53
+
54
+ Algorithm:
55
+ a. **Topological layers by explicit Task Dependencies** (entire working set):
56
+ - Layer 0 = tasks where every Dependency is in `[x] DONE` set.
57
+ - Layer L+1 = tasks where every Dependency is either DONE OR placed in layers ≤ L.
58
+ - Tasks with deps on IN_PROGRESS / BLOCKED tickets → marked `⏸️ waiting` and excluded from the layer plan.
59
+ b. **File-conflict split within each layer:**
60
+ - For each task in layer, aggregate file set = union of ALL its phases' `Target Files` (read from each phase block — minimal extra read).
61
+ - Two tasks in same layer with overlapping aggregate file sets → cannot run in parallel.
62
+ - Greedy split: assign tasks to parallel sub-batches such that no two tasks in a sub-batch share files. Conflict → push to next sub-batch within same layer.
63
+ - Result: each layer = list of sub-batches; sub-batches within a layer run sequentially; tasks within a sub-batch run in parallel.
64
+
65
+ Cycle detection: working set with unresolved deps after all layering → cycle. Halt with explicit cycle path.
66
+
67
+ **Preflight: blocker scan** (per `AX_BLOCKER_RESOLUTION_TRAIL`). For each ticket in working set, run `~/Developer/gennady/ai/skills/sdd-execute/scripts/sdd check-blockers <ticket>` (skill helper scripts ship with the sibling `sdd-execute` skill). Any ticket with unresolved blockers → mark `✋ AWAITING UNBLOCK` (NOT failed); exclude from batch dispatch with explicit list of pending decisions. Distinguish in summary from `❌ FAILED` tasks.
68
+
69
+ 3. **Show full plan to operator:**
70
+
71
+ ```
72
+ 📋 Execution Plan
73
+
74
+ Already ✅ DONE: <N> tasks (<list of TSK-NN, max 8 shown then "…">)
75
+
76
+ Layer 0 [parallel, 3 tasks]:
77
+ TSK-01 — Implement port A | deps: none | phases: P1 impl, P2 test
78
+ TSK-02 — Implement port B | deps: none | phases: P1 impl, P2 test
79
+ TSK-03 — Implement port C | deps: none | phases: P1 impl, P2 test
80
+
81
+ Layer 1 [parallel, 2 tasks]:
82
+ TSK-04 — Compose AB | deps: TSK-01,TSK-02 | phases: P1 impl, P2 test
83
+ TSK-05 — Compose AC | deps: TSK-01,TSK-03 | phases: P1 impl, P2 test
84
+
85
+ Layer 2 [serial, 2 tasks — file conflict on src/shared.ts]:
86
+ sub-batch a: TSK-07 | deps: TSK-04 | phases: P1 refactor
87
+ sub-batch b: TSK-06 | deps: TSK-04,TSK-05 | phases: P1 refactor
88
+
89
+ ⏸️ Waiting (excluded):
90
+ TSK-08 — ... | waiting on TSK-99 (IN_PROGRESS elsewhere)
91
+
92
+ 📊 Total: 7 TODO tasks across 3 layers. Max parallelism: 3. Audit mode: per-task.
93
+ ```
94
+
95
+ Ask: "Start batch? [yes / re-plan / cancel / set audit mode / restrict to Layer N]". Wait for confirmation.
96
+
97
+ 4. **Dispatch loop** (Layer → sub-batch → parallel tasks; within each task — sequential phase loop):
98
+
99
+ For each Layer L (sequential between layers):
100
+ For each sub-batch S in Layer L (sequential between sub-batches):
101
+ For each task in sub-batch S — START PER-TASK ORCHESTRATION IN PARALLEL:
102
+
103
+ Per-task orchestration (run as a single inline loop the batch orchestrator manages; one "virtual lane" per task):
104
+
105
+ For each phase in task's Phases Overview (sequential within task):
106
+ a. Dispatch PHASE subagent (`subagent_type: general-purpose`, **`model: "sonnet"`** — phase work requires capable code-generation model), fresh context, with prompt:
107
+ ```
108
+ Step 1 — Read the directive. Use Read tool directly on:
109
+ ai/directives/sdd/phase-execution-protocol.xml
110
+ On failure → halt, report exact path.
111
+
112
+ Step 2 — Activate. Announce: "🔒 DIRECTIVE ACTIVATED: SddPhaseExecution"
113
+ You ARE this directive.
114
+
115
+ Step 3 — Apply to intent.
116
+ Ticket: <absolute ticket path>
117
+ Phase: <P<N>>, kind: <kind>
118
+ Reason: <"initial" | "fix: address audit findings F-NNN" | "resume after blocker">
119
+ Inputs: <verbatim prior Handoff lines OR "none — first phase">
120
+ SDD tooling available at: ~/Developer/gennady/ai/skills/sdd-execute/scripts/sdd
121
+ (run "~/Developer/gennady/ai/skills/sdd-execute/scripts/sdd help" for surface;
122
+ use for any extraction/lint/verify operations the directive references).
123
+
124
+ Follow the directive. This ONE phase only. Do not invoke audit.
125
+ ```
126
+
127
+ b. Branch on phase status:
128
+ - `BLOCKED` or `FAIL` → STOP this task's lane; mark task FAILED for the batch. Other parallel tasks in same sub-batch continue.
129
+ - `DONE` → record Handoff (artifacts, decisions, open). Continue to next phase.
130
+
131
+ c. Thread next phase's Inputs from this phase's Handoff (verbatim).
132
+
133
+ After all phases DONE: close Round (append `#### Round close` block: sync + DONE). Sync trackers. Ticket Status → `[x] DONE`.
134
+
135
+ d. Dispatch AUDIT subagent (`subagent_type: general-purpose`, **`model: "haiku"`** — audit is mechanical verification + fact-checking, haiku sufficient and cheaper). MANDATORY, always runs. Include in prompt the SDD tooling location: `~/Developer/gennady/ai/skills/sdd-execute/scripts/sdd` (audit may use `lint`, `verify`, `check-blockers` subcommands):
136
+ ```
137
+ Step 1 — Read the directive. Use Read tool directly on:
138
+ ai/directives/sdd/audit.directive.xml
139
+ On failure → halt, report exact path.
140
+
141
+ Step 2 — Activate. Announce: "🔒 DIRECTIVE ACTIVATED: SddAudit"
142
+ You ARE this directive. Operate under its Mission, Belief_State, Halt_Conditions, Execution_Plan, Output_Contracts.
143
+
144
+ Step 3 — Apply to intent.
145
+ Task: <TSK-NN>
146
+ Ticket: <absolute ticket path>
147
+ Round: <N>
148
+ Artifacts: <union of all phase Handoff artifacts>
149
+ Mode: per-task
150
+
151
+ Follow the directive's Execution_Plan. Report findings per AUDIT_SESSION_SUMMARY_FORMAT.
152
+ ```
153
+ Wait for return. If dispatch fails → retry once. If fails again → mark task FAILED.
154
+
155
+ e. Branch on audit status:
156
+ - `PASS` / `PASS_WITH_ACKNOWLEDGED_RISKS` → task complete; continue lane (next task in batch).
157
+ - `FAIL` AND `audit_attempt = 1` → trigger selective phase re-run.
158
+ Open new Round with reason `audit-driven fix: F-NNN, F-MMM`.
159
+ For each phase in `phases_to_fix` (sequential, declared order subset):
160
+ Dispatch PHASE subagent with `Reason: fix: address audit findings F-NNN, F-MMM` and audit findings list in Inputs. Wait.
161
+ On BLOCKED/FAIL → STOP this task's lane; mark task FAILED.
162
+ After all fix phases DONE → close Round → dispatch AUDIT (round 2, fresh context). Branch again:
163
+ PASS → task complete.
164
+ FAIL (audit_attempt = 2) → STOP lane; mark task FAILED.
165
+
166
+ — Wait for all parallel task lanes in sub-batch to finish.
167
+ — Any task FAILED → continue batch (other layers may not depend on it; if they do they'll be marked `⏸️ waiting`). Operator gets failure list in final summary.
168
+
169
+ 5. **End of batch:**
170
+
171
+ Dispatch ONE verification check across all completed tasks:
172
+
173
+ ```
174
+ Verify for scope <scope>:
175
+ 1. Read tasks/<scope>/README.md — confirm all task statuses match their tickets' Meta Status.
176
+ 2. Read tasks/README.md Tracker Index — confirm aggregate counts match.
177
+ 3. If mismatches found → fix sync directly.
178
+ ```
179
+
180
+ 6. **Final summary table:**
181
+
182
+ ```
183
+ 📊 Batch Summary
184
+
185
+ | Task-ID | Phases | Audit (round) | 🔄 phases_fixed | Final | Files |
186
+ |---|---|---|---|---|---|
187
+ | TSK-04 | P1✅ P2✅ | ✅ R1 | — | ✅ PASS | 2 |
188
+ | TSK-05 | P1✅ P2✅ | ❌→✅ R2 | P2 | ✅ PASS | 1 |
189
+ | TSK-06 | P1✅ P2❌ | — | — | ❌ phase-FAIL | 0 |
190
+
191
+ 📊 ✅ <N> · 🔄 <R> · ❌ <F> · 🛑 <B> · ⏸️ waiting <S>
192
+
193
+ 🔍 Epic audit (if run): <✅ PASS | ❌ FAIL — 🔴 N cross-task findings>
194
+ ```
195
+
196
+ Any audit = FAIL → recommend `/sdd-execute <TSK-NN>` for targeted re-run.
197
+ </Protocol>
198
+
199
+ <HardForbidden>
200
+ - Reading phase-execution-protocol.xml or audit.directive.xml yourself. (Subagents do.)
201
+ - Reading full ticket files (sections 3 bodies, 4 BDD, 5 Verification, 6 Coverage). During planning, read ONLY sections 1 + 2 + 7-current-Round.
202
+ - Writing code or phase blocks in Execution Log. (Phase subagents do.)
203
+ - Sharing context between phase subagents of different tasks. Each lane is isolated; orchestrator threads only typed Handoffs within ONE task's lane.
204
+ - Skipping audit after Round close in default (per-task) mode. Audit dispatch is mandatory.
205
+ - Audit retry beyond 2 total attempts per task. Hard cap.
206
+ - Re-running phases not flagged in `phases_to_fix`. The map finding-location → phase is the contract.
207
+ - Parallel dispatch ACROSS layers. Layers run sequentially.
208
+ - Parallel dispatch ACROSS sub-batches in same layer. Sub-batches exist exactly because of file conflicts.
209
+ - Parallel dispatch ACROSS phases of the SAME task. Phases are sequential by declared Deps within a task. Cross-task parallelism is the legitimate use of parallel sub-batches.
210
+ - Auto-reopening on phase BLOCKED/FAIL within a task. Only on audit FAIL after Round close the selective phase retry kicks in (max once per task).
211
+ - Skipping the planning step. Even for 2-task batches the orchestrator MUST emit the layer plan and ask for confirmation.
212
+ </HardForbidden>
213
+ </SddExecuteBatchOrchestrator>
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: sdd-fix
3
+ description: Take findings (code review, sdd-check, audit output, bug report), classify, plan, agree with operator, execute fixes, reopen tasks, dispatch execution, verify. Use for "исправь", "почини", "fix", "sdd-fix", after code review or sdd-check.
4
+ compatibility: opencode
5
+ ---
6
+
7
+ 1. **Extract intent.** Parse findings from operator's context — code review, sdd-check output, audit summary, bug report. If no findings → HALT with explicit ask.
8
+
9
+ 2. **Load & activate directive.** Read in full: `~/Developer/gennady/ai/directives/sdd/fix.directive.xml`
10
+ Announce: `🔒 DIRECTIVE ACTIVATED: SddFix`
11
+ You ARE this directive now.
12
+
13
+ 3. **Apply directive to intent.** Pass parsed findings. Follow Execution_Plan: classify → plan → agree → execute → dispatch → verify.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: sdd-infra
3
+ description: Design or evolve an infrastructure scope — package manager, type-checker, linter, formatter, test runner, git hooks, CI. Scope-type=infrastructure discovery session. Use for bootstrapping tooling for a new infra scope (infra-base, infra-golang, infra-frontend) or pivoting/extending an existing one.
4
+ compatibility: opencode
5
+ ---
6
+
7
+ 1. **Extract intent.** Operator wants to bootstrap or evolve infrastructure scope. Scope-type is fixed: `infrastructure`. Resolve scope name from intake.
8
+
9
+ 2. **Load & activate directive.** Read in full: `~/Developer/gennady/ai/directives/sdd/discovery.directive.xml`
10
+ Announce: `🔒 DIRECTIVE ACTIVATED: SddDiscovery | infrastructure`
11
+ You ARE this directive now.
12
+
13
+ 3. **Apply directive to intent.** Force scope-type=`infrastructure`. Mode auto-detected per `AX_MODE_AUTO_DETECT_OR_HALT`. Follow Execution_Plan end-to-end.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: sdd-module-decomposition
3
+ description: Decompose a product or library scope into module specs with closed-world entity inventory, public surfaces, DbC contracts (Ports / Adapters / Services). Only applicable to scope-type=product and scope-type=library. Modes auto-detected: initial, add-module, refine-module.
4
+ compatibility: opencode
5
+ ---
6
+
7
+ 1. **Extract intent.** Operator wants to decompose scope `<name>` into modules. Verify scope-type ∈ {product, library} — infrastructure / contracts forbidden.
8
+
9
+ 2. **Load & activate directive.** Read in full: `~/Developer/gennady/ai/directives/sdd/module-decomposition.directive.xml`
10
+ Announce: `🔒 DIRECTIVE ACTIVATED: SddModuleDecomposition`
11
+ You ARE this directive now.
12
+
13
+ 3. **Apply directive to intent.** Mode auto-detected per `AX_MODE_AUTO_DETECT_OR_HALT`. Follow Execution_Plan end-to-end. Do not deviate.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: sdd-scaffold
3
+ description: Decompose specs (root + domain + infra) into a DAG of compact task tickets ready for autonomous execution by sdd-execute orchestrator. Materializes Cascade Table, Tracker Index, BDD scenarios, Phases Overview + per-phase Rules. Use for first task generation from spec tree, or scaffolding tasks for a new/refined domain. Modes auto-detected: initial, extend-dag.
4
+ compatibility: opencode
5
+ ---
6
+
7
+ 1. **Extract intent.** Operator wants to scaffold tasks for {scope | all scopes}. Mode: `initial` (no `tasks/` yet) or `extend-dag` (`tasks/` exists, adding to it).
8
+
9
+ 2. **Load & activate directive.** Read in full: `~/Developer/gennady/ai/directives/sdd/scaffold.directive.xml`
10
+ Announce: `🔒 DIRECTIVE ACTIVATED: SddScaffold`
11
+ You ARE this directive now.
12
+
13
+ 3. **Apply directive to intent.** Mode auto-detected per `AX_MODE_AUTO_DETECT_OR_HALT`. Follow Execution_Plan end-to-end. Do not deviate.
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: sdd-setup
3
+ description: Initialize or update the project portal (specs/README.md) — Vision, Scope Graph, and Scopes table. This is the sole owner of the project portal. Idempotent: run any number of times to add scopes, update vision, or bootstrap infra-base. Always run this first for a brand new project.
4
+ compatibility: opencode
5
+ ---
6
+
7
+ 1. **Extract intent.** Operator wants to initialize or update the project portal. Operation may be: bootstrap new project, add a scope to Scope Graph, update Vision, sync after discovery.
8
+
9
+ 2. **Load & activate directive.** Read in full: `~/Developer/gennady/ai/directives/sdd/setup.directive.xml`
10
+ Announce: `🔒 DIRECTIVE ACTIVATED: SddSetup`
11
+ You ARE this directive now.
12
+
13
+ 3. **Apply directive to intent.** Mode auto-detected per `AX_IDEMPOTENT_MODES`. Follow Execution_Plan end-to-end. Do not deviate.
@@ -1,6 +1,6 @@
1
- <ResultConventions keywords="result, error-handling, isErr, TessellError, unwrap, success, fail" type="coding-rule" ver="1.0">
1
+ <ResultConventions keywords="result, error-handling, isErr, TessellError, must, success, fail" type="coding-rule" ver="1.2">
2
2
  <Mission>
3
- Invariants for the Result pattern from @tessell/core/result. Four binary idioms (R1–R4) are enforced via ESLint custom rules (eslint-plugin-tessell-result); each maps to a forbidden idiom in AGENTS.md that survived code review and was caught retroactively. One architectural convention (AX_RESULT_PUBLIC_BOUNDARY) is code-review-only — not mechanically detectable.
3
+ Invariants for the Result pattern from @tessell/core/result. Seven conventions (R1–R7) are enforced via ESLint custom rules (eslint-plugin-tessell-result); each codifies an idiom from AGENTS.md that survived code review. The architectural convention AX_RESULT_PUBLIC_BOUNDARY is largely code-review-only — R7 enforces its mechanically-detectable subset. Canonical consumption idiom: `must` + try/catch.
4
4
  </Mission>
5
5
 
6
6
  <Belief_State>
@@ -17,10 +17,20 @@
17
17
  </Axiom>
18
18
 
19
19
  <Axiom id="AX_NO_RESULT_ISERR_SHORT_CIRCUIT">
20
- `if (isErr(r)) return r` and `if (!isOk(r)) return r` are forbidden. Use `unwrap + try/catch` — that is the whole point of the convention.
20
+ `if (isErr(r)) return r` and `if (!isOk(r)) return r` are forbidden. Use `must` + try/catch — that is the whole point of the convention.
21
21
  No autofix: requires restructuring the surrounding function, not a one-line substitution.
22
22
  </Axiom>
23
23
 
24
+ <Axiom id="AX_NO_RESULT_OK_SHORT_CIRCUIT">
25
+ `if (!r.ok) return r` and `if (r.ok === false) return r` (property-access short-circuit form, the twin of AX_NO_RESULT_ISERR_SHORT_CIRCUIT) are forbidden. Use `must` + try/catch.
26
+ Detection: IfStatement whose test is `!r.ok` or `r.ok === false`, whose consequent is a bare `return r` (or a block with exactly one such return), and whose returned identifier matches the object of the `.ok` access.
27
+ No autofix: requires restructuring the surrounding function, not a one-line substitution.
28
+ </Axiom>
29
+
30
+ <Axiom id="AX_MUST_EXTRACTOR">
31
+ Extract a Result's value with `must`: `must(result)` returns the data or throws the contained error. It is synchronous and takes only a resolved Result — for a `Promise<Result>` write `must(await fn())`, so a forgotten await is a compile error. Combine with try/catch at the boundary.
32
+ </Axiom>
33
+
24
34
  <Axiom id="AX_NO_BARE_THROW_UNKNOWN">
25
35
  `throw catchBinding` without wrapping in `TessellError.cast` is forbidden when the binding is a CatchClause parameter (type unknown). Applies in wrapper/guard functions that rethrow, not only in catch blocks that return fail().
26
36
  Detection: scope analysis — ThrowStatement whose argument resolves to a CatchClause parameter, regardless of variable name (cause, err, e, error).
@@ -31,13 +41,18 @@
31
41
  Result is the transport form of error across the public / port boundary — not an internal control-flow primitive. Public surface (port interface methods, exported factory return types, closures returned from factories) MUST return `Result<T>`. Inside the same class:
32
42
  - protected/private async helpers with I/O → throw; the public caller wraps in try/catch and returns `fail(error)` (per AX_CATCH_LOG_RECOVER in typescript-rules).
33
43
  - pure helpers (predicates, classifiers) → honest return type (`Error | null`, scalar, enum literal); not Result.
34
- - Result in protected is permitted only when the helper carries a typed `kind` the public call-site immediately unwraps — and even then, throw is usually cleaner because it avoids the `Result → unwrapSync → throw → catch → re-emit` double-packaging pattern.
44
+ - Result in protected is permitted only when the helper carries a typed `kind` the public call-site immediately extracts (via `must`) — and even then, throw is usually cleaner because it avoids the `Result → must → throw → catch → re-emit` double-packaging pattern.
35
45
 
36
46
  Rationale: mixing Result and null-pattern in helpers of one class produces structural noise (two error-channel styles in one surface) and double-packaging. The convention keeps Result as a boundary artifact, not an internal one.
37
47
 
38
48
  Not ESLint-enforced. The public/private boundary is not mechanically detectable: closures returned from factories (e.g. `defineDataStorageQuery → (storage, params) => Promise<Result<R>>`) are public-by-intent but private-by-syntax, and methods on factory-returned object literals (e.g. `defineDataOperation`) are not visible as class members. Enforced via code review and this directive.
39
49
  </Axiom>
40
50
 
51
+ <Axiom id="AX_GUARDED_RESULT_BOUNDARY">
52
+ A public Result-returning surface guards thrown errors. If a public class method or exported function returns `Result<T>` / `Promise<Result<T>>` and calls `must(...)`, that call must sit inside a try/catch whose `catch` returns `fail(...)` — otherwise the thrown error escapes the boundary instead of becoming `Err`.
53
+ Detection: explicit return-type annotation `Result`/`Promise<Result>` + a `must` call outside try (no autofix; optional suggestion). ESLint-enforceable subset of AX_RESULT_PUBLIC_BOUNDARY — factory-returned closures stay code-review (private-by-syntax).
54
+ </Axiom>
55
+
41
56
  <Axiom id="AX_CONFIGURABLE_NAMES">
42
57
  Every rule that matches function or type names accepts an options object with configurable identifiers: resultTypeName, isErrFn, isOkFn, successFn, failFn, castFn.
43
58
  Defaults match @tessell/core/result exports. On package rename — update config, not the rule.
@@ -47,9 +62,12 @@
47
62
  <Reward_Criteria>
48
63
  - R1 flags `Result<T, DataStorageError>`, autofixes to `Result<T>`. Does NOT flag `Result<T, E>` where E is a type parameter of the enclosing generic.
49
64
  - R2 flags `{ ok: true, data: x, error: null }`, autofixes to `success(x)`.
50
- - R3 flags `if (isErr(r)) return r` with no autofix; error message cites `unwrap + try/catch`.
65
+ - R3 flags `if (isErr(r)) return r` with no autofix; error message cites `must` + try/catch.
51
66
  - R4 flags `throw e` inside any catch where e is the catch binding, regardless of variable name.
52
- - R3 and R4 carry explanatory comment in eslint.config.ts (non-autofix path per eslint-setup AX_CUSTOM_PLUGINS_OBEY_META_POLICY).
53
- - Each rule has Vitest tests: positive case, negative case, edge case (R1: type param exception; R4: non-catch-binding throw not flagged).
67
+ - R5 flags `if (!r.ok) return r` and `if (r.ok === false) return r` with no autofix; does NOT flag `if (!r.ok) doSomethingElse()`.
68
+ - R6 enforces `must` as the only Result extractor: autofixes to `must` where unambiguous, report-only otherwise; acts only on result-module identifiers, never foreign packages. Detection/autofix matrix: rule + TSK-58.
69
+ - R7 flags an unguarded `must(...)` (or a catch not returning `fail`) in a public class method / exported function annotated `Result`/`Promise<Result>`; no autofix (optional suggestion). Does NOT flag private/protected, inferred-return-type, or factory-returned closures.
70
+ - R3, R4, R5, R7 and the non-autofix path of R6 carry explanatory comment in eslint.config.ts (per eslint-setup AX_CUSTOM_PLUGINS_OBEY_META_POLICY).
71
+ - Each rule has Vitest tests: positive case, negative case, edge case (R1: type param exception; R4: non-catch-binding throw not flagged; R6: autofixable vs report-only forms + foreign-import not flagged; R7: factory-closure/private/inferred-type not flagged).
54
72
  </Reward_Criteria>
55
73
  </ResultConventions>
@@ -294,7 +294,7 @@
294
294
  1. TRACE_HEADER (STACK `ROOT__PRECONDITIONS_CHECK`).
295
295
  2. Inspect Execution Log: `[x] DONE` present? Verification commands executed and recorded?
296
296
  3. Not closed → `H_TICKET_NOT_DONE`. Module or scope spec missing → `H_NO_MODULE_SPEC`.
297
- 4. **Mechanical pre-pass.** (a) Lint: changed `.ts` files in this Round (per `AX_GIT_DIFF_SCAN`) → `npx tsx /Users/k.lebedev/Developer/gennady/cli/gennady.ts lint <files...>`; each issue → `RULES_COMPLIANCE_VIOLATION` tagged `mechanically-detected: <rule-id>`. No `.ts` / tool absent → skip silently / log warning. (b) Anchor balance: `~/.claude/skills/sdd-execute/scripts/sdd scan <project-root>`; each `anchor-mismatch:<opens>-open/<closes>-close` line in `[WARNINGS]` → `EXECUTION_LOG_INCOMPLETE` (`MAJOR`) tagged `anchor-unbalanced`, `loc=<file>:<opens>/<closes>`. Universal — name-agnostic, works on any markdown artifact. Per-ticket name coverage happens in STEP_2_5.
297
+ 4. **Mechanical pre-pass.** (a) Lint: changed `.ts` files in this Round (per `AX_GIT_DIFF_SCAN`) → `npx tsx ~/Developer/gennady/cli/gennady.ts lint <files...>`; each issue → `RULES_COMPLIANCE_VIOLATION` tagged `mechanically-detected: <rule-id>`. No `.ts` / tool absent → skip silently / log warning. (b) Anchor balance: `~/.claude/skills/sdd-execute/scripts/sdd scan <project-root>`; each `anchor-mismatch:<opens>-open/<closes>-close` line in `[WARNINGS]` → `EXECUTION_LOG_INCOMPLETE` (`MAJOR`) tagged `anchor-unbalanced`, `loc=<file>:<opens>/<closes>`. Universal — name-agnostic, works on any markdown artifact. Per-ticket name coverage happens in STEP_2_5.
298
298
  5. Phase Progress + Approval Check. STOP otherwise → STEP_2.
299
299
  </Action>
300
300
  </Step>
@@ -0,0 +1,78 @@
1
+ <SddCriticProtocol keywords="critic, artifact-review, spec-review, task-review, bdd-audit, blind-spot, comprehension-gap, isolation" type="directive" ver="1.0">
2
+ <Directive_Context>
3
+ <Mission>
4
+ Read ONE artifact — spec or task — and emit a structured critique. ISOLATED context: you see ONLY this artifact and its parent spec (tasks only). READ and REPORT only. NEVER edit files. Find specification defects that threaten production: ambiguous boundaries, missing realistic error paths, unstated runtime assumptions, contradictions, incomplete BDD scenarios, misalignment with parent spec.
5
+ </Mission>
6
+ </Directive_Context>
7
+
8
+ <Belief_State>
9
+ <Axiom id="AX_READ_ONLY">Read artifact + parent spec. Write text output. NEVER edit files — orchestrator applies edits.</Axiom>
10
+ <Axiom id="AX_ISOLATION">Only artifact + parent spec. No other files. Confusion → underspecification.</Axiom>
11
+ <Axiom id="AX_COMPREHENSION_FIRST">Report understanding before problems. Misunderstanding signals ambiguity.</Axiom>
12
+
13
+ <Axiom id="AX_SPEC_DIMENSIONS">
14
+ Spec quality dimensions:
15
+ 1. Boundary — explicit scope / out-of-scope statements.
16
+ 2. Purpose — who uses this, for what. Use cases.
17
+ 3. Entities — all named, public surfaces defined, relationships clear.
18
+ 4. Contracts — Ports/Adapters/Services: pre/post conditions, invariants.
19
+ 5. Dependencies — external deps named and versioned.
20
+ 6. Failure modes — what breaks when dep unavailable, input invalid, happy path fails.
21
+ 7. Non-goals — explicit exclusions.
22
+ 8. Consistency — no internal contradictions.
23
+ 9. Testability — claims verifiable, not vague ("should be fast").
24
+ </Axiom>
25
+
26
+ <Axiom id="AX_TASK_DIMENSIONS">
27
+ Task quality dimensions:
28
+ 1. BDD — Happy path, edge cases (empty/max/boundary), error paths (network/file/timeout), negative cases. Concrete GIVEN/WHEN/THEN required.
29
+ 2. Spec alignment — entity names match spec. Contracts covered by phases. Verification refs correct.
30
+ 3. Phases — ordered correctly, deps explicit, no gaps (impl without test), Target Files non-overlapping.
31
+ 4. Clarity — fresh agent can build from this alone. Inputs/outputs specified.
32
+ 5. Completeness — all sections filled, no <TBD> or <YYYY-MM-DD>.
33
+ </Axiom>
34
+
35
+ <Axiom id="AX_SEVERITY">
36
+ CRITICAL — unusable, downstream agent produces wrong work.
37
+ MAJOR — gap requiring rework.
38
+ MINOR — improvement, vague wording.
39
+ INFO — observation.
40
+ </Axiom>
41
+
42
+ <Axiom id="AX_UNCERTAINTY_IS_SIGNAL">"I don't understand X" is valid output. Uncertainty = underspecification.</Axiom>
43
+
44
+ <Axiom id="AX_PRODUCTION_REALISM">
45
+ Test: would this gap cause user-visible failure or data loss within one month of deployment? Internal boundaries → type system is the contract, do not flag type-violation scenarios. External boundaries (API, I/O, user input, third-party) → input validation gaps are real.
46
+ </Axiom>
47
+ </Belief_State>
48
+
49
+ <Anti_Patterns>
50
+ <Pattern id="AP_EDIT">Editing files. Read + report only.</Pattern>
51
+ <Pattern id="AP_SURFACE">Reading headers only. Read full content.</Pattern>
52
+ <Pattern id="AP_NITPICK">Minor wording flagged as CRITICAL. Focus on what breaks downstream agent.</Pattern>
53
+ <Pattern id="AP_CERTAINTY">Declaring certainty without verification. "Not sure" > wrong answer.</Pattern>
54
+ <Pattern id="AP_FORMAT_BIAS">Assuming quality from formatting. Structure ≠ correctness.</Pattern>
55
+ <Pattern id="AP_CREEP">Reading beyond artifact + parent spec.</Pattern>
56
+ <Pattern id="AP_INTERNAL_PARANOIA">Flagging type violations at internal boundaries. Type system prevents these.</Pattern>
57
+ </Anti_Patterns>
58
+
59
+ <Execution_Plan>
60
+ <Step id="1_READ"><Goal>Read artifact end-to-end.</Goal><Action>Read artifact fully. For task: read parent spec — entity inventory, contracts, relevant requirements. No other files.</Action></Step>
61
+ <Step id="2_UNDERSTAND"><Goal>Articulate understanding.</Goal><Action>Write "## What I understood". Spec: system, boundaries, entities. Task: change, phases, BDD scenarios.</Action></Step>
62
+ <Step id="3_CONFUSION"><Goal>Flag confusion.</Goal><Action>Write "## What I did NOT understand". Per point: section name, what is unclear.</Action></Step>
63
+ <Step id="4_FIND"><Goal>Apply quality dimensions.</Goal><Action>Check each dimension from AX_SPEC_DIMENSIONS or AX_TASK_DIMENSIONS. Per finding: `### <dimension> — <summary>` then `Location | Finding | Why | Severity | Suggested fix`. Write under "## Problems found".</Action></Step>
64
+ <Step id="5_VERDICT"><Goal>Emit verdict.</Goal><Action>Write "## Verdict" — CLEAN (no CRITICAL/MAJOR), NEEDS_WORK (MAJOR, no CRITICAL), CRITICAL (≥1 CRITICAL).</Action></Step>
65
+ </Execution_Plan>
66
+
67
+ <Output_Contracts>
68
+ <Contract id="OC_STRUCTURED">Exact headers: "## What I understood", "## What I did NOT understand", "## Problems found", "## Verdict". No greetings, no sign-off. Machine-parseable.</Contract>
69
+ </Output_Contracts>
70
+
71
+ <HardForbidden>
72
+ - Edit. Read + report. Orchestrator edits.
73
+ - Read beyond artifact + parent spec.
74
+ - Fabricate certainty.
75
+ - Invent internal type-violation scenarios.
76
+ - Surface-scan.
77
+ </HardForbidden>
78
+ </SddCriticProtocol>
@@ -0,0 +1,158 @@
1
+ <SddCritic keywords="critic, spec-review, task-review, bdd-audit, blind-spot, autonomous-polish, multi-round, pre-execute, orchestration" type="directive" ver="2.0">
2
+ <Directive_Context>
3
+ <Mission>
4
+ Autonomous critique loop for SDD artifacts — spec, task, or batch (spec + all tasks). You are the ORCHESTRATOR in the root session. Per round: dispatch one isolated critic subagent, evaluate feedback against full project context, surgically edit artifact, re-dispatch if edits applied (max 5 rounds). For batch: spec first, then tasks in DAG layers — parallel within layer, sequential between layers. On CLEAN: delete `## Critic Rounds` (temporary scaffolding). Artifact is clean, improvements integrated.
5
+ </Mission>
6
+ </Directive_Context>
7
+
8
+ <Belief_State>
9
+ <Axiom id="AX_OWNER">Orchestrator owns artifact, applies edits. Critic is sensor — reports only, never edits.</Axiom>
10
+ <Axiom id="AX_ISOLATION_SIGNAL">Critic receives ONLY artifact + parent spec. Confusion = underspecification. Fix the artifact.</Axiom>
11
+ <Axiom id="AX_RE_DISPATCH">Any edit → re-dispatch mandatory. Edits may create contradictions detectable only by fresh isolated agent.</Axiom>
12
+ <Axiom id="AX_STOP_NO_EDITS">Zero edits → stop. Unchanged input → unchanged verdict → infinite loop.</Axiom>
13
+ <Axiom id="AX_CAP_5">Max 5 rounds. Round 5 + edits + not CLEAN → stop, flag MAX_ROUNDS.</Axiom>
14
+ <Axiom id="AX_REJECTION_REASON">Every rejection cites specific context: file, section, entity that resolves the concern. No vague "more context."</Axiom>
15
+ <Axiom id="AX_DEFAULT_ACCEPT">Uncertain → ACCEPT. Cost of rejecting real finding > cost of accepting marginal one.</Axiom>
16
+ <Axiom id="AX_CONFUSION_BUG">Critic confusion ("don't understand X") → artifact underspecified → ALWAYS accept, clarify.</Axiom>
17
+ <Axiom id="AX_SURGICAL">Close the gap only. No restructure, rewrite, restyle. Structural overhaul → suggest re-scaffold, stop.</Axiom>
18
+ <Axiom id="AX_SCRATCH_LOG">`## Critic Rounds` = temporary working memory for orchestrator between rounds. Deleted on final CLEAN.</Axiom>
19
+ <Axiom id="AX_TASK_PARALLEL">Tasks critiqued in DAG layers. Same layer (no inter-dependencies) → parallel dispatch. Different layers → sequential.</Axiom>
20
+ <Axiom id="AX_LANG">Directive: English. Artifact prose (Critic Rounds, summary): Russian.</Axiom>
21
+ </Belief_State>
22
+
23
+ <Halt_Conditions>
24
+ | 🛑 ID | Trigger |
25
+ |---|---|
26
+ | H_NO_ARTIFACT | Path does not resolve to .spec.md / .task-*.md |
27
+ | H_PARENT_SPEC_MISSING | Task scope spec not found |
28
+ | H_DISPATCH_FAILED | Critic subagent dispatch failed twice |
29
+ | H_STRUCTURAL | Artifact needs restructuring beyond surgical edits |
30
+ </Halt_Conditions>
31
+
32
+ <Anti_Patterns>
33
+ <Pattern id="AP_SELF_CRITIQUE">Critiquing artifact yourself. Dispatch isolated critic.</Pattern>
34
+ <Pattern id="AP_NO_RE_DISPATCH">Edits without re-dispatch. Edit invalidates prior verdict.</Pattern>
35
+ <Pattern id="AP_SPIN">Re-dispatch with zero edits. Same input → same verdict.</Pattern>
36
+ <Pattern id="AP_OVEREDIT">Rewriting sections. Close the gap, don't redecorate.</Pattern>
37
+ <Pattern id="AP_DISMISS_CONFUSION">Ignoring "I don't understand X". Always fix.</Pattern>
38
+ <Pattern id="AP_VAGUE_REJECT">Rejecting without citing specific context.</Pattern>
39
+ </Anti_Patterns>
40
+
41
+ <Execution_Plan>
42
+ <Step id="0_RESOLVE">
43
+ <Goal>Resolve what to critique.</Goal>
44
+ <Action>
45
+ Operator input → determine scope:
46
+ - .spec.md path → ask: (1) spec only, (2) spec + all tasks, (3) all tasks only.
47
+ - .task-*.md path → single task, no question.
48
+ - scope name / tasks/<scope>/ → all tasks in scope.
49
+ Build queue: spec-first if included, then tasks in DAG layers.
50
+ For each task: read §1 Meta → resolve parent spec. Missing → H_PARENT_SPEC_MISSING.
51
+ </Action>
52
+ </Step>
53
+
54
+ <Step id="1_DISPATCH">
55
+ <Goal>Dispatch one isolated critic subagent.</Goal>
56
+ <Action>
57
+ Dispatch subagent, fresh context:
58
+ ```
59
+ Step 1 — Read directive: ai/directives/sdd/critic-protocol.xml
60
+ Step 2 — Activate. Announce: "🔒 SddCriticProtocol"
61
+ Step 3 — Apply. Artifact: <path>, Parent spec: <path|N/A>, Round: <N>.
62
+ Follow Execution_Plan. Do not deviate.
63
+ ```
64
+ Fail → retry once. Fail again → H_DISPATCH_FAILED.
65
+ </Action>
66
+ </Step>
67
+
68
+ <Step id="2_EVALUATE">
69
+ <Goal>Classify findings: ACCEPT or REJECT.</Goal>
70
+ <Action>
71
+ ACCEPT: genuine gap, misunderstanding reveals ambiguity, would break downstream agent, or uncertain (AX_DEFAULT_ACCEPT).
72
+ REJECT: misreading no competent agent would make AND specific context cited that resolves it.
73
+ Confusion points → ALWAYS accept (AX_CONFUSION_BUG).
74
+ Zero accepted → go to STEP_5 (stop). Any accepted → go to STEP_3.
75
+ </Action>
76
+ </Step>
77
+
78
+ <Step id="3_EDIT">
79
+ <Goal>Surgical edit.</Goal>
80
+ <Action>
81
+ Per accepted finding: add missing BDD scenario, clarify boundary, correct entity ref, fill placeholder. Target only the gap. Structural rewrite → H_STRUCTURAL.
82
+ </Action>
83
+ </Step>
84
+
85
+ <Step id="4_RECORD">
86
+ <Goal>Append scratch log.</Goal>
87
+ <Action>
88
+ Create/append `## Critic Rounds`:
89
+ ```
90
+ ### Round N — YYYY-MM-DD
91
+ - Verdict: <CLEAN|NEEDS_WORK|CRITICAL>
92
+ - Accepted: N — <list>
93
+ - Rejected: N — "<finding>" → <reason>
94
+ - Changes: <list>
95
+ ```
96
+ Append-only.
97
+ </Action>
98
+ </Step>
99
+
100
+ <Step id="5_DECIDE">
101
+ <Goal>Re-dispatch or conclude.</Goal>
102
+ <Action>
103
+ Edits applied AND round < 5 → round++, go to STEP_1.
104
+ No edits → conclude (go to STEP_6).
105
+ Round 5 → conclude, flag MAX_ROUNDS if not CLEAN.
106
+ </Action>
107
+ </Step>
108
+
109
+ <Step id="6_FINALIZE">
110
+ <Goal>Cleanup and detailed final summary.</Goal>
111
+ <Action>
112
+ If final critic verdict CLEAN → DELETE `## Critic Rounds` section from artifact.
113
+ If not CLEAN → keep section as documentation of unresolved findings.
114
+
115
+ Emit FULL summary (operator needs detail to discuss, challenge, or revert):
116
+ ```
117
+ 🔍 sdd-critic — <path>
118
+
119
+ 📊 Rounds: N
120
+ R1: <verdict>
121
+ 🔴 CRITICAL: <N> 🟠 MAJOR: <N> 🟡 MINOR: <N> 🔵 INFO: <N>
122
+ Принято:
123
+ - <finding summary> → <what was changed>
124
+ - ...
125
+ Отклонено:
126
+ - "<finding summary>" → <reason (specific context)>
127
+ - ...
128
+
129
+ R2: <verdict>
130
+ (same structure)
131
+ ...
132
+
133
+ RN: <verdict> → <stop reason>
134
+
135
+ ✏️ All changes:
136
+ - <change>
137
+ - ...
138
+
139
+ ⚠️ Unresolved (if not CLEAN):
140
+ - <finding> → <recommendation>
141
+
142
+ 📍 Artifact: <path> — <CLEAN | NEEDS_WORK | CRITICAL>
143
+ ```
144
+ </Action>
145
+ </Step>
146
+ </Execution_Plan>
147
+
148
+ <HardForbidden>
149
+ - Self-critique. Dispatch critic.
150
+ - Re-dispatch with zero edits.
151
+ - >5 rounds.
152
+ - Rewrite artifact.
153
+ - Share full context with critic.
154
+ - Keep `## Critic Rounds` after CLEAN.
155
+ - ACCEPT without edit.
156
+ - REJECT without specific context.
157
+ </HardForbidden>
158
+ </SddCritic>