---
title: How the article writing framework works
description: An ~18-step pipeline under a strict charter — one concern, one owner — with grounded drafting, schema-controlled LLM output and a single quality gate at the end.
locale: en
version: 0.2.0
canonical: https://enterium-developer-docs.pages.dev/developers/how-it-works/writing-framework/
---

> Documentation index: https://enterium-developer-docs.pages.dev/developers/llms.txt — every page of this portal has a Markdown twin at <route>.md; the frozen API contract is at https://enterium-developer-docs.pages.dev/developers/api/openapi.json.

**The problem:** LLM article generation degrades into entropy when every
step can touch every concern — five different steps "improving" tone
produce a sixth voice nobody chose. The framework's answer is a charter:
**one concern, one owner** — and everything else is plumbing between
owners.

## Layer 1 — the charter

The pipeline is ~18 steps, but five of them own the article:

```mermaid
flowchart LR
    PLAN[PLAN<br/>structure +<br/>fact contract] --> WRITE[WRITE<br/>all prose is born here]
    WRITE --> VOICE[VOICE<br/>rhythm + voice rules]
    VOICE --> FRAME[FRAME<br/>intro · about ·<br/>conclusion · FAQ]
    FRAME --> GATE[GATE<br/>the single<br/>sanitize → score → verdict]
```

Everything before PLAN is preparation (fetch, summarize, ontology
alignment, author selection); everything between owners is mechanical
(images, references, layout). No step outside WRITE may generate prose;
no step outside GATE may pass a verdict. The practical payoff: when tone
regresses, exactly one step is suspect.

## Layer 2 — grounded drafting

Drafting retrieves from the contract's [research corpus](../rag-flywheel/)
at three points (planning, writing, gating), and the references section is
built **cited-first**: only sources the text actually used, not a wall of
retrieved-but-ignored links. A cross-encoder reranker re-orders retrieved
facts before they reach the prompt — a measured quality lever that fails
open (a reranker outage degrades ranking, never blocks generation).

The author is selected from the contract's roster by weighted random
draw, and the author's bio feeds the VOICE owner as raw material — voice
is a per-author property, not a global constant.

## Layer 3 — schema-controlled LLM output

Structured steps demand structured output — literally. LLM calls that
must return JSON use **provider-enforced JSON-schema decoding** (the
grammar constrains generation), after live probes showed that two
plausible-looking alternatives were silent no-ops on the provider. The
old "repair truncated JSON" patch was deleted; a parse failure now takes
a *measured* fallback path instead of a silent one, and a guard test
pins the provider facts so a regression cannot sneak back.

Section generation runs **concurrently** under a semaphore — sections
are independent by construction once the PLAN owner has fixed the
structure and fact contract, so parallelism costs nothing in coherence.

## Layer 4 — one gate, growing teeth

The GATE step is the pipeline's single verdict point: mechanical
sanitize, the scoring battery, brand-safety signals, grounding checks —
accumulated over successive spec generations into one place. It is the
largest step in the pipeline by far, and that is the design: gates are
*supposed* to accrete here, rather than scatter.

## Trade-offs

The charter's numeric goals are not all met — the gate step has grown
well past the size target as new checks landed, and one planned step
consolidation hasn't happened. Section parallelism shipped alongside a
version promotion without its own dedicated A/B protocol (the design doc
still lists that as open). Both are visible, tracked deviations — the
charter is a direction the pipeline is held against, not a myth of
perfection.

## See it in two minutes

Any article's run record lists every step with its timing and outcome;
the [Version lifecycle](../../pipelines/versioning/) page explains why
each change to this framework is a new immutable carve.
