concrete/relations/fill-reads-computed
A fill decision reads a sourced slot (a fact, a `compute()` or a mirror), which settles only after every fill has run.
A fill decision reads a sourced slot (a fact, a compute() or a mirror), which settles only after every fill has run.
Graded by the relations stage of concrete check, in the probe venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
The two kinds of read run at different times, and the order is fixed. A fill's
reads is FILL-TIME: the executor is shown the upstream value while it writes this
section, which is what lets one section's brief continue from another's. A SOURCED slot —
bound to a fact, a compute(), or a mirror of another slot — is written by no fill: it
resolves wherever the content is read, from its inputs as they stand then, which is what
keeps it current whenever they change.
So a fill that reads a sourced slot is asking for a value that the fill itself never holds. It would be handed the empty one on every fill, forever, and nothing would ever say so: the fill would simply write copy about nothing. A fill reads facts and the slots a fill writes, whichever way the slot it would read is sourced.
Fix
Read what the sourced slot reads. A sourced slot is a pure function of the facts and of
other slots' values, so whatever the brief actually needs is reachable without it: put
the facts it is computed from — the units, the address, the photos — on the fill's own
reads as fact refs. A mirror's upstream, if a fill writes it, is the slot to read.
Where the dependency really is on another section's written value, read a slot that section's own fill writes, not one it sources.
Before and after
import { compute, fact, fill, Section, section, Slot, text } from "@homepages/concrete";
const Hero = section(
{
key: "hero",
label: "Hero",
slots: { unit_count: text.short({ label: "Unit count", cap: 20, source: compute({ reads: [fact.property.units] }, (units) => String(units.length)) }) },
},
({ slot }) => (
<Section>
<Slot.Text slot={slot.unit_count} as="p" />
</Section>
),
);
export const Summary = section(
{
key: "summary",
label: "Summary",
slots: {
blurb: text.medium({
label: "Blurb",
cap: 120,
// Resolved where the content is read — never handed to this fill.
source: fill.write({ reads: [Hero.slots.unit_count], brief: "Say how many units the property has, in one plain sentence." }),
}),
},
},
({ slot }) => (
<Section>
<Slot.Text slot={slot.blurb} as="p" />
</Section>
),
);import { fact, fill, Section, section, Slot, text } from "@homepages/concrete";
export const Summary = section(
{
key: "summary",
label: "Summary",
slots: {
blurb: text.medium({
label: "Blurb",
cap: 120,
// The compute counted the units; the fill reads the units themselves.
source: fill.write({
reads: [fact.property.units],
brief: "Say how many units the property has, in one plain sentence.",
}),
}),
},
},
({ slot }) => (
<Section>
<Slot.Text slot={slot.blurb} as="p" />
</Section>
),
);