---
name: translation-synthesis
description: Stage 6a translation generator — produce structure-preserving verse-aligned English from Greek, adversarially reviewed against PD witnesses. Skipped when a versification-candidate witness is successfully versified via the Stage 6 fast path.
allowed-tools: Bash(python3:*), Bash(sqlite3:*), Bash(pi:*), Bash(find:*), Bash(wc:*), Bash(ls:*), Bash(bash:*), Bash(git:*), Bash(jq:*), Read, Write, Edit, Grep, Glob
---

# Translation Synthesis (Stage 6a)

Generate a structure-preserving English translation aligned 1:1 with the Greek reference system.

This skill is the **Stage 6a owner** — the first half of Stage 6.

**Stage 6a is conditional.** Before this skill runs, the orchestrator attempts the **witness versification fast path** (`/versify try-witness`). If a `versification-candidate` witness is successfully versified (100% coverage, 1:1 mapping), that witness becomes the versified edition and Stage 6a is skipped entirely.

Stage 6a runs when:
- No witness is classified as `versification-candidate`
- All versification-candidate witnesses fail automated versification (segment count mismatch, reference mismatch, coverage < 100%)
- The orchestrator explicitly requests fresh generation

When Stage 6a does run, the generated translation is the primary English content for that text.

## Quick Status

Generated translation chapters: !`find ${LYCEUM_TEXTS_DIR:-output/texts} -path '*/versification/chapter_*.json' 2>/dev/null | wc -l`
Texts with generated translations: !`find ${LYCEUM_TEXTS_DIR:-output/texts} -path '*/versification/chapter_01.json' 2>/dev/null | xargs -I{} dirname {} | xargs -I{} dirname {} | sort -u | wc -l`

## Commands

- `/translation-synthesis run [work]` — Generate or regenerate the verse-aligned translation for one text
- `/translation-synthesis review [work]` — Re-run adversarial review on existing generated translations
- `/translation-synthesis status [work]` — Summarize generation progress, review verdicts, and known issues

Target: $ARGUMENTS

---

## Owned Responsibilities

### Owns
- Stage 6a translation generation
- structure-preserving English output (one segment per Greek segment)
- adversarial review against PD witness translations
- generation metadata (model, timestamp, witness used)
- review reports with issues and verdicts

### Does not own
- PD witness collection (Stage 5 — translation-witness)
- structural validation and DB import (Stage 6b — versify)
- interlinear/gloss generation (Stage 8)
- final ship promotion (Stage 10)

---

## Witness Versification (Fast Path)

Before Stage 6a generation runs, the orchestrator invokes `/versify try-witness [work]` to attempt the fast path. This is documented here for context — the actual logic lives in the versify skill.

### When the fast path succeeds
- A `versification-candidate` witness was found in the witness catalog
- Its references map 1:1 to Greek segments
- Coverage is 100%
- The witness is imported as the versified edition
- **Stage 6a is skipped** — no translation is generated
- The witness still gets a **validation pass** (checked for empty segments, reference integrity, completeness) via `/versify try-witness`

### When the fast path fails
- No `versification-candidate` exists, OR
- All candidates fail automated versification
- **Stage 6a runs normally** — generate a fresh translation with adversarial review
- Then Stage 6b validates and imports the generated translation

### What this means for this skill
- This skill's `run` command is only invoked when the fast path has already failed
- All generation requirements, adversarial review, and quality standards still apply
- The fast path does not change how generation works — it only determines whether generation happens at all

---

## Generation Requirements

The generated translation MUST be:

1. **Structure-preserving**: exactly one English segment per Greek segment (verse, sentence, or unit)
2. **Faithful**: accurate to the Greek meaning, segment-by-segment — no paraphrasing across boundaries
3. **Learner-readable**: clear, natural English that helps learners understand what the text says
4. **Consistent**: recurring Greek terms get consistent English equivalents where reasonable
5. **Labeled**: output includes model name, timestamp, and witness translator used for comparison

The generated translation MUST NOT:
- Rearrange clauses across segment boundaries
- Merge or split segments
- Add explanatory content not in the Greek
- Be presented as a historical/literary translation

