# Binary Gates

> Stage 1 of the Evaluation Pipeline. Objective pass/fail criteria.

Any option that fails ANY gate is eliminated. No exceptions.

---

## Gate Categories

### 1. Canon Continuity
**Question:** Does this option contradict anything established in the project's canon?

**Check Against:**
- `thematic_spine.md` — Theme, question, mythology
- `characters.md` — Established character traits, arcs, wounds
- `relationship_map.md` — Established relationship dynamics
- `structure_outline.md` — Locked plot points, established beats
- `world.md` / `series_bible.md` — World rules, faction relationships

**Pass:** No contradictions found.
**Fail:** Contradicts established element. Cite specific contradiction.

**Example Failure:**
```
FAIL: Canon Continuity
Option B states the ASI can read human emotions directly.
This contradicts established rule in world.md:
"ASI perceives patterns, not emotions. It infers state from behavior."
```

---

### 2. Required Elements
**Question:** Does this option contain all components required by the objective?

**Required elements vary by decision type:**

| Decision Type | Required Elements |
|---------------|-------------------|
| Character proposal | Name, role, arc type, wound, need layers, thematic connection |
| Anchor definition | Type, relationship to protagonist, how it challenges the Lie |
| Plot beat | Episode, plot advance, character pivot, reversal |
| World element | Setting detail, how it creates pressure, thematic function |

**Pass:** All required elements present.
**Fail:** Missing element(s). List what's missing.

**Example Failure:**
```
FAIL: Required Elements
Option A (Ghost anchor) is missing:
- How the Ghost challenges the protagonist's Lie
- Specific episodes where Ghost memory appears
```

---

### 3. Thematic Connection
**Question:** Does this option explicitly connect to the thematic question?

The option must state HOW it serves the theme, not just assert that it does.

**Pass:** Clear, explicit statement of thematic connection with reasoning.
**Fail:** No connection stated, or connection is vague/asserted without reasoning.

**Example Pass:**
```
"The Mirror anchor directly embodies the thematic question 'Can different
minds trust each other?' because the protagonist must literally trust a
non-human intelligence to understand themselves. The relationship IS the
question made concrete."
```

**Example Failure:**
```
FAIL: Thematic Connection
Option C states "This serves the theme" but doesn't explain how.
The connection between a Ghost anchor and "trust across cognitive divides"
is not articulated.
```

---

### 4. Logic Chain
**Question:** Does A → B → C follow causally?

For plot/structure proposals, verify:
- Effects follow from causes
- Character reactions follow from their established traits
- Consequences follow from actions

**Pass:** Clear causal chain with no gaps.
**Fail:** Effect precedes cause, or causal link missing.

**Example Failure:**
```
FAIL: Logic Chain
Option A: "The protagonist trusts the ASI completely by Episode 20"
But the protagonist is established as deeply suspicious of AI.
No bridge events are proposed between Episodes 1-20 to explain this shift.
```

---

### 5. Constraint Compliance
**Question:** Does this option meet all stated constraints?

Constraints come from:
- The development objective itself
- Genre/demographic requirements
- Format limitations (60 episodes, V12 word counts)
- Project-specific rules

**Pass:** All constraints satisfied.
**Fail:** One or more constraints violated. Cite which.

**Example Constraints:**
```
Objective constraints:
- Anchor must be human or can justify non-human
- Must create sustained tension across 60 episodes
- Anchor relationship should not be primarily romantic (avoids romance-first dynamic)

Demographic constraints:
- Must support competence porn (protagonist skilled)
- Action over melodrama
- Romance B-plots allowed and encouraged; romance A-plots discouraged
```

**Example Failure:**
```
FAIL: Constraint Compliance
Option B makes the anchor relationship purely romantic with no other dramatic function.
This creates a romance-first dynamic, which conflicts with demographic guidance.
Note: Romance B-plots are allowed; the issue is when anchor = romantic interest only.
```

---

## Gate Execution

### Prompt Template

```
You are evaluating an option against binary gates.

OBJECTIVE: {objective}

OPTION BEING EVALUATED:
{option_content}

CANON DOCUMENTS:
{relevant_canon_excerpts}

CONSTRAINTS:
{stated_constraints}

For each gate, answer PASS or FAIL with brief reasoning:

1. CANON CONTINUITY: Does this contradict established canon?
2. REQUIRED ELEMENTS: Does this contain all required components?
3. THEMATIC CONNECTION: Is the thematic connection explicit and reasoned?
4. LOGIC CHAIN: Does the causal reasoning hold?
5. CONSTRAINT COMPLIANCE: Are all constraints satisfied?

Format:
GATE 1: [PASS/FAIL] - [reasoning]
GATE 2: [PASS/FAIL] - [reasoning]
...

FINAL: [PASS if all gates pass / FAIL if any gate fails]
```

---

## Output Format

### All Gates Pass
```
BINARY GATES: Option A — PASSED ✓

Gate 1 (Canon Continuity):    ✓ No contradictions
Gate 2 (Required Elements):   ✓ All present
Gate 3 (Thematic Connection): ✓ Explicit and reasoned
Gate 4 (Logic Chain):         ✓ Causal flow intact
Gate 5 (Constraint Compliance): ✓ All constraints met

Option A advances to Stage 2: Rubric Scoring
```

### Any Gate Fails
```
BINARY GATES: Option B — FAILED ✗

Gate 1 (Canon Continuity):    ✓ No contradictions
Gate 2 (Required Elements):   ✗ FAIL
  Missing: How anchor challenges protagonist's Lie
Gate 3 (Thematic Connection): ✓ Explicit and reasoned
Gate 4 (Logic Chain):         ✓ Causal flow intact
Gate 5 (Constraint Compliance): ✓ All constraints met

Option B eliminated from evaluation.
```

---

## Handling Edge Cases

### Ambiguous Canon
If canon is unclear on a point, the option passes this gate but is flagged:
```
Gate 1: ✓ PASS (with note)
Note: Canon unclear on whether ASI can detect lies.
This option assumes it can. Verify with user before finalizing.
```

### Missing Required Element That Could Be Added
If an element is missing but the option is otherwise strong:
```
Gate 2: ✗ FAIL
Missing: Specific episodes for Ghost appearances

SUGGESTION: This option could pass if episodes were specified.
Consider returning to Character Agent with feedback:
"Add episode schedule for Ghost memory appearances."
```

### Constraint Seems Wrong
If a constraint appears to limit good options:
```
Gate 5: ✗ FAIL
Violates: "Anchor relationship should not be primarily romantic"

NOTE: Option C includes romantic elements but also strong non-romantic
dramatic functions. This may not actually violate the constraint.
Recommend: CONDITIONAL PASS — flag for user clarification.
```

---

## Integration

**Called by:** Showrunner Agent (before rubric scoring)

**Input:** Options from specialist agents + canon documents + constraints

**Output:**
- List of passing options (advance to Stage 2)
- List of failed options with specific failure reasons
- Flags/notes for user attention

**If all options fail:** Return to specialist with feedback for regeneration.
