Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 127 additions & 76 deletions Packs/pai-algorithm-skill/src/skills/THEALGORITHM/Phases/Learn.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,71 @@
# LEARN Phase

**Purpose:** OUTPUT results for user to evaluate. User rates outputs for the memory system.
**Purpose:** OUTPUT results for user to evaluate AND capture learnings for the memory system.

**ISC Mutation:** ARCHIVE completed ISC, output results
**ISC Mutation:** ARCHIVE completed ISC, output results, capture learnings

**Gate Question:** Have I provided everything the user needs to evaluate the work?
**Gate Question:** Have I provided everything the user needs to evaluate the work AND captured learnings?

**CRITICAL:** NO SELF-RATING. The assistant does NOT rate its own work. User rates outputs for the memory system.

## What Happens

1. **Output final ISC** - Show completed state with all capabilities and statuses
2. **Present deliverables** - Show what was produced
3. **Document capability usage** - What capabilities were used and how they performed
4. **Archive or iterate** - Complete if successful, iterate if blocked
3. **Capture learnings** - Extract and persist insights (AUTOMATED)
4. **Record signals** - Track patterns, failures, loopbacks (AUTOMATED)
5. **Archive or iterate** - Complete if successful, iterate if blocked

## Learning Capture (NEW - AUTOMATED)

The LEARN phase now automatically captures learnings using the new tools:

### Quick Commands

```bash
# Full learning capture (RECOMMENDED - does everything)
bun run $PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts learn

# Or individual tools:

# 1. Capture learnings from ISC
bun run $PAI_DIR/skills/THEALGORITHM/Tools/LearningCapture.ts capture

# 2. Record task completion
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts complete -w "task name" -i 1 --success

# 3. Analyze patterns
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts analyze

# 4. Complete work item
bun run $PAI_DIR/skills/THEALGORITHM/Tools/WorkItemManager.ts complete --success -s "summary"
```

### What Gets Captured

| Type | Location | Description |
|------|----------|-------------|
| **Capability Performance** | `MEMORY/Learning/EXECUTE/` | How well each capability performed |
| **Estimation Accuracy** | `MEMORY/Learning/PLAN/` | Was effort level appropriate? |
| **Patterns** | `MEMORY/Learning/ALGORITHM/` | Blocked/adjusted row patterns |
| **Session Summary** | `MEMORY/Learning/sessions/` | Markdown summary of the run |
| **Signals** | `MEMORY/Signals/patterns.jsonl` | Aggregated patterns for analysis |

### Signal Tracking

```bash
# Record a failure during VERIFY
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts failure \
-w "Add auth" -c "tests pass" -e "all green" -o "3 failing"

# Record a loopback
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts loopback \
-w "Add auth" --from VERIFY --to THINK -r "unclear requirements"

# Record user rating (after user feedback)
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts rating \
-w "Add auth" -s 4 -f "good work"
```

## NO Self-Rating

Expand All @@ -27,7 +79,8 @@
- Present the work clearly
- Show what was accomplished
- Document what capabilities were used
- Let user evaluate and rate for memory
- Capture learnings automatically
- Let user evaluate and rate

## Output Format

Expand Down Expand Up @@ -57,122 +110,120 @@ Present results clearly for user to evaluate:
| execution.engineer | Success | Parallel tasks efficient |
...

## Learnings Captured

✅ [X] learnings automatically captured to MEMORY/Learning/
✅ [X] patterns analyzed and saved to MEMORY/Signals/
✅ [X] session summary created

## For Memory System

User: Please rate this work for the memory system.
User: Please rate this work (1-5) for the memory system.
```

## Learning Categories
## Full LEARN Phase Workflow

| Category | What to Document | For |
|----------|------------------|-----|
| **Capability Usage** | Which capabilities were effective? | Future task planning |
| **Process** | What phases were hard? Easy? | Algorithm improvement |
| **Estimation** | Was effort level accurate? | Calibration |
```bash
# 1. Transition to LEARN phase
bun run $PAI_DIR/skills/THEALGORITHM/Tools/AlgorithmDisplay.ts phase LEARN

## Review the Evolution
# 2. Show final ISC
bun run $PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts show -o markdown

```bash
# View the full evolution log
bun run ISCManager.ts log
# 3. Capture all learnings (AUTOMATED)
bun run $PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts learn

# 4. Present to user for rating

# View final ISC state
bun run ISCManager.ts show -o markdown
# 5. After user rates (if they do):
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts rating -w "task" -s [1-5] -f "feedback"

# Get summary statistics
bun run ISCManager.ts summary
# 6. Archive ISC (also captures learnings if not done)
bun run $PAI_DIR/skills/THEALGORITHM/Tools/ISCManager.ts clear
```

