deepflow 0.1.91 → 0.1.92

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.
@@ -85,7 +85,21 @@ For each `[ ]` task: `TaskCreate(subject: "{task_id}: {description}", activeForm
85
85
 
86
86
  ### 3–4. READY TASKS
87
87
 
88
- Warn if unplanned `specs/*.md` (excluding doing-/done-) exist (non-blocking). Ready = TaskList where status: "pending" AND blockedBy: empty.
88
+ Warn if unplanned `specs/*.md` (excluding doing-/done-) exist (non-blocking).
89
+
90
+ **Wave computation (shell injection — do NOT compute manually):**
91
+ ```
92
+ WAVE_PLAN=!`node bin/wave-runner.js --plan PLAN.md 2>/dev/null || echo 'WAVE_ERROR'`
93
+ ```
94
+ Parse the output to determine the current wave. Output format:
95
+ ```
96
+ Wave 1: T1 — description, T4 — description
97
+ Wave 2: T2 — description
98
+ ...
99
+ ```
100
+ If output is `WAVE_ERROR` or `(no pending tasks)`, fall back to TaskList where status: "pending" AND blockedBy: empty for wave 1.
101
+
102
+ Ready = tasks listed in Wave 1 of the wave-runner output (cross-referenced with TaskList status: "pending").
89
103
 
90
104
  ### 5. SPAWN AGENTS
91
105
 
@@ -93,17 +107,44 @@ Context ≥50% → checkpoint and exit. Before spawning: `TaskUpdate(status: "in
93
107
 
94
108
  **Token tracking start:** Store `start_percentage` (from context.json) and `start_timestamp` (ISO 8601) keyed by task_id. Omit if unavailable.
95
109
 
96
- **NEVER use `isolation: "worktree"`.** Deepflow manages a shared worktree so wave 2 sees wave 1 commits. **Spawn ALL ready tasks in ONE message** except file conflicts.
110
+ **Spawn ALL ready tasks in ONE message** except file conflicts.
111
+
112
+ **Intra-wave isolation:** For standard (non-spike, non-optimize) parallel tasks, use `isolation: "worktree"` so each agent works in its own isolated branch. Spikes use sub-worktrees managed by §5.7. Optimize tasks run one at a time in the shared worktree.
97
113
 
98
114
  **File conflicts (1 file = 1 writer):** Check `Files:` lists. Overlap → spawn lowest-numbered only; rest stay pending. Log: `"⏳ T{N} deferred — file conflict with T{M} on {filename}"`
99
115
 
100
116
  **≥2 [SPIKE] tasks same problem →** Parallel Spike Probes (§5.7). **[OPTIMIZE] tasks →** Optimize Cycle (§5.9), one at a time.
101
117
 
118
+ ### 5.1. INTRA-WAVE CHERRY-PICK MERGE
119
+
120
+ After ALL wave-N agents complete (all notifications received and ratchet checks done), collect their commits and cherry-pick into the shared worktree BEFORE wave N+1 begins.
121
+
122
+ **Ordering:** Cherry-pick in ascending task-number order (T1 before T2 before T3, etc.) to ensure deterministic application.
123
+
124
+ **Per commit (via §5.8 haiku context-fork):**
125
+ ```
126
+ Spawn Agent(model="haiku", isolation: "none", run_in_background=false):
127
+ Working directory: {SHARED_WORKTREE_PATH}
128
+ Run: git cherry-pick {task_commit_sha}
129
+ Return exactly ONE line: "cherry-pick: applied {sha} cleanly" or "cherry-pick: conflict in {file}"
130
+ Last line: TASK_STATUS:pass or TASK_STATUS:fail
131
+ ```
132
+
133
+ **On TASK_STATUS:pass:** Cherry-pick succeeded. Log: `"✓ T{N}: cherry-picked {sha} to shared worktree"`.
134
+
135
+ **On TASK_STATUS:fail (conflict detected):**
136
+ 1. Spawn haiku context-fork: `git cherry-pick --abort` — receive one-line confirmation.
137
+ 2. Log: `"✗ T{N}: cherry-pick conflict — reverting agent commit"`.
138
+ 3. Spawn haiku context-fork in the **agent's isolated worktree**: `git revert HEAD --no-edit` — receive one-line summary.
139
+ 4. `TaskUpdate(status: "pending")`. Task will retry in a future wave.
140
+
141
+ **Wave gate:** Wave N+1 MUST NOT start until all wave-N cherry-picks complete (pass or revert). This ensures wave N+1 agents see the full integrated state of wave N.
142
+
102
143
  ### 5.5. RATCHET CHECK
103
144
 
104
145
  Run `node bin/ratchet.js` in the worktree directory after each agent completes:
105
146
  ```bash
106
- node bin/ratchet.js --worktree ${WORKTREE_PATH} --snapshot .deepflow/auto-snapshot.txt
147
+ node bin/ratchet.js --worktree ${WORKTREE_PATH} --snapshot .deepflow/auto-snapshot.txt --task T{N}
107
148
  ```
108
149
 
109
150
  The script handles all health checks internally and outputs structured JSON:
@@ -124,7 +165,11 @@ The script handles all health checks internally and outputs structured JSON:
124
165
 
125
166
  **Orchestrator response by exit code:**
126
167
  - **Exit 0 (PASS):** Commit stands. Proceed to §5.6 wave test agent.
127
- - **Exit 1 (FAIL):** Script already reverted. Set `TaskUpdate(status: "pending")`. Report: `"✗ T{n}: reverted"`.
168
+ - **Exit 1 (FAIL):** Script already reverted. Set `TaskUpdate(status: "pending")`. Recompute remaining waves:
169
+ ```
170
+ WAVE_PLAN=!`node bin/wave-runner.js --plan PLAN.md --recalc --failed T{N} 2>/dev/null || echo 'WAVE_ERROR'`
171
+ ```
172
+ Report: `"✗ T{n}: reverted"`.
128
173
  - **Exit 2 (SALVAGEABLE):** Spawn `Agent(model="haiku")` to fix lint/typecheck issues. Re-run `node bin/ratchet.js`. If still non-zero → revert both commits, set status pending.
129
174
 
130
175
  **Edit scope validation:** `git diff HEAD~1 --name-only` vs allowed globs. Violation → revert, report.
@@ -155,7 +200,7 @@ Omit if context.json/token-history.jsonl/awk unavailable. Never fail ratchet for
155
200
  **Attempt tracking:** Initialize `attempt_count = 1` and `failure_feedback = ""` per task when first spawned. Max 3 total attempts (1 initial + 2 retries).
156
201
 
157
202
  **Flow:**
158
- 1. Capture the implementation diff: `git -C ${WORKTREE_PATH} diff HEAD~1` store as `IMPL_DIFF`.
203
+ 1. Capture the implementation diff summary via haiku context-fork (§5.8): spawn haiku with `git -C ${WORKTREE_PATH} diff HEAD~1`; receive one-line summary (e.g., `diff: 3 files, +47/-12 lines`). The Wave Test agent will read the full diff itself via the `Read` tool or `git diff HEAD~1` — do NOT capture or pass the raw diff to the Wave Test prompt.
159
204
  2. Gather dedup context:
160
205
  - Read `.deepflow/auto-snapshot.txt` → store full file list as `SNAPSHOT_FILES`.
161
206
  - Extract existing test function names: `grep -h 'describe\|it(\|test(\|def test_\|func Test' $(cat .deepflow/auto-snapshot.txt) 2>/dev/null | head -50` → store as `EXISTING_TEST_NAMES`.
@@ -198,7 +243,7 @@ Trigger: ≥2 [SPIKE] tasks with same blocker or identical hypothesis.
198
243
  5. **Winner selection** (no LLM judge): disqualify regressions. Standard: fewer regressions > coverage > fewer files > first complete. Optimize: best metric delta > fewer regressions > fewer files. No passes → reset pending for debugger.
199
244
  6. Preserve all worktrees. Losers: branch + `-failed`. Record in checkpoint.json.
200
245
  7. Log all outcomes to `.deepflow/auto-memory.yaml` under `spike_insights`+`probe_learnings` (schema in src/skills/auto-cycle/SKILL.md). Both winners and losers.
201
- 8. Cherry-pick winner into shared worktree. Winner → `[x] [PROBE_WINNER]`, losers → `[~] [PROBE_FAILED]`.
246
+ 8. Cherry-pick winner into shared worktree via haiku context-fork (§5.8): spawn haiku with `git cherry-pick {winner_sha}`; receive one-line summary. Winner → `[x] [PROBE_WINNER]`, losers → `[~] [PROBE_FAILED]`.
202
247
 
203
248
  #### 5.7.1. PROBE DIVERSITY (Optimize Probes)
204
249
 
@@ -212,6 +257,37 @@ Roles: **contextualizada** (refine best), **contraditoria** (opposite of best),
212
257
 
213
258
  Every set: ≥1 contraditoria + ≥1 ingenua. contextualizada from round 2+ only. Scale persists in `optimize_state.probe_scale`.
214
259
 
260
+ ### 5.8. HAIKU GIT-OPS (context-fork)
261
+
262
+ <!-- AC-7: git diff/stash/cherry-pick run in a haiku context-fork; orchestrator receives one-line summary -->
263
+
264
+ Git operations that produce large output (diff, stash, cherry-pick conflict output) MUST be delegated to a context-forked haiku subagent. Raw output never enters the orchestrator context.
265
+
266
+ **Trigger:** Any of: post-implementation diff capture (§5.6 step 1), revert confirmation, cherry-pick merge-back.
267
+
268
+ **Pattern:**
269
+ ```
270
+ Spawn Agent(model="haiku", run_in_background=false):
271
+ Working directory: {WORKTREE_PATH}
272
+ Run: {git command}
273
+ Return exactly ONE line: "{operation}: {N lines changed / N files / outcome}"
274
+ Do NOT output the raw diff or full command output.
275
+ Last line: TASK_STATUS:pass or TASK_STATUS:fail
276
+ ```
277
+
278
+ **Examples by operation:**
279
+
280
+ | Operation | Git command | Expected one-line summary |
281
+ |-----------|-------------|--------------------------|
282
+ | Post-impl diff | `git diff HEAD~1` | `diff: 3 files, +47/-12 lines` |
283
+ | Stash check | `git stash list` | `stash: 2 entries (stash@{0}: T3 work-in-progress)` |
284
+ | Cherry-pick | `git cherry-pick {sha}` | `cherry-pick: applied {sha} cleanly` or `cherry-pick: conflict in {file}` |
285
+ | Revert confirm | `git log --oneline -3` | `log: HEAD={sha} T3-impl, parent={sha} T2-impl` |
286
+
287
+ **Orchestrator stores the one-line summary only.** Never stores or logs the haiku subagent transcript.
288
+
289
+ **Fallback:** If haiku subagent returns TASK_STATUS:fail, orchestrator runs the minimal shell equivalent (`git diff --stat HEAD~1`) directly — this produces compact output safe for orchestrator context.
290
+
215
291
  ### 5.9. OPTIMIZE CYCLE
216
292
 
217
293
  Trigger: task has `Optimize:` block. One at a time, N cycles until stop condition.
@@ -284,8 +360,7 @@ You are a QA engineer. Write unit tests for the following code changes.
284
360
  Use {test_framework}. Test behavioral correctness, not implementation details.
285
361
  Spec: {spec}. Task: {task_id}.
286
362
 
287
- Implementation diff:
288
- {IMPL_DIFF}
363
+ To inspect the implementation diff, use the `Read` tool or run `git diff HEAD~1` in the worktree.
289
364
 
290
365
  --- MIDDLE ---
291
366
  Files changed: {changed_files}