use ingraph_codegen::tower::{Fan, Router, Stage, StepModel, TowerModel};
use crate::{attribute, errors::Errors, value};
#[cfg(test)]
mod tests;
pub(crate) fn parse(
input: &syn::DeriveInput,
arguments: &[syn::Attribute],
) -> syn::Result<TowerModel> {
let mut errors = Errors::default();
crate::host::refuse_a_moved_option_block(&input.attrs, &mut errors);
let (krate, question, answer) = options(arguments, &mut errors);
concrete(&input.generics, &mut errors);
let fields = match named_fields(input) {
Ok(fields) => fields,
Err(terminal) => return Err(errors.seal(terminal)),
};
let steps: Vec<StepModel> = fields
.named
.iter()
.filter_map(|field| {
let name = field.ident.clone()?;
Some(step(field, name, &mut errors))
})
.collect();
segments(&steps, &mut errors);
errors.into_result(TowerModel {
krate: krate.unwrap_or_else(|| syn::parse_quote!(::ingraph)),
name: input.ident.clone(),
vis: input.vis.clone(),
question,
answer,
steps,
})
}
fn options(
attrs: &[syn::Attribute],
errors: &mut Errors,
) -> (Option<syn::Path>, Option<syn::Type>, Option<syn::Type>) {
let mut krate: Option<syn::Path> = None;
let mut question: Option<syn::Type> = None;
let mut answer: Option<syn::Type> = None;
attribute::walk(attrs, errors, |meta, errors| {
if meta.path.is_ident("crate") {
match value::parse_literal::<syn::Path>(
&meta,
"`#[ingraph(crate = \"…\")]` must be a path to the `ingraph` crate, in a string literal",
) {
Ok(path) => attribute::set_once(
&mut krate,
path,
&meta.path,
"`crate` is declared more than once — one declaration names one crate",
errors,
),
Err(e) => refuse_value(&meta, e, errors),
}
return Ok(());
}
if meta.path.is_ident("question") {
return one_type(&meta, &mut question, &QUESTION, errors);
}
if meta.path.is_ident("answer") {
return one_type(&meta, &mut answer, &ANSWER, errors);
}
if let Some(word) = RETIRED_INLINE.iter().find(|word| meta.path.is_ident(*word)) {
errors.push(attribute::named(&meta, retired_inline(word)));
return Ok(());
}
errors.push(attribute::unknown(
&meta,
"unknown entry in `#[ingraph::tower(…)]` — it takes `question(type = \"…\")` (what the whole \
tower is asked), `answer(type = \"…\")` (what its chain must ARRIVE at, checked against the \
last step's own answer), each also spellable as `… = \"…\"`, and `crate = \"…\"`. WHAT the \
steps are is the declaration's own fields, and what each answers is the word beside it",
&["question", "answer", "crate"],
));
Ok(())
});
(krate, question, answer)
}
fn one_type<T: syn::parse::Parse>(
meta: &syn::meta::ParseNestedMeta<'_>,
seat: &mut Option<T>,
words: &OneType,
errors: &mut Errors,
) -> syn::Result<()> {
if attribute::has_value(meta) {
match value::parse_literal::<T>(meta, words.ty) {
Ok(named) => attribute::set_once(seat, named, &meta.path, words.twice, errors),
Err(e) => refuse_value(meta, e, errors),
}
return Ok(());
}
if !attribute::has_block(meta) || attribute::empty_group(meta) {
errors.push(attribute::unknown(meta, words.empty, &[]));
return Ok(());
}
let mut typed_at: Option<syn::Path> = None;
let mut refused = false;
let walked = meta.parse_nested_meta(|inner| {
if inner.path.is_ident("type") {
typed_at = Some(inner.path.clone());
match value::parse_literal::<T>(&inner, words.ty) {
Ok(named) => attribute::set_once(seat, named, &inner.path, words.twice, errors),
Err(e) => refuse_value(&inner, e, errors),
}
return Ok(());
}
refused = true;
errors.push(attribute::unknown(&inner, words.inner, &["type"]));
Ok(())
});
if let Err(e) = walked {
refused = true;
errors.push(e);
}
if seat.is_none() && typed_at.is_none() && !refused {
errors.push(syn::Error::new_spanned(&meta.path, words.empty));
}
Ok(())
}
fn step(field: &syn::Field, name: syn::Ident, errors: &mut Errors) -> StepModel {
let mut answer: Option<syn::Type> = None;
let mut answered_at: Option<syn::Path> = None;
let mut awaited: Option<syn::Path> = None;
let mut annotation: Option<syn::Type> = None;
let mut expander: Option<syn::Path> = None;
let mut routed: Option<Fan> = None;
attribute::walk(&field.attrs, errors, |meta, errors| {
if meta.path.is_ident("answer") {
answered_at.get_or_insert_with(|| meta.path.clone());
match value::parse_literal::<syn::Type>(&meta, STEP_ANSWER_TYPE) {
Ok(answered) => attribute::set_once(
&mut answer,
answered,
&meta.path,
"`answer` is declared more than once on this step — one step answers one type, and the \
next step's question is it",
errors,
),
Err(e) => refuse_value(&meta, e, errors),
}
return Ok(());
}
if meta.path.is_ident("async") {
if attribute::has_value(&meta) || attribute::has_block(&meta) {
errors.push(attribute::named(&meta, ASYNC_BARE.to_owned()));
return Ok(());
}
attribute::set_once(
&mut awaited,
meta.path.clone(),
&meta.path,
"`async` is declared more than once on this step — one step wears one face",
errors,
);
return Ok(());
}
if meta.path.is_ident(ANNOTATE) {
return one_type(&meta, &mut annotation, &ANNOTATION, errors);
}
if meta.path.is_ident(EXPAND) {
return one_type(&meta, &mut expander, &EXPANDER, errors);
}
if meta.path.is_ident(ROUTE) {
return route(&meta, &mut routed, &name, errors);
}
if meta.path.is_ident("options") {
errors.push(attribute::named(&meta, options_reserved(&name)));
return Ok(());
}
if meta.path.is_ident("name") {
errors.push(attribute::named(&meta, retired_name(&name)));
return Ok(());
}
errors.push(attribute::unknown(
&meta,
"unknown entry in `#[ingraph(…)]` on a step — a step takes `answer = \"…\"` (what it \
answers, which is the next step's question), `async` (which face its hop demands), and the \
three words that open a PIPELINE STAGE: `annotate(type = \"…\")`, where the question is \
enriched in place, `expand(type = \"…\")`, where it widens, and `route(router = …, slot = \
\"…\")`, where it crosses into one probe per lane. Its NAME is the field's own and its \
SERVER is the field's type, so neither has a word",
&["answer", "async", ANNOTATE, EXPAND, ROUTE],
));
Ok(())
});
let (annotation, fan) = segment(annotation, expander, routed, &name, errors);
if let (Some(fan), Some(at)) = (&fan, &awaited) {
errors.push(syn::Error::new_spanned(at, fan_wears_no_face(&name, fan)));
}
if let (Some(_), Some(at)) = (&annotation, &answered_at) {
errors.push(syn::Error::new_spanned(
at,
annotation_answers_itself(&name),
));
}
StepModel {
field: name.clone(),
ty: field.ty.clone(),
answer,
awaited: awaited.is_some(),
fan,
annotation,
}
}
fn fan_wears_no_face(field: &syn::Ident, fan: &Fan) -> String {
let (segment, face) = match fan {
Fan::Expand { .. } => (
"the WIDENING",
"an expansion awaits through the expand seam's own call face, and a blocking expander reaches \
it through the lift bridge",
),
Fan::Route { .. } => (
"the CROSSING",
"routing is pure computation over a question and a roster, so a router has one face and it is \
the blocking one",
),
};
format!(
"`async` names the face a step's SERVER wears, and `{field}` opens {segment} rather than \
holding a server — `{word}` puts the segment's own SEAT in this field, and a seat answers no \
`serve` call for a face to be about. What face the SEGMENT wears is not an author's to choose: \
{face}. Take the word off",
word = fan.word(),
)
}
fn segment(
annotation: Option<syn::Type>,
expander: Option<syn::Path>,
routed: Option<Fan>,
field: &syn::Ident,
errors: &mut Errors,
) -> (Option<syn::Type>, Option<Fan>) {
let written: Vec<&'static str> = [
annotation.is_some().then_some(ANNOTATE),
expander.is_some().then_some(EXPAND),
routed.is_some().then_some(ROUTE),
]
.into_iter()
.flatten()
.collect();
if written.len() > 1 {
errors.push(syn::Error::new_spanned(
field,
one_segment_per_step(field, &written),
));
return (None, None);
}
let fan = match (expander, routed) {
(Some(expander), _) => Some(Fan::Expand { expander }),
(None, routed) => routed,
};
(annotation, fan)
}
fn refuse_value(meta: &syn::meta::ParseNestedMeta<'_>, error: syn::Error, errors: &mut Errors) {
errors.push(error);
attribute::skip_entry(meta);
}
fn named_fields(input: &syn::DeriveInput) -> syn::Result<&syn::FieldsNamed> {
match &input.data {
syn::Data::Struct(data) => match &data.fields {
syn::Fields::Named(named) if !named.named.is_empty() => Ok(named),
syn::Fields::Named(named) => Err(syn::Error::new_spanned(named, EMPTY_TOWER)),
syn::Fields::Unit => Err(syn::Error::new_spanned(&input.ident, EMPTY_TOWER)),
syn::Fields::Unnamed(unnamed) => Err(syn::Error::new_spanned(unnamed, POSITIONAL_STEPS)),
},
syn::Data::Enum(_) | syn::Data::Union(_) => Err(syn::Error::new_spanned(
&input.ident,
"`#[ingraph::tower]` supports structs only — a tower's FIELDS are its steps, in the order \
they are walked, and variants are a choice between things rather than a chain of them",
)),
}
}
fn concrete(generics: &syn::Generics, errors: &mut Errors) {
const WHY: &str = "a tower takes no generic parameter — the emission states ONE chain over ONE \
declaration, and a parameter is not a type until it is substituted, so a \
generic tower would prove its connectivity for nobody";
if !generics.params.is_empty() {
errors.push(syn::Error::new_spanned(generics, WHY));
} else if let Some(clause) = &generics.where_clause {
errors.push(syn::Error::new_spanned(clause, WHY));
}
}
const RETIRED_INLINE: &[&str] = &["arm", "chain"];
fn retired_inline(word: &str) -> String {
format!(
"`{word}` is the RETIRED inline tower form — `tower(arm(chain(…)))`, written on an election. A \
tower is its OWN declaration now and its fields are its steps; what binds one to an index is \
the search recipe's own `tower(…)` word, so an election carries no tower vocabulary at all"
)
}
fn retired_name(field: &syn::Ident) -> String {
format!(
"`name` is the retired inline form's word — `{field}` already IS this step's name. Fields are \
steps, so one name serves the steps struct, the tower's options and the schema row, and there \
is no default for an override word to correct"
)
}
fn options_reserved(field: &syn::Ident) -> String {
format!(
"`options` is not a step's word. A step's knobs are its SERVER's own `Serve::Options` seat — \
`{field}`'s type declares it, not this declaration — and what a caller names reaches that seat \
through the emitted `<Tower>StepOptions`, which carries one row per step already. A step whose \
server seats `()` takes no knobs at all, so an options word written for one would be naming \
knobs nothing reads"
)
}
const ANNOTATE: &str = "annotate";
const EXPAND: &str = "expand";
const ROUTE: &str = "route";
const ROUTER: &str = "router";
const SLOT: &str = "slot";
const ANNOTATION: OneType = OneType {
empty: "`annotate` names no type — write `annotate = \"path::to::Annotation\"`, or \
`annotate(type = \"path::to::Annotation\")` for the full form. There is no bare word to \
write instead: what a question is enriched WITH is the declaring crate's own type, and a \
language tag, a detected script and a classified intent are all one mechanism here",
ty: "`annotate` names the TYPE this stage writes into the question — quoted, because the word \
names a type this declaration did not mint and the compiler resolves where the expansion \
lands. It is what the walk asks the question about before it spends the step's operator: a \
question already carrying one is handed on untouched",
twice: "`annotate` is declared more than once on this step — one step fills one annotation, and \
the full form and the sugar fill the same seat",
inner: "unknown entry in `annotate(…)` — it names the TYPE this stage writes into the question \
and nothing else. WHO writes it is the field's own type, and whether a caller already \
supplied one is the question's own answer rather than a word",
};
const EXPANDER: OneType = OneType {
empty: "`expand` names no type — write `expand = \"path::to::Expander\"`, or `expand(type = \
\"path::to::Expander\")` for the full form. There is no bare word to write instead: this \
framework ships no expander, so a synonym table, a spelling fixer and a translator are \
all the declaring crate's",
ty: "`expand` names the TYPE that widens this question — quoted, because the word names a type \
this declaration did not mint and the compiler resolves where the expansion lands. What it \
writes down is this declaration's DEFAULT; a deployment installs its own at launch",
twice: "`expand` is declared more than once on this step — one step opens one widening, and the \
full form and the sugar fill the same seat",
inner: "unknown entry in `expand(…)` — it names the TYPE that widens this question and nothing \
else. How wide a widening goes is the expander's own knobs, and what an arm is weighted \
by is the tower's own options",
};
fn route(
meta: &syn::meta::ParseNestedMeta<'_>,
seat: &mut Option<Fan>,
field: &syn::Ident,
errors: &mut Errors,
) -> syn::Result<()> {
if attribute::has_value(meta) {
errors.push(attribute::named(meta, route_has_no_sugar(field)));
return Ok(());
}
if !attribute::has_block(meta) || attribute::empty_group(meta) {
errors.push(attribute::named(meta, route_names_its_properties(field)));
return Ok(());
}
let mut written = RouteForm::default();
meta.parse_nested_meta(|property| {
match ROUTE_PROPERTIES
.iter()
.find(|known| property.path.is_ident(known.word))
{
Some(known) => (known.read)(&property, &mut written, field, errors),
None => {
written.refused = true;
errors.push(attribute::unknown(
&property,
&unknown_route_property(field),
&property_words(),
));
}
}
Ok(())
})?;
if let Some(fan) = settled(written, &meta.path, field, errors) {
attribute::set_once(seat, fan, &meta.path, &route_twice(field), errors);
}
Ok(())
}
struct RouteProperty {
word: &'static str,
read: fn(&syn::meta::ParseNestedMeta<'_>, &mut RouteForm, &syn::Ident, &mut Errors),
}
const ROUTE_PROPERTIES: &[RouteProperty] = &[
RouteProperty {
word: ROUTER,
read: read_router,
},
RouteProperty {
word: SLOT,
read: read_slot,
},
];
#[derive(Default)]
struct RouteForm {
router: Option<Router>,
router_spoken: bool,
slot: Option<syn::Path>,
slot_spoken: bool,
refused: bool,
}
fn read_router(
property: &syn::meta::ParseNestedMeta<'_>,
written: &mut RouteForm,
field: &syn::Ident,
errors: &mut Errors,
) {
if written.router_spoken {
errors.push(attribute::named(property, property_once(ROUTER, field)));
return;
}
written.router_spoken = true;
written.router = router_value(property, field, errors);
}
fn read_slot(
property: &syn::meta::ParseNestedMeta<'_>,
written: &mut RouteForm,
field: &syn::Ident,
errors: &mut Errors,
) {
if written.slot_spoken {
errors.push(attribute::named(property, property_once(SLOT, field)));
return;
}
written.slot_spoken = true;
match value::parse_literal::<syn::Path>(property, SLOT_IS_A_QUOTED_PATH) {
Ok(slot) => written.slot = Some(slot),
Err(e) => refuse_value(property, e, errors),
}
}
fn router_value(
property: &syn::meta::ParseNestedMeta<'_>,
field: &syn::Ident,
errors: &mut Errors,
) -> Option<Router> {
let Ok(stream) = property.value() else {
errors.push(attribute::named(property, router_shape(field)));
return None;
};
if stream.peek(syn::LitStr) {
return match stream
.parse::<syn::LitStr>()
.and_then(|spelled| spelled.parse::<syn::Path>())
{
Ok(path) => Some(Router::Declared(path)),
Err(e) => {
errors.push(syn::Error::new(e.span(), ROUTER_IS_A_PATH));
attribute::skip_entry(property);
None
}
};
}
if stream.peek(syn::Ident) {
let Ok(word) = stream.parse::<syn::Ident>() else {
errors.push(attribute::named(property, router_shape(field)));
return None;
};
let Some(shipped) = Router::shipped(&word.to_string()) else {
errors.push(syn::Error::new_spanned(
&word,
format!(
"{unknown}{suggestion}",
unknown = unshipped_router(&word),
suggestion = crate::suggest::did_you_mean(&word.to_string(), Router::SHIPPED),
),
));
attribute::skip_entry(property);
return None;
};
if !property.input.is_empty() && !property.input.peek(syn::Token![,]) {
errors.push(syn::Error::new_spanned(&word, router_shape(field)));
attribute::skip_entry(property);
return None;
}
return Some(shipped);
}
errors.push(attribute::named(property, router_shape(field)));
None
}
fn settled(
written: RouteForm,
at: &syn::Path,
field: &syn::Ident,
errors: &mut Errors,
) -> Option<Fan> {
if written.refused {
return None;
}
if !written.router_spoken {
errors.push(syn::Error::new_spanned(at, route_names_no_router(field)));
}
if !written.slot_spoken {
errors.push(syn::Error::new_spanned(at, route_names_no_slot(field)));
}
Some(Fan::Route {
router: written.router?,
slot: written.slot?,
})
}
fn property_words() -> Vec<&'static str> {
ROUTE_PROPERTIES.iter().map(|known| known.word).collect()
}
fn property_roster() -> String {
ROUTE_PROPERTIES
.iter()
.map(|known| format!("`{}`", known.word))
.collect::<Vec<_>>()
.join(" and ")
}
fn segments(steps: &[StepModel], errors: &mut Errors) {
let mut opened: Vec<(Stage, &syn::Ident)> = Vec::new();
for step in steps {
let Some(stage) = step.stage() else {
continue;
};
if let Some((_, first)) = opened.iter().find(|(seen, _)| *seen == stage) {
errors.push(syn::Error::new_spanned(
&step.field,
one_segment_per_kind(stage, first),
));
continue;
}
opened.push((stage, &step.field));
}
for pair in opened.windows(2) {
let [(first, at_first), (second, at_second)] = pair else {
continue;
};
if second < first {
errors.push(syn::Error::new_spanned(
at_first,
out_of_order(*first, at_first, *second, at_second),
));
}
}
}
fn route_has_no_sugar(field: &syn::Ident) -> String {
format!(
"`{ROUTE}` names TWO things and has no short spelling — write `{ROUTE}({ROUTER} = …, {SLOT} = \
\"path::to::Slot\")` on `{field}`. What makes a mis-wiring a compile error at the seat rather \
than a conversion somewhere in the middle is the EQUALITY between what the router answers and \
what one lane of the slot is asked with, and a form that names the router alone holds one half \
of it"
)
}
fn route_names_its_properties(field: &syn::Ident) -> String {
format!(
"`{ROUTE}` names no property — write `{ROUTE}({ROUTER} = …, {SLOT} = \"path::to::Slot\")` on \
`{field}`. It opens the segment where this question CROSSES into one probe per lane, and both \
halves of that crossing are named here: WHO chooses the lanes, and WHOSE lanes they are"
)
}
fn route_twice(field: &syn::Ident) -> String {
format!(
"`{ROUTE}` is declared more than once on `{field}` — one step opens one crossing, and a second \
lane fan is a second step"
)
}
fn route_names_no_router(field: &syn::Ident) -> String {
format!(
"`{ROUTE}(…)` on `{field}` names no `{ROUTER}` — write `{ROUTER} = {shipped}` for one this \
framework ships, or `{ROUTER} = \"path::to::Router\"` for the declaring crate's. The word \
decides WHO cuts a question into lanes, and a crossing with nothing to make that choice with \
would have to ask an arbitrary one",
shipped = Router::SHIPPED[2],
)
}
fn route_names_no_slot(field: &syn::Ident) -> String {
format!(
"`{ROUTE}(…)` on `{field}` names no `{SLOT}` — write `{SLOT} = \"path::to::Slot\"`. A slot is \
the `(elected field × engine)` pairing a declaration's own expansion minted, and it is what \
states the currency ONE LANE is asked in: without it the router's answer is checked against \
nothing"
)
}
fn property_once(word: &str, field: &syn::Ident) -> String {
format!(
"`{word}` is declared more than once in `{ROUTE}(…)` on `{field}` — one crossing has one of \
each"
)
}
fn unknown_route_property(field: &syn::Ident) -> String {
format!(
"unknown property in `{ROUTE}(…)` on `{field}` — the FULL FORM names the crossing's {roster} \
and nothing else: `{ROUTE}({ROUTER} = …, {SLOT} = \"path::to::Slot\")`. How DEEP a lane is \
read and what its score is floored at are the recipe's words, and what a lane is leaned on by \
is the tower's own options",
roster = property_roster(),
)
}
fn router_shape(field: &syn::Ident) -> String {
format!(
"`{ROUTER}` on `{field}` is a shipped router's BARE word or the declaring crate's own QUOTED \
path — `{ROUTER} = {shipped}`, or `{ROUTER} = \"path::to::Router\"`. It carries nothing else: \
what a router is built from is the slot's own roster, which the declaration already names",
shipped = Router::SHIPPED[2],
)
}
fn unshipped_router(word: &syn::Ident) -> String {
format!(
"`{word}` is not a router this framework ships. The bare words are {roster}; every other router \
there is arrives QUOTED — `{ROUTER} = \"path::to::Router\"` — because a bare word is a promise \
this crate can write the whole binding, which it can keep only for a type it ships",
roster = Router::SHIPPED
.iter()
.map(|word| format!("`{word}`"))
.collect::<Vec<_>>()
.join(", "),
)
}
const ROUTER_IS_A_PATH: &str = "`router = \"path::to::Router\"` names the type that cuts a question into lanes. It is QUOTED \
because it refers to a type this declaration did not mint, which is the law `expand` and the \
recipe's own `tower` word are written under; whether that type IS a lane router, and whether \
what it answers meets the slot's probe currency, are rustc's at the seat the expansion writes";
const SLOT_IS_A_QUOTED_PATH: &str = "`slot = \"path::to::Slot\"` names the slot whose lanes this crossing asks. It is QUOTED for \
`router`'s reason — the word names a type this declaration did not mint — and what a router \
wired to it must answer in is that slot's own `LanedStore::Probe`, checked where the compiler \
resolves both";
fn one_segment_per_step(field: &syn::Ident, written: &[&str]) -> String {
let words = written
.iter()
.map(|word| format!("`{word}`"))
.collect::<Vec<_>>()
.join(" and ");
format!(
"`{field}` writes {words}, and a step opens ONE segment. `{ANNOTATE}` is where a question is \
ENRICHED in place, `{EXPAND}` is where it WIDENS and `{ROUTE}` is where it CROSSES into probes \
— stages of one pipeline rather than facts about one hop, and writing them on separate steps \
is exactly how their order is stated"
)
}
fn one_segment_per_kind(stage: Stage, first: &syn::Ident) -> String {
let why = match stage {
Stage::Annotate => {
"a tower annotates ONE question: the stage fills the seat only where the caller left it \
empty, so a second stage over that seat would run exactly where the first did not — which \
is nowhere"
}
Stage::Expand => {
"a tower widens ONE question: the fold takes the original and its widenings as one family, \
and a second widening would be a family the dedup and the arm weights have no law for"
}
Stage::Route => {
"a tower has ONE lane fan: the weights compose one lane emphasis with one arm weight, and a \
second crossing would be probes in a second currency with no fold defined over them"
}
};
format!(
"`{word}` is already open at `{first}`, and {why}",
word = stage.word()
)
}
fn annotation_answers_itself(field: &syn::Ident) -> String {
format!(
"`answer` decides nothing on `{field}`, which opens the ANNOTATION stage — a step that \
annotates hands back the question it was given, so both of its ends are the type the chain \
already arrived at and there is no seat here for a word to fill. Take it off: what `{ANNOTATE}` \
names is the ANNOTATION's type, which is what the stage writes rather than what the step \
answers"
)
}
fn out_of_order(
later: Stage,
at_later: &syn::Ident,
earlier: Stage,
at_earlier: &syn::Ident,
) -> String {
format!(
"`{later_word}` on `{at_later}` comes before `{earlier_word}` on `{at_earlier}`, and the \
pipeline's stages run the other way round: {why}. Move the step; the order is not corrected \
here, because a tower's fields ARE its walk and a pass that reordered one would be rewriting \
the chain its author wrote",
later_word = later.word(),
earlier_word = earlier.word(),
why = earlier.why_first(),
)
}
struct OneType {
empty: &'static str,
ty: &'static str,
twice: &'static str,
inner: &'static str,
}
const QUESTION: OneType = OneType {
empty: "`question` names no type — write `question(type = \"path::to::Question\")`, or `question \
= \"path::to::Question\"` for the sugar",
ty: "`question` names the TYPE the whole tower is asked — quoted, because the word names a type \
this declaration cannot resolve and the compiler resolves where the expansion lands",
twice: "`question` is declared more than once — one tower is asked one type, and the full form \
and the sugar fill the same seat",
inner: "unknown entry in `question(…)` — it names the TYPE the whole tower is asked and nothing \
else. What each step answers is the word beside that step",
};
const ANSWER: OneType = OneType {
empty: "`answer` names no type — write `answer = \"path::to::Answer\"`, or `answer(type = \
\"path::to::Answer\")` for the full form. OMIT it where the tower's answer is simply \
whatever its last step arrives at",
ty: "`answer` names the TYPE the whole tower is pinned to answer — quoted, because the word names \
a type this declaration cannot resolve and the compiler resolves where the expansion lands",
twice: "`answer` is declared more than once at the tower — one tower answers one type, and the \
full form and the sugar fill the same seat",
inner: "unknown entry in `answer(…)` — it names the TYPE this tower's chain must arrive at and \
nothing else. The word DECIDES nothing: a tower answers what its last step answers, and \
this is the intent that derivation is checked against",
};
const STEP_ANSWER_TYPE: &str = "`answer` names the TYPE this step answers — quoted, because the word names a type this \
declaration cannot resolve and the compiler resolves where the expansion lands";
const ASYNC_BARE: &str = "`async` is a bare word here — it names the FACE this step's hop demands, and the step's body \
is its own author's, so there is nothing to configure";
const EMPTY_TOWER: &str = "a tower declares no step — its FIELDS are its steps, so one with none has no chain to state \
and no answer to name";
const POSITIONAL_STEPS: &str = "a tower must be a struct with NAMED fields — a field's name is the step's name, which is one \
name serving the steps struct, the tower's options and the schema row alike, and a positional \
field has none of them";