Sources
Looking up where a slot's value comes from — the fact namespace, a computation, a mirrored slot, a fill.
fact
Signature
import { fact, text } from "@homepages/concrete";
const city = text.short({
source: fact.property.address.city,
label: "City",
});Parameters
fact.property.* reads the property root, and fact.property is the whole namespace. A
unit's or a contact's members are read through a row() of its table (below). Inside
a list's item the element is read through a row declared from it (unit.beds), never
through the namespace.
fact.property spells the property's facts as the platform's fact registry nests
them, and that is the spelling to write. The address is one fact whose parts are
typed members — fact.property.address.street, .unit, .city, .state,
.postal, .latitude and .longitude — each read-only, null when absent,
and the coordinates a pair: both or neither. A member the address does not have is
a compile error, exactly as a misspelled fact is. fact.property.address itself is
the whole address, an AddressValue — null when the property holds no place —
which an address() slot binds and a compute or a fill's
reads takes whole. No text slot binds it: a line of it is a formatting, a
compute() over the address (contract/source). fact.property.description is
the property's description as a bindable fact, and fact.property.listing_intent
is its scalar fact. Each stores the fact's
registry path (property.address.city); hover one to read what it holds.
A contact row's address member is the address itself,
which an address() slot binds and edits.
Four entries are tables rather than scalars: fact.property.units,
fact.property.commercial_spaces, fact.property.contacts and
fact.property.comparables. A table is a list. A
list() takes one as its source — every row, live, and the list edits the table
(slot builders) — and a row() names one as its
from, its type and the set it is picked from, holding its first row unless a
source says otherwise; the user may re-pick it
(slot builders).
A table's members are read only through a row. Declare one —
const agent = row({ label: "Agent", from: fact.property.contacts }) — and
agent.phone is that contact's phone: a slot's source:, and a legal entry in any
compute or fill reads. A row with no source holds its
table's first row, so agent is the primary contact, and locked: true keeps it on that
row: how a section reads the primary contact or the primary unit. A
row sourced by the element inside a list's item holds that item's row. Each member is
typed as the table declares it. At the top level a number member
also sits on a text slot, as a flat fact does, so a stat line binds
text.short({ source: primary.beds, label: "Beds" }); inside a
list's item a member keeps its own kind, and a url or select slot refuses it
anywhere. A row that holds nothing reads null for every
member, and a slot bound to one has nothing to update everywhere.
fact.property.uploads is every upload the property holds — photos, floor plans,
videos, tours and documents — in the list's order. Three sorted lists
read the same way: fact.property.property_media, what shows the property (its photos,
videos and tours), fact.property.floor_plans, its floor plans, and
fact.property.property_documents, what sets out its specifics (an offering memorandum,
a rent roll, a lease, a survey, a plan set, a disclosure, and an image or video only
where it records them). The platform sorts each out of the uploads, and one upload may
sit in several. Each holds what it sorts in an order of its own: the media as a walk
through the property, the documents headline materials first, the floor plans from the
lowest floor up, so a list sourced straight from one reads in that sequence. All four are READ-only. A compute reads each as readonly Media[], each item its asset's
record, in the list's order, and a fill's reads shows the model each asset as
what is known about it. None binds a slot, a list included: a media slot or a list
of media picks out of one, or several, by naming them as its from.
A media list is never what a slot's value IS: it is what a compute or a fill decision READS.
Every entry, bindable or readable, is a typed REF — the one handle a source:, a
compute's reads and a fill decision's reads all take. A ref carries the
value type its entry reads at, which is what types the argument a declaration
receives.
Constraints
Always a value you pass, never a call you make. Each entry is a literal, so a misspelled fact name is a compile error at the call site rather than a check-time failure.
Never an option saying where an edit goes: the source decides (Facts and provenance).
Never an extra key on the emitted binding. Container and value type reach you through the type and its doc comment, never as runtime properties, because the serialized source object is strict.
Never a fact and a fill at once: a slot declares its origin once, in
source:, and a value baked from a fact is not also generated. A source: is one
fact, slot, member, element or compute(), or an ordered list of fills — never a list
holding a derivation, which the builder refuses where it is declared.
Never a read-only entry as a source. The media lists (fact.property.uploads,
fact.property.property_media, fact.property.floor_plans,
fact.property.property_documents) and fact.property.description are
legal in any reads and illegal on a slot, and the split is
enforced by the type — the mistake is a compile error at the call site, not a
check-time failure. A slot showing the description binds
fact.property.description instead; a slot showing a photo picks it
(image({ from: fact.property.property_media, source: fill.pick({ brief }) })).
Never a bare branch. fact.property names no entry of its own, so it is neither a
binding nor a read; name the entry you want.
Never a table read by position. A table answers no index; a row says which element a member comes from, and the user can re-pick it.
Never a fact as the source: of a list item's field. A property fact is the same
value in every item, so the item reads its element or a row's member, and a fact
goes in the reads of the field's compute or fill instead.
Example
import { compute, fact, list, number, object, row, text } from "@homepages/concrete";
const primary = row({ label: "Primary home", from: fact.property.units, locked: true });
const sqft = number({ source: primary.sqft, label: "Square feet" });
const city = text.short({ source: fact.property.address.city, label: "City" });
const locality = text.short({
label: "Locality",
source: compute(
{ reads: [fact.property.address.city, fact.property.address.state] },
(town, region) => [town, region].filter((part) => part !== null).join(", "),
),
});
const agent = row({ label: "Agent", from: fact.property.contacts, locked: true });
const agentName = text.short({
source: agent.name,
label: "Agent",
cap: 40,
});
const agentPhone = text.short({ source: agent.phone, label: "Agent phone", cap: 40 });
const bedsLine = text.short({ source: primary.beds, label: "Beds" });
const units = list({
label: "Homes",
source: fact.property.units,
item: (el) => {
const unit = row({ label: "Home", from: fact.property.units, source: el });
const name = text.medium({ source: unit.label, label: "Home", cap: 20 });
return object({
label: name,
fields: {
unit,
name,
beds: number({ source: unit.beds, label: "Beds" }),
},
});
},
});Rules that apply
contract/source,
contract/row-rule,
contract/row-source,
contract/record-collection.
compute
Signature
import { compute, fact, section, text } from "@homepages/concrete";
const summary = text.short({
label: "Photo count",
source: compute({ reads: [fact.property.property_media] }, (media) => {
const photos = media.filter((asset) => asset.kind === "image");
return `${String(photos.length)} photos`;
}),
});
// In a real workspace this is imported from the other section's own module.
const Hero = section(
{
key: "hero",
label: "Hero",
slots: { property_name: text.short({ label: "Property name", source: fact.property.address.street }) },
},
() => null,
);
// One positional value per ref, facts and slots alike.
const propertyName = text.short({
label: "Property name",
source: compute(
{ reads: [fact.property.address, Hero.slots.property_name] },
(address, heroName) => heroName ?? address?.street ?? "",
),
});Parameters
compute({ reads }, fn) hands the callback ONE ARGUMENT PER REF, in reads
order, each at that ref's own value type. A fact ref is any fact.* entry
(fact.property.address, fact.property.uploads); a slot ref comes off another section's
value — Hero.slots.property_name for a slot, Hero.slots.agent.fields.contact
for a field of a top-level object, Video.display.visibility for a display entry.
The two mix freely in one list, and the callback sees exactly what
it listed and nothing else: there is no view of the whole property or the whole
site, so no section key can shadow a fact container and a body cannot reach a
value it did not declare.
The ORDER is the contract. Swap two refs and the parameters no longer describe what arrives, which is why a wrong positional type is a compile error and an unused parameter is a lint one.
Every SLOT read is | undefined. The section may be placed on no page of this
template, its page may be disabled, or the slot may simply be empty — three
different absences with one spelling, and the callback has to say what it does
with nothing. A FACT read is not: a fact settles before any fill, and carries its
own null where it has no value.
A read of a slot is the stored value whatever the upstream section's visibility; visibility is its own ref, and neither implies the other.
A slot of the SAME section is read through its own const — hoist it and name it,
reads: [headline] — because Section.slots.* does not exist until the section
does. Its value arrives at the sibling's own value type, | undefined, like any
slot read. A field of one of the section's top-level objects is a sibling too, read
by the const it was declared as, whether the reader is a top-level slot, a field of
the same or another object, or a field of a list's item. A field of a list's item is
never read this way: it holds one value per item, so no sibling can name it. The section's display entries read its slots the same way, a variant
included reading a slot it gates: when decides which fields the editor shows,
and every declared slot is filled whatever case the variant takes. A computed
entry settles once the section's fills have run, and again when an edit changes a
slot it reads, unless the user has set that entry themselves.
An address the section declares is read either way: whole, by its const
(reads: [place] hands over the AddressValue), or by part — place.city,
place.latitude — each part at its own type and null when absent, read through the address exactly as a row's member is read through the row.
A slot ref or a sibling const may also BE the source: — source: Hero.slots.title,
source: headline — which makes the slot a MIRROR: it holds exactly the upstream's
value, resolved wherever the content is read. A mirror is stored as the slot
ref itself, and an edit to it edits the upstream
(where an edit goes), a list's membership included. A row mirrors a row the
same way: a row the user re-picks is an object's field, whose card shows its bar,
and another section mirrors it through the object's field ref — a re-pick in the
card moves every mirror.
compute(() => X) reads nothing: a constant, called with no arguments. Every other
compute declares its reads, and those refs are exactly what the callback receives
and exactly what the section asks of the property. A table ref hands over its rows,
typed by the exported row types — FactsUnit, FactsCommercialSpace, FactsContact and
FactsComparable — so a named helper can say what it takes; an address reads as an
AddressValue. A table's row
is what the property holds: its id, each member under its own name (label on a
unit), null for an unanswered member, an image as its asset's record, and a
comparable's address as an address value.
A media read hands records wherever it lands. fact.property.uploads,
fact.property.property_media, fact.property.floor_plans and
fact.property.property_documents each read as
readonly Media[]: one record shape for every kind, narrowed by kind ("image",
"video", "tour" or "document") to ImageMedia, VideoMedia, TourMedia or
DocumentMedia. A record carries the upload's id, its kind, its name,
mime and bytes, a pasted link's url and provider, and added_at; and what
was learned about it — its account (what the platform learned of it, in plain
statements for a reader who cannot see it; a tour's and a linked video's from what its
provider states and its cover image, so who presents a tour, its rooms and its address
are there), a document's page_count, duration_ms, a video's poster_at_ms (the
instant, in milliseconds, of the frame a model chose as its poster), width, height,
captured_at and a tour's scan_count — each null when unknown. A subset is a read
of the sorted list that holds it, filtered by kind in the callback: the photos are
media.filter((asset) => asset.kind === "image") over fact.property.property_media, the
videos and tours the same filter on their kind, the floor plans
fact.property.floor_plans whole, the documents that set out the property's specifics
the same filter over fact.property.property_documents, and every document that filter
over fact.property.uploads — a hosted video's provider is null, and a document's
file name is its name. A unit's floor plan image, read through unit.floor_plans
or fact.property.units, is a Media; a contact's headshot is a Media or
null; a section's image slot read by a compute is its asset's record, not the
slot's framing.
A compute may hand a record it read straight to a media slot of its kind, and the
slot stores it as its reference:
image({ source: compute({ reads: [Gallery.slots.slides] }, (rows) => rows?.[0]?.photo ?? null) }).
Constraints
Always synchronous. A promise-returning callback collapses to an unassignable return type, so an async one fails to compile rather than running async at derive time.
Always a value of the kind the slot admits: the binding is checked against the slot's own value type, so a computation returning the wrong shape is a compile error.
Always handle absence. A property may carry no unit and no contact card, so a
row's member reads null when the row holds nothing, and the property's media may hold no photo, video or tour,
so a filter of it may come back empty.
Always a mirror at its upstream's kind: a value of its value type, a row from the
same table, a list of the same element. The upstream's value must be assignable to
the mirror's, checked where the mirror is written, and
relations/mirror-type re-checks the kinds the
build carries. A projection or a join is a compute, never a mirror.
Never React, and never a clock or a random source. The callback compiles into the section's logic bundle, which carries no React and must derive the same value twice from the same facts.
Never an inline closure you also want to test. Name it an export and hand the
name to compute(); an inlined function is unreachable from a test.
Never an undeclared read. The body's parameters ARE its reads, so there is
nothing else in scope to reach for — which is the contract, because an undeclared
read is a dependency the editor would never re-derive.
Never a loop. The sections of a template form a DAG over every read, so two
sections may not read each other, however indirectly
(relations/section-cycle), and a read names
only sections the site map places
(relations/unplaced-read). Inside one section a
const cannot be read before it is declared, so sibling reads cannot loop at all.
Example
import { compute, fact, select, text } from "@homepages/concrete";
export const priceLine = (intent: string | null): string =>
intent === "for_rent" ? "Per month" : "Asking price";
const label = text.short({ label: "Price label", source: compute({ reads: [fact.property.listing_intent] }, priceLine) });
const density = select({
from: ["gallery", "single"],
source: compute({ reads: [fact.property.property_media] }, (media) =>
media.filter((asset) => asset.kind === "image").length > 6 ? "gallery" : "single",
),
});A display entry takes the declared form with nothing added, which is how a section hides itself when another one is hidden:
import { compute, fact, section, select, text } from "@homepages/concrete";
const Video = section(
{
key: "video",
label: "Video",
display: {
visibility: select({
from: ["visible", "hidden"],
source: compute({ reads: [fact.property.uploads] }, (uploads) => (uploads.some((asset) => asset.kind === "video") ? "visible" : "hidden")),
}),
},
slots: { caption: text.short({ label: "Caption", source: fact.property.address.city }) },
},
() => null,
);
const visibility = select({
from: ["visible", "hidden"],
source: compute({ reads: [Video.display.visibility] }, (videoVisibility) => (videoVisibility === "hidden" ? "hidden" : "visible")),
});A mirror names the slot it holds, off another section or off a sibling const, and a
compute or a fill reads a sibling the same way:
import { compute, fact, fill, section, text } from "@homepages/concrete";
const Hero = section(
{
key: "hero",
label: "Hero",
slots: { title: text.short({ label: "Title", cap: 60, source: fact.property.address.street }) },
},
() => null,
);
const headline = text.medium({
label: "Headline",
cap: 80,
source: fill.write({ reads: [fact.property.description], brief: "One confident, specific sentence." }),
});
const Band = section(
{
key: "band",
label: "Band",
slots: {
headline,
title: text.short({ label: "Title", cap: 60, source: Hero.slots.title }),
footer_line: text.medium({ label: "Footer line", cap: 80, source: headline }),
eyebrow: text.short({
label: "Eyebrow",
cap: 80,
source: compute({ reads: [headline] }, (value) => value?.toUpperCase() ?? ""),
}),
subhead: text.medium({
label: "Subhead",
cap: 120,
source: fill.write({ reads: [headline, fact.property.description], brief: "One sentence that adds to the headline without repeating it." }),
}),
},
},
() => null,
);Rules that apply
contract/source,
contract/interpolation,
logic/section-build-failed,
server/no-nondeterminism,
relations/section-cycle,
relations/unplaced-read,
relations/mirror-type.
fill
Signature
import { fact, fill, image, list, poi, text } from "@homepages/concrete";
const headline = text.medium({
label: "Headline",
cap: 60,
source: fill.write({
reads: [fact.property.address, fact.property.description],
brief: "A marketing headline in one sentence. Confident, no exclamation marks.",
}),
});
const cover = image({
label: "Cover photo",
from: fact.property.property_media,
source: fill.pick({ brief: "The strongest exterior, in daylight." }),
});
const dining = list({
label: "Dining",
max: 3,
source: fill.find({
reads: [fact.property.address, fact.property.uploads],
brief: "Sit-down restaurants within walking distance.",
}),
item: poi(),
});Parameters
A fill has the model produce the slot's value, once. The slot holding it declares the output, the fill its verb and its input (AI fill).
fill.write({ brief, reads?, none? }) writes a value of its holder's kind: a
text slot is written, and a number is estimated — a figure the model proposes
for the user to confirm. As a list's source it writes every element at the list's
item (item: text.short({ cap: 40 })), and the list's min and max bound how
many. A write has no candidates.
fill.pick({ brief, reads?, unique? }) picks among its holder's
candidates, so whatever it picks is one of them — on every holder: the media of the
slot's kind in the lists its from names on an image, video, tour or
document (from: fact.property.property_media, fact.property.floor_plans for a floor
plan, fact.property.property_documents for a document of the property's specifics, or
fact.property.uploads; several in order are their union), which a pick on
a media slot always states, the keys on a select, the table or tables on a row
(fact.property.comparables), and on
a list the one candidate holder of its plain item — the item itself
(item: image({ from: fact.property.property_media })) or exactly one field
of its object item, which the item's other fields read by its const
(the kinds of list). Those
candidates are what the user may choose from too. A list's items take the order the answer gives them: best first, or the order the brief names ("order them as a walk through the property").
The model judges every candidate — it belongs, it does not, or it cannot tell — and
only one it is sure belongs is picked, so a pick that finds none leaves its slot empty;
the brief says what counts as belonging.
fill.find({ brief, reads?, none? }) finds places and addresses — a standalone
poi() or address(), an object's address() field, or a list of either. The model plans one place
search around the home from the brief and the reads, choosing the phrase and how far to look, then
chooses among the results; the platform's
place lookup supplies every stored field of each row, so a find names no candidate set. The
holder decides how many: a poi() takes exactly one, a list between its min and
max. With fact.property.uploads in its reads, the model reads the notes the
uploaded documents carry and aims the search so the places they name for the slot would be
among the results, putting them first when they are. A named place the search does not
surface is simply not picked.
An address is found the same way, except where the documents write it: the one street
address they write for the brief is looked up, with no search, and kept only
when the address found has the same street number and street and the same postal
code (or, when either gives none, the same city), a check by rule and not by the
model. The unit the documents write is
carried onto it. A written address that cannot be confirmed finds nothing. Every part and
the coordinates come from the lookup, and the
value's source is "resolved". A place the documents name without a street
address is not looked up, so the brief's search finds it instead.
A source: takes one fill or an ordered list of them —
source: [fill.pick({ brief: "The strongest exterior." }), fill.pick({ brief: "Any exterior." })]
— and source: f and source: [f] are one declaration. What the list yields follows
from its holder, never from an option: a list holds the union of what every fill
yields, in fill order; a single value, a row or an object's label holds the first
fill, in order, that yields one. Each fill is held to the slot as if it stood alone,
and every pick among them chooses from the same candidates, the holder's from.
brief is the whole instruction: what to write or pick, who reads it, its shape,
and who speaks where the text is someone's own words. It is the one prose key a fill
has. Phrasing a brief is how to write one.
reads is exactly what the model sees beside the brief, and nothing else: fact
refs (fact.property.address, fact.property.description, fact.property.uploads), slot refs
off other sections (Hero.slots.headline, Video.display.variant), a slot of the
same section through its own const, exactly as a compute reads one
(reads: [cover]), a member of a row or a part of an address in scope
(comp.distance_m, place.city), and — inside a
list's item — the element itself (photo). A fill reading a sibling runs after the
fill that writes it, so a second pick can be told to differ from the first, and a
display entry's fill, the section's last decision, is shown whatever its sibling
fills wrote. One fill's reads never widen another's. A pick needs none to see its
candidates — they are its holder's — but may read what its brief judges them against.
fact.property.uploads shows the model every upload as what is known about it —
its kind, name, caption and the rest, never a link or a storage key — and
the notes the uploaded documents carry ride along with it, which is what a find
looks places up in and what a write copies from.
none: true admits the empty answer — "" for text, null for a single asset or
a number, [] for a list. It is a switch: the brief's last sentence says when producing
nothing is right, and that sentence is the bar the model judges it against. Omit it
and an empty answer is a defect the platform retries. It is a write's and an address
find's: a pick's verdict already leaves its slot empty when no candidate belongs, and a
find of places — a poi() or a list of them — fills empty when it finds nothing,
whether or not it declares none, since no place of a kind nearby is an answer. An
address find without none that finds nothing — no address fits the brief, a written
address cannot be confirmed, or the home has no coordinates to search around — is a
failed fill: the slot keeps its previous value and the editor shows the failure.
unique is a pick's own: a pick is a set, so it is true by default, and a pick
inside a list's item never repeats an element across the items. unique: false
lifts the restriction and instructs nothing else.
A list is never padded. An answer outside the list's min and max is asked
again, up to three times; one still over is cut to max, and one still short is
kept as the model produced it. Whether a thin list's section still shows is its
visibility entry's call.
Constraints
Always a brief, and nothing but the verb's own options: the brief is the one
prose key, so tone, shape and person are sentences in it, and an unknown key is a
compile error. No verb takes count — the list's own min and max bound how
many items it fills — and none takes cap: a write's budget is its holder's
cap, the slot's own or the written list's item's, and a url, date, email
or phone has none, since its form bounds it.
Never a candidate set on a fill: a pick's candidates are its holder's from, and a picked
list's item is a plain declaration holding one — never a function, since a pick
supplies no element to call it with.
Always a max on a list a fill sources — a fill is an open supply, and the list
bounds it — and an item on a list a fill.write sources. A row takes only a
fill.pick.
Always the verb the kind admits. A text, number, url, date, email or
phone slot is written; a select, an
asset, a document and a row are picked; a place or an address, or a list of them,
is found — never written or picked. An option on a
slot that cannot enforce it is a compile error, a hoisted binding included, and
concrete check refuses one that reaches the built spec anyway.
Never a fill on a binding-only kind — a fact-sourced select — and
never on a top-level select with from: a
hand-written vocabulary is picked inside a list's object item, one key per item. A
display entry takes fill.pick({ brief, reads? }), choosing from the entry's
from exactly — it always resolves a case, so it never abstains.
A number takes a fill only for an estimate. A figure the platform holds — a
price the agent entered, a square footage, a comparable's sale — is a fact, and is
bound; a fill is for a figure that is a judgement, such as a suggested price band,
that the user confirms. A number field of a list's object item takes no fill.
Never a fill on a list's item: a list's fills produce the whole list, so they sit on
the list's source:. A field of an object item carries its own.
Never re-filled when a fact changes. A filled slot is not a bound one: the model produces it once, and after that the value is the user's, unlike a bound or computed slot.
Never a read of a SOURCED slot — a fact binding, a computed slot or a mirror —
which settles only after every fill has run
(relations/fill-reads-computed); a
sourced sibling is refused when the section is declared, a display entry's fill
included. Never a slot that is not in the section's slots record
(logic/section-build-failed).
Always a cap on a written text slot, and on a written list's item: that
cap is the budget the model writes to
(contract/cap).
Example
import { fact, fill, image, list, number, object, row, select, text } from "@homepages/concrete";
const EMPHASIS = ["regular", "highlight"] as const;
const gallery = list({
label: "Gallery",
max: 8,
source: fill.pick({
brief: "Every photograph of the property, ordered as a walk through it. Drop anything that is not a photograph of the property, and return none when nothing is.",
}),
item: image({ from: fact.property.property_media }),
});
const faq = list({
label: "Questions",
max: 5,
source: fill.write({
reads: [fact.property.address, fact.property.description],
brief: "Questions a buyer would ask, each on a different topic, each ending in a question mark.",
}),
item: (question) =>
object({
label: question,
fields: {
answer: text.long({
label: "Answer",
cap: 400,
source: fill.write({ reads: [fact.property.description, question], brief: "Answer the question plainly from the facts." }),
}),
},
}),
});
const comp = row({ label: "Comparable", from: fact.property.comparables });
const comps = list({
label: "Comparable sales",
max: 6,
source: fill.pick({ brief: "The nearest, most recent sold comparables, closest first." }),
item: object({
label: comp.address.street,
fields: {
comp,
price: number({ label: "Price", source: comp.price }),
emphasis: select({
label: "Emphasis",
from: EMPHASIS,
source: fill.pick({ reads: [comp.distance_m], unique: false, brief: "Highlight the closest sale." }),
}),
},
}),
});
Rules that apply
contract/fill-verb,
contract/cap,
contract/writer-reads-fact,
contract/list-fill,
contract/count-bounds,
contract/row-fill,
contract/poi-curation,
contract/reads-readable,
contract/interpolation,
contract/display-evidence,
contract/produces-known-slot,
relations/fill-reads-computed.
See also
slot builders for the head every origin rides on, Phrasing a brief for what a fill's brief must say, Facts and provenance for why a slot's provenance is declared beside it, and AI fill for why a fill is declared rather than prompted.
