mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-10 17:11:04 +08:00
Refactor workflow-lite-planex documentation to standardize phase naming and improve clarity
- Updated phase references in SKILL.md and 01-lite-plan.md to use "LP-Phase" prefix for consistency. - Added critical context isolation note in 01-lite-plan.md to clarify phase invocation rules. - Enhanced execution process descriptions to reflect updated phase naming conventions. Improve error handling in frontend routing - Introduced ChunkErrorBoundary component to handle lazy-loaded chunk load failures. - Wrapped lazy-loaded routes with error boundary and suspense for better user experience. - Created PageSkeleton component for loading states in lazy-loaded routes. Sanitize header values in notification routes - Added regex validation for header values to prevent XSS attacks by allowing only printable ASCII characters. Enhance mobile responsiveness in documentation styles - Updated CSS breakpoints to use custom properties for better maintainability. - Improved layout styles across various components to ensure consistent behavior on mobile devices.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Command: Dispatch
|
||||
|
||||
Create the performance optimization task chain with correct dependencies and structured task descriptions.
|
||||
Create the performance optimization task chain with correct dependencies and structured task descriptions. Supports single, fan-out, independent, and auto parallel modes.
|
||||
|
||||
## Phase 2: Context Loading
|
||||
|
||||
@@ -9,12 +9,16 @@ Create the performance optimization task chain with correct dependencies and str
|
||||
| User requirement | From coordinator Phase 1 | Yes |
|
||||
| Session folder | From coordinator Phase 2 | Yes |
|
||||
| Pipeline definition | From SKILL.md Pipeline Definitions | Yes |
|
||||
| Parallel mode | From session.json `parallel_mode` | Yes |
|
||||
| Max branches | From session.json `max_branches` | Yes |
|
||||
| Independent targets | From session.json `independent_targets` (independent mode only) | Conditional |
|
||||
|
||||
1. Load user requirement and optimization scope from session.json
|
||||
2. Load pipeline stage definitions from SKILL.md Task Metadata Registry
|
||||
3. Determine if single-pass or multi-pass optimization is needed
|
||||
3. Read `parallel_mode` and `max_branches` from session.json
|
||||
4. For `independent` mode: read `independent_targets` array from session.json
|
||||
|
||||
## Phase 3: Task Chain Creation
|
||||
## Phase 3: Task Chain Creation (Mode-Branched)
|
||||
|
||||
### Task Description Template
|
||||
|
||||
@@ -32,20 +36,33 @@ TASK:
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: <branch-id or 'none'>
|
||||
- Upstream artifacts: <artifact-1>, <artifact-2>
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: <deliverable path> + <quality criteria>
|
||||
CONSTRAINTS: <scope limits, focus areas>
|
||||
---
|
||||
InnerLoop: <true|false>",
|
||||
InnerLoop: <true|false>
|
||||
BranchId: <B01|A|none>",
|
||||
blockedBy: [<dependency-list>],
|
||||
status: "pending"
|
||||
})
|
||||
```
|
||||
|
||||
### Task Chain
|
||||
### Mode Router
|
||||
|
||||
Create tasks in dependency order:
|
||||
| Mode | Action |
|
||||
|------|--------|
|
||||
| `single` | Create 5 tasks (PROFILE → STRATEGY → IMPL → BENCH + REVIEW) -- unchanged from linear pipeline |
|
||||
| `auto` | Create PROFILE-001 + STRATEGY-001 only. **Defer branch creation to CP-2.5** after strategy completes |
|
||||
| `fan-out` | Create PROFILE-001 + STRATEGY-001 only. **Defer branch creation to CP-2.5** after strategy completes |
|
||||
| `independent` | Create M complete pipelines immediately (one per target) |
|
||||
|
||||
---
|
||||
|
||||
### Single Mode Task Chain
|
||||
|
||||
Create tasks in dependency order (backward compatible, unchanged):
|
||||
|
||||
**PROFILE-001** (profiler, Stage 1):
|
||||
```
|
||||
@@ -59,6 +76,7 @@ TASK:
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: none
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: <session>/artifacts/baseline-metrics.json + <session>/artifacts/bottleneck-report.md | Quantified metrics with evidence
|
||||
CONSTRAINTS: Focus on <optimization-scope> | Profile before any changes
|
||||
@@ -77,13 +95,15 @@ TASK:
|
||||
- Analyze bottleneck report and baseline metrics
|
||||
- Select optimization strategies per bottleneck type
|
||||
- Prioritize by impact/effort ratio, define success criteria
|
||||
- Each optimization MUST have a unique OPT-ID (OPT-001, OPT-002, ...) with non-overlapping target files
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: none
|
||||
- Upstream artifacts: baseline-metrics.json, bottleneck-report.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: <session>/artifacts/optimization-plan.md | Priority-ordered with improvement targets
|
||||
CONSTRAINTS: Focus on highest-impact optimizations | Risk assessment required
|
||||
EXPECTED: <session>/artifacts/optimization-plan.md | Priority-ordered with improvement targets, discrete OPT-IDs
|
||||
CONSTRAINTS: Focus on highest-impact optimizations | Risk assessment required | Non-overlapping file targets per OPT-ID
|
||||
---
|
||||
InnerLoop: false",
|
||||
blockedBy: ["PROFILE-001"],
|
||||
@@ -103,6 +123,7 @@ TASK:
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: none
|
||||
- Upstream artifacts: optimization-plan.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: Modified source files + validation passing | Optimizations applied without regressions
|
||||
@@ -126,6 +147,7 @@ TASK:
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: none
|
||||
- Upstream artifacts: baseline-metrics.json, optimization-plan.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: <session>/artifacts/benchmark-results.json | Per-metric comparison with verdicts
|
||||
@@ -149,6 +171,7 @@ TASK:
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: <optimization-scope>
|
||||
- Branch: none
|
||||
- Upstream artifacts: optimization-plan.md, benchmark-results.json (if available)
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: <session>/artifacts/review-report.md | Per-dimension findings with severity
|
||||
@@ -160,16 +183,190 @@ InnerLoop: false",
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Auto / Fan-out Mode Task Chain (Deferred Branching)
|
||||
|
||||
For `auto` and `fan-out` modes, create only shared stages now. Branch tasks are created at **CP-2.5** after STRATEGY-001 completes.
|
||||
|
||||
Create PROFILE-001 and STRATEGY-001 with same templates as single mode above.
|
||||
|
||||
**Do NOT create IMPL/BENCH/REVIEW tasks yet.** They are created by the CP-2.5 Branch Creation subroutine in monitor.md.
|
||||
|
||||
---
|
||||
|
||||
### Independent Mode Task Chain
|
||||
|
||||
For `independent` mode, create M complete pipelines -- one per target in `independent_targets` array.
|
||||
|
||||
Pipeline prefix chars: `A, B, C, D, E, F, G, H, I, J` (from config `pipeline_prefix_chars`).
|
||||
|
||||
For each target index `i` (0-based), with prefix char `P = pipeline_prefix_chars[i]`:
|
||||
|
||||
```
|
||||
// Create session subdirectory for this pipeline
|
||||
Bash("mkdir -p <session>/artifacts/pipelines/<P>")
|
||||
|
||||
TaskCreate({ subject: "PROFILE-<P>01", ... }) // blockedBy: []
|
||||
TaskCreate({ subject: "STRATEGY-<P>01", ... }) // blockedBy: ["PROFILE-<P>01"]
|
||||
TaskCreate({ subject: "IMPL-<P>01", ... }) // blockedBy: ["STRATEGY-<P>01"]
|
||||
TaskCreate({ subject: "BENCH-<P>01", ... }) // blockedBy: ["IMPL-<P>01"]
|
||||
TaskCreate({ subject: "REVIEW-<P>01", ... }) // blockedBy: ["IMPL-<P>01"]
|
||||
```
|
||||
|
||||
Task descriptions follow same template as single mode, with additions:
|
||||
- `Branch: <P>` in CONTEXT
|
||||
- Artifact paths use `<session>/artifacts/pipelines/<P>/` instead of `<session>/artifacts/`
|
||||
- Shared-memory namespace uses `<role>.<P>` (e.g., `profiler.A`, `optimizer.B`)
|
||||
- Each pipeline's scope is its specific target from `independent_targets[i]`
|
||||
|
||||
Example for pipeline A with target "optimize rendering":
|
||||
```
|
||||
TaskCreate({
|
||||
subject: "PROFILE-A01",
|
||||
description: "PURPOSE: Profile rendering performance | Success: Rendering bottlenecks identified
|
||||
TASK:
|
||||
- Detect project type and available profiling tools
|
||||
- Execute profiling focused on rendering performance
|
||||
- Collect baseline metrics and rank rendering bottlenecks
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Scope: optimize rendering
|
||||
- Pipeline: A
|
||||
- Shared memory: <session>/wisdom/shared-memory.json (namespace: profiler.A)
|
||||
EXPECTED: <session>/artifacts/pipelines/A/baseline-metrics.json + bottleneck-report.md
|
||||
CONSTRAINTS: Focus on rendering scope
|
||||
---
|
||||
InnerLoop: false
|
||||
PipelineId: A",
|
||||
status: "pending"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### CP-2.5: Branch Creation Subroutine
|
||||
|
||||
**Triggered by**: monitor.md handleCallback when STRATEGY-001 completes in `auto` or `fan-out` mode.
|
||||
|
||||
**Procedure**:
|
||||
|
||||
1. Read `<session>/artifacts/optimization-plan.md` to count OPT-IDs
|
||||
2. Read `shared-memory.json` -> `strategist.optimization_count`
|
||||
3. **Auto mode decision**:
|
||||
|
||||
| Optimization Count | Decision |
|
||||
|-------------------|----------|
|
||||
| count <= 2 | Switch to `single` mode -- create IMPL-001, BENCH-001, REVIEW-001 (standard single pipeline) |
|
||||
| count >= 3 | Switch to `fan-out` mode -- create branch tasks below |
|
||||
|
||||
4. Update session.json with resolved `parallel_mode` (auto -> single or fan-out)
|
||||
|
||||
5. **Fan-out branch creation** (when count >= 3 or forced fan-out):
|
||||
- Truncate to `max_branches` if `optimization_count > max_branches` (keep top N by priority)
|
||||
- For each optimization `i` (1-indexed), branch ID = `B{NN}` where NN = zero-padded i:
|
||||
|
||||
```
|
||||
// Create branch artifact directory
|
||||
Bash("mkdir -p <session>/artifacts/branches/B{NN}")
|
||||
|
||||
// Extract single OPT detail to branch
|
||||
Write("<session>/artifacts/branches/B{NN}/optimization-detail.md",
|
||||
extracted OPT-{NNN} block from optimization-plan.md)
|
||||
```
|
||||
|
||||
6. Create branch tasks for each branch B{NN}:
|
||||
|
||||
```
|
||||
TaskCreate({
|
||||
subject: "IMPL-B{NN}",
|
||||
description: "PURPOSE: Implement optimization OPT-{NNN} | Success: Single optimization applied, compiles, tests pass
|
||||
TASK:
|
||||
- Load optimization detail from branches/B{NN}/optimization-detail.md
|
||||
- Apply this single optimization to target files
|
||||
- Validate changes compile and pass existing tests
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Branch: B{NN}
|
||||
- Upstream artifacts: branches/B{NN}/optimization-detail.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json (namespace: optimizer.B{NN})
|
||||
EXPECTED: Modified source files for OPT-{NNN} only
|
||||
CONSTRAINTS: Only implement this branch's optimization | Do not touch files outside OPT-{NNN} scope
|
||||
---
|
||||
InnerLoop: false
|
||||
BranchId: B{NN}",
|
||||
blockedBy: ["STRATEGY-001"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "BENCH-B{NN}",
|
||||
description: "PURPOSE: Benchmark branch B{NN} optimization | Success: OPT-{NNN} metrics meet success criteria
|
||||
TASK:
|
||||
- Load baseline metrics and OPT-{NNN} success criteria
|
||||
- Benchmark only metrics relevant to this optimization
|
||||
- Compare against baseline, calculate improvement
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Branch: B{NN}
|
||||
- Upstream artifacts: baseline-metrics.json, branches/B{NN}/optimization-detail.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json (namespace: benchmarker.B{NN})
|
||||
EXPECTED: <session>/artifacts/branches/B{NN}/benchmark-results.json
|
||||
CONSTRAINTS: Only benchmark this branch's metrics
|
||||
---
|
||||
InnerLoop: false
|
||||
BranchId: B{NN}",
|
||||
blockedBy: ["IMPL-B{NN}"],
|
||||
status: "pending"
|
||||
})
|
||||
|
||||
TaskCreate({
|
||||
subject: "REVIEW-B{NN}",
|
||||
description: "PURPOSE: Review branch B{NN} optimization code | Success: Code quality verified for OPT-{NNN}
|
||||
TASK:
|
||||
- Load modified files from optimizer.B{NN} shared-memory namespace
|
||||
- Review across 5 dimensions for this branch's changes only
|
||||
- Issue verdict: APPROVE, REVISE, or REJECT
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Branch: B{NN}
|
||||
- Upstream artifacts: branches/B{NN}/optimization-detail.md
|
||||
- Shared memory: <session>/wisdom/shared-memory.json (namespace: reviewer.B{NN})
|
||||
EXPECTED: <session>/artifacts/branches/B{NN}/review-report.md
|
||||
CONSTRAINTS: Only review this branch's changes
|
||||
---
|
||||
InnerLoop: false
|
||||
BranchId: B{NN}",
|
||||
blockedBy: ["IMPL-B{NN}"],
|
||||
status: "pending"
|
||||
})
|
||||
```
|
||||
|
||||
7. Update session.json:
|
||||
- `branches`: array of branch IDs (["B01", "B02", ...])
|
||||
- `fix_cycles`: object keyed by branch ID, all initialized to 0
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Validation
|
||||
|
||||
Verify task chain integrity:
|
||||
|
||||
| Check | Method | Expected |
|
||||
|-------|--------|----------|
|
||||
| All 5 tasks created | TaskList count | 5 tasks |
|
||||
| Dependencies correct | STRATEGY blocks on PROFILE, IMPL blocks on STRATEGY, BENCH+REVIEW block on IMPL | All valid |
|
||||
| Task count correct | TaskList count | single: 5, auto/fan-out: 2 (pre-CP-2.5), independent: 5*M |
|
||||
| Dependencies correct | Trace dependency graph | Acyclic, correct blockedBy |
|
||||
| No circular dependencies | Trace dependency graph | Acyclic |
|
||||
| All task IDs use correct prefixes | PROFILE-*, STRATEGY-*, IMPL-*, BENCH-*, REVIEW-* | Match role registry |
|
||||
| Task IDs use correct prefixes | Pattern check | Match naming rules per mode |
|
||||
| Structured descriptions complete | Each has PURPOSE/TASK/CONTEXT/EXPECTED/CONSTRAINTS | All present |
|
||||
| Branch/Pipeline IDs consistent | Cross-check with session.json | Match |
|
||||
|
||||
### Naming Rules Summary
|
||||
|
||||
| Mode | Stage 3 | Stage 4 | Fix |
|
||||
|------|---------|---------|-----|
|
||||
| Single | IMPL-001 | BENCH-001, REVIEW-001 | FIX-001, FIX-002 |
|
||||
| Fan-out | IMPL-B01 | BENCH-B01, REVIEW-B01 | FIX-B01-1, FIX-B01-2 |
|
||||
| Independent | IMPL-A01 | BENCH-A01, REVIEW-A01 | FIX-A01-1, FIX-A01-2 |
|
||||
|
||||
If validation fails, fix the specific task and re-validate.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Command: Monitor
|
||||
|
||||
Handle all coordinator monitoring events: worker callbacks, status checks, pipeline advancement, and completion.
|
||||
Handle all coordinator monitoring events: worker callbacks, status checks, pipeline advancement, and completion. Supports single, fan-out, and independent parallel modes with per-branch/pipeline tracking.
|
||||
|
||||
## Phase 2: Context Loading
|
||||
|
||||
@@ -11,7 +11,7 @@ Handle all coordinator monitoring events: worker callbacks, status checks, pipel
|
||||
| Trigger event | From Entry Router detection | Yes |
|
||||
| Pipeline definition | From SKILL.md | Yes |
|
||||
|
||||
1. Load session.json for current state and fix cycle count
|
||||
1. Load session.json for current state, `parallel_mode`, `branches`, `fix_cycles`
|
||||
2. Run TaskList() to get current task statuses
|
||||
3. Identify trigger event type from Entry Router
|
||||
|
||||
@@ -21,7 +21,14 @@ Handle all coordinator monitoring events: worker callbacks, status checks, pipel
|
||||
|
||||
Triggered when a worker sends completion message.
|
||||
|
||||
1. Parse message to identify role and task ID
|
||||
1. Parse message to identify role, task ID, and **branch/pipeline label**:
|
||||
|
||||
| Message Pattern | Branch Detection |
|
||||
|----------------|-----------------|
|
||||
| `[optimizer-B01]` or task ID `IMPL-B01` | Branch `B01` (fan-out) |
|
||||
| `[profiler-A]` or task ID `PROFILE-A01` | Pipeline `A` (independent) |
|
||||
| `[profiler]` or task ID `PROFILE-001` | No branch (single) |
|
||||
|
||||
2. Mark task as completed:
|
||||
|
||||
```
|
||||
@@ -29,15 +36,23 @@ TaskUpdate({ taskId: "<task-id>", status: "completed" })
|
||||
```
|
||||
|
||||
3. Record completion in session state
|
||||
4. Check if checkpoint feedback is configured for this stage:
|
||||
|
||||
4. **CP-2.5 check** (auto/fan-out mode only):
|
||||
- If completed task is STRATEGY-001 AND `parallel_mode` is `auto` or `fan-out`:
|
||||
- Execute **CP-2.5 Branch Creation** subroutine from dispatch.md
|
||||
- After branch creation, proceed to handleSpawnNext (spawns all IMPL-B* in parallel)
|
||||
- STOP after spawning
|
||||
|
||||
5. Check if checkpoint feedback is configured for this stage:
|
||||
|
||||
| Completed Task | Checkpoint | Action |
|
||||
|---------------|------------|--------|
|
||||
| PROFILE-001 | CP-1 | Notify user: bottleneck report ready for review |
|
||||
| STRATEGY-001 | CP-2 | Notify user: optimization plan ready for review |
|
||||
| BENCH-001 or REVIEW-001 | CP-3 | Check verdicts (see Review-Fix Cycle below) |
|
||||
| PROFILE-001 / PROFILE-{P}01 | CP-1 | Notify user: bottleneck report ready for review |
|
||||
| STRATEGY-001 / STRATEGY-{P}01 | CP-2 | Notify user: optimization plan ready for review |
|
||||
| STRATEGY-001 (auto/fan-out) | CP-2.5 | Execute branch creation, then notify user with branch count |
|
||||
| BENCH-* or REVIEW-* | CP-3 | Check verdicts per branch (see Review-Fix Cycle below) |
|
||||
|
||||
5. Proceed to handleSpawnNext
|
||||
6. Proceed to handleSpawnNext
|
||||
|
||||
### handleSpawnNext
|
||||
|
||||
@@ -70,11 +85,23 @@ Execute built-in Phase 1 -> role-spec Phase 2-4 -> built-in Phase 5.`
|
||||
})
|
||||
```
|
||||
|
||||
3. For Stage 4 (BENCH-001 + REVIEW-001): spawn both in parallel since both block on IMPL-001
|
||||
3. **Parallel spawn rules by mode**:
|
||||
|
||||
| Mode | Scenario | Spawn Behavior |
|
||||
|------|----------|---------------|
|
||||
| Single | Stage 4 ready | Spawn BENCH-001 + REVIEW-001 in parallel |
|
||||
| Fan-out (CP-2.5 done) | All IMPL-B* unblocked | Spawn ALL IMPL-B* in parallel |
|
||||
| Fan-out (IMPL-B{NN} done) | BENCH-B{NN} + REVIEW-B{NN} ready | Spawn both for that branch in parallel |
|
||||
| Independent | Any unblocked task | Spawn all ready tasks across all pipelines in parallel |
|
||||
|
||||
4. STOP after spawning -- wait for next callback
|
||||
|
||||
### Review-Fix Cycle (CP-3)
|
||||
|
||||
**Per-branch/pipeline scoping**: Each branch/pipeline has its own independent fix cycle.
|
||||
|
||||
#### Single Mode (unchanged)
|
||||
|
||||
When both BENCH-001 and REVIEW-001 are completed:
|
||||
|
||||
1. Read benchmark verdict from shared-memory (benchmarker namespace)
|
||||
@@ -88,45 +115,89 @@ When both BENCH-001 and REVIEW-001 are completed:
|
||||
| FAIL | REVISE/REJECT | Create FIX task with combined feedback |
|
||||
| Any | REJECT | Create FIX task + flag for strategist re-evaluation |
|
||||
|
||||
3. Check fix cycle count:
|
||||
#### Fan-out Mode (per-branch)
|
||||
|
||||
When both BENCH-B{NN} and REVIEW-B{NN} are completed for a specific branch:
|
||||
|
||||
1. Read benchmark verdict from `benchmarker.B{NN}` namespace
|
||||
2. Read review verdict from `reviewer.B{NN}` namespace
|
||||
3. Apply same verdict matrix as single mode, but scoped to this branch only
|
||||
4. **Other branches are unaffected** -- they continue independently
|
||||
|
||||
#### Independent Mode (per-pipeline)
|
||||
|
||||
When both BENCH-{P}01 and REVIEW-{P}01 are completed for a specific pipeline:
|
||||
|
||||
1. Read verdicts from `benchmarker.{P}` and `reviewer.{P}` namespaces
|
||||
2. Apply same verdict matrix, scoped to this pipeline only
|
||||
|
||||
#### Fix Cycle Count Tracking
|
||||
|
||||
Fix cycles are tracked per branch/pipeline in `session.json`:
|
||||
|
||||
```json
|
||||
// Single mode
|
||||
{ "fix_cycles": { "main": 0 } }
|
||||
|
||||
// Fan-out mode
|
||||
{ "fix_cycles": { "B01": 0, "B02": 1, "B03": 0 } }
|
||||
|
||||
// Independent mode
|
||||
{ "fix_cycles": { "A": 0, "B": 2 } }
|
||||
```
|
||||
|
||||
| Cycle Count | Action |
|
||||
|-------------|--------|
|
||||
| < 3 | Create FIX task, increment cycle count |
|
||||
| >= 3 | Escalate to user with summary of remaining issues |
|
||||
| < 3 | Create FIX task, increment cycle count for this branch/pipeline |
|
||||
| >= 3 | Escalate THIS branch/pipeline to user. Other branches continue |
|
||||
|
||||
4. Create FIX task if needed:
|
||||
#### FIX Task Creation (branched)
|
||||
|
||||
**Fan-out mode**:
|
||||
```
|
||||
TaskCreate({
|
||||
subject: "FIX-<N>",
|
||||
description: "PURPOSE: Fix issues identified by review/benchmark | Success: All flagged issues resolved
|
||||
subject: "FIX-B{NN}-{cycle}",
|
||||
description: "PURPOSE: Fix issues in branch B{NN} from review/benchmark | Success: All flagged issues resolved
|
||||
TASK:
|
||||
- Address review findings: <specific-findings>
|
||||
- Fix benchmark regressions: <specific-regressions>
|
||||
- Re-validate after fixes
|
||||
CONTEXT:
|
||||
- Session: <session-folder>
|
||||
- Upstream artifacts: review-report.md, benchmark-results.json
|
||||
- Shared memory: <session>/wisdom/shared-memory.json
|
||||
EXPECTED: Fixed source files | All flagged issues addressed
|
||||
CONSTRAINTS: Targeted fixes only | Do not introduce new changes
|
||||
- Branch: B{NN}
|
||||
- Upstream artifacts: branches/B{NN}/review-report.md, branches/B{NN}/benchmark-results.json
|
||||
- Shared memory: <session>/wisdom/shared-memory.json (namespace: optimizer.B{NN})
|
||||
EXPECTED: Fixed source files for B{NN} only
|
||||
CONSTRAINTS: Targeted fixes only | Do not touch other branches
|
||||
---
|
||||
InnerLoop: true",
|
||||
InnerLoop: false
|
||||
BranchId: B{NN}",
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
```
|
||||
|
||||
5. Create new BENCH and REVIEW tasks blocked on FIX task
|
||||
6. Proceed to handleSpawnNext (spawns optimizer for FIX task)
|
||||
Create new BENCH and REVIEW with retry suffix:
|
||||
- `BENCH-B{NN}-R{cycle}` blocked on `FIX-B{NN}-{cycle}`
|
||||
- `REVIEW-B{NN}-R{cycle}` blocked on `FIX-B{NN}-{cycle}`
|
||||
|
||||
**Independent mode**:
|
||||
```
|
||||
TaskCreate({
|
||||
subject: "FIX-{P}01-{cycle}",
|
||||
...same pattern with pipeline prefix...
|
||||
blockedBy: [],
|
||||
status: "pending"
|
||||
})
|
||||
```
|
||||
|
||||
Create `BENCH-{P}01-R{cycle}` and `REVIEW-{P}01-R{cycle}`.
|
||||
|
||||
### handleCheck
|
||||
|
||||
Output current pipeline status without advancing.
|
||||
|
||||
1. Build status graph from task list:
|
||||
Output current pipeline status grouped by branch/pipeline.
|
||||
|
||||
**Single mode** (unchanged):
|
||||
```
|
||||
Pipeline Status:
|
||||
[DONE] PROFILE-001 (profiler) -> bottleneck-report.md
|
||||
@@ -139,7 +210,47 @@ Fix Cycles: 0/3
|
||||
Session: <session-id>
|
||||
```
|
||||
|
||||
2. Output status -- do NOT advance pipeline
|
||||
**Fan-out mode**:
|
||||
```
|
||||
Pipeline Status (fan-out, 3 branches):
|
||||
Shared Stages:
|
||||
[DONE] PROFILE-001 (profiler) -> bottleneck-report.md
|
||||
[DONE] STRATEGY-001 (strategist) -> optimization-plan.md (4 OPT-IDs)
|
||||
|
||||
Branch B01 (OPT-001: <title>):
|
||||
[RUN] IMPL-B01 (optimizer) -> implementing...
|
||||
[WAIT] BENCH-B01 (benchmarker) -> blocked by IMPL-B01
|
||||
[WAIT] REVIEW-B01 (reviewer) -> blocked by IMPL-B01
|
||||
Fix Cycles: 0/3
|
||||
|
||||
Branch B02 (OPT-002: <title>):
|
||||
[DONE] IMPL-B02 (optimizer) -> done
|
||||
[RUN] BENCH-B02 (benchmarker) -> benchmarking...
|
||||
[RUN] REVIEW-B02 (reviewer) -> reviewing...
|
||||
Fix Cycles: 0/3
|
||||
|
||||
Branch B03 (OPT-003: <title>):
|
||||
[FAIL] IMPL-B03 (optimizer) -> failed
|
||||
Fix Cycles: 0/3 [BRANCH FAILED]
|
||||
|
||||
Session: <session-id>
|
||||
```
|
||||
|
||||
**Independent mode**:
|
||||
```
|
||||
Pipeline Status (independent, 2 pipelines):
|
||||
Pipeline A (target: optimize rendering):
|
||||
[DONE] PROFILE-A01 -> [DONE] STRATEGY-A01 -> [RUN] IMPL-A01 -> ...
|
||||
Fix Cycles: 0/3
|
||||
|
||||
Pipeline B (target: optimize API):
|
||||
[DONE] PROFILE-B01 -> [DONE] STRATEGY-B01 -> [DONE] IMPL-B01 -> ...
|
||||
Fix Cycles: 1/3
|
||||
|
||||
Session: <session-id>
|
||||
```
|
||||
|
||||
Output status -- do NOT advance pipeline.
|
||||
|
||||
### handleResume
|
||||
|
||||
@@ -148,7 +259,8 @@ Resume pipeline after user pause or interruption.
|
||||
1. Audit task list for inconsistencies:
|
||||
- Tasks stuck in "in_progress" -> reset to "pending"
|
||||
- Tasks with completed blockers but still "pending" -> include in spawn list
|
||||
2. Proceed to handleSpawnNext
|
||||
2. For fan-out/independent: check each branch/pipeline independently
|
||||
3. Proceed to handleSpawnNext
|
||||
|
||||
### handleConsensus
|
||||
|
||||
@@ -156,46 +268,65 @@ Handle consensus_blocked signals from discuss rounds.
|
||||
|
||||
| Severity | Action |
|
||||
|----------|--------|
|
||||
| HIGH | Pause pipeline, notify user with findings summary |
|
||||
| MEDIUM | Create revision task for the blocked role |
|
||||
| HIGH | Pause pipeline (or branch), notify user with findings summary |
|
||||
| MEDIUM | Create revision task for the blocked role (scoped to branch if applicable) |
|
||||
| LOW | Log finding, continue pipeline |
|
||||
|
||||
### handleComplete
|
||||
|
||||
Triggered when all pipeline tasks are completed and no fix cycles remain.
|
||||
|
||||
1. Verify all tasks have status "completed":
|
||||
**Completion check varies by mode**:
|
||||
|
||||
```
|
||||
TaskList()
|
||||
```
|
||||
| Mode | Completion Condition |
|
||||
|------|---------------------|
|
||||
| Single | All 5 tasks (+ any FIX/retry tasks) have status "completed" |
|
||||
| Fan-out | ALL branches have BENCH + REVIEW completed with PASS/APPROVE (or escalated), shared stages done |
|
||||
| Independent | ALL pipelines have BENCH + REVIEW completed with PASS/APPROVE (or escalated) |
|
||||
|
||||
2. If any tasks not completed, return to handleSpawnNext
|
||||
3. If all completed, transition to coordinator Phase 5 (Report + Completion Action)
|
||||
**Aggregate results** before transitioning to Phase 5:
|
||||
|
||||
1. For fan-out mode: collect per-branch benchmark results into `<session>/artifacts/aggregate-results.json`:
|
||||
```json
|
||||
{
|
||||
"branches": {
|
||||
"B01": { "opt_id": "OPT-001", "bench_verdict": "PASS", "review_verdict": "APPROVE", "improvement": "..." },
|
||||
"B02": { "opt_id": "OPT-002", "bench_verdict": "PASS", "review_verdict": "APPROVE", "improvement": "..." },
|
||||
"B03": { "status": "failed", "reason": "IMPL failed" }
|
||||
},
|
||||
"overall": { "total_branches": 3, "passed": 2, "failed": 1 }
|
||||
}
|
||||
```
|
||||
|
||||
2. For independent mode: collect per-pipeline results similarly
|
||||
|
||||
3. If any tasks not completed, return to handleSpawnNext
|
||||
4. If all completed (allowing for failed branches marked as such), transition to coordinator Phase 5
|
||||
|
||||
### handleRevise
|
||||
|
||||
Triggered by user "revise <TASK-ID> [feedback]" command.
|
||||
|
||||
1. Parse target task ID and optional feedback
|
||||
2. Create revision task with same role but updated requirements
|
||||
3. Set blockedBy to empty (immediate execution)
|
||||
4. Cascade: create new downstream tasks that depend on the revised task
|
||||
5. Proceed to handleSpawnNext
|
||||
2. Detect branch/pipeline from task ID pattern
|
||||
3. Create revision task with same role but updated requirements, scoped to branch
|
||||
4. Set blockedBy to empty (immediate execution)
|
||||
5. Cascade: create new downstream tasks within same branch only
|
||||
6. Proceed to handleSpawnNext
|
||||
|
||||
### handleFeedback
|
||||
|
||||
Triggered by user "feedback <text>" command.
|
||||
|
||||
1. Analyze feedback text to determine impact scope
|
||||
2. Identify which pipeline stage and role should handle the feedback
|
||||
3. Create targeted revision task
|
||||
2. Identify which pipeline stage, role, and branch/pipeline should handle the feedback
|
||||
3. Create targeted revision task (scoped to branch if applicable)
|
||||
4. Proceed to handleSpawnNext
|
||||
|
||||
## Phase 4: State Persistence
|
||||
|
||||
After every handler execution:
|
||||
|
||||
1. Update session.json with current state (active tasks, fix cycle count, last event)
|
||||
1. Update session.json with current state (active tasks, fix cycle counts per branch, last event, resolved parallel_mode)
|
||||
2. Verify task list consistency
|
||||
3. STOP and wait for next event
|
||||
|
||||
@@ -55,6 +55,8 @@ When coordinator is invoked, detect invocation type:
|
||||
| Detection | Condition | Handler |
|
||||
|-----------|-----------|---------|
|
||||
| Worker callback | Message contains role tag [profiler], [strategist], [optimizer], [benchmarker], [reviewer] | -> handleCallback |
|
||||
| Branch callback | Message contains branch tag [optimizer-B01], [benchmarker-B02], etc. | -> handleCallback (branch-aware) |
|
||||
| Pipeline callback | Message contains pipeline tag [profiler-A], [optimizer-B], etc. | -> handleCallback (pipeline-aware) |
|
||||
| Consensus blocked | Message contains "consensus_blocked" | -> handleConsensus |
|
||||
| Status check | Arguments contain "check" or "status" | -> handleCheck |
|
||||
| Manual resume | Arguments contain "resume" or "continue" | -> handleResume |
|
||||
@@ -68,10 +70,10 @@ For callback/check/resume/complete: load `commands/monitor.md` and execute match
|
||||
|
||||
1. **Load session context** (if exists):
|
||||
- Scan `.workflow/.team/PERF-OPT-*/team-session.json` for active/paused sessions
|
||||
- If found, extract session folder path and status
|
||||
- If found, extract session folder path, status, and `parallel_mode`
|
||||
|
||||
2. **Parse $ARGUMENTS** for detection keywords:
|
||||
- Check for role name tags in message content
|
||||
- Check for role name tags in message content (including branch variants like `[optimizer-B01]`)
|
||||
- Check for "check", "status", "resume", "continue" keywords
|
||||
- Check for "consensus_blocked" signal
|
||||
|
||||
@@ -114,15 +116,26 @@ TeamCreate({ team_name: "perf-opt" })
|
||||
## Phase 1: Requirement Clarification
|
||||
|
||||
1. Parse user task description from $ARGUMENTS
|
||||
2. Identify optimization target:
|
||||
2. **Parse parallel mode flags**:
|
||||
|
||||
| Flag | Value | Default |
|
||||
|------|-------|---------|
|
||||
| `--parallel-mode` | `single`, `fan-out`, `independent`, `auto` | `auto` |
|
||||
| `--max-branches` | integer 1-10 | 5 (from config) |
|
||||
|
||||
- For `independent` mode: remaining positional arguments after flags are `independent_targets` array
|
||||
- Example: `--parallel-mode=independent "optimize rendering" "optimize API"` -> targets = ["optimize rendering", "optimize API"]
|
||||
|
||||
3. Identify optimization target:
|
||||
|
||||
| Signal | Target |
|
||||
|--------|--------|
|
||||
| Specific file/module mentioned | Scoped optimization |
|
||||
| "slow", "performance", generic | Full application profiling |
|
||||
| Specific metric mentioned (FCP, memory, startup) | Targeted metric optimization |
|
||||
| Multiple quoted targets (independent mode) | Per-target scoped optimization |
|
||||
|
||||
3. If target is unclear, ask for clarification:
|
||||
4. If target is unclear, ask for clarification:
|
||||
|
||||
```
|
||||
AskUserQuestion({
|
||||
@@ -133,7 +146,7 @@ AskUserQuestion({
|
||||
})
|
||||
```
|
||||
|
||||
4. Record optimization requirement with scope and target metrics
|
||||
5. Record optimization requirement with scope, target metrics, parallel_mode, and max_branches
|
||||
|
||||
---
|
||||
|
||||
@@ -145,12 +158,38 @@ AskUserQuestion({
|
||||
Bash("mkdir -p .workflow/<session-id>/artifacts .workflow/<session-id>/explorations .workflow/<session-id>/wisdom .workflow/<session-id>/discussions")
|
||||
```
|
||||
|
||||
2. Write session.json with status="active", team_name, requirement, timestamp
|
||||
For independent mode, also create pipeline subdirectories:
|
||||
```
|
||||
// For each target in independent_targets
|
||||
Bash("mkdir -p .workflow/<session-id>/artifacts/pipelines/A .workflow/<session-id>/artifacts/pipelines/B ...")
|
||||
```
|
||||
|
||||
2. Write session.json with extended fields:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "active",
|
||||
"team_name": "perf-opt",
|
||||
"requirement": "<requirement>",
|
||||
"timestamp": "<ISO-8601>",
|
||||
"parallel_mode": "<auto|single|fan-out|independent>",
|
||||
"max_branches": 5,
|
||||
"branches": [],
|
||||
"independent_targets": [],
|
||||
"fix_cycles": {}
|
||||
}
|
||||
```
|
||||
|
||||
- `parallel_mode`: from Phase 1 parsing (default: "auto")
|
||||
- `max_branches`: from Phase 1 parsing (default: 5)
|
||||
- `branches`: populated at CP-2.5 for fan-out mode (e.g., ["B01", "B02", "B03"])
|
||||
- `independent_targets`: populated for independent mode (e.g., ["optimize rendering", "optimize API"])
|
||||
- `fix_cycles`: populated per-branch/pipeline as fix cycles occur
|
||||
|
||||
3. Initialize shared-memory.json:
|
||||
|
||||
```
|
||||
Write("<session>/wisdom/shared-memory.json", { "session_id": "<session-id>", "requirement": "<requirement>" })
|
||||
Write("<session>/wisdom/shared-memory.json", { "session_id": "<session-id>", "requirement": "<requirement>", "parallel_mode": "<mode>" })
|
||||
```
|
||||
|
||||
4. Create team:
|
||||
|
||||
Reference in New Issue
Block a user