# Consensus Protocol — PPTX Ralplan

## Overview
Sequential Planner → Architect → Critic loop for PPTX slide structure planning. The loop runs until all reviewers APPROVE or max iterations (3) are exhausted.

## Agent Roles

### Planner (Orchestrator acts as Planner)
- Reads the interview spec (or direct user request)
- Writes the direction card first (`direction-step.md`): tonality, two named alternatives, reason from the measured content; a bare request gets the style question first (SKILL.md), the card records its answer
- Creates a slide-by-slide implementation plan
- Specifies layout, content, data, and render path per slide

### Architect (Agent tool with agents/architect.md)
- Reviews plan for layout feasibility, template compliance
- Checks font names, dimensions, data expression validity
- Flags BLOCKER issues that would cause rendering failures

### Critic (Agent tool with agents/critic.md)
- Evaluates content quality, anti-slop compliance
- Checks for forbidden patterns, generic headings, padding
- Scores overall quality on 1-10 scale

## Loop Process

```
Iteration 1:
  Planner creates plan
      ↓
  Architect reviews → APPROVE or REJECT with issues
      ↓ (if REJECT)
  Planner revises based on Architect feedback
      ↓
  Architect reviews again
      ↓
  Critic evaluates → APPROVE or REJECT
      ↓ (if REJECT)
  Planner revises based on Critic feedback

Iteration 2: (if previous rejected)
  [repeat Planner → Architect → Critic sequence]

Iteration 3: (final attempt)
  [repeat, force-approve if still has only minor issues]
```

## Approval Gates

### Architect APPROVE Criteria
- All layouts valid: under a tonality, every `layout:` is a family or variant the chosen pack lists (`--list-layouts <tonality>`)
- Font usage matches the chosen template (for per-weight-family fonts like 에이투지체/Example Sans, weight is selected by family name, not a bold flag)
- Dimensions match the chosen template (e.g. 10×7.5in 4:3 for BOILERPLATE-*, 10.833×7.5in for a custom template)
- No anti-slop violations
- Render paths appropriate per slide complexity

### Critic APPROVE Criteria
- Quality score ≥ 7/10
- Zero CRITICAL issues
- At most 2 MAJOR issues
- No FORBIDDEN_TERMS

### Forced Approval
If after 3 iterations the plan has only MINOR issues, force-approve with notes. Do not loop indefinitely.

## State Persistence
State is stored in `.pptx-pipeline/plan-state.json`:
```json
{
  "active": true,
  "iteration": 1,
  "max_iterations": 3,
  "architect_verdict": null,
  "critic_verdict": null,
  "issues_resolved": [],
  "started_at": "ISO timestamp"
}
```

## Output Plan Format
Write to `.pptx-pipeline/plan-{slug}.md`:
```markdown
# PPTX Implementation Plan: {title}

## Consensus Metadata
- Iterations: {n}
- Architect verdict: APPROVE
- Critic verdict: APPROVE
- Quality score: N/10
- Direction: {tonality} (alternatives: {a}, {b}); density/variance {d}/{v}

## Slide-by-Slide Implementation
### Slide 1: Cover
- Layout: cover
- Title: "..."
- Metadata: date, department
- Render path: compile-deck.js

### Slide 2: TOC
- Layout: content
- Title: "목차"
- Items: [...]
- Render path: compile-deck.js

### Slide 3-N: Content
- Layout: content | main
- Title: "..."
- Body: [bullet structure]
- Data: [table spec if any]
- Render path: compile-deck.js | pptxgenjs-direct

### Slide N+1: Summary
- Layout: summary
- Group 1: [heading + items]
- Group 2: [heading + items]
- Image: [path or none]
- Table: [spec or none]
- Render path: compile-deck.js

### Slide N+2: Closing
- Layout: closing variant of the pack (e.g. closing-ask, closing-decision-box)
- Title: noun-phrase label naming the request (never "감사합니다" alone)
- Body: items to approve, next step with owner and date
- Render path: compile-deck.js

## QA Plan
- Compile: `node scripts/compile-deck.js deck.md --template <TEMPLATE> --pptx output.pptx --embed-fonts` (omit `--template` for a tonality deck; the frontmatter `tonality:` sets the look, and a legacy template is used only when the user named it)
- Verify: `python scripts/inventory.py output.pptx verify.json --issues-only`
- No FORBIDDEN_TERMS check: `python validate_pptx.py output.pptx`
```
