How to/Building the writer pipeline
PROCESS 02 / THE WRITER

Building the
writer pipeline.

The writer turns a saved dataset into OpenUI Lang statements. It reasons about which component answers each fact group and follows rules from the prompt, the sports pack and the briefing. The compiler then checks every statement, derives what each part shows, asks for one repair and fills what is still missing.

ReasoningRulesGateRepairProbeInteractive system guide
01 / FOLLOW ONE STATEMENT

From prompt to screen.

Add one stage at a time
PROMPTSystem turn + user turnRules · signatures · tokens · templates · request · briefing
The compiler validates the contract. The writer owns relevance.
02 / WRITE THE REASONING INTO THE PROMPT

Shape finds candidates. Meaning picks one.

6 probe cases

placements matches records against component contracts, so the briefing lists every candidate whose shape fits. The writer reads the request first, then keeps the candidate whose useWhen answers it. These are the contrast cases from the relevance probe: each one supplies a fitting record the request did not ask for.

Prompt only · verified by probe:writer
REQUESTShow only Egor Demin's individual key statistics from his latest game.Records supplied: game, player
Read the request first↓
SUBJECTOne player, Egor Demin
FACTSHis key statistics
TIME SCOPEOne game, the latest
SUBJECTS COMPAREDNone
Data-shape candidates, not yet judged↓
d.answers.q1.gameMatchCard

The record fits this component's contract.

d.answers.q1.playerStatsCard

The record fits this component's contract.

01 of 06
↳
The silent check runs before the writer answers.

The selected components answer the original request. Every requested available fact is visible. Unrelated context is omitted. Every referenced sub-statement is defined and reachable. To change a decision, edit the useWhen in components.ts and name the neighbour it is not.

Silent check ↗placements ↗Briefing candidates ↗
03 / VALIDATE EACH STATEMENT

The first failed check stops it.

5 statements

admit runs six checks in order. Pick a statement to see where it stops and the message the compiler records. Messages are quoted from the code. The rule explorers below show the name, data and vocabulary checks.

template
REJECTED
stats = MetricBars({ columns: [] })
template

MetricBars takes a data reference for record (d.<path> or an @Each item)

ADMITTED
stats = MetricBars(d.answers.q1.comparison)
Why

The failure from the full Demin rerun. Dataset shaping timed out and the writer built records itself. A component's record is always a data reference.

Rejected statements return in repair, word for word.
parseName ↗validate ↗expandCall ↗
04 / RULES FOR EVERY SCREEN

The shape of a program.

6 rules

These rules are in the system prompt for any domain. Most of them are also gate checks, so a statement that breaks one never reaches the screen.

System prompt · Prompt + gate

Each part is one statement with a lowerCamel label. A large part splits into label_name sub-statements. The writer never writes root, d, Screen, queries, mutations, state or actions, and a part never references another part.

WITHOUT THE RULE
root = Screen([table, scorers])
table = Card([scorers_list])
What the compiler says

root is written by the server. scorers_list is not a sub-statement of table; parts cannot contain other parts.

WITH THE RULE
table = Card([table_rows])
table_rows = Stack("v", 12, [...])
Result

Both statements are admitted. The compiler renames the part to pickN and writes root itself.

01 of 06
05 / SPORTS RULES

How a sports screen reads.

8 rules

These rules come from the sports pack and the briefing. All but TeamPoints are prompt only, so a statement that ignores one is still admitted.

Pack templates · Prompt only

Every item of a match's statBars renders with StatBar, including shots, corners, saves, fouls and cards. No Progress and no row of figures instead.

WITHOUT THE RULE
stats = Stack("v", 12, [@Each(d.answers.q1.match.statBars, "s",
  Progress(s.home, "bar", null, s.label)
)])
What the screen shows

Admitted. One side shows as a bar and the comparison is lost.

WITH THE RULE
stats = Stack("v", 12, [@Each(d.answers.q1.match.statBars, "s", StatBar(s))])
Result

Both teams' figures at the edges, with a split bar between them.

01 of 08
06 / CHECK COVERAGE, REPAIR ONCE

What the writer is asked to fix.

Pick a first pass

A part shows a question when it reads that answer's content. Reads of status, question, title, source, asOf and team do not count. An unavailable answer counts only when a part reads its note.

Repair round 1
FIRST PASS
demin = Text(d.answers.q1.title, "headline")
Gaps found

The part is admitted, but title names an answer and does not show it. q1 is still a gap.

Appended to the same messages↓
REPAIR REQUEST
Repair. Write only the statements that finish these parts or show these questions; do not repeat admitted statements.
Questions not yet shown (read their answer data):
q1: Show only Egor Demin's individual key statistics from his latest game.
After repair↓
IF REPAIR SHOWS q1The writer's part ships

The new statements are admitted like any other. No default part is added.

IF q1 IS STILL A GAPquestion-fallback

q1 was not shown by the writer; the server added its default part. Unfinished parts are dropped with part-incomplete.

The default part picks the first fitting component, with no relevance check.
shows ↗Repair message ↗Fallback parts ↗
07 / VERIFY THE WRITER

Test the same records under different requests.

No model calls
COMMAND
npm run check:writer-relevance
What it checks

Every component compiles from its catalog sample after player-image enrichment, with no issues and no fallback. No contract repeats a field. Each probe's expected component has a fitting record.

↳
A pass is not an accuracy estimate.

The probes use prepared datasets. They do not test the planner, the feed adapters or dataset shaping. The full Demin rerun failed in shaping, a stage the probes skip.

Offline audit ↗Live probe ↗
08 / ADD A BOUNDARY

Put the rule where its scope is.

A prompt rule asks. A gate rule enforces. Write a rule as an instruction, with the exact call when there is one. The icon-led row rule includes the full statement to copy.

ANY DOMAIN

System prompt

Add it to writerMessages. Keep anything that varies per request out of it, so the cache entry stays shared.

System prompt ↗
SPORTS

Pack templates

Add it to SPORTS_SCREEN.templates, next to the component it is about. A rule about which component fits goes in that component's useWhen.

Sports rules ↗
ONE ANSWER

Briefing

A rule that depends on one answer's data, such as its note or source, goes in briefing.

Briefing ↗
MUST NEVER BREAK

Gate

Add a check to validate for any domain, or to the pack's refuses for one. The writer reads its message in repair, so name the fix, as the TeamPoints message does.

refuses ↗
WHY THIS SHAPE

Validation proves the screen is well formed. It cannot prove it is the right screen.

Every gate check has a test a statement can fail: a name, a path, a type, a count. Relevance has no such test inside one compile, because a wrong component with a valid record is still a valid statement. That is why the reasoning lives in the prompt and is measured by contrast probes, where the same records meet different requests.

compose ↗Fixed system prompt ↗TeamPoints refusal ↗
Built from the local implementationmetrics-comparison-fixes · Source links point to main.Probe cases come from check-writer-relevance.ts. Compiler messages are quoted from the code.Live probe results are recorded in WRITER_RELEVANCE.md and were not rerun for this guide.
Open the Preview ↗