---

## Adversarial Review

Every generated translation batch is reviewed against PD witness translations.

### Review checks
1. **MISTRANSLATION**: meaning that differs from the Greek
2. **HALLUCINATION**: content added that is not in the Greek
3. **OMISSION**: Greek content that was dropped
4. **CLAUSE REARRANGEMENT**: significant reordering away from Greek structure
5. **TERM INCONSISTENCY**: same Greek word translated differently without reason

### Review output
Each review produces a JSON object:
```json
{
  "verdict": "pass" | "fail",
  "issues": [
    {
      "reference": "2.3",
      "type": "mistranslation",
      "description": "...",
      "suggested_fix": "..."
    }
  ],
  "notes": "..."
}
```

### Handling review failures
- Issues are logged but translations are kept (human review will catch serious problems)
- High issue counts should trigger re-examination
- Critical mistranslations should be fixed before proceeding to Stage 6b

---

## Workflows

## `/translation-synthesis run`

Generate or regenerate the verse-aligned translation.

### Prerequisites
- Stage 5 complete: at least one PD witness available for adversarial comparison
- Greek edition segments exist in the database
- Workspace has witness information (if using canonical workspace)

### Execution

#### Using the generation script directly
```bash
# Preview chapter 1 without saving
python3 scripts/generate_translation.py --text <text_key> --chapter 1 --preview

# Generate specific chapter
python3 scripts/generate_translation.py --text <text_key> --chapter 1

# Generate all chapters
python3 scripts/generate_translation.py --text <text_key> --all

# Resume from a specific chapter
python3 scripts/generate_translation.py --text <text_key> --all --start-chapter 15
```

#### Execution modes
- `--mode api`: Uses ANTHROPIC_API_KEY to call the Anthropic API directly (faster)
- `--mode agent`: Spawns pi subprocesses (no API key required, slower)
- Auto-detection: uses API mode if key is available, otherwise agent mode

#### Adding new texts
Currently `generate_translation.py` requires text configuration in its `TEXT_CONFIG` dict. To add a new text:
1. Add entry with `greek_edition_id`, `english_edition_id` (witness), work URN, generated URN
2. Run generation
3. Optionally use `--import` to import directly to DB

### Output location
```
$LYCEUM_TEXTS_DIR/<slug>/versification/
├── chapter_01.json
├── chapter_02.json
└── ...
```

### Chapter file format
```json
{
  "chapter": 1,
  "generated_at": "2026-03-15T04:44:15.458022+00:00",
  "model": "claude-sonnet-4-20250514",
  "witness": "Bernadotte Perrin (1919)",
  "segments": [
    {"reference": "1.1", "translation": "..."},
    {"reference": "1.2", "translation": "..."}
  ],
  "reviews": [
    {"verdict": "pass", "issues": [], "notes": "..."}
  ]
}
```

---

## `/translation-synthesis review`

Re-run adversarial review on existing generated translations.

Useful when:
- New/better PD witnesses have been gathered
- Review prompts have been improved
- Issues from initial review need re-examination

### Steps
1. Load existing chapter files from `versification/`
2. Load current PD witness(es)
3. Re-run review prompts
4. Update review sections in chapter files
5. Report aggregate pass/fail/issue counts

---

## `/translation-synthesis status`

Summarize current state.

### Report includes
- Chapters generated vs total expected
- Review verdicts (pass/fail counts)
- Issue breakdown by type
- Outstanding high-severity issues
- Readiness for Stage 6b (versify)

### SQL helpers
```sql
-- Count Greek segments by chapter
SELECT 
  CAST(SUBSTR(reference, 1, INSTR(reference, '.') - 1) AS INTEGER) as chapter,
  COUNT(*) as segments
FROM segments 
WHERE edition_id = <greek_edition_id>
GROUP BY chapter;

-- Count generated segments
SELECT COUNT(*) FROM segments WHERE edition_id = <generated_edition_id>;
```

---

## Important Rules

### Generation is skipped only via the fast path
Do NOT skip translation synthesis for ad-hoc reasons like:
- "The existing Perrin/Murray/Long translation is good enough"
- "This text already has verse numbers"
- "It's biblical so we can use KJV/ASV"

