feat: add strategy abstraction with pdca and pipeline strategies

This commit is contained in:
2026-04-04 09:32:51 +02:00
parent a6dcd2c956
commit 29762a8464
4 changed files with 164 additions and 3 deletions

View File

@@ -63,7 +63,38 @@ After emitting `run.start`, record `SEQ_RUN_START=1`.
If `--start-from` is specified, verify that the required prior artifacts exist in `.archeflow/artifacts/${RUN_ID}/` before skipping phases. If missing, abort with an error.
#### 0a. Lib Script Validation
#### 0a. Strategy Resolution
Determine the execution strategy before proceeding. Strategy controls the overall flow shape (cyclic vs linear).
```bash
# Read strategy from config or CLI flag
STRATEGY=$(grep '^strategy:' "$CONFIG" 2>/dev/null | sed 's/strategy:\s*//' | tr -d '"' | head -1)
STRATEGY="${STRATEGY:-auto}"
# CLI override: --strategy pdca|pipeline
# (parsed from invocation args, overrides config)
# Auto-select logic
if [[ "$STRATEGY" == "auto" ]]; then
TASK_LOWER=$(echo "$TASK" | tr '[:upper:]' '[:lower:]')
if echo "$TASK_LOWER" | grep -qE '(fix|bug|patch|hotfix)'; then
STRATEGY="pipeline"
elif echo "$TASK_LOWER" | grep -qE '(refactor|redesign|review)'; then
STRATEGY="pdca"
elif [[ "$WORKFLOW" == "thorough" ]]; then
STRATEGY="pdca"
else
STRATEGY="pdca"
fi
fi
echo "Strategy: $STRATEGY"
```
**Strategy dispatch:** If `STRATEGY=pdca`, execute Steps 1-5 below (existing PDCA flow). If `STRATEGY=pipeline`, skip to the "Pipeline Strategy Execution" section at the end of this skill.
#### 0b. Lib Script Validation
Verify that all required library scripts exist and are executable before proceeding. Fail fast if any dependency is missing.
@@ -102,7 +133,7 @@ if ! command -v jq &>/dev/null; then
fi
```
#### 0b. Memory Injection
#### 0c. Memory Injection
Load cross-run memory lessons and inject into agent prompts. Use `--audit` to track which lessons were injected for this run:
@@ -121,7 +152,7 @@ ${MEMORY_LESSONS}"
fi
```
#### 0c. Model Configuration
#### 0d. Model Configuration
Read model assignment from `.archeflow/config.yaml` and resolve the model for each archetype based on the current workflow. Per-workflow overrides take precedence over per-archetype overrides, which take precedence over the default.
@@ -740,3 +771,74 @@ Run ID: <run_id> | Workflow: <standard> | Cycle: 1/<max>
Artifacts: .archeflow/artifacts/<run_id>/
Report: .archeflow/events/<run_id>.jsonl
```
---
## Pipeline Strategy Execution
When `STRATEGY=pipeline`, execute this linear flow instead of the PDCA cycle above.
### Pipeline Phases
```
Plan -> Implement -> Spec-Review -> Quality-Review -> Verify
```
No cycle-back. Each phase runs once.
### 1. Plan
Spawn Creator only (no Explorer). Use fast-workflow Creator prompt with Mini-Reflect.
Save output to `.archeflow/artifacts/${RUN_ID}/plan-creator.md`.
### 2. Implement
Spawn Maker in isolated worktree with Creator's proposal.
Save output to `.archeflow/artifacts/${RUN_ID}/do-maker.md`.
### 3. Spec-Review
Run Guardian and Skeptic **sequentially** (Guardian first, then Skeptic only if Guardian has findings).
- Guardian receives: Maker's git diff + proposal risk section
- Skeptic receives: Creator's proposal (assumptions focus)
Save to `check-guardian.md` and `check-skeptic.md`.
### 4. Quality-Review
Spawn Sage with proposal + diff + implementation summary.
Save to `check-sage.md`.
### 5. Verify
Run the project's test suite. If tests pass and no CRITICAL findings exist:
1. Merge the Maker's branch
2. Emit `run.complete`
If CRITICAL findings exist:
1. Spawn Maker for a **single targeted fix** — provide only the CRITICAL findings as context
2. Re-run tests
3. If still failing, report to user (do not cycle back)
WARNINGs are logged in the run event but do not block the merge.
### Pipeline Progress Display
```
━━━ ArcheFlow Pipeline: <task> ━━━━━━━━━━━━━━━━
Run ID: <run_id> | Strategy: pipeline
[Plan] Creator designing... -> done (20s)
[Implement] Maker building... -> done (60s, 3 files)
[Spec] Guardian reviewing... -> APPROVED
[Quality] Sage reviewing... -> APPROVED (1 WARNING)
[Verify] Tests passing... -> merged to main
━━━ Complete: 2m 15s ━━━━━━━━━━━━━━━━━━━━━━━━━━
```