## Document Capability Usage
## Memory Locations

For each capability used, note:
- **What capability:** e.g., `research.perplexity`, `execution.engineer`
- **What it did:** Brief description of how it was used
- **Effectiveness:** Did it work well for this task?
| Path | Purpose |
|------|---------|
| `$PAI_DIR/MEMORY/Learning/ALGORITHM/` | Algorithm-specific learnings |
| `$PAI_DIR/MEMORY/Learning/EXECUTE/` | Capability performance |
| `$PAI_DIR/MEMORY/Learning/PLAN/` | Estimation accuracy |
| `$PAI_DIR/MEMORY/Learning/sessions/` | Session summaries (markdown) |
| `$PAI_DIR/MEMORY/Signals/patterns.jsonl` | Aggregated patterns |
| `$PAI_DIR/MEMORY/Signals/failures.jsonl` | Failure records |
| `$PAI_DIR/MEMORY/Signals/loopbacks.jsonl` | Loopback records |
| `$PAI_DIR/MEMORY/Signals/ratings.jsonl` | User ratings |
| `$PAI_DIR/MEMORY/State/algorithm-stats.json` | Overall statistics |
| `$PAI_DIR/MEMORY/State/algorithm-streak.json` | Success streak |

This helps improve future capability selection.
## Viewing Learnings

```bash
# List recent learnings
bun run $PAI_DIR/skills/THEALGORITHM/Tools/LearningCapture.ts list -l 20

# Show learning statistics
bun run $PAI_DIR/skills/THEALGORITHM/Tools/LearningCapture.ts stats

# Show signal report
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts report

# Show algorithm stats
bun run $PAI_DIR/skills/THEALGORITHM/Tools/SignalCapture.ts stats
```

## Learning Categories

| Category | What to Document | For |
|----------|------------------|-----|
| **Capability Usage** | Which capabilities were effective? | Future task planning |
| **Process** | What phases were hard? Easy? | Algorithm improvement |
| **Estimation** | Was effort level accurate? | Calibration |
| **Patterns** | What patterns emerge? | Long-term optimization |

## Iteration Decision

| Outcome | Action |
|---------|--------|
| All rows PASS/ADJUSTED | Archive ISC, output for user |
| All rows PASS/ADJUSTED | Capture learnings, archive ISC, output for user |
| Some rows BLOCKED | Iterate - return to appropriate phase |
| Scope fundamentally wrong | Iterate from OBSERVE |

**Iteration flow:**
```
BLOCKED in verification
Record failure signal
Analyze blockers
If implementation issue → Return to EXECUTE
If plan issue → Return to PLAN
If requirements issue → Return to THINK
If scope issue → Return to OBSERVE
Record loopback signal
Increment iteration counter
Re-run from that phase
```

## Archive Completed Work

```bash
# Archive the ISC (saves to archive, clears current)
bun run ISCManager.ts clear

# This creates: $PAI_DIR/MEMORY/Work/archive-{timestamp}.json
```

## Example Output

**Request:** "Add logout button to navbar"
**Effort:** STANDARD | **Iterations:** 1

**ISC Final State:**
- 7 rows total
- 6 PASS, 1 ADJUSTED
- 2 parallel execution groups

**Capabilities Used:**
| Capability | Result | Notes |
|------------|--------|-------|
| execution.engineer×2 | Success | Parallel UI tasks |
| execution.qa_tester | Success | Caught mobile issue |
| verification.browser | Success | Visual verification |

**Deliverables:**
- Logout button component in `components/LogoutButton.tsx`
- Updated navbar with logout integration
- Tests passing, browser-verified

**For Memory System:**
User: Please rate this work for the memory system.

## Commands

```bash
# Update phase
bun run ISCManager.ts phase -p LEARN

# Start new iteration (if needed)
bun run ISCManager.ts iterate

# Archive completed ISC
bun run ISCManager.ts clear
```

## Exit Criteria

**If successful:**
- Final ISC displayed with capabilities
- Deliverables presented
- Capability usage documented
- ✅ Learnings captured to MEMORY/Learning/
- ✅ Signals recorded to MEMORY/Signals/
- ✅ Session summary created
- Ready for user's evaluation

**If iterating:**
- Blockers analyzed
- Failure signals recorded
- Loopback signals recorded
- Return phase identified
- Iteration counter incremented
- Ready to re-enter earlier phase
Loading