# Writing Module — Codex (per FVW v8 §22)

**Module ID:** `oscar.writing`
**Per FVW v8 v0.10.0 §22:** C1-C9 contract items.
**Status:** Constitutional behaviour contract.

---

## C1 — Behaviour Inventory

### Files

| File | LOC | Purpose |
|---|---|---|
| `app/src/writing/draft.ts` | 237 | 5 AI ops (full post, outline, section, tone rewrite, title/tags/summary) |

### Functions

- `draftFullPost(brief)` — full blog post via askOscar
- `draftOutline(brief)` — 5-7 section headings
- `draftSection(title, brief)` — single section
- `rewriteForTone(text, tone, audience?)` — tone rewrite
- `suggestTitle(text)` / `suggestTags(text)` / `generateSummary(text)` — aux helpers
- `blogToHtml(md)` — markdown→HTML (headings, bold/italic, lists, links, code)
- `slugify(text)` / `wordCount(text)` / `readingMinutes(text)`

---

## C2 — State Machine with Transitions

States: idle → drafting → reviewing → published (per BlogPost data model)

---

## C3 — Side Effect List

Routes through askOscar() — single cached adapter. IDB writes via postsRepo.

---

## C4 — Input Validation Contract

Per app/src/writing/ module-specific validation.

---

## C5 — Failure Modes

Per coverage-matrix.md.

---

## C6 — User Simulation List

5+ representative flows. See `pact/recipes/writing/coverage-matrix.md`.

---

## C7 — Reproducibility Test

Per module.

---

## C8 — Shape Matrix (per FVW v8 §30)

Per-surface × per-mode × per-chip × per-state.

| Surface | Modes | Chips | States |
|---|---|---|---|
| (per module) | | write / save / export / ai-draft / ai-outline / ai-rewrite | |

---

## C9 — State Shape Inventory

### C9.1 localStorage

```
none directly
```

### C9.2 In-memory

Per module files.

### C9.3 IDB

posts store (BlogPost records)

---

## END OF WRITING CODEX