The **only** legitimate way to skip Stage 6a is via the witness versification fast path (`/versify try-witness`), which requires:
- A witness explicitly classified as `versification-candidate` in the Stage 5 catalog
- Automated versification succeeding with 100% coverage and 1:1 mapping
- The orchestrator confirming the fast path result before skipping generation

If the fast path was not attempted or did not succeed, generation MUST run.

### Per-chapter isolation
- Process one chapter at a time
- Never mix segments from different chapters in a batch
- Save after each chapter to enable resume

### Labeling
All output must be clearly labeled as generated:
- `generated_at` timestamp
- `model` name
- `witness` used for comparison
- URN includes "generated" marker (e.g., `...generated-eng1`)

### Rate limiting
When using API mode, include delays between batches to avoid rate limits.

---

## Lessons Learned

### Why generation is the default (and the fast path is an exception)
1. Pope's Iliad cannot be forced into line-level 1:1 alignment — too literary, wrong structure
2. Townsend's Aesop is too loose for reliable verse alignment
3. Murray's Homer requires range-based fallback with imperfect coverage
4. Long's Meditations required elaborate DP mapping with hand-verified tables
5. Even "verse-aligned" biblical texts have numbering variations

Generating a structure-preserving translation eliminates all alignment-mode classification effort for the majority of texts.

### When the fast path works (and why it exists)
Some texts have PD translations that are already naturally 1:1 with the Greek:
- NT witnesses (ASV, KJV) share the same verse numbering as the Greek — despite occasional variations, automated versification can handle these when the match rate is high enough
- Scholarly literal translations of segmented texts (e.g., Perrin's Plutarch with section markers) may already align structurally
- The fast path exists to avoid expensive LLM generation when a perfectly good literal PD translation already has the right structure

The key insight: the old problems (Pope, Townsend, Murray, Long) were caused by trying to force-align *unsuitable* witnesses. The fast path only attempts versification on witnesses that Stage 5 has explicitly classified as `versification-candidate` — witnesses that are literal, reference-aligned, and structurally compatible.

### What makes a good witness for comparison
- Literal scholarly translations catch more errors
- Multiple witnesses increase confidence
- Literary/idiomatic translations may miss structural issues
- Witness doesn't need to be aligned — just readable for comparison

---

## Verification Contract

This skill follows the Stage 6a contract.

### Verify
- Generated translation has one segment per Greek segment
- Adversarial review was performed against at least one PD witness
- No cross-chapter contamination
- Model/timestamp metadata is present
- Issues are documented (even if verdict is "pass")

### Minimum evidence
- Chapter files under `versification/`
- Each chapter file has `segments` and `reviews`
- `generated_at`, `model`, and `witness` fields present

### Pass criteria
- 100% structural coverage: every Greek segment has a generated translation
- Adversarial review completed for all chapters
- No unresolved critical mistranslations blocking Stage 6b
- Output is labeled as generated

### Failure examples
- Generated translation hallucinates content not in the Greek
- Adversarial review was skipped
- Segments are merged or split relative to Greek structure
- Chapter files missing review data

### Next steps after pass
- Proceed to `/versify run <work>` for structural validation and DB import

---

## Verification

After completing this stage, run the automated verification script:

```bash
bash scripts/verify_stage_6a.sh "${SLUG}"
```

Exit codes: 0=PASS (advance), 1=FAIL (block), 2=WARN (advance with notes).
The orchestrator runs this automatically; when executing manually, check the output for [FAIL] or [WARN] lines.

---

## Key Files

| File | Purpose |
|---|---|
| `scripts/generate_translation.py` | Core generation script |
| `$LYCEUM_TEXTS_DIR/<slug>/versification/` | Generated chapter files |
| `.pi/skills/versify/SKILL.md` | Stage 6b (validation/import) |
| `.pi/skills/translation-witness/SKILL.md` | Stage 5 (witness collection) |
| `docs/text-pipeline-master-plan-2026-03-13.md` | Pipeline architecture |
