1 Commits

Author SHA1 Message Date
f9afca0c58 refactor: trim act-phase skill from 371 to 140 lines
Remove duplicated routing tables, verbose JSON event examples,
writing/prose domain template (belongs in domains/colette-bridge),
--start-from section (belongs in run skill), and redundant checklist.
Consolidate three Agent() templates into one compact template.
Preserve all routing rules, decision logic, and feedback format.
2026-04-06 20:39:34 +02:00
7 changed files with 397 additions and 381 deletions

View File

@@ -15,7 +15,7 @@
], ],
"skills": [ "skills": [
"run", "orchestration", "plan-phase", "do-phase", "check-phase", "act-phase", "run", "orchestration", "plan-phase", "do-phase", "check-phase", "act-phase",
"shadow-detection", "convergence", "artifact-routing", "shadow-detection", "attention-filters", "convergence", "artifact-routing",
"process-log", "memory", "effectiveness", "progress", "process-log", "memory", "effectiveness", "progress",
"colette-bridge", "git-integration", "multi-project", "colette-bridge", "git-integration", "multi-project",
"custom-archetypes", "workflow-design", "domains", "cost-tracking", "custom-archetypes", "workflow-design", "domains", "cost-tracking",

View File

@@ -164,6 +164,7 @@ ArcheFlow ships with 24 skills organized by function.
| Skill | Description | | Skill | Description |
|-------|-------------| |-------|-------------|
| `archeflow:shadow-detection` | Quantitative dysfunction detection and automatic correction | | `archeflow:shadow-detection` | Quantitative dysfunction detection and automatic correction |
| `archeflow:attention-filters` | Context optimization per archetype -- each agent gets only what it needs |
| `archeflow:convergence` | Detects convergence, stalling, and oscillation in multi-cycle runs | | `archeflow:convergence` | Detects convergence, stalling, and oscillation in multi-cycle runs |
| `archeflow:artifact-routing` | Inter-phase artifact protocol -- naming, storage, routing, archiving | | `archeflow:artifact-routing` | Inter-phase artifact protocol -- naming, storage, routing, archiving |
@@ -357,6 +358,7 @@ archeflow/
│ ├── check-phase/ # Check protocols │ ├── check-phase/ # Check protocols
│ ├── act-phase/ # Act phase decision logic │ ├── act-phase/ # Act phase decision logic
│ ├── shadow-detection/ # Dysfunction detection │ ├── shadow-detection/ # Dysfunction detection
│ ├── attention-filters/ # Context optimization
│ ├── convergence/ # Cycle convergence detection │ ├── convergence/ # Cycle convergence detection
│ ├── artifact-routing/ # Inter-phase artifact protocol │ ├── artifact-routing/ # Inter-phase artifact protocol
│ ├── process-log/ # Event-sourced JSONL logging │ ├── process-log/ # Event-sourced JSONL logging

View File

@@ -1,292 +1,46 @@
--- ---
name: act-phase name: act-phase
description: | description: |
Use after the Check phase completes. Collects reviewer findings, prioritizes them, routes fixes to the right agent or tool, applies fixes systematically, and decides whether to exit or cycle. Use after the Check phase completes. Collects reviewer findings, routes fixes, applies them, decides whether to exit or cycle.
<example>Automatically loaded during orchestration after Check phase</example> <example>Automatically loaded during orchestration after Check phase</example>
<example>User: "Run just the act phase on existing findings"</example>
--- ---
# Act Phase # Act Phase
After all reviewers complete, the Act phase turns findings into fixes and decides whether the cycle is done. This is the bridge between "what's wrong" and "what we do about it." Turn Check phase findings into fixes, then decide: exit or cycle.
## Overview
``` ```
Check phase output → Collect → Prioritize → Route → Fix → Verify → Exit or Cycle Check output → Collect → Deduplicate → Route → Fix → Exit or Cycle
``` ```
--- ---
## Step 1: Finding Collection ## Step 1: Collect and Consolidate Findings
Parse all reviewer outputs into one consolidated findings table. Use the standardized format from the `check-phase` skill. Parse all reviewer outputs into one table grouped by severity (CRITICAL / WARNING / INFO):
```markdown
## Findings Summary — Cycle N
### CRITICAL (must fix before next cycle)
| # | Source | Location | Category | Description | Suggested Fix | | # | Source | Location | Category | Description | Suggested Fix |
|---|--------|----------|----------|-------------|---------------| |---|--------|----------|----------|-------------|---------------|
| 1 | guardian | src/auth/handler.ts:48 | security | Empty string bypasses validation | Add length check | | 1 | guardian | src/auth/handler.ts:48 | security | Empty string bypasses validation | Add length check |
| 2 | trickster | src/api/parse.ts:92 | reliability | Null input causes crash | Guard with null check |
### WARNING (should fix)
| # | Source | Location | Category | Description | Suggested Fix |
|---|--------|----------|----------|-------------|---------------|
| 3 | sage | tests/auth.test.ts:15 | testing | Test names don't describe behavior | Rename to "should reject expired tokens" |
| 4 | guardian | src/auth/handler.ts:52 | security | Missing rate limit | Add rate limiter middleware |
### INFO (nice to have)
| # | Source | Location | Category | Description | Suggested Fix |
|---|--------|----------|----------|-------------|---------------|
| 5 | skeptic | src/auth/handler.ts:30 | design | Consider caching validated tokens | Add TTL cache |
```
### Deduplication ### Deduplication
Before listing findings, deduplicate across reviewers (same rule as `check-phase`): Same file + same category + similar description = one finding. Use the higher severity, credit all sources (e.g. `guardian + skeptic`).
- Same file + same category + similar description = one finding
- Use the higher severity
- Credit all sources: `guardian + skeptic`
- Don't double-count in severity tallies
### Cross-Cycle Tracking ### Cross-Cycle Tracking (cycle > 1)
Compare against prior cycle findings (if cycle > 1): Compare against prior cycle findings:
- **Resolved:** Finding from cycle N-1 no longer present mark resolved, do not re-raise - **Resolved** no longer present, mark resolved, do not re-raise
- **Persisting:** Same location + category still present → increment `cycle_count` - **Persisting** — same location + category, increment `cycle_count`
- **New:** Finding not seen before → add with `cycle_count: 1` - **New** — first appearance, `cycle_count: 1`
If a finding persists for 2+ consecutive cycles, flag for user escalation (see Step 5). Finding persisting 2+ cycles = flag for escalation (see Step 4).
--- ---
## Step 2: Fix Routing ## Step 2: Fix Routing
Not all findings are fixed the same way. Route each finding based on its nature: This is the **canonical routing table** (single source of truth for the whole system):
| Category | Fix Route | Rationale |
|----------|-----------|-----------|
| `security` | Spawn Maker with targeted instructions | Security fixes need tested code changes |
| `reliability` | Spawn Maker with targeted instructions | Same — code-level fix with test |
| `breaking-change` | Route to Creator in next cycle | Design decision needed |
| `design` | Route to Creator in next cycle | Architecture change, not a patch |
| `dependency` | Spawn Maker with targeted instructions | Package update or removal |
| `quality` | Spawn Maker or apply directly | Depends on scope (see below) |
| `testing` | Spawn Maker with targeted instructions | Tests need to be written and run |
| `consistency` | Apply directly or spawn Maker | Naming/style → direct. Pattern change → Maker |
### Direct Fix (no agent)
Apply directly with Edit tool when **all** of these are true:
- The fix is mechanical (typo, naming, formatting, import order)
- No behavioral change
- No test update needed
- Exactly one file affected
Examples: rename a variable, fix a typo in a string, reorder imports, fix indentation.
### Maker Fix (spawn agent)
Spawn a targeted Maker when the fix involves:
- Code logic changes
- New or modified tests
- Multiple files
- Any behavioral change
Provide the Maker with:
1. The specific finding(s) to address (not all findings — just the routed ones)
2. The file and line location
3. The suggested fix from the reviewer
4. The Maker's original branch (to apply fixes on top)
```
Agent(
description: "Fix: <finding description>",
prompt: "You are the MAKER archetype.
Apply this fix on branch: <maker's branch>
Finding: <source> | <severity> | <category>
Location: <file:line>
Issue: <description>
Suggested fix: <fix>
Rules:
1. Fix ONLY this issue — no other changes
2. Add/update tests if the fix changes behavior
3. Run existing tests — nothing may break
4. Commit with message: 'fix: <description>'
Do NOT refactor surrounding code.",
isolation: "worktree",
mode: "bypassPermissions"
)
```
### Writing/Prose Fix (domain-specific)
For writing projects (books, stories), voice or prose findings need special context:
```
Agent(
description: "Fix: voice drift in <file>",
prompt: "You are the MAKER archetype.
Apply this prose fix on branch: <maker's branch>
Finding: <source> | <severity> | <category>
Location: <file:line>
Issue: <description>
Voice profile to match: <load from .archeflow/config.yaml or project voice profile>
Rules:
1. Fix the flagged passage to match the voice profile
2. Do not rewrite surrounding paragraphs
3. Preserve the narrative intent — only change voice/style
4. Commit with message: 'fix: <description>'",
isolation: "worktree",
mode: "bypassPermissions"
)
```
### Design Fix (route to next cycle)
Findings that require design changes are NOT fixed in the Act phase. They become structured feedback for the Creator in the next PDCA cycle. Collect them into `act-feedback.md` (see Step 5).
---
## Step 3: Fix Application Protocol
Apply fixes in severity order: CRITICAL first, then WARNING, then INFO. Within the same severity, fix in file order (reduces context switching).
### For each fix:
1. **Apply the change** (direct edit or via Maker agent)
2. **Emit `fix.applied` event:**
```json
{
"type": "fix.applied",
"phase": "act",
"agent": "maker",
"data": {
"source": "guardian",
"finding": "Empty string bypasses validation",
"file": "src/auth/handler.ts",
"line": 48,
"severity": "CRITICAL",
"before": "<old code>",
"after": "<new code>"
},
"parent": [<seq of the review.verdict that found it>]
}
```
3. **Targeted re-check** (if the fix is non-trivial):
- Re-run only the reviewer that raised the finding
- Scope the re-check to just the changed file(s)
- If the re-check raises new findings → add them to the findings list with source `re-check:<reviewer>`
### Batching Maker Fixes
If multiple findings route to the same Maker and affect the same file or tightly coupled files, batch them into a single Maker spawn:
```
Agent(
description: "Fix: 3 findings in src/auth/",
prompt: "You are the MAKER archetype.
Apply these fixes on branch: <maker's branch>
1. [CRITICAL] src/auth/handler.ts:48 — Empty string bypass → Add length check
2. [WARNING] src/auth/handler.ts:52 — Missing rate limit → Add middleware
3. [WARNING] tests/auth.test.ts:15 — Bad test names → Rename to behavior descriptions
Fix all three. Commit each as a separate commit.
Run tests after all fixes."
)
```
Batch only within the same functional area. Don't batch unrelated fixes — the Maker loses focus.
---
## Step 4: Exit Decision
After all fixes are applied, evaluate exit conditions:
### Decision Tree
```
┌─ Count remaining CRITICAL findings (including from re-checks)
├─ CRITICAL = 0 AND completion criteria met (if defined)
│ └─ EXIT: Proceed to merge
├─ CRITICAL = 0 AND completion criteria NOT met
│ └─ CYCLE: Feed back "completion criteria failing" to Creator
├─ CRITICAL > 0 AND cycles_remaining > 0
│ └─ CYCLE: Build feedback, go to Plan phase
├─ CRITICAL > 0 AND cycles_remaining = 0
│ └─ STOP: Report to user with unresolved findings
└─ Same CRITICAL finding persisted 2+ cycles
└─ ESCALATE: Stop and ask user for guidance
```
### Emit `cycle.boundary` event:
```json
{
"type": "cycle.boundary",
"phase": "act",
"data": {
"cycle": 1,
"max_cycles": 2,
"exit_condition": "all_approved",
"met": false,
"critical_remaining": 1,
"warning_remaining": 2,
"info_remaining": 1,
"fixes_applied": 3,
"design_issues_forwarded": 1,
"next_action": "cycle"
}
}
```
---
## Step 5: Cycle Feedback Protocol
When cycling back, produce `act-feedback.md` as a structured handoff. This replaces dumping raw findings.
```markdown
## Cycle N Feedback → Cycle N+1
### For Creator (design changes needed)
| # | Source | Severity | Category | Issue | Cycles Open |
|---|--------|----------|----------|-------|-------------|
| 1 | guardian | CRITICAL | security | SQL injection in user input | 1 |
| 2 | skeptic | WARNING | design | Assumes single-tenant only | 1 |
### For Maker (implementation fixes needed)
| # | Source | Severity | Category | Issue | Cycles Open |
|---|--------|----------|----------|-------|-------------|
| 3 | sage | WARNING | testing | Test assertions too weak | 1 |
| 4 | trickster | WARNING | reliability | Error path not tested | 1 |
### Resolved in This Cycle
| # | Source | Issue | How Resolved |
|---|--------|-------|--------------|
| 5 | guardian | Missing rate limit | Added rate limiter middleware (commit abc123) |
| 6 | sage | Test names unclear | Renamed to behavior descriptions (commit def456) |
### Persisting Issues (escalation candidates)
| # | Source | Issue | Cycles Open | Action |
|---|--------|-------|-------------|--------|
| — | — | — | — | — |
```
**Routing rules** (canonical table — matches orchestration and artifact-routing skills):
| Source | Category | Routes to | Reason | | Source | Category | Routes to | Reason |
|--------|----------|-----------|--------| |--------|----------|-----------|--------|
@@ -296,76 +50,91 @@ When cycling back, produce `act-feedback.md` as a structured handoff. This repla
| Sage | quality, consistency | Maker | Implementation refinement | | Sage | quality, consistency | Maker | Implementation refinement |
| Sage | testing | Maker | Test gap, not design flaw | | Sage | testing | Maker | Test gap, not design flaw |
| Trickster | reliability (design flaw) | Creator | Needs redesign | | Trickster | reliability (design flaw) | Creator | Needs redesign |
| Trickster | reliability (test gap) | Maker | Needs more tests | | Trickster | reliability (test gap), testing | Maker | Needs more tests |
| Trickster | testing | Maker | Edge case not covered |
**Disambiguation rule:** When in doubt: if the fix requires changing the approach, route to Creator. If it requires changing the code within the existing approach, route to Maker. **Disambiguation:** If the fix requires changing the approach Creator. If it requires changing code within the existing approach Maker.
### Direct Fix (no agent)
Apply with Edit tool when **all** are true:
- Mechanical (typo, naming, formatting, import order)
- No behavioral change
- No test update needed
- Single file
### Maker Fix (spawn agent)
Spawn a targeted Maker when the fix involves code logic, tests, multiple files, or behavioral changes. Batch findings in the same file area into one Maker spawn.
```
Agent(
description: "Fix: <description>",
prompt: "You are the MAKER archetype.
Branch: <maker's branch>
Findings:
1. [CRITICAL] file:line — issue → suggested fix
2. [WARNING] file:line — issue → suggested fix
Rules: fix ONLY these issues, add/update tests if behavior changes,
run tests, commit each fix separately as 'fix: <description>'.
Do NOT refactor surrounding code.",
isolation: "worktree",
mode: "bypassPermissions"
)
```
### Design Fix (route to Creator)
Design findings are NOT fixed in Act. Collect them into `act-feedback.md` for the Creator in the next cycle (see Step 5).
--- ---
## Step 6: Incremental Runs ## Step 3: Fix Application
Support starting the orchestration from any phase by reusing existing artifacts. Apply in severity order: CRITICAL → WARNING → INFO. Within same severity, group by file.
### `--start-from check` For each fix:
1. Apply the change (direct edit or via Maker agent)
Re-run Check + Act on existing Do artifacts: 2. Emit `fix.applied` event with source, finding, file, severity, before/after
1. Read `.archeflow/artifacts/<run_id>/` for Maker branch and implementation summary 3. For non-trivial fixes: re-run only the originating reviewer scoped to changed files. New findings from re-check get added with source `re-check:<reviewer>`
2. Verify the Maker branch still exists (`git branch --list`)
3. Spawn reviewers against the existing branch
4. Proceed through Act phase normally
### `--start-from act`
Re-run Act with existing Check findings:
1. Read `.archeflow/artifacts/<run_id>/` for Check phase consolidated output
2. Parse findings from the stored reviewer outputs
3. Skip finding collection (already done) — proceed from Step 2 (Fix Routing)
### `--start-from do`
Re-run Do + Check + Act with existing Plan:
1. Read `.archeflow/artifacts/<run_id>/` for Creator's proposal
2. Verify proposal exists and is parseable
3. Spawn Maker with the existing proposal
4. Proceed through Check and Act normally
### Artifact Verification
Before starting from a mid-point, verify required artifacts exist:
```
--start-from do → needs: proposal (Creator output)
--start-from check → needs: proposal + implementation (Maker branch + summary)
--start-from act → needs: proposal + implementation + review outputs
```
If artifacts are missing, report which ones and abort. Don't guess or generate placeholders.
### Event Continuity
For incremental runs, emit events with `parent` pointing to the existing artifacts' events:
1. Read the existing `<run_id>.jsonl` to find the last `seq` number
2. Continue sequence numbering from there
3. Set `parent` on the first new event to point to the last event of the prior phase
--- ---
## Act Phase Checklist (Quick Reference) ## Step 4: Exit Decision
``` ```
□ Parse all reviewer outputs into consolidated findings table CRITICAL = 0 AND criteria met → EXIT: proceed to merge
□ Deduplicate across reviewers CRITICAL = 0 AND criteria NOT met → CYCLE: feedback to Creator
□ Compare against prior cycle findings (if cycle > 1) CRITICAL > 0 AND cycles remaining → CYCLE: build feedback, go to Plan
□ Route each finding: direct fix / Maker / Creator feedback CRITICAL > 0 AND no cycles left → STOP: report unresolved to user
□ Apply direct fixes first (fastest) Same CRITICAL persists 2+ cycles → ESCALATE: ask user for guidance
□ Spawn Maker(s) for code fixes (batch by file area)
□ Emit fix.applied event for each fix
□ Re-check non-trivial fixes with the originating reviewer
□ Count remaining CRITICALs after all fixes
□ Check completion criteria (if defined)
□ Decide: exit / cycle / escalate
□ If cycling: produce act-feedback.md with routed findings
□ If exiting: proceed to merge (see orchestration skill Step 4)
□ Emit cycle.boundary event
``` ```
Emit `cycle.boundary` event with: cycle number, max_cycles, critical/warning/info remaining, fixes applied, next action.
---
## Step 5: Cycle Feedback
When cycling back, produce `act-feedback.md`:
```markdown
## Cycle N → Cycle N+1
### For Creator (design changes needed)
| # | Source | Severity | Category | Issue | Cycles Open |
|---|--------|----------|----------|-------|-------------|
### For Maker (implementation fixes needed)
| # | Source | Severity | Category | Issue | Cycles Open |
|---|--------|----------|----------|-------|-------------|
### Resolved This Cycle
| # | Source | Issue | How Resolved |
|---|--------|-------|--------------|
### Persisting Issues (escalation candidates)
| # | Source | Issue | Cycles Open | Action |
|---|--------|-------|-------------|--------|
```
Route findings into Creator vs Maker sections using the routing table in Step 2.

View File

@@ -0,0 +1,121 @@
---
name: attention-filters
description: Use when spawning archetype agents to decide what context each agent receives. Reduces token waste and sharpens focus by passing only relevant artifacts.
---
# Attention Filters
Each archetype needs different context. Pass only what's relevant — not everything.
| Archetype | Receives | Does NOT Receive |
|-----------|----------|-----------------|
| Explorer | Task description, codebase access | Prior proposals or reviews |
| Creator | Explorer's research + task description | Implementation details |
| Maker | Creator's proposal | Explorer's research, reviews |
| Guardian | Maker's git diff + proposal risk section | Explorer's research |
| Skeptic | Creator's proposal (focus: assumptions) | Git diff details |
| Trickster | Maker's git diff only | Everything else |
| Sage | Proposal + implementation + diff | Explorer's raw research |
## Why This Matters
- **Token cost:** A Guardian reading the Explorer's 2000-word research wastes ~2600 tokens on irrelevant context
- **Focus:** An agent with too much context drifts from its archetype's concern
- **Shadow prevention:** Over-loading context encourages rabbit-holing (Explorer) and scope creep (Maker)
## In Practice
When spawning a Check-phase agent, include only the filtered context in the prompt:
```
# Guardian receives:
"Review these changes: <git diff output>
The proposal identified these risks: <risks section only>
Verdict: APPROVED or REJECTED with findings."
# NOT:
"Here is the full research, the full proposal, the full implementation,
the full git log, and everything else we have..."
```
## Prompt Construction Templates
### Explorer
- **Receives:** Task description, file tree (max 200 lines), prior-cycle feedback (if cycle 2+)
- **Excludes:** Creator proposals, Maker diffs, reviewer outputs
- **Token target:** ~2000 tokens input
### Creator
- **Receives:** Task description, Explorer research (if available), prior-cycle feedback (if cycle 2+)
- **Excludes:** Maker diffs, reviewer outputs
- **Token target:** ~3000 tokens input
### Maker
- **Receives:** Creator's proposal (full), test strategy section, file list
- **Excludes:** Explorer research, reviewer outputs, prior-cycle feedback
- **Token target:** ~2500 tokens input
### Guardian
- **Receives:** Maker's git diff, proposal risk section, test results
- **Excludes:** Explorer research, Creator rationale, Skeptic/Sage outputs
- **Token target:** ~2000 tokens input
### Skeptic
- **Receives:** Creator's proposal (assumptions + architecture decision), confidence scores
- **Excludes:** Git diff details, Explorer raw research, other reviewer outputs
- **Token target:** ~1500 tokens input
### Trickster
- **Receives:** Maker's git diff only, attack surface summary (file types + entry points)
- **Excludes:** Proposal, research, other reviewer outputs
- **Token target:** ~1500 tokens input
### Sage
- **Receives:** Creator's proposal, Maker's implementation summary + diff, test results
- **Excludes:** Explorer raw research, other reviewer verdicts
- **Token target:** ~2500 tokens input
## Token Budget Targets
| Archetype | Fast | Standard | Thorough |
|-----------|------|----------|----------|
| Explorer | skip | 2000 | 3000 |
| Creator | 2000 | 3000 | 4000 |
| Maker | 2000 | 2500 | 3000 |
| Guardian | 1500 | 2000 | 2500 |
| Skeptic | skip | 1500 | 2000 |
| Trickster | skip | skip | 1500 |
| Sage | skip | 2500 | 3000 |
"skip" means the archetype is not spawned in that workflow tier.
## Cycle-Back Filtering
When injecting prior-cycle feedback into cycle 2+:
1. **Summary only** — pass the structured feedback table (issue, source, severity), not full reviewer artifacts
2. **Strip resolved items** — if a finding was marked Fixed in the Act phase, exclude it
3. **Compress context** — prior proposal diffs reduce to "What Changed" section only (not full re-proposal)
4. **Cap at 500 tokens** — if feedback exceeds this, summarize by severity (CRITICAL first, then WARNING, drop INFO)
## Filter Verification Checklist
Before spawning each agent, verify:
- [ ] Prompt contains ONLY the artifacts listed in that archetype's "Receives" above
- [ ] No cross-contamination from other reviewers' outputs
- [ ] Token count is within 20% of the target for the current workflow tier
- [ ] Prior-cycle feedback (if any) is summarized, not raw
- [ ] Excluded artifacts are genuinely absent (search for keywords like file paths from excluded sources)
## Context Isolation
Attention filters control *what* each agent receives. Context isolation controls *how* that context is constructed — ensuring agents operate on provided facts, not ambient knowledge.
### Rules
1. **No session bleed.** Agents receive fresh context only — constructed from task description, artifact files, or extracted sections. They must not inherit session state, chat history, or prior agent prompts.
2. **No cross-agent contamination.** An agent receives another agent's output only if the attention filter table above explicitly allows it. Guardian does not see Skeptic's output. Skeptic does not see the Maker's diff. Violations produce unreliable reviews.
3. **Controller-constructed only.** All agent context is assembled by the orchestrator from: (a) the task description, (b) artifact files on disk, or (c) extracted sections of those artifacts. Agents never pull their own context.
4. **No ambient knowledge.** Agents cannot "remember" findings from prior phases or cycles unless that information is explicitly injected via the cycle-back filtering protocol above. An agent that references information not in its prompt is hallucinating.
5. **Verification.** Before spawning each agent, confirm the constructed prompt has zero references to other agents' raw outputs that are not in the "Receives" column. Search for file paths, archetype names, and finding descriptions from excluded sources.

View File

@@ -1,110 +1,233 @@
--- ---
name: check-phase name: check-phase
description: Use when acting as Guardian, Skeptic, Sage, or Trickster in the Check phase. Defines review rules, finding format, attention filters, and spawning protocol. description: Use when you are acting as Guardian, Skeptic, Sage, or Trickster archetype in the Check phase. Defines shared review rules and output format.
--- ---
# Check Phase # Check Phase
Reviewers examine the Maker's implementation. This skill defines shared rules, finding format, and spawning protocol. Multiple reviewers examine the Maker's implementation in parallel. Each agent definition has its specific protocol — this skill defines the shared rules.
## Shared Rules ## Shared Rules
1. Review against the proposal's intended design, not invented requirements. 1. **Read the proposal first.** Review against the intended design, not invented requirements.
2. Read actual code via `git diff` on the Maker's branch. 2. **Read the actual code.** Use `git diff` on the Maker's branch. Don't review descriptions alone.
3. Use the finding format below for every issue. 3. **Structured findings.** Use the standardized finding format below for every issue.
4. Give a clear verdict: `APPROVED` or `REJECTED` with rationale. 4. **Clear verdict:** `APPROVED` or `REJECTED` with rationale.
5. `STATUS: DONE` signals agent completion. `APPROVED`/`REJECTED` is domain output. Both are parsed independently. 5. **Status tokens are separate from verdicts.** The `STATUS: DONE` line signals the agent finished successfully. The `APPROVED`/`REJECTED` verdict is domain output. A reviewer can be `STATUS: DONE` with verdict `REJECTED` — that is normal. Parse both independently.
## Finding Format ## Finding Format
Every finding must use this format for cross-cycle tracking:
```
| Location | Severity | Category | Description | Fix | | Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----| |----------|----------|----------|-------------|-----|
| src/auth/handler.ts:48 | CRITICAL | security | Empty string bypasses validation | Add length check | | src/auth/handler.ts:48 | CRITICAL | security | Empty string bypasses validation | Add length check before processing |
```
**Severity:** CRITICAL = must fix, blocks approval. WARNING = should fix, doesn't block alone. INFO = nice to have, never blocks. **Severity:**
- **CRITICAL** — Must fix. Blocks approval.
- **WARNING** — Should fix. Doesn't block alone.
- **INFO** — Nice to have. Never blocks.
**Categories:** `security` `reliability` `design` `breaking-change` `dependency` `quality` `testing` `consistency` **Categories** (use consistently for cross-cycle tracking):
- `security` — Injection, auth bypass, data exposure, secrets
- `reliability` — Error handling, edge cases, race conditions, crashes
- `design` — Architecture, assumptions, scalability, coupling
- `breaking-change` — API compatibility, schema migrations, removals
- `dependency` — New deps, version conflicts, license issues
- `quality` — Readability, maintainability, naming, duplication
- `testing` — Missing tests, weak assertions, untested paths
- `consistency` — Deviates from codebase patterns
## Evidence Requirements ## Consolidated Output
Every CRITICAL or WARNING must include concrete evidence. Without evidence, downgrade to INFO. After all reviewers finish, compile:
**Valid evidence:** command output, exit codes, code citations with line numbers, git diff excerpts, reproduction steps. ```markdown
## Check Phase Results — Cycle N
**Banned in CRITICAL/WARNING:** "might be", "could potentially", "appears to", "seems like", "may not". Rewrite with evidence or downgrade. ### Guardian: APPROVED
| Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----|
| src/auth/handler.ts:52 | WARNING | security | Missing rate limit | Add rate limiter middleware |
For each CRITICAL/WARNING, state: (1) what was tested, (2) what was observed, (3) what correct behavior should be. ### Skeptic: APPROVED
| Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----|
| src/auth/handler.ts:30 | INFO | design | Consider caching validated tokens | Add TTL cache for token validation |
## Attention Filters ### Sage: APPROVED
| Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----|
| tests/auth.test.ts:15 | WARNING | testing | Test names don't describe behavior | Rename to "should reject expired tokens" |
Each archetype receives only relevant context. Do not pass everything. ### Trickster: REJECTED
| Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----|
| src/auth/handler.ts:48 | CRITICAL | reliability | Empty string bypasses validation | Add `if (!token || token.trim() === '')` guard |
| Archetype | Receives | Excludes | ### Deduplication
|-----------|----------|----------| If two reviewers raise the same issue (same file + same category), merge:
| Guardian | Maker's git diff + proposal risk section + test results | Explorer research, Creator rationale, other reviewers | | Guardian + Skeptic | CRITICAL | security | Input not sanitized (src/api.ts:30) | Add validation |
| Skeptic | Creator's proposal (assumptions + architecture) + confidence scores | Git diff, Explorer research, other reviewers |
| Sage | Creator's proposal + Maker's diff + implementation summary + test results | Explorer raw research, other reviewer verdicts |
| Trickster | Maker's git diff + attack surface summary (file types + entry points) | Proposal, research, other reviewers |
**Token budget targets:** Use the higher severity. Don't double-count in the verdict.
| Archetype | Fast | Standard | Thorough | ### Verdict: REJECTED — 1 critical finding
|-----------|------|----------|----------| → Build cycle feedback (see orchestration skill) and feed to Plan phase
| Guardian | 1500 | 2000 | 2500 | ```
| Skeptic | skip | 1500 | 2000 |
| Trickster | skip | skip | 1500 |
| Sage | skip | 2500 | 3000 |
**Context isolation:** Agents receive fresh, controller-constructed context only. No session bleed, no cross-agent contamination, no ambient knowledge. Verify zero references to excluded artifacts before spawning.
**Cycle-back filtering (cycle 2+):** Pass structured feedback table only (not full reviewer artifacts). Strip resolved items. Cap at 500 tokens — summarize by severity if exceeded.
## Reviewer Spawning Protocol ## Reviewer Spawning Protocol
This section defines the exact sequence for spawning reviewers in the Check phase.
### Step 1: Guardian First (mandatory) ### Step 1: Guardian First (mandatory)
Guardian always runs first. It receives the Maker's git diff and the proposal's risk section only. Guardian always runs first, before any other reviewer. It receives the Maker's git diff and the proposal's risk section only.
**Context for Guardian:**
- `git diff main...<maker-branch>` (the actual code changes)
- Risk section from `plan-creator.md` (if present)
- Do NOT include: Explorer research, full proposal, other reviewer outputs
```
Agent(
description: "Guardian: security and risk review for <task>",
prompt: "You are the GUARDIAN archetype.
Review the diff: <maker's diff>
Proposal risks: <risk section from plan-creator.md>
Assess: security vulnerabilities, reliability risks, breaking changes, dependency risks.
Output: APPROVED or REJECTED with findings in the standardized format.
Each finding: | Location | Severity | Category | Description | Fix |",
model: <resolve_model guardian $WORKFLOW>
)
```
Save output to `.archeflow/artifacts/${RUN_ID}/check-guardian.md`. Save output to `.archeflow/artifacts/${RUN_ID}/check-guardian.md`.
### Step 2: A2 Fast-Path Evaluation ### Step 2: A2 Fast-Path Evaluation
After Guardian completes, count CRITICAL and WARNING findings in its output. If both are zero, and not escalated, and not first cycle of a thorough workflow — skip remaining reviewers and proceed to Act phase. After Guardian completes, parse its output before spawning other reviewers:
### Step 3: Parallel Remaining Reviewers ```bash
CRITICAL_COUNT=$(grep -c "| CRITICAL |" ".archeflow/artifacts/${RUN_ID}/check-guardian.md" || echo 0)
WARNING_COUNT=$(grep -c "| WARNING |" ".archeflow/artifacts/${RUN_ID}/check-guardian.md" || echo 0)
If A2 does not trigger, spawn remaining reviewers in parallel: # A2 fast-path: skip remaining reviewers if Guardian is clean
# Exception: first cycle of thorough workflows always spawns all reviewers
if [[ "$CRITICAL_COUNT" -eq 0 && "$WARNING_COUNT" -eq 0 \
&& "$ESCALATED" != "true" \
&& ! ("$WORKFLOW" == "thorough" && "$CYCLE" -eq 1) ]]; then
echo "Guardian fast-path: 0 CRITICAL, 0 WARNING — skipping remaining reviewers."
# Proceed directly to Act phase
fi
```
### Step 3: Parallel Reviewer Spawning
If A2 does not trigger, spawn remaining reviewers in parallel based on workflow:
| Workflow | Reviewers (after Guardian) | | Workflow | Reviewers (after Guardian) |
|----------|--------------------------| |----------|--------------------------|
| `fast` | None (Guardian only) | | `fast` | None (Guardian only) |
| `fast` (escalated) | Skeptic + Sage | | `fast` (escalated via A1) | Skeptic + Sage |
| `standard` | Skeptic + Sage | | `standard` | Skeptic + Sage |
| `thorough` | Skeptic + Sage + Trickster | | `thorough` | Skeptic + Sage + Trickster |
Each reviewer gets context per the attention filters above. Spawn all applicable reviewers in a single message with multiple Agent calls:
### Step 4: Collect and Consolidate ```
# Standard workflow example — spawn Skeptic and Sage in parallel:
Agent(
description: "Skeptic: challenge assumptions for <task>",
prompt: "<Skeptic prompt with Creator's proposal>",
model: <resolve_model skeptic $WORKFLOW>
)
For each reviewer: save to `.archeflow/artifacts/${RUN_ID}/check-<archetype>.md`, emit `review.verdict` event, record sequence number. Agent(
description: "Sage: holistic quality review for <task>",
**Deduplication:** If two reviewers raise the same issue (same file + same category), merge into one finding using the higher severity. Don't double-count. prompt: "<Sage prompt with proposal + diff + implementation summary>",
model: <resolve_model sage $WORKFLOW>
**Verdict:** Count CRITICAL findings across all reviewers (after dedup). Any CRITICAL = `REJECTED`. Otherwise `APPROVED`. )
Example consolidated output:
```markdown
## Check Phase Results — Cycle 1
### Guardian: APPROVED
| Location | Severity | Category | Description | Fix |
|----------|----------|----------|-------------|-----|
| src/auth.ts:52 | WARNING | security | Missing rate limit | Add rate limiter |
### Verdict: APPROVED — 0 critical, 1 warning
``` ```
## Timeout Handling Each reviewer gets context per the attention filters defined in `archeflow:orchestration`:
- **Skeptic:** Creator's proposal (assumptions section focus)
- **Sage:** Creator's proposal + Maker's diff + implementation summary
- **Trickster:** Maker's diff only
Each reviewer has a **5-minute timeout**. On timeout: emit `agent.complete` with `"error": true`, log WARNING, treat as no findings, proceed. ### Step 4: Collect Results
**Exception:** Guardian timeout is blocking — abort Check phase and report to user. Wait for all spawned reviewers to return. For each:
1. Save output to `.archeflow/artifacts/${RUN_ID}/check-<archetype>.md`
2. Emit `review.verdict` event with findings
3. Record sequence number for DAG parent tracking
### Timeout Handling
Each reviewer has a **5-minute timeout**. If a reviewer does not return within 5 minutes:
1. Emit `agent.complete` with `"error": true, "reason": "timeout"`
2. Log a WARNING — do not block the run
3. Treat the timed-out reviewer as having delivered no findings (neither approved nor rejected)
4. Proceed with available verdicts
If Guardian times out, this is a blocking failure — abort the Check phase and report to the user.
### Re-Check Protocol (Act Phase Fixes)
When the Act phase routes findings back to the Maker and the Maker applies fixes in a subsequent cycle, the Check phase re-runs with the updated diff. Reviewers who previously rejected should focus on whether their specific findings were addressed. The structured feedback from `act-feedback.md` provides the mapping of which findings were routed where.
---
## Evidence Requirements
Every CRITICAL or WARNING finding must include concrete evidence. Findings without evidence are downgraded to INFO.
### Evidence Types
| Type | Example | When Required |
|------|---------|---------------|
| Command output | `npm test` output showing failure | Test-related findings |
| Exit code | `exit code 1 from eslint` | Tool-based validation |
| Code citation | `src/auth.ts:48 — \`if (token) { ... }\`` | Logic or security findings |
| Git diff | `+ db.query(userInput)` (unsanitized) | Implementation review |
| Reproduction steps | "1. Send POST with empty body, 2. Observe 500" | Runtime behavior findings |
### Banned Phrases
The following phrases are not permitted in CRITICAL or WARNING findings. They indicate speculation, not evidence:
- "might be"
- "could potentially"
- "appears to"
- "seems like"
- "may not"
A finding using these phrases must either be rewritten with evidence or downgraded to INFO.
### Verification Protocol
For each CRITICAL or WARNING finding, state:
1. **What was tested** — the specific code path, input, or scenario examined
2. **What was observed** — the actual behavior or code construct found
3. **What correct behavior should be** — the expected alternative
### Downgrade Rule
If a reviewer produces a CRITICAL or WARNING finding without any of the evidence types above, the orchestrator downgrades it to INFO and emits a `decision` event:
```bash
./lib/archeflow-event.sh "$RUN_ID" decision check "" \
'{"what":"evidence_downgrade","from":"CRITICAL","to":"INFO","finding":"<description>","reviewer":"<archetype>","reason":"no evidence provided"}'
```
---
## Why Structured Findings Matter
The standardized format enables:
- **Cross-cycle tracking:** Same category + location = same issue. Can detect resolution or regression.
- **Feedback routing:** Security/design findings → Creator. Quality/testing findings → Maker.
- **Shadow detection:** CRITICAL:WARNING ratios, finding counts, and category distributions are measurable.
- **Metrics:** Severity counts feed into the orchestration summary.

View File

@@ -186,7 +186,7 @@ When regenerating:
## Per-Agent Attention Filters ## Per-Agent Attention Filters
Not every agent needs the full bundle. The bridge defines attention filters that control which sections each archetype receives. This extends the base attention filters from `archeflow:check-phase`. Not every agent needs the full bundle. The bridge defines attention filters that control which sections each archetype receives. This extends the base attention filters from `archeflow:attention-filters`.
| Archetype | Bundle sections injected | Rationale | | Archetype | Bundle sections injected | Rationale |
|-----------|------------------------|-----------| |-----------|------------------------|-----------|

View File

@@ -157,6 +157,7 @@ Read `.archeflow/session-log.md` and show the last 5 orchestration summaries in
### Quality and Safety ### Quality and Safety
- **archeflow:shadow-detection** -- Quantitative dysfunction detection and correction - **archeflow:shadow-detection** -- Quantitative dysfunction detection and correction
- **archeflow:attention-filters** -- Context optimization per archetype
- **archeflow:convergence** -- Detects convergence, stalling, and oscillation in multi-cycle runs - **archeflow:convergence** -- Detects convergence, stalling, and oscillation in multi-cycle runs
- **archeflow:artifact-routing** -- Inter-phase artifact protocol for naming, storage, and routing - **archeflow:artifact-routing** -- Inter-phase artifact protocol for naming, storage, and routing