@lotics/cli 0.212.0 → 0.214.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/cli.js CHANGED
@@ -39098,10 +39098,12 @@ var SHAPE_REGISTRY = {
39098
39098
  level: slot("measure", false, { limit: true }),
39099
39099
  when: slot("when")
39100
39100
  },
39101
- // THE ROWS OF A DESK ARE EITHER THE JOB OR A LINE OF ONE, and only the
39102
- // `parent` role says which — so the door and the recipe come off it rather
39103
- // than off one constant that made a case and an itinerary line one screen.
39104
- archetype: { by: "parent", carrying: "line", alone: "work_record" },
39101
+ // THE ROWS OF A DESK ARE THE JOB, A LINE OF ONE, OR THE PARTY BEHIND BOTH:
39102
+ // `parent` says the rows belong to something, and being what another
39103
+ // entity's rows are NAMED by says those rows are what this entity's work is
39104
+ // about — so the door and the recipe come off those two rather than off one
39105
+ // constant that made a case, an itinerary line and an account one screen.
39106
+ archetype: { by: "parent", carrying: "line", alone: { named_by_rows: "profile", else: "work_record" } },
39105
39107
  tabs: "lifecycle",
39106
39108
  bands: BOTH_BANDS,
39107
39109
  lists: true,
@@ -39489,6 +39491,7 @@ function shapeFansObligations(shape) {
39489
39491
  }
39490
39492
  var CONTEXT_COLUMNS = 4;
39491
39493
  var SEATED_COLUMNS = 6;
39494
+ var HISTORY_ROWS = 5;
39492
39495
  function shapeDrawsColumns(shape) {
39493
39496
  return shapeListsRows(shape) && shapeRowsAreTable(shape) && !shapeFansObligations(shape);
39494
39497
  }
@@ -39524,11 +39527,29 @@ function layoutRefusal(drawn, layout) {
39524
39527
  if (offered.includes(layout)) return void 0;
39525
39528
  return `is drawn as a ${layout}, which these rows do not afford \u2014 they afford ${offered.join(", ")}`;
39526
39529
  }
39527
- function shapeMarksParty(shape) {
39528
- if (shape === CUSTOM_SHAPE) return false;
39529
- const declared = SHAPE_REGISTRY[shape];
39530
- return declared.archetype === "profile";
39530
+ function leadsWithMark(lead) {
39531
+ return lead === "mark" || lead === "picture" || lead === "paper";
39532
+ }
39533
+ function archetypeMarksParty(archetype) {
39534
+ return archetype === "profile";
39531
39535
  }
39536
+ var DRAWN_ROLES = [
39537
+ // WHAT THE ROW IS, first: the name the reader stated. A code the system
39538
+ // minted is the record's title and search key and never a column.
39539
+ "identity",
39540
+ "when",
39541
+ "lifecycle",
39542
+ // What the row IS, right after where it stands: a kind decides how the figures
39543
+ // beside it are read, so it outlives the money.
39544
+ "category",
39545
+ "amount",
39546
+ "measure",
39547
+ "expected_set",
39548
+ "party",
39549
+ "contact",
39550
+ "verdict"
39551
+ ];
39552
+ var columnPriority = (role) => DRAWN_ROLES.findIndex((drawn) => drawn === role) + 1;
39532
39553
 
39533
39554
  // ../shared/src/schemas/workspace_plan.ts
39534
39555
  var ARCHETYPE_DOOR = {
@@ -39563,13 +39584,13 @@ var contractPresentationSchema = zod_default.object({
39563
39584
  */
39564
39585
  until: contractAliasSchema.optional().describe("For a gantt: the date field each bar is drawn TO; absent, the bar runs for the days its measure counts")
39565
39586
  }).strict();
39566
- function leadRefusal(shape, drawn, lead) {
39587
+ function leadRefusal(archetype, drawn, lead) {
39567
39588
  if (lead === "none") return void 0;
39568
39589
  if (lead === "figure") {
39569
39590
  return drawn.has("amount") ? void 0 : "leads with the figure, and no column of these rows is drawn as their amount";
39570
39591
  }
39571
39592
  if (!drawn.has("mark")) return `leads with the ${lead}, and no column of these rows is drawn as their mark`;
39572
- if (shapeMarksParty(shape) === (lead === "mark")) return void 0;
39593
+ if (archetypeMarksParty(archetype) === (lead === "mark")) return void 0;
39573
39594
  if (lead === "mark") {
39574
39595
  return "leads with the mark, and these rows are things \u2014 a thing has no initials to stand in for a picture, so it leads with `picture`";
39575
39596
  }
@@ -39690,6 +39711,10 @@ var contractLensSchema = zod_default.strictObject({
39690
39711
  label: zod_default.string().min(1).describe("What the chip is called"),
39691
39712
  predicates: zod_default.array(contractPredicateSchema).min(1).describe("The sets it offers, in this order")
39692
39713
  }).describe("A lens the MODEL states as predicates over the entity's fields, where no select holds the answer");
39714
+ var contractMemberLensSchema = zod_default.strictObject({
39715
+ field: contractAliasSchema.describe("A select_member field of the entity \u2014 who the row is for"),
39716
+ default: zod_default.literal("mine").describe("The register opens narrowed to the reader's own rows")
39717
+ }).describe("A member field's lens, opened on the reader's own rows");
39693
39718
  var contractSnapshotSchema = zod_default.strictObject({
39694
39719
  field: contractAliasSchema.describe("The number field the reading is in"),
39695
39720
  at: zod_default.literal("end").describe("The reading STANDING at the window's end, rather than the sum of the readings in it")
@@ -39735,8 +39760,8 @@ var contractScreenSchema = zod_default.object({
39735
39760
  "Acts on the RECORD's own sections, keyed by the alias each section is derived from \u2014 a field alias (its progress, its prose, its set, its charge, its files) or a child entity's alias (its register, its desk, its run, its thread)"
39736
39761
  ),
39737
39762
  sections: zod_default.record(contractAliasSchema, contractSectionDrawSchema).optional().describe("How a section of the RECORD is DRAWN, keyed by the child entity alias its register is derived from"),
39738
- filters: zod_default.array(zod_default.union([contractAliasSchema, contractLensSchema])).min(1).optional().describe(
39739
- "The chips beside the search \u2014 a single-select field's alias, or a lens this model states as predicates over the entity's fields"
39763
+ filters: zod_default.array(zod_default.union([contractAliasSchema, contractLensSchema, contractMemberLensSchema])).min(1).optional().describe(
39764
+ `The chips beside the search \u2014 a single-select or select_member field's alias, \`{"field": \u2026, "default": "mine"}\` to open a member field on the reader's own rows, or a lens this model states as predicates over the entity's fields`
39740
39765
  ),
39741
39766
  facts: zod_default.object({
39742
39767
  groups: zod_default.array(
@@ -39822,14 +39847,14 @@ function resolveScreen(app, entityByAlias, roles, templates = [], rules = {}) {
39822
39847
  if (Object.hasOwn(slotSpec, name)) continue;
39823
39848
  findings.push({ severity: "error", path: `${path23}.slots.${name}`, message: `"${shapeLabel}" has no slot "${name}" \u2014 its slots are ${Object.keys(slotSpec).join(", ")}` });
39824
39849
  }
39825
- const stated2 = (name) => {
39850
+ const stated3 = (name) => {
39826
39851
  const clause = screen.slots?.[name];
39827
39852
  if (clause === void 0) return void 0;
39828
39853
  if (typeof clause === "string") return { field: clause };
39829
39854
  return Array.isArray(clause) ? { field: clause[0], tiers: clause.slice(1) } : clause;
39830
39855
  };
39831
39856
  if (entity === void 0) return { type: "invalid", findings };
39832
- const record2 = screen.record ?? recordDoor(screen.shape, entity, roles);
39857
+ const record2 = screen.record ?? recordDoor(screen.shape, entity, [...entityByAlias.values()], roles);
39833
39858
  const revealed = expandRefusal(screen.shape, record2);
39834
39859
  if (revealed !== void 0) findings.push({ severity: "error", path: `${path23}.record`, message: revealed });
39835
39860
  const arranged = revealedLayoutRefusal(record2, screen.presentation?.layout);
@@ -39839,7 +39864,7 @@ function resolveScreen(app, entityByAlias, roles, templates = [], rules = {}) {
39839
39864
  const slots = [];
39840
39865
  const boundBy = /* @__PURE__ */ new Map();
39841
39866
  for (const [name, spec] of Object.entries(slotSpec)) {
39842
- const clause = stated2(name);
39867
+ const clause = stated3(name);
39843
39868
  const named2 = clause?.field;
39844
39869
  const takes = spec.roles.map((role) => `"${role}"`).join(" or a ");
39845
39870
  let field = null;
@@ -40044,6 +40069,15 @@ function resolveColumns(path23, screen, entity, entities, fieldByAlias, boundBy,
40044
40069
  }
40045
40070
  return drawn;
40046
40071
  }
40072
+ function columnCountsRows(field) {
40073
+ return field.type === "rollup" && field.aggregate_option.operation === "count";
40074
+ }
40075
+ function countedThrough(entity, field) {
40076
+ if (field.type !== "rollup") return void 0;
40077
+ const through = entity.fields.find((candidate) => candidate.alias === field.source_field_alias);
40078
+ if (through?.type !== "select_record_link" || through.paired_field_alias === void 0) return void 0;
40079
+ return { child: through.target_entity, link: through.paired_field_alias };
40080
+ }
40047
40081
  function resolveScope(app, entity, entityByAlias, findings) {
40048
40082
  const declared = app.scope;
40049
40083
  if (declared === void 0) return null;
@@ -40068,19 +40102,33 @@ function resolveFilters(path23, screen, entity, entities, fieldByAlias, tabs, fi
40068
40102
  const declared = screen.filters;
40069
40103
  if (declared === void 0) return [];
40070
40104
  const at2 = `${path23}.filters`;
40071
- for (const dup of findDuplicates(declared.map((one) => typeof one === "string" ? one : one.label))) {
40105
+ for (const dup of findDuplicates(declared.map((one) => typeof one === "string" ? one : "field" in one ? one.field : one.label))) {
40072
40106
  findings.push({ severity: "error", path: at2, message: `names "${dup}" twice \u2014 one dimension is one chip` });
40073
40107
  }
40074
40108
  return declared.flatMap((one) => {
40075
- if (typeof one !== "string") return resolveDerivedLens(one, at2, entity, entities, findings);
40076
- const alias = one;
40109
+ if (typeof one !== "string" && !("field" in one)) return resolveDerivedLens(one, at2, entity, entities, findings);
40110
+ const mineFirst = typeof one !== "string";
40111
+ const alias = typeof one === "string" ? one : one.field;
40077
40112
  const field = fieldByAlias.get(alias);
40078
40113
  if (field === void 0) {
40079
40114
  findings.push({ severity: "error", path: at2, message: `names "${alias}", which is not a field of entity "${entity.alias}"` });
40080
40115
  return [];
40081
40116
  }
40117
+ if (field.type === "select_member") return [{ kind: "member", field, mineFirst }];
40118
+ if (mineFirst) {
40119
+ findings.push({
40120
+ severity: "error",
40121
+ path: at2,
40122
+ message: `opens "${alias}" on "mine", and it is a ${field.type} \u2014 the reader's own rows are the rows a select_member field names them on`
40123
+ });
40124
+ return [];
40125
+ }
40082
40126
  if (field.type !== "select") {
40083
- findings.push({ severity: "error", path: at2, message: `names "${alias}", a ${field.type} \u2014 a lens beside the search is a select field's options` });
40127
+ findings.push({
40128
+ severity: "error",
40129
+ path: at2,
40130
+ message: `names "${alias}", a ${field.type} \u2014 a lens beside the search is a select field's options, or a select_member field's "mine"`
40131
+ });
40084
40132
  return [];
40085
40133
  }
40086
40134
  if (field.multi === true) {
@@ -40195,13 +40243,13 @@ function actDuplicates(acts, at2, menu, findings) {
40195
40243
  function resolveActs(path23, screen, entity, roles, entityByAlias, rules, fieldByAlias, templates, findings) {
40196
40244
  const declared = screen.acts;
40197
40245
  if (declared === void 0) return { row: [], selection: [], record: [], export: null, import: null };
40198
- const stated2 = declared.row ?? [];
40246
+ const stated3 = declared.row ?? [];
40199
40247
  const at2 = `${path23}.acts.row`;
40200
- actDuplicates(stated2, at2, "a row's menu", findings);
40248
+ actDuplicates(stated3, at2, "a row's menu", findings);
40201
40249
  for (const refusal of ctaRefusals(declared)) {
40202
40250
  findings.push({ severity: "error", path: `${path23}.acts.${refusal.reach}`, message: refusal.message });
40203
40251
  }
40204
- const row = stated2.flatMap((act, index) => resolveAct(act, `${at2}.${index}`, screen, entity, roles, fieldByAlias, templates, findings));
40252
+ const row = stated3.flatMap((act, index) => resolveAct(act, `${at2}.${index}`, screen, entity, roles, fieldByAlias, templates, findings));
40205
40253
  const selection = resolveSelectionActs(path23, screen, entity, roles, fieldByAlias, templates, findings);
40206
40254
  const record2 = resolveRecordActs(path23, screen, entity, roles, fieldByAlias, templates, findings);
40207
40255
  return {
@@ -40386,13 +40434,13 @@ function resolveActWhen(declared, at2, entity, roles, fieldByAlias, findings) {
40386
40434
  return { field, in: declared.in };
40387
40435
  }
40388
40436
  function resolveActInputs(declared, at2, entity, fieldByAlias, findings) {
40389
- const stated2 = Object.entries(declared);
40390
- if (stated2.length === 0) {
40437
+ const stated3 = Object.entries(declared);
40438
+ if (stated3.length === 0) {
40391
40439
  findings.push({ severity: "error", path: at2, message: `hands its workflow nothing \u2014 name the input the row is sent under, as \`{"<input>": "record"}\`` });
40392
40440
  return void 0;
40393
40441
  }
40394
40442
  const inputs = [];
40395
- for (const [name, alias] of stated2) {
40443
+ for (const [name, alias] of stated3) {
40396
40444
  if (alias === RECORD_INPUT) {
40397
40445
  inputs.push({ name, field: null });
40398
40446
  continue;
@@ -40657,8 +40705,8 @@ var MONEY_HOPS = 8;
40657
40705
  function moneyOf(field, entity, entities, roles = {}, hops = 0) {
40658
40706
  const unit = statedMoney(field, entity, entities, roles, hops);
40659
40707
  if (unit === void 0 || hops > 0) return unit;
40660
- const stated2 = entity.fields.find((candidate) => roleOf(roles, entity.alias, candidate.alias)?.role === "currency");
40661
- return stated2 === void 0 ? unit : { ...unit, currencyField: stated2 };
40708
+ const stated3 = entity.fields.find((candidate) => roleOf(roles, entity.alias, candidate.alias)?.role === "currency");
40709
+ return stated3 === void 0 ? unit : { ...unit, currencyField: stated3 };
40662
40710
  }
40663
40711
  function statedMoney(field, entity, entities, roles, hops) {
40664
40712
  if (hops >= MONEY_HOPS) return void 0;
@@ -40731,27 +40779,30 @@ function measureAlert(entity, roles, fieldAlias) {
40731
40779
  function measureReadingOf(entity, roles, fieldAlias) {
40732
40780
  return roleOf(roles, entity.alias, fieldAlias)?.reading === "threshold" ? "threshold" : void 0;
40733
40781
  }
40734
- var RECORD_CHILD_VIA = ["parent", "party", "link"];
40782
+ var RECORD_CHILD_VIA = ["parent", "named", "link"];
40783
+ function viaOf(role) {
40784
+ if (role === "parent") return "parent";
40785
+ return role === "party" || role === "identity" ? "named" : "link";
40786
+ }
40735
40787
  var CHILD_COLUMN_ROLES = [
40736
40788
  "identity",
40737
- "mark",
40738
- "party",
40739
- "contact",
40740
40789
  "when",
40741
- "expected_set",
40742
- "measure",
40743
- "amount",
40744
40790
  "lifecycle",
40745
40791
  // What the row IS, after where it stands: a kind is read once the reader knows
40746
40792
  // which row this is and how it is going.
40747
40793
  "category",
40748
- "verdict"
40794
+ "amount",
40795
+ "measure",
40796
+ "expected_set",
40797
+ "party",
40798
+ "contact",
40799
+ "verdict",
40800
+ "mark"
40749
40801
  ];
40750
40802
  function childLinks(child, entity, roles, via) {
40751
40803
  return child.fields.filter((field) => {
40752
40804
  if (field.type !== "select_record_link" || field.target_entity !== entity.alias) return false;
40753
- const role = roleOf(roles, child.alias, field.alias)?.role;
40754
- return via === "link" ? role !== "parent" && role !== "party" : role === via;
40805
+ return viaOf(roleOf(roles, child.alias, field.alias)?.role) === via;
40755
40806
  });
40756
40807
  }
40757
40808
  function mirrorsOwnOneLink(entity, child, link) {
@@ -40764,6 +40815,15 @@ function mirrorsOwnOneLink(entity, child, link) {
40764
40815
  );
40765
40816
  return back.length === 1 && own.length === 1 && own[0].cardinality === "one";
40766
40817
  }
40818
+ function relationKey(child, link) {
40819
+ return `${child}.${link}`;
40820
+ }
40821
+ function drawsBothWays(field, drawn) {
40822
+ if (field.type !== "select_record_link" || field.sync_both_ways !== true || field.paired_field_alias === void 0) {
40823
+ return false;
40824
+ }
40825
+ return drawn.has(relationKey(field.target_entity, field.paired_field_alias));
40826
+ }
40767
40827
  function requiredSubset(entity, entities, roles, field, parent) {
40768
40828
  const requiredBy = roleOf(roles, entity.alias, field.alias)?.required_by;
40769
40829
  if (requiredBy === void 0) return void 0;
@@ -40791,11 +40851,15 @@ function owedRows(entity, roles, child, link) {
40791
40851
  function fieldsWithRole(entity, roles, role) {
40792
40852
  return entity.fields.filter((field) => roleOf(roles, entity.alias, field.alias)?.role === role);
40793
40853
  }
40854
+ function childWhen(child, roles) {
40855
+ return fieldsWithRole(child, roles, "when")[0];
40856
+ }
40794
40857
  function namingFields(entity, roles) {
40795
40858
  const named2 = fieldsWithRole(entity, roles, "identity");
40796
40859
  return named2.length > 0 ? named2 : fieldsWithRole(entity, roles, "reference");
40797
40860
  }
40798
40861
  function childTimeline(child, entities, roles) {
40862
+ if (fieldsWithRole(child, roles, "lifecycle").length > 0) return void 0;
40799
40863
  for (const planned of fieldsWithRole(child, roles, "obligation")) {
40800
40864
  const stamp = roleOf(roles, child.alias, planned.alias)?.satisfied_by;
40801
40865
  const actual = child.fields.find((candidate) => candidate.alias === stamp);
@@ -40828,6 +40892,19 @@ function childThread(child, roles, via) {
40828
40892
  ...awaiting === void 0 ? {} : { awaiting }
40829
40893
  };
40830
40894
  }
40895
+ function journalDay(child, roles) {
40896
+ const when = fieldsWithRole(child, roles, "when")[0];
40897
+ if (when !== void 0 && !countsDown(roleOf(roles, child.alias, when.alias))) return when;
40898
+ return child.fields.find((field) => field.type === "date" && roleOf(roles, child.alias, field.alias) === void 0);
40899
+ }
40900
+ function childJournal(child, roles, via) {
40901
+ if (via !== "parent" || fieldsWithRole(child, roles, "lifecycle").length > 0) return void 0;
40902
+ const body = child.fields.find((field) => field.type === "text" && field.format === "markdown");
40903
+ const when = journalDay(child, roles);
40904
+ if (body === void 0 || when === void 0) return void 0;
40905
+ const author = child.fields.find((field) => field.type === "select_member");
40906
+ return { body, when, ...author === void 0 ? {} : { author } };
40907
+ }
40831
40908
  function threadShortOf(child, roles) {
40832
40909
  if (fieldsWithRole(child, roles, "identity").length > 0) return void 0;
40833
40910
  if (!child.fields.some((field) => field.type === "text" && field.format === "markdown")) return void 0;
@@ -40857,23 +40934,26 @@ function recordKey(entity, roles, named2) {
40857
40934
  const spare = entity.fields.filter((field) => field.alias !== named2 && role(field) !== "identity");
40858
40935
  return spare.find((field) => role(field) === "parent") ?? spare.find((field) => role(field) === "reference") ?? spare.find((field) => field.type === "autonumber" && role(field) === void 0) ?? spare.find((field) => field.type === "formula" && formulaResultType(field.formula) === "text" && role(field) === void 0);
40859
40936
  }
40860
- function recordHeader(screen, roles) {
40937
+ function recordHeader(screen, entities, roles) {
40861
40938
  const bound = (role) => screen.slots.find((entry) => entry.role === role && entry.field !== null)?.field ?? void 0;
40862
40939
  const title = bound("identity") ?? namingFields(screen.entity, roles)[0];
40863
40940
  const measure = bound("measure");
40864
40941
  const level = measure === void 0 ? void 0 : measureAlert(screen.entity, roles, measure.alias);
40865
- const charge = recordCharge(screen.screen.shape, screen.entity, roles, screen.record);
40942
+ const charge = recordCharge(screen.screen.shape, screen.entity, entities, roles, screen.record);
40866
40943
  const inBand = /* @__PURE__ */ new Set([
40867
- ...bandFields(recordBand(screen.screen.shape, screen.entity, roles, screen.record)).map((field) => field.alias),
40944
+ ...bandFields(recordBand(screen.screen.shape, screen.entity, entities, roles, screen.record)).map((field) => field.alias),
40868
40945
  ...charge === void 0 ? [] : [charge.amount.alias]
40869
40946
  ]);
40870
- const archetype = recordArchetype(screen.screen.shape, screen.entity, roles);
40947
+ const archetype = recordArchetype(screen.screen.shape, screen.entity, entities, roles);
40871
40948
  const subtitle = recordKey(screen.entity, roles, title?.alias) ?? bound("when");
40872
40949
  const partySlot = screen.slots.find((entry) => entry.role === "party" && entry.field !== null);
40873
40950
  const party = archetype === "work_record" && screen.record === "page" ? partySlot === void 0 || partySlot.field === null ? fieldsWithRole(screen.entity, roles, "party") : [partySlot.field, ...partySlot.also] : [];
40874
40951
  const figure = bound("amount") ?? (level === void 0 ? measure : void 0);
40952
+ const lead = screen.screen.presentation?.lead;
40953
+ const mark = screen.record === "page" && (lead === void 0 || leadsWithMark(lead)) ? fieldsWithRole(screen.entity, roles, "mark")[0] : void 0;
40875
40954
  return {
40876
40955
  title,
40956
+ ...mark === void 0 ? {} : { mark },
40877
40957
  subtitle: subtitle === void 0 || inBand.has(subtitle.alias) ? void 0 : subtitle,
40878
40958
  party: party.filter((field) => !inBand.has(field.alias)),
40879
40959
  // Which number is THE figure is the screen's choice among the ones it
@@ -40898,17 +40978,17 @@ function recordHistory(entity, entities, roles) {
40898
40978
  const by = column(HISTORY_BY);
40899
40979
  return { plan: { child, link, stage, at: at2, ...by === void 0 ? {} : { by } }, child, back };
40900
40980
  }
40901
- function recordSections(entity, entities, roles, header, shape = CUSTOM_SHAPE, door = recordDoor(shape, entity, roles), drawn = void 0) {
40902
- const band = recordBand(shape, entity, roles, door);
40981
+ function recordSections(entity, entities, roles, header, shape = CUSTOM_SHAPE, door = recordDoor(shape, entity, entities, roles), drawn = void 0) {
40982
+ const band = recordBand(shape, entity, entities, roles, door);
40903
40983
  const lifecycle = fieldsWithRole(entity, roles, "lifecycle")[0];
40904
40984
  const flow = lifecycle === void 0 ? void 0 : roleOf(roles, entity.alias, lifecycle.alias);
40905
40985
  const history = recordHistory(entity, entities, roles);
40906
- const prose = recipeOf(shape, entity, roles, door).leads === "prose" ? entity.fields.filter((field) => field.type === "text" && field.format === "markdown") : [];
40907
- const charge = recordCharge(shape, entity, roles, door);
40986
+ const prose = recipeOf(shape, entity, entities, roles, door).leads === "prose" ? entity.fields.filter((field) => field.type === "text" && field.format === "markdown") : [];
40987
+ const charge = recordCharge(shape, entity, entities, roles, door);
40908
40988
  const ownSets = fieldsWithRole(entity, roles, "expected_set").filter(
40909
40989
  (field) => field.type === "select" && field.multi === true
40910
40990
  );
40911
- const files = fileFields(entity, roles);
40991
+ const files = fileFields(entity, roles).filter((field) => field.alias !== header.mark?.alias);
40912
40992
  const sets = ownSets.map((field) => ({
40913
40993
  kind: "expected_set",
40914
40994
  source: "own",
@@ -40917,12 +40997,16 @@ function recordSections(entity, entities, roles, header, shape = CUSTOM_SHAPE, d
40917
40997
  }));
40918
40998
  const children = [];
40919
40999
  const listed = /* @__PURE__ */ new Set();
41000
+ const drawnRelations = /* @__PURE__ */ new Set();
40920
41001
  for (const via of RECORD_CHILD_VIA) {
40921
41002
  for (const child of entities) {
40922
41003
  if (child.alias === history?.child.alias) continue;
40923
41004
  for (const link of childLinks(child, entity, roles, via)) {
40924
41005
  if (child.alias !== entity.alias && mirrorsOwnOneLink(entity, child, link)) continue;
40925
- if (child.alias !== entity.alias) listed.add(child.alias);
41006
+ if (child.alias !== entity.alias) {
41007
+ listed.add(child.alias);
41008
+ drawnRelations.add(relationKey(child.alias, link.alias));
41009
+ }
40926
41010
  const setField = fieldsWithRole(child, roles, "expected_set").find(
40927
41011
  (field) => field.type === "select" && field.multi !== true
40928
41012
  );
@@ -40953,6 +41037,11 @@ function recordSections(entity, entities, roles, header, shape = CUSTOM_SHAPE, d
40953
41037
  children.push({ kind: "thread", child, via, link, fields: byRole2, ...said, ...clock === void 0 ? {} : { clock } });
40954
41038
  continue;
40955
41039
  }
41040
+ const kept = childJournal(child, roles, via);
41041
+ if (kept !== void 0) {
41042
+ children.push({ kind: "journal", child, via, link, fields: byRole2, ...kept });
41043
+ continue;
41044
+ }
40956
41045
  const expected = owedRows(entity, roles, child, link);
40957
41046
  children.push({ kind: "children", child, via, link, fields: byRole2, ...expected === void 0 ? {} : { expected } });
40958
41047
  }
@@ -40982,12 +41071,13 @@ function recordSections(entity, entities, roles, header, shape = CUSTOM_SHAPE, d
40982
41071
  // changed among the facts — the strip is a way to act, not the place a
40983
41072
  // reader corrects an address.
40984
41073
  ...header.title === void 0 ? [] : [header.title],
41074
+ ...header.mark === void 0 ? [] : [header.mark],
40985
41075
  ...header.party,
40986
41076
  ...header.figure === void 0 ? [] : [header.figure]
40987
41077
  ].map((field) => field.alias)
40988
41078
  );
40989
41079
  const facts = entity.fields.filter(
40990
- (field) => !owned.has(field.alias) && (field.type !== "select_record_link" || field.cardinality === "one" || !listed.has(field.target_entity))
41080
+ (field) => !owned.has(field.alias) && !drawsBothWays(field, drawnRelations) && (field.type !== "select_record_link" || field.cardinality === "one" || !listed.has(field.target_entity))
40991
41081
  );
40992
41082
  const levels = {};
40993
41083
  for (const field of facts) {
@@ -41038,25 +41128,58 @@ function sectionAliases(section) {
41038
41128
  case "children":
41039
41129
  case "timeline":
41040
41130
  case "thread":
41131
+ case "journal":
41041
41132
  return [section.child.alias];
41042
41133
  case "files":
41043
41134
  return section.fields.map((field) => field.alias);
41044
41135
  }
41045
41136
  }
41046
- function recordArchetype(shape, entity, roles) {
41137
+ var COMPOSED_SECTIONS = ["thread", "journal"];
41138
+ function sectionRelation(section) {
41139
+ if (section.kind === "children" || section.kind === "timeline" || section.kind === "thread" || section.kind === "journal") {
41140
+ return { kind: section.kind, child: section.child, via: section.via, link: section.link };
41141
+ }
41142
+ if (section.kind === "expected_set" && section.source === "child") {
41143
+ return { kind: section.kind, child: section.child, via: section.via, link: section.link };
41144
+ }
41145
+ if (section.kind === "progress" && section.history !== void 0) {
41146
+ return { kind: "progress", child: section.history.child, via: "parent", link: section.history.link };
41147
+ }
41148
+ return void 0;
41149
+ }
41150
+ function recordAddsChild(entity, section, mounts) {
41151
+ const relation = sectionRelation(section);
41152
+ if (relation === void 0 || relation.via !== "parent" || relation.child.alias === entity.alias) return false;
41153
+ if (relation.kind === "progress") return false;
41154
+ return mounts || COMPOSED_SECTIONS.includes(relation.kind);
41155
+ }
41156
+ function recordArchetype(shape, entity, entities, roles) {
41047
41157
  if (shape === CUSTOM_SHAPE) return void 0;
41048
41158
  const declared = SHAPE_REGISTRY[shape];
41049
- return declared.archetype === void 0 ? void 0 : archetypeOf(declared.archetype, entity, roles);
41159
+ return declared.archetype === void 0 ? void 0 : archetypeOf(declared.archetype, entity, entities, roles);
41050
41160
  }
41051
- function recordDoor(shape, entity, roles) {
41161
+ function recordDoor(shape, entity, entities, roles) {
41052
41162
  if (shape === CUSTOM_SHAPE) return "drawer";
41053
41163
  const declared = SHAPE_REGISTRY[shape];
41054
41164
  if (declared.record !== void 0) return declared.record;
41055
- return ARCHETYPE_DOOR[archetypeOf(declared.archetype, entity, roles)];
41165
+ return ARCHETYPE_DOOR[archetypeOf(declared.archetype, entity, entities, roles)];
41056
41166
  }
41057
- function archetypeOf(declared, entity, roles) {
41167
+ function archetypeOf(declared, entity, entities, roles) {
41058
41168
  if (typeof declared === "string") return declared;
41059
- return fieldsWithRole(entity, roles, declared.by).length > 0 ? declared.carrying : declared.alone;
41169
+ if (fieldsWithRole(entity, roles, declared.by).length > 0) return declared.carrying;
41170
+ const alone = declared.alone;
41171
+ if (typeof alone === "string") return alone;
41172
+ return namedByRows(entity, entities, roles) ? alone.named_by_rows : alone.else;
41173
+ }
41174
+ function namedParties(entity, entities, roles) {
41175
+ return entities.flatMap((other) => {
41176
+ if (other.alias === entity.alias) return [];
41177
+ const links = childLinks(entity, other, roles, "named");
41178
+ return links.length === 0 ? [] : [{ entity: other, links }];
41179
+ });
41180
+ }
41181
+ function namedByRows(entity, entities, roles) {
41182
+ return entities.some((other) => namedParties(other, [entity], roles).length > 0);
41060
41183
  }
41061
41184
  function figureCell(entity, roles, field) {
41062
41185
  const decl = roleOf(roles, entity.alias, field.alias);
@@ -41075,9 +41198,9 @@ function remainderOf(entity, minuend, subtrahend) {
41075
41198
  return field.formula.expression.replace(/\{[^{}]*\}/g, "").trim() === "-";
41076
41199
  });
41077
41200
  }
41078
- function recordCharge(shape, entity, roles, door = recordDoor(shape, entity, roles)) {
41201
+ function recordCharge(shape, entity, entities, roles, door = recordDoor(shape, entity, entities, roles)) {
41079
41202
  const amount = fieldsWithRole(entity, roles, "amount")[0];
41080
- if (bandFields(recordBand(shape, entity, roles, door)).some((field) => field.alias === amount?.alias)) return void 0;
41203
+ if (bandFields(recordBand(shape, entity, entities, roles, door)).some((field) => field.alias === amount?.alias)) return void 0;
41081
41204
  if (amount === void 0 || amount.type !== "formula") return void 0;
41082
41205
  const operands = parseFieldRefTokens(amount.formula.expression).map(
41083
41206
  (token) => entity.fields.find((field) => field.alias === token)
@@ -41091,9 +41214,9 @@ function recordCharge(shape, entity, roles, door = recordDoor(shape, entity, rol
41091
41214
  return { amount, quantity: counted[0], unitPrice: priced[0] };
41092
41215
  }
41093
41216
  var BAND_CELLS = 4;
41094
- function recordBand(shape, entity, roles, door = recordDoor(shape, entity, roles)) {
41217
+ function recordBand(shape, entity, entities, roles, door = recordDoor(shape, entity, entities, roles)) {
41095
41218
  if (door !== "page") return void 0;
41096
- const archetype = recordArchetype(shape, entity, roles);
41219
+ const archetype = recordArchetype(shape, entity, entities, roles);
41097
41220
  const amount = fieldsWithRole(entity, roles, "amount")[0];
41098
41221
  if (archetype === "catalogue_item") {
41099
41222
  const against = amount === void 0 ? void 0 : roleOf(roles, entity.alias, amount.alias)?.against;
@@ -41104,12 +41227,10 @@ function recordBand(shape, entity, roles, door = recordDoor(shape, entity, roles
41104
41227
  if (archetype === "work_record") {
41105
41228
  const measure = fieldsWithRole(entity, roles, "measure")[0];
41106
41229
  const remainder = amount === void 0 || measure === void 0 ? void 0 : remainderOf(entity, amount, measure);
41107
- const due = recordDeadline(entity, roles);
41108
41230
  cells.push(
41109
41231
  ...amount === void 0 ? [] : [figureCell(entity, roles, amount)],
41110
41232
  ...measure === void 0 ? [] : [figureCell(entity, roles, measure)],
41111
- ...remainder === void 0 ? [] : [{ kind: "amount", field: remainder }],
41112
- ...due === void 0 ? [] : [{ kind: "countdown", field: due }]
41233
+ ...remainder === void 0 ? [] : [{ kind: "amount", field: remainder }]
41113
41234
  );
41114
41235
  }
41115
41236
  if (archetype === "profile") {
@@ -41120,8 +41241,10 @@ function recordBand(shape, entity, roles, door = recordDoor(shape, entity, roles
41120
41241
  }).map((field) => figureCell(entity, roles, field))
41121
41242
  );
41122
41243
  }
41123
- const stated2 = cells.slice(0, BAND_CELLS);
41124
- return stated2.length < 2 ? void 0 : { kind: "money", cells: [stated2[0], stated2[1], ...stated2.slice(2)] };
41244
+ const due = recordDeadline(entity, roles);
41245
+ const closing = due === void 0 ? [] : [{ kind: "countdown", field: due }];
41246
+ const stated3 = [...cells.slice(0, BAND_CELLS - closing.length), ...closing];
41247
+ return stated3.length < 2 ? void 0 : { kind: "money", cells: [stated3[0], stated3[1], ...stated3.slice(2)] };
41125
41248
  }
41126
41249
  var CONTACT_WORDS = [
41127
41250
  { kind: "email", words: ["email", "e-mail", "mail", "thu dien tu"] },
@@ -41135,7 +41258,7 @@ function contactReach(field) {
41135
41258
  const said = ` ${foldDiacritics(`${field.label} ${field.alias}`).toLowerCase().replace(/[^a-z0-9-]+/g, " ")} `;
41136
41259
  return CONTACT_WORDS.find(({ words }) => words.some((word) => said.includes(` ${word} `)))?.kind;
41137
41260
  }
41138
- function recordContacts(shape, entity, roles, door = recordDoor(shape, entity, roles)) {
41261
+ function recordContacts(entity, roles, door) {
41139
41262
  if (door !== "page") return [];
41140
41263
  return fieldsWithRole(entity, roles, "contact").filter((field) => contactReach(field) !== void 0);
41141
41264
  }
@@ -41203,6 +41326,12 @@ function registerRuns(screen, roles) {
41203
41326
  function screenWhen(screen, roles) {
41204
41327
  return screen.slots.find((entry) => entry.role === "when" && entry.field !== null)?.field ?? fieldsWithRole(screen.entity, roles, "when")[0];
41205
41328
  }
41329
+ function registerOrder(screen, roles) {
41330
+ const field = screenWhen(screen, roles);
41331
+ if (field === void 0) return void 0;
41332
+ const deadline = countsDown(roleOf(roles, screen.entity.alias, field.alias));
41333
+ return { field, direction: deadline || registerReadsForward(screen.screen.shape) ? "asc" : "desc", deadline };
41334
+ }
41206
41335
  function recordUntil(entity, roles, when) {
41207
41336
  const until = roleOf(roles, entity.alias, when.alias)?.until;
41208
41337
  if (until === void 0) return void 0;
@@ -41227,8 +41356,9 @@ var RECIPES = {
41227
41356
  children: "open",
41228
41357
  ledger: "open",
41229
41358
  // THE CORRESPONDENCE ABOUT THE WORK, after the work: a thread is read once
41230
- // the reader knows what it is about.
41359
+ // the reader knows what it is about, and so is the log kept about it.
41231
41360
  thread: "open",
41361
+ journal: "open",
41232
41362
  prose: "open",
41233
41363
  named_by: "related"
41234
41364
  },
@@ -41238,6 +41368,7 @@ var RECIPES = {
41238
41368
  charge: "open",
41239
41369
  ledger: "open",
41240
41370
  thread: "open",
41371
+ journal: "open",
41241
41372
  children: "open",
41242
41373
  expected_set: "open",
41243
41374
  prose: "open",
@@ -41246,6 +41377,12 @@ var RECIPES = {
41246
41377
  named_by: "related"
41247
41378
  },
41248
41379
  profile: {
41380
+ // WHERE THE ACCOUNT STANDS, AND THE ONE ACT THAT MOVES IT ON — first, the
41381
+ // same place a job leads with it. An account walks stages like any other
41382
+ // work, and under every history its ladder was seven bands down a page
41383
+ // nobody scrolls that far: a reader who came to move a prospect on read
41384
+ // four registers of what that prospect has already done instead.
41385
+ progress: "open",
41249
41386
  // THE HISTORY IS THE BODY. What a party's record is read for is the rows
41250
41387
  // that name it, so they stand OPEN — counted as one line at the end, a
41251
41388
  // profile would be a name, a phone number and four numbers in a list. ONE
@@ -41255,9 +41392,9 @@ var RECIPES = {
41255
41392
  children: "open",
41256
41393
  ledger: "open",
41257
41394
  thread: "open",
41395
+ journal: "open",
41258
41396
  expected_set: "open",
41259
41397
  charge: "open",
41260
- progress: "open",
41261
41398
  timeline: "open",
41262
41399
  prose: "open",
41263
41400
  facts: "open",
@@ -41272,6 +41409,7 @@ var RECIPES = {
41272
41409
  children: "open",
41273
41410
  ledger: "open",
41274
41411
  thread: "open",
41412
+ journal: "open",
41275
41413
  facts: "open",
41276
41414
  files: "open",
41277
41415
  named_by: "related"
@@ -41287,6 +41425,7 @@ var RECIPES = {
41287
41425
  children: "open",
41288
41426
  ledger: "open",
41289
41427
  thread: "open",
41428
+ journal: "open",
41290
41429
  named_by: "related"
41291
41430
  },
41292
41431
  plain: {
@@ -41300,12 +41439,14 @@ var RECIPES = {
41300
41439
  children: "open",
41301
41440
  ledger: "open",
41302
41441
  thread: "open",
41442
+ journal: "open",
41303
41443
  named_by: "related"
41304
41444
  }
41305
41445
  };
41306
- function recipeOf(shape, entity, roles, door) {
41307
- const steps = RECIPES[door === "expand" ? "line" : recordArchetype(shape, entity, roles) ?? "plain"];
41308
- return { steps, leads: Object.keys(steps)[0] };
41446
+ function recipeOf(shape, entity, entities, roles, door) {
41447
+ const archetype = drawnArchetype(recordArchetype(shape, entity, entities, roles), door);
41448
+ const steps = RECIPES[archetype ?? "plain"];
41449
+ return { archetype, steps, leads: Object.keys(steps)[0] };
41309
41450
  }
41310
41451
  function slotOf(section, roles) {
41311
41452
  if (section.kind !== "children") return section.kind;
@@ -41318,12 +41459,66 @@ function slotOf(section, roles) {
41318
41459
  function childRegisterShape(slot2) {
41319
41460
  return slot2 === "ledger" ? "transaction_ledger" : "lifecycle_desk";
41320
41461
  }
41321
- function recordRecipe(shape, entity, entities, roles, header, door = recordDoor(shape, entity, roles), drawn = void 0) {
41462
+ function restingScreen(args) {
41463
+ return {
41464
+ app: args.app,
41465
+ screen: {
41466
+ alias: args.alias,
41467
+ label: args.entity.label,
41468
+ shape: args.shape,
41469
+ entity: args.entity.alias,
41470
+ record: args.record,
41471
+ ...args.writes === void 0 ? {} : { writes: args.writes }
41472
+ },
41473
+ entity: args.entity,
41474
+ shapeLabel: SHAPE_REGISTRY[args.shape].label,
41475
+ record: args.record,
41476
+ tabs: null,
41477
+ slots: [],
41478
+ outcomes: {},
41479
+ columns: [],
41480
+ acts: { row: [], selection: [], record: [], export: null, import: null },
41481
+ summary: { columnTotals: [], bandTotals: [], above: null, ageing: null, trend: null },
41482
+ period: null,
41483
+ filters: [],
41484
+ obligations: [],
41485
+ factGroups: [],
41486
+ scope: null,
41487
+ sectionActs: /* @__PURE__ */ new Map()
41488
+ };
41489
+ }
41490
+ var PARTY_SHAPE = "party_register";
41491
+ function partySurfaces(register, entities, roles) {
41492
+ return namedParties(register.entity, entities, roles).map(({ entity, links }) => ({
41493
+ entity,
41494
+ links,
41495
+ screen: restingScreen({
41496
+ app: register.app,
41497
+ alias: entity.alias,
41498
+ entity,
41499
+ shape: PARTY_SHAPE,
41500
+ record: recordDoor(PARTY_SHAPE, entity, entities, roles),
41501
+ writes: register.screen.writes
41502
+ })
41503
+ }));
41504
+ }
41505
+ function drawnArchetype(archetype, door) {
41506
+ return door === "expand" ? "line" : archetype;
41507
+ }
41508
+ function recordRecipe(shape, entity, entities, roles, header, door = recordDoor(shape, entity, entities, roles), drawn = void 0) {
41322
41509
  const sections = recordSections(entity, entities, roles, header, shape, door, drawn);
41323
- const entries2 = Object.entries(recipeOf(shape, entity, roles, door).steps).flatMap(
41510
+ const { archetype, steps } = recipeOf(shape, entity, entities, roles, door);
41511
+ const entries2 = Object.entries(steps).flatMap(
41324
41512
  ([slot2, draw]) => sections.flatMap((section) => slotOf(section, roles) === slot2 ? [{ draw, slot: slot2, section }] : [])
41325
41513
  );
41326
41514
  const visiting = (entry) => entry.draw === "open" && entry.section.kind === "children" && entry.section.via !== "parent";
41515
+ if (archetype === "profile") {
41516
+ return entries2.map((entry) => {
41517
+ if (!visiting(entry)) return entry;
41518
+ const via = sectionRelation(entry.section)?.via;
41519
+ return { ...entry, draw: via === "named" ? "capped" : "related" };
41520
+ });
41521
+ }
41327
41522
  const first2 = entries2.findIndex(visiting);
41328
41523
  return entries2.map((entry, at2) => visiting(entry) && at2 !== first2 ? { ...entry, draw: "related" } : entry);
41329
41524
  }
@@ -41430,7 +41625,7 @@ function checkDeskStages(screen) {
41430
41625
  ];
41431
41626
  }
41432
41627
  function checkSeatedColumns(screen) {
41433
- const context = screen.columns.length;
41628
+ const context = screen.columns.filter((field) => !columnCountsRows(field)).length;
41434
41629
  const bySlots = screen.slots.filter((slot2) => slot2.field !== null && slot2.role !== "mark").length;
41435
41630
  if (context === 0 || bySlots + context <= SEATED_COLUMNS) return [];
41436
41631
  return [
@@ -41449,15 +41644,15 @@ function drawnColumns(screen, roles) {
41449
41644
  });
41450
41645
  }
41451
41646
  function checkPresentation(screen, roles, entities) {
41452
- const stated2 = screen.screen.presentation;
41453
- if (stated2 === void 0) return [];
41647
+ const stated3 = screen.screen.presentation;
41648
+ if (stated3 === void 0) return [];
41454
41649
  const path23 = `apps.${screen.app.alias}.screen.presentation`;
41455
41650
  const drawn = drawnColumns(screen, roles);
41456
41651
  const held = new Set(drawn.map((column) => column.role));
41457
41652
  return [
41458
- ...stated2.lead === void 0 ? [] : [leadRefusal(screen.screen.shape, held, stated2.lead)],
41459
- ...stated2.layout === void 0 ? [] : [layoutRefusal(drawn, stated2.layout)],
41460
- ...stated2.until === void 0 ? [] : [untilRefusal(screen, entities, drawn, stated2.until)]
41653
+ ...stated3.lead === void 0 ? [] : [leadRefusal(recordArchetype(screen.screen.shape, screen.entity, entities, roles), held, stated3.lead)],
41654
+ ...stated3.layout === void 0 ? [] : [layoutRefusal(drawn, stated3.layout)],
41655
+ ...stated3.until === void 0 ? [] : [untilRefusal(screen, entities, drawn, stated3.until)]
41461
41656
  ].flatMap((message2) => message2 === void 0 ? [] : [{ severity: "error", path: path23, message: message2 }]);
41462
41657
  }
41463
41658
  function untilRefusal(screen, entities, drawn, until) {
@@ -41479,7 +41674,7 @@ function untilRefusal(screen, entities, drawn, until) {
41479
41674
  function checkFactGroups(screen, entities, roles) {
41480
41675
  if (screen.factGroups.length === 0) return [];
41481
41676
  const path23 = `apps.${screen.app.alias}.screen.facts.groups`;
41482
- const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, roles), screen.screen.shape, screen.record, screen.screen.sections);
41677
+ const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.screen.shape, screen.record, screen.screen.sections);
41483
41678
  const facts = new Set(sections.flatMap((section) => section.kind === "facts" ? section.fields.map((field) => field.alias) : []));
41484
41679
  return screen.factGroups.flatMap(
41485
41680
  (group) => group.fields.flatMap(
@@ -41494,7 +41689,7 @@ function checkFactGroups(screen, entities, roles) {
41494
41689
  );
41495
41690
  }
41496
41691
  function childRegisters(screen, entities, roles) {
41497
- const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, roles), screen.screen.shape, screen.record, screen.screen.sections);
41692
+ const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.screen.shape, screen.record, screen.screen.sections);
41498
41693
  return new Map(sections.flatMap((section) => section.kind === "children" ? [[section.child.alias, section]] : []));
41499
41694
  }
41500
41695
  function checkSectionDraws(screen, entities, roles) {
@@ -41520,7 +41715,7 @@ function checkSectionDraws(screen, entities, roles) {
41520
41715
  {
41521
41716
  severity: "error",
41522
41717
  path: at2,
41523
- message: `names "${alias}", whose rows this record is merely the ${section.via} of \u2014 these draws are over the rows a record OWNS, and a line added to a history belongs to the job it is about rather than to what is reading it`
41718
+ message: `names "${alias}", whose rows this record does not OWN \u2014 these draws are over the rows a record owns, and a line added to a history belongs to the job it is about rather than to what is reading it`
41524
41719
  }
41525
41720
  ];
41526
41721
  }
@@ -41578,15 +41773,17 @@ function checkSectionDraws(screen, entities, roles) {
41578
41773
  });
41579
41774
  }
41580
41775
  function unregisteredChildren(screen, entities, roles, registered) {
41581
- const entries2 = recordRecipe(screen.screen.shape, screen.entity, entities, roles, recordHeader(screen, roles), screen.record, screen.screen.sections);
41776
+ const entries2 = recordRecipe(screen.screen.shape, screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.record, screen.screen.sections);
41582
41777
  const priced = new Set(
41583
41778
  Object.entries(screen.screen.sections ?? {}).flatMap(([alias, clause]) => clause.draw === "worksheet" ? [alias] : [])
41584
41779
  );
41585
41780
  const read2 = new Set(
41586
41781
  entries2.flatMap(({ draw, section }) => {
41587
- if (draw !== "open") return [];
41588
- if (section.kind === "children" || section.kind === "timeline") return [section.child.alias];
41589
- return section.kind === "expected_set" && section.source === "child" ? [section.child.alias] : [];
41782
+ if (draw !== "open" && draw !== "capped" || recordAddsChild(screen.entity, section, screen.record === "page")) return [];
41783
+ const relation = sectionRelation(section);
41784
+ if (relation === void 0) return [];
41785
+ if (relation.kind === "progress") return [];
41786
+ return COMPOSED_SECTIONS.includes(relation.kind) ? [] : [relation.child.alias];
41590
41787
  })
41591
41788
  );
41592
41789
  return [...read2].filter((alias) => !registered.has(alias) && !priced.has(alias));
@@ -41599,7 +41796,7 @@ function checkChildRegisters(screen, entities, roles, registered) {
41599
41796
  }));
41600
41797
  }
41601
41798
  function sectionActTargets(screen, entities, roles) {
41602
- const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, roles), screen.screen.shape, screen.record, screen.screen.sections);
41799
+ const sections = recordSections(screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.screen.shape, screen.record, screen.screen.sections);
41603
41800
  const found = /* @__PURE__ */ new Map();
41604
41801
  for (const alias of screen.sectionActs.keys()) {
41605
41802
  found.set(
@@ -41614,7 +41811,7 @@ function checkSectionActs(screen, entities, roles) {
41614
41811
  const targets = sectionActTargets(screen, entities, roles);
41615
41812
  const offered = [
41616
41813
  ...new Set(
41617
- recordSections(screen.entity, entities, roles, recordHeader(screen, roles), screen.screen.shape, screen.record, screen.screen.sections).flatMap(
41814
+ recordSections(screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.screen.shape, screen.record, screen.screen.sections).flatMap(
41618
41815
  (section) => sectionAliases(section)
41619
41816
  )
41620
41817
  )
@@ -41953,9 +42150,9 @@ function checkWriteRules(entities, rules, roles) {
41953
42150
  }
41954
42151
  return findings;
41955
42152
  }
41956
- function checkDefaultFrom(entity, field, stated2, byAlias2, path23) {
42153
+ function checkDefaultFrom(entity, field, stated3, byAlias2, path23) {
41957
42154
  const entities = [...byAlias2.values()];
41958
- const [linkAlias, sourceAlias] = stated2.split(".");
42155
+ const [linkAlias, sourceAlias] = stated3.split(".");
41959
42156
  const link = entity.fields.find((one) => one.alias === linkAlias);
41960
42157
  if (link === void 0 || link.type !== "select_record_link") {
41961
42158
  return [
@@ -42733,7 +42930,7 @@ function resultSideEffects(result) {
42733
42930
  }
42734
42931
 
42735
42932
  // src/version.ts
42736
- var VERSION = "0.212.0";
42933
+ var VERSION = "0.214.0";
42737
42934
 
42738
42935
  // src/timezone.ts
42739
42936
  function machineTimezone() {
@@ -51249,6 +51446,7 @@ function optionsQueryAlias(target, display) {
51249
51446
  return `${target}_${display}_options`;
51250
51447
  }
51251
51448
  var OPTIONS_SEARCH_PARAM = "search";
51449
+ var MINE_PARAM = "mine";
51252
51450
  var str = (value) => JSON.stringify(value);
51253
51451
  function pascal(alias) {
51254
51452
  return alias.split(/[^a-zA-Z0-9]+/).filter((part) => part !== "").map((part) => part[0].toUpperCase() + part.slice(1)).join("");
@@ -51344,18 +51542,6 @@ var WORDS = {
51344
51542
  }
51345
51543
  }
51346
51544
  };
51347
- function sectionRelation(section) {
51348
- if (section.kind === "children" || section.kind === "timeline" || section.kind === "thread") {
51349
- return { kind: section.kind, child: section.child, via: section.via, link: section.link };
51350
- }
51351
- if (section.kind === "expected_set" && section.source === "child") {
51352
- return { kind: section.kind, child: section.child, via: section.via, link: section.link };
51353
- }
51354
- if (section.kind === "progress" && section.history !== void 0) {
51355
- return { kind: "progress", child: section.history.child, via: "parent", link: section.history.link };
51356
- }
51357
- return void 0;
51358
- }
51359
51545
  function sectionChild(section) {
51360
51546
  return sectionRelation(section)?.child;
51361
51547
  }
@@ -51364,37 +51550,16 @@ function childQueryAlias(entity, child, link) {
51364
51550
  }
51365
51551
  function childSurfaceScreen(parent, entry, mounts) {
51366
51552
  const relation = sectionRelation(entry.section);
51367
- if (relation === void 0 || relation.via !== "parent" || relation.child.alias === parent.entity.alias) return void 0;
51368
- if (relation.kind === "progress") return void 0;
51369
- if (!mounts && relation.kind !== "thread") return void 0;
51553
+ if (relation === void 0 || !recordAddsChild(parent.entity, entry.section, mounts)) return void 0;
51370
51554
  const { child, link } = relation;
51371
- const shape = childRegisterShape(entry.slot);
51372
- return {
51555
+ return restingScreen({
51373
51556
  app: parent.app,
51374
- screen: {
51375
- alias: childQueryAlias(parent.entity.alias, child.alias, link.alias),
51376
- label: child.label,
51377
- shape,
51378
- entity: child.alias,
51379
- record: "drawer",
51380
- ...parent.screen.writes === void 0 ? {} : { writes: parent.screen.writes }
51381
- },
51557
+ alias: childQueryAlias(parent.entity.alias, child.alias, link.alias),
51382
51558
  entity: child,
51383
- shapeLabel: SHAPE_REGISTRY[shape].label,
51559
+ shape: childRegisterShape(entry.slot),
51384
51560
  record: "drawer",
51385
- tabs: null,
51386
- slots: [],
51387
- outcomes: {},
51388
- columns: [],
51389
- acts: { row: [], selection: [], record: [], export: null, import: null },
51390
- summary: { columnTotals: [], bandTotals: [], above: null, ageing: null, trend: null },
51391
- period: null,
51392
- filters: [],
51393
- obligations: [],
51394
- factGroups: [],
51395
- scope: null,
51396
- sectionActs: /* @__PURE__ */ new Map()
51397
- };
51561
+ writes: parent.screen.writes
51562
+ });
51398
51563
  }
51399
51564
  function unfiled(entry, under) {
51400
51565
  if (under === void 0 || entry.section.kind !== "facts") return [entry];
@@ -51405,26 +51570,7 @@ function sectionHeading(child, link, sections, draw) {
51405
51570
  const reaching = sections.filter((entry) => entry.draw === draw && sectionChild(entry.section)?.alias === child.alias);
51406
51571
  return reaching.length > 1 ? `${child.label} (${link.label})` : child.label;
51407
51572
  }
51408
- var DRAWN_ROLES = [
51409
- // WHO OR WHAT THE ROW IS, first: the name the reader stated, then the party
51410
- // it is about — a case is scanned by its customer, a payment by its
51411
- // counterparty. A code the system minted is the record's title and search
51412
- // key and never a column ({@link drawnAsColumn}).
51413
- "identity",
51414
- "party",
51415
- "lifecycle",
51416
- // What the row IS, right after where it stands: a kind decides how the figures
51417
- // beside it are read, so it outlives the clock and the money.
51418
- "category",
51419
- "when",
51420
- "amount",
51421
- "measure",
51422
- "expected_set",
51423
- "contact",
51424
- "verdict"
51425
- ];
51426
51573
  var drawnAsColumn = (role, field) => DRAWN_ROLES.includes(role) && (role !== "identity" || isEditable(field));
51427
- var columnPriority = (role) => DRAWN_ROLES.indexOf(role) + 1;
51428
51574
  var RECORD_CHILD_COLUMNS = 4;
51429
51575
  function shownOnRecord(drawn, roles) {
51430
51576
  if (drawn.length <= RECORD_CHILD_COLUMNS) return [...drawn];
@@ -51660,9 +51806,10 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51660
51806
  if (!scopes.has(entity.alias)) scopes.set(entity.alias, readRowRule(entity, fields, groups, missing));
51661
51807
  return scopes.get(entity.alias);
51662
51808
  };
51663
- const bindOne = (screen2, at2, under) => {
51809
+ const bindOne = (screen2, at2, names, under) => {
51664
51810
  const mounts = under === void 0 && screen2.record === "page";
51665
- const header = recordHeader(screen2, roles);
51811
+ const header = recordHeader(screen2, entities, roles);
51812
+ const archetype = recordArchetype(screen2.screen.shape, screen2.entity, entities, roles);
51666
51813
  const identity = header.title ?? null;
51667
51814
  const limits = /* @__PURE__ */ new Map();
51668
51815
  const wanted2 = [
@@ -51688,7 +51835,7 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51688
51835
  if (own === void 0) return void 0;
51689
51836
  const subject = bindSubject(at2, screen2, entities, roles, aliased, live, scopeOf, missing);
51690
51837
  const narrowing = subject === void 0 ? void 0 : scopeNarrowing(screen2, subject, own.fields);
51691
- const band = recordBand(screen2.screen.shape, screen2.entity, roles, screen2.record);
51838
+ const band = recordBand(screen2.screen.shape, screen2.entity, entities, roles, screen2.record);
51692
51839
  const sections = recordRecipe(screen2.screen.shape, screen2.entity, entities, roles, header, screen2.record, screen2.screen.sections).flatMap(
51693
51840
  (entry2) => unfiled(entry2, under)
51694
51841
  );
@@ -51709,8 +51856,8 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51709
51856
  const conditions = narrowing2 === void 0 ? void 0 : optionsWhereConditions(narrowing2, target);
51710
51857
  const sourceAliases = new Set(
51711
51858
  owner.fields.flatMap((candidate) => {
51712
- const stated2 = writeRuleOf(rules, owner.alias, candidate.alias)?.default_from;
51713
- return stated2 === void 0 || !stated2.startsWith(`${field.alias}.`) ? [] : [stated2.slice(field.alias.length + 1)];
51859
+ const stated3 = writeRuleOf(rules, owner.alias, candidate.alias)?.default_from;
51860
+ return stated3 === void 0 || !stated3.startsWith(`${field.alias}.`) ? [] : [stated3.slice(field.alias.length + 1)];
51714
51861
  })
51715
51862
  );
51716
51863
  const sourceFields = target.fields.filter((candidate) => sourceAliases.has(candidate.alias));
@@ -51777,7 +51924,7 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51777
51924
  if (relation === void 0) return;
51778
51925
  const { slot: step, draw } = entry2;
51779
51926
  const { kind, child, via, link: linkField } = relation;
51780
- const itinerary = draw === "related" ? void 0 : recordItinerary(recordArchetype(screen2.screen.shape, screen2.entity, roles), step, child, roles);
51927
+ const itinerary = draw === "open" ? recordItinerary(archetype, step, child, roles) : void 0;
51781
51928
  const operandAliases = /* @__PURE__ */ new Set([
51782
51929
  // The row's own currency is read the same way: a figure printed in the
51783
51930
  // workspace's money on a line the business quoted in another is a wrong
@@ -51815,7 +51962,7 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51815
51962
  const scoped = new Set((child.read_scope?.any ?? []).flatMap((clause) => "field" in clause ? [clause.field] : []));
51816
51963
  const scopeFields = child.fields.filter((field) => scoped.has(field.alias));
51817
51964
  const opened = childSurfaceScreen(screen2, entry2, mounts);
51818
- const surface = opened === void 0 ? void 0 : bindOne(opened, `${at2}.${child.alias}`, linkField);
51965
+ const surface = opened === void 0 ? void 0 : bindOne(opened, `${at2}.${child.alias}`, false, linkField);
51819
51966
  if (opened !== void 0 && surface === void 0) return;
51820
51967
  const found = surface === void 0 ? bindTable(`${at2}.${child.alias}`, child, entities, roles, [linkField, ...drawn, ...operandFields, ...scopeFields], aliased, live, missing) : { table: surface.table, tableAlias: surface.tableAlias, fields: surface.fields };
51821
51968
  if (found === void 0) return;
@@ -51836,7 +51983,8 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51836
51983
  if (boundField !== void 0 && !fields.has(field.alias)) operands.set(field.alias, boundField);
51837
51984
  }
51838
51985
  const scope2 = scopeOf(child, found.fields);
51839
- const when = child.fields.find((field) => roleOf(roles, child.alias, field.alias)?.role === "when");
51986
+ const logged = entry2.section.kind === "journal" ? entry2.section.when : void 0;
51987
+ const when = logged ?? childWhen(child, roles);
51840
51988
  const dated = when === void 0 ? void 0 : found.fields.get(when.alias);
51841
51989
  const runSlot2 = itinerary?.slot === void 0 ? void 0 : found.fields.get(itinerary.slot.alias);
51842
51990
  const order = dated === void 0 ? void 0 : {
@@ -51882,6 +52030,14 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51882
52030
  bindChild(entry2, section.fields, void 0, void 0, void 0, [section.body]);
51883
52031
  continue;
51884
52032
  }
52033
+ if (section.kind === "journal") {
52034
+ bindChild(entry2, section.fields, void 0, void 0, void 0, [
52035
+ section.body,
52036
+ section.when,
52037
+ ...section.author === void 0 ? [] : [section.author]
52038
+ ]);
52039
+ continue;
52040
+ }
51885
52041
  if (section.kind === "progress") {
51886
52042
  const history = section.history;
51887
52043
  if (history !== void 0) {
@@ -51914,16 +52070,31 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51914
52070
  section.filesField
51915
52071
  );
51916
52072
  }
52073
+ const parties = /* @__PURE__ */ new Map();
52074
+ for (const party of names ? partySurfaces(screen2, entities, roles) : []) {
52075
+ const surface = bindOne(party.screen, `${at2}.${party.entity.alias}`, false);
52076
+ if (surface === void 0) continue;
52077
+ const bound = party.links.flatMap((link) => {
52078
+ const field = own.fields.get(link.alias);
52079
+ return field === void 0 ? [] : [field];
52080
+ });
52081
+ if (bound.length > 0) parties.set(party.entity.alias, { surface, links: bound });
52082
+ }
51917
52083
  const scope = scopeOf(screen2.entity, own.fields);
51918
52084
  const mark = screen2.entity.fields.find((field) => roleOf(roles, screen2.entity.alias, field.alias)?.role === "mark");
51919
- const whenField = screenWhen(screen2, roles);
51920
- const day = whenField === void 0 ? void 0 : own.fields.get(whenField.alias);
52085
+ const ordered = registerOrder(screen2, roles);
52086
+ const dayField = ordered === void 0 ? void 0 : own.fields.get(ordered.field.alias);
52087
+ const day = ordered === void 0 || dayField === void 0 ? void 0 : { field: dayField, direction: ordered.direction };
51921
52088
  const runs = registerRuns(screen2, roles);
51922
52089
  const runSlot = runs === void 0 ? void 0 : own.fields.get(runs.slot.alias);
52090
+ const memberLens = screen2.filters.find((lens) => lens.kind === "member");
52091
+ const memberField = memberLens === void 0 ? void 0 : own.fields.get(memberLens.field.alias);
52092
+ const mine = memberLens === void 0 || memberField === void 0 ? void 0 : { field: memberField, param: MINE_PARAM, first: memberLens.mineFirst };
51923
52093
  const entry = {
51924
52094
  screen: screen2,
51925
52095
  table: own.table,
51926
52096
  tableAlias: own.tableAlias,
52097
+ ...archetype === void 0 ? {} : { archetype },
51927
52098
  header,
51928
52099
  ...band === void 0 ? {} : { band },
51929
52100
  fields: own.fields,
@@ -51931,11 +52102,13 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51931
52102
  sections,
51932
52103
  children,
51933
52104
  mounts,
52105
+ parties,
51934
52106
  links,
51935
52107
  createLinks,
51936
52108
  words,
51937
52109
  rules,
51938
52110
  ...mark === void 0 ? {} : { mark: mark.alias },
52111
+ ...mine === void 0 ? {} : { mine },
51939
52112
  ...day === void 0 ? {} : { day },
51940
52113
  ...day === void 0 || runSlot === void 0 ? {} : { runSlot },
51941
52114
  ...scope === void 0 ? {} : { scope },
@@ -51963,7 +52136,7 @@ function bindScreen(screen, live, roles, entities, rules, groups = /* @__PURE__
51963
52136
  }
51964
52137
  return entry;
51965
52138
  };
51966
- return { bound: bindOne(screen, screen.app.alias), missing };
52139
+ return { bound: bindOne(screen, screen.app.alias, true), missing };
51967
52140
  }
51968
52141
  var STATED_FIELD_TYPES = [
51969
52142
  "text",
@@ -52011,15 +52184,15 @@ function mintedWith(target, display, keys2) {
52011
52184
  function inputNames(field, bound) {
52012
52185
  return fieldInputs(bound.alias, field.type);
52013
52186
  }
52014
- function countedRelations(entry) {
52187
+ function handedOnRelations(entry) {
52015
52188
  return entry.sections.flatMap(({ draw, section }) => {
52016
- if (draw !== "related" || section.kind !== "children") return [];
52189
+ if (draw !== "related" && draw !== "capped" || section.kind !== "children") return [];
52017
52190
  const child = entry.children.get(childKey(section.child.alias, section.link.alias));
52018
52191
  return child === void 0 ? [] : [child];
52019
52192
  });
52020
52193
  }
52021
52194
  function childOpens(entry, child) {
52022
- if (!entry.mounts || child.section === "thread") return void 0;
52195
+ if (!entry.mounts || COMPOSED_SECTIONS.includes(child.section)) return void 0;
52023
52196
  return child.surface !== void 0 || child.entity.alias === entry.screen.entity.alias ? child.entity.alias : void 0;
52024
52197
  }
52025
52198
  function childSurfaces(entry) {
@@ -52031,7 +52204,7 @@ function childSurfaces(entry) {
52031
52204
  }
52032
52205
  function childEditor(entry, child) {
52033
52206
  if (child.surface === void 0) return void 0;
52034
- return childOpens(entry, child) !== void 0 || child.section === "thread" ? child.surface : void 0;
52207
+ return childOpens(entry, child) !== void 0 || COMPOSED_SECTIONS.includes(child.section) ? child.surface : void 0;
52035
52208
  }
52036
52209
  function childEditors(entry) {
52037
52210
  return new Map(
@@ -52041,6 +52214,28 @@ function childEditors(entry) {
52041
52214
  })
52042
52215
  );
52043
52216
  }
52217
+ function appSurfaces(entry) {
52218
+ const surfaces = /* @__PURE__ */ new Map();
52219
+ const reached = [
52220
+ entry,
52221
+ ...childSurfaces(entry).values(),
52222
+ ...[...entry.parties.values()].flatMap((party) => [party.surface, ...childSurfaces(party.surface).values()])
52223
+ ];
52224
+ for (const surface of reached) if (!surfaces.has(surface.screen.entity.alias)) surfaces.set(surface.screen.entity.alias, surface);
52225
+ return [...surfaces.values()];
52226
+ }
52227
+ function appEditors(entry) {
52228
+ const editors = /* @__PURE__ */ new Map([[entry.screen.entity.alias, entry]]);
52229
+ const kept = [
52230
+ ...childEditors(entry),
52231
+ ...[...entry.parties.values()].flatMap((party) => [
52232
+ [party.surface.screen.entity.alias, party.surface],
52233
+ ...childEditors(party.surface)
52234
+ ])
52235
+ ];
52236
+ for (const [alias, surface] of kept) if (!editors.has(alias)) editors.set(alias, surface);
52237
+ return editors;
52238
+ }
52044
52239
  function planWrites(entry) {
52045
52240
  if (entry.screen.screen.writes === false) return void 0;
52046
52241
  if (!entry.screen.entity.fields.some((field) => stated(entry, field))) return void 0;
@@ -52048,7 +52243,6 @@ function planWrites(entry) {
52048
52243
  }
52049
52244
  function savedFields(entry) {
52050
52245
  if (entry.screen.screen.writes === false) return [];
52051
- const led = entry.screen.record === "page" ? entry.mark : void 0;
52052
52246
  const banded = bandDeadlines(entry).filter((field) => stated(entry, field));
52053
52247
  return banded.concat(entry.sections.flatMap(({ section }) => {
52054
52248
  if (section.kind === "facts") return section.fields.filter((field) => stated(entry, field));
@@ -52056,7 +52250,7 @@ function savedFields(entry) {
52056
52250
  if (section.kind === "prose") return stated(entry, section.field) ? [section.field] : [];
52057
52251
  if (section.kind === "charge") return [section.quantity, section.unitPrice].filter((field) => stated(entry, field));
52058
52252
  if (section.kind !== "files") return [];
52059
- const pile = editablePile(entry, section.fields.filter((field) => field.alias !== led && entry.fields.has(field.alias)));
52253
+ const pile = editablePile(entry, section.fields.filter((field) => entry.fields.has(field.alias)));
52060
52254
  return pile === void 0 ? [] : [pile];
52061
52255
  }));
52062
52256
  }
@@ -52087,24 +52281,27 @@ function scopeCondition(subject, narrowing) {
52087
52281
  return narrowing.kind === "own" ? { node_type: "condition", type: "record_id", operator: "is_any_of", value } : { node_type: "condition", type: "select_record_link", field_key: narrowing.field.id, operator: "has_any_of", value };
52088
52282
  }
52089
52283
  function planTableNames(screen, entities, roles) {
52090
- return [...new Set(surfaceTables(screen, entities, roles, screen.record === "page"))];
52284
+ return [...new Set(surfaceTables(screen, entities, roles, screen.record === "page", true))];
52091
52285
  }
52092
- function surfaceTables(screen, entities, roles, mounts, under) {
52093
- const names = [screen.entity.label, ...screen.scope === null ? [] : [screen.scope.entity.label]];
52094
- const recipe = recordRecipe(screen.screen.shape, screen.entity, entities, roles, recordHeader(screen, roles), screen.record, screen.screen.sections);
52286
+ function surfaceTables(screen, entities, roles, mounts, names, under) {
52287
+ const tables = [screen.entity.label, ...screen.scope === null ? [] : [screen.scope.entity.label]];
52288
+ const recipe = recordRecipe(screen.screen.shape, screen.entity, entities, roles, recordHeader(screen, entities, roles), screen.record, screen.screen.sections);
52095
52289
  const sections = recipe.map((entry) => entry.section);
52096
- for (const { target } of factLinkTargets(screen, sections, entities, roles, true)) names.push(target.label);
52097
- for (const { target } of createLinkTargets(screen, entities, roles, true, under)) names.push(target.label);
52290
+ for (const { target } of factLinkTargets(screen, sections, entities, roles, true)) tables.push(target.label);
52291
+ for (const { target } of createLinkTargets(screen, entities, roles, true, under)) tables.push(target.label);
52098
52292
  for (const entry of recipe) {
52099
52293
  const opened = childSurfaceScreen(screen, entry, mounts);
52100
52294
  if (opened !== void 0) {
52101
- names.push(...surfaceTables(opened, entities, roles, false, sectionRelation(entry.section)?.link));
52295
+ tables.push(...surfaceTables(opened, entities, roles, false, false, sectionRelation(entry.section)?.link));
52102
52296
  continue;
52103
52297
  }
52104
52298
  const child = sectionChild(entry.section);
52105
- if (child !== void 0) names.push(child.label);
52299
+ if (child !== void 0) tables.push(child.label);
52106
52300
  }
52107
- return names;
52301
+ for (const party of names ? partySurfaces(screen, entities, roles) : []) {
52302
+ tables.push(...surfaceTables(party.screen, entities, roles, party.screen.record === "page", false));
52303
+ }
52304
+ return tables;
52108
52305
  }
52109
52306
  function projection(fields) {
52110
52307
  return fields.map((field) => ({ source: field.id, output: field.alias }));
@@ -52115,16 +52312,25 @@ function unique2(fields) {
52115
52312
  function planQueries(entry) {
52116
52313
  const queries = {};
52117
52314
  const inbound = registerFilters(entry);
52118
- const order = registerReadsForward(entry.screen.screen.shape) ? "asc" : "desc";
52119
52315
  const sort = entry.day === void 0 ? void 0 : [
52120
- { field_key: entry.day.id, order },
52316
+ { field_key: entry.day.field.id, order: entry.day.direction },
52121
52317
  ...entry.runSlot === void 0 ? [] : [{ field_key: entry.runSlot.id, order: "asc" }]
52122
52318
  ];
52123
52319
  const narrowing = [...inbound];
52124
52320
  const subject = entry.subject;
52125
52321
  const picked = subject === void 0 || entry.narrowing === void 0 ? void 0 : scopeCondition(subject, entry.narrowing);
52322
+ const mine = entry.mine;
52126
52323
  const narrowed = [
52127
52324
  ...picked === void 0 ? [] : [picked],
52325
+ ...mine === void 0 ? [] : [
52326
+ {
52327
+ node_type: "condition",
52328
+ type: "select_member",
52329
+ field_key: mine.field.id,
52330
+ operator: "has_any_of",
52331
+ value: [`{{params.${mine.param}}}`]
52332
+ }
52333
+ ],
52128
52334
  ...narrowing.map(
52129
52335
  ([alias, { link }]) => ({
52130
52336
  node_type: "condition",
@@ -52141,6 +52347,7 @@ function planQueries(entry) {
52141
52347
  );
52142
52348
  const params = {
52143
52349
  ...picked === void 0 || subject === void 0 ? {} : { [subject.param]: { type: "record_link", table_id: subject.table.id, required: true } },
52350
+ ...mine === void 0 ? {} : { [mine.param]: { type: "member", required: false } },
52144
52351
  ...Object.fromEntries(
52145
52352
  narrowing.map(([alias, { opens }]) => [registerFilterParam(alias), { type: "record_link", table_id: opens.id, required: false }])
52146
52353
  )
@@ -52176,38 +52383,45 @@ function planQueries(entry) {
52176
52383
  description: entry.words.queries.picker(subject.table.name, subject.display.label)
52177
52384
  };
52178
52385
  }
52179
- const record2 = recordQueryAlias(entry.screen.entity.alias);
52180
- if (entry.screen.record === "page" && queries[record2] === void 0) {
52181
- queries[record2] = {
52182
- ast: {
52183
- kind: "project",
52184
- from: {
52185
- kind: "from_table",
52186
- table_id: entry.table.id,
52187
- // THE RULE RIDES THE BY-ID READ TOO. A record page is reached by
52188
- // pasting a url, so the read that answers it is exactly where a row
52189
- // the reader may not see would be served one row at a time.
52190
- //
52191
- // AND SO DOES THE SUBJECT, for the same reason: the one way into this
52192
- // app that never went through the register is a pasted address, which
52193
- // is exactly how a record of another project is reached. The param is
52194
- // OPTIONAL here — a page arrived at cold may be holding no pick yet,
52195
- // and an unprovided param prunes its condition rather than refusing
52196
- // the read.
52197
- filter: withScope(byId(entry.screen.entity.alias, picked), entry.scope)
52198
- },
52199
- columns: projection([...entry.fields.values()])
52200
- },
52201
- params: {
52202
- [recordParam(entry.screen.entity.alias)]: { type: "record_link", table_id: entry.table.id },
52203
- ...picked === void 0 || subject === void 0 ? {} : { [subject.param]: { type: "record_link", table_id: subject.table.id, required: false } }
52204
- },
52205
- description: entry.words.queries.record(entry.screen.entity.label, entry.screen.screen.label)
52206
- };
52207
- }
52386
+ recordRead(queries, entry, picked, subject);
52208
52387
  surfaceReads(queries, entry);
52388
+ for (const party of entry.parties.values()) {
52389
+ recordRead(queries, party.surface, void 0, void 0);
52390
+ surfaceReads(queries, party.surface);
52391
+ }
52209
52392
  return queries;
52210
52393
  }
52394
+ function recordRead(queries, entry, picked, subject) {
52395
+ const entity = entry.screen.entity.alias;
52396
+ const record2 = recordQueryAlias(entity);
52397
+ if (entry.screen.record !== "page" || queries[record2] !== void 0) return;
52398
+ queries[record2] = {
52399
+ ast: {
52400
+ kind: "project",
52401
+ from: {
52402
+ kind: "from_table",
52403
+ table_id: entry.table.id,
52404
+ // THE RULE RIDES THE BY-ID READ TOO. A record page is reached by
52405
+ // pasting a url, so the read that answers it is exactly where a row
52406
+ // the reader may not see would be served one row at a time.
52407
+ //
52408
+ // AND SO DOES THE SUBJECT, for the same reason: the one way into this
52409
+ // app that never went through the register is a pasted address, which
52410
+ // is exactly how a record of another project is reached. The param is
52411
+ // OPTIONAL here — a page arrived at cold may be holding no pick yet,
52412
+ // and an unprovided param prunes its condition rather than refusing
52413
+ // the read.
52414
+ filter: withScope(byId(entity, picked), entry.scope)
52415
+ },
52416
+ columns: projection([...entry.fields.values()])
52417
+ },
52418
+ params: {
52419
+ [recordParam(entity)]: { type: "record_link", table_id: entry.table.id },
52420
+ ...picked === void 0 || subject === void 0 ? {} : { [subject.param]: { type: "record_link", table_id: subject.table.id, required: false } }
52421
+ },
52422
+ description: entry.words.queries.record(entry.screen.entity.label, entry.screen.screen.label)
52423
+ };
52424
+ }
52211
52425
  function surfaceReads(queries, entry) {
52212
52426
  for (const link of entry.createLinks.values()) {
52213
52427
  if (queries[link.alias] !== void 0) continue;
@@ -52273,7 +52487,7 @@ function surfaceReads(queries, entry) {
52273
52487
  }
52274
52488
  function registerFilters(entry) {
52275
52489
  const filters = /* @__PURE__ */ new Map();
52276
- for (const child of countedRelations(entry)) {
52490
+ for (const child of handedOnRelations(entry)) {
52277
52491
  if (child.entity.alias !== entry.screen.entity.alias) continue;
52278
52492
  const link = entry.fields.get(child.linkAlias);
52279
52493
  if (link === void 0) continue;
@@ -52336,6 +52550,20 @@ var specFieldSchema = zod_default.object({
52336
52550
  format: textFormatSchema.optional(),
52337
52551
  /** A select or a link that holds SEVERAL — read as a list, never re-pointed by a picker. */
52338
52552
  multi: zod_default.literal(true).optional(),
52553
+ /**
52554
+ * THE RECORD THIS COLUMN'S NAME IS A DOOR ONTO — a key of `records`, where
52555
+ * this app opens the record of the entity the link points at.
52556
+ *
52557
+ * ON THE FIELD, because every surface that draws the value asks the same
52558
+ * question: the register's subject cell, its counterparty column, the party
52559
+ * line under a record's name. A cell that merely PRINTED the name sent the
52560
+ * reader hunting for a second app to correct a phone number.
52561
+ *
52562
+ * The door is the READER's, never the editor's: a fact whose picker
52563
+ * re-points the link is a control, and a press that navigated away from it
52564
+ * would lose whatever else the reader had typed.
52565
+ */
52566
+ opens: contractAliasSchema.optional(),
52339
52567
  money: specMoneySchema.optional(),
52340
52568
  /** A SHARE, already in percent units. */
52341
52569
  percent: zod_default.literal(true).optional(),
@@ -52563,7 +52791,30 @@ var specPredicateSchema = zod_default.object({
52563
52791
  }).strict();
52564
52792
  var specLensSchema = zod_default.union([
52565
52793
  specColumnAliasSchema,
52566
- zod_default.object({ label: zod_default.string().min(1), predicates: zod_default.array(specPredicateSchema).min(1) }).strict()
52794
+ zod_default.object({ label: zod_default.string().min(1), predicates: zod_default.array(specPredicateSchema).min(1) }).strict(),
52795
+ /**
52796
+ * WHOSE ROWS THESE ARE, read against the person reading them — the two sets a
52797
+ * member column holds, and which of them the register opens on.
52798
+ *
52799
+ * The narrowing is the READ's (`params.mine`), not a pass over the rows in
52800
+ * hand: this is the set the register opens at, so narrowing the page it had
52801
+ * already answered with would open the desk on whichever of the reader's rows
52802
+ * came back first.
52803
+ */
52804
+ zod_default.object({
52805
+ member: specColumnAliasSchema,
52806
+ /** The register query's own param for it — the member the read narrows to. Unprovided, the condition prunes. */
52807
+ param: zod_default.string().min(1),
52808
+ default: zod_default.literal("mine").optional()
52809
+ }).strict()
52810
+ ]);
52811
+ var specContextColumnSchema = zod_default.union([
52812
+ specColumnAliasSchema,
52813
+ zod_default.object({
52814
+ field: specColumnAliasSchema,
52815
+ counts: zod_default.literal("rows"),
52816
+ opens: zod_default.literal(true).optional()
52817
+ }).strict()
52567
52818
  ]);
52568
52819
  var specObligationSchema = zod_default.object({
52569
52820
  label: zod_default.string().min(1),
@@ -52605,7 +52856,7 @@ var specScreenSchema = zod_default.object({
52605
52856
  * before the answer. Bounded here as well as in the plan, because a spec is
52606
52857
  * also written by hand.
52607
52858
  */
52608
- columns: zod_default.array(specColumnAliasSchema).min(1).max(CONTEXT_COLUMNS).optional(),
52859
+ columns: zod_default.array(specContextColumnSchema).min(1).max(CONTEXT_COLUMNS).optional(),
52609
52860
  /**
52610
52861
  * For each lifecycle this screen draws, the options that END the flow. A row
52611
52862
  * in one has ARRIVED, so the ladder draws it beside the flow rather than as
@@ -52662,7 +52913,12 @@ var specBandSchema = zod_default.discriminatedUnion("kind", [
52662
52913
  zod_default.object({ kind: zod_default.literal("comparison"), value: specColumnAliasSchema, reference: specColumnAliasSchema }).strict()
52663
52914
  ]);
52664
52915
  var specContactSchema = zod_default.discriminatedUnion("kind", [
52665
- /** The party the job is for — a name this app states rather than an address it reaches. */
52916
+ /**
52917
+ * The party the job is for — a name rather than an address. Where this app
52918
+ * carries that party's own record the name is the door onto it, which the
52919
+ * column itself states (`SpecField.opens`); where it does not, the line states
52920
+ * the name and offers nothing to press.
52921
+ */
52666
52922
  zod_default.object({ kind: zod_default.literal("party"), field: specColumnAliasSchema }).strict(),
52667
52923
  zod_default.object({
52668
52924
  kind: zod_default.literal("reach"),
@@ -52902,6 +53158,24 @@ var specSectionSchema = zod_default.discriminatedUnion("kind", [
52902
53158
  summary: zod_default.array(specColumnAliasSchema).min(1).optional(),
52903
53159
  ...sectionActs
52904
53160
  }).strict(),
53161
+ /**
53162
+ * A CAPPED HISTORY — rows that NAME this record, standing open at their
53163
+ * latest few under a heading that says how many there are in all.
53164
+ *
53165
+ * The rows are not this record's, so the section holds them the way the
53166
+ * counted line does: it reads the latest of them, counts the whole, and its
53167
+ * foot hands the reader the register that OWNS them.
53168
+ */
53169
+ zod_default.object({
53170
+ kind: zod_default.literal("children"),
53171
+ key: zod_default.string().min(1),
53172
+ heading: zod_default.string().min(1),
53173
+ draw: zod_default.literal("capped"),
53174
+ child: specChildSchema,
53175
+ /** The param this app's own register reads this record off its route by — the foot's door, where those rows are its. */
53176
+ opens: zod_default.string().min(1).optional(),
53177
+ ...sectionActs
53178
+ }).strict(),
52905
53179
  /** THE SHEET AND ITS FIGURES ARE ONE CLAUSE — neither is declarable without the other. */
52906
53180
  zod_default.object({
52907
53181
  kind: zod_default.literal("children"),
@@ -52953,6 +53227,23 @@ var specSectionSchema = zod_default.discriminatedUnion("kind", [
52953
53227
  clock: specColumnAliasSchema.optional(),
52954
53228
  ...sectionActs
52955
53229
  }).strict(),
53230
+ /**
53231
+ * A LOG this record's own people keep — dated entries, newest first, each read
53232
+ * in the words somebody wrote rather than as a row of columns.
53233
+ */
53234
+ zod_default.object({
53235
+ kind: zod_default.literal("journal"),
53236
+ key: zod_default.string().min(1),
53237
+ heading: zod_default.string().min(1),
53238
+ child: specChildSchema,
53239
+ /** The entry itself. */
53240
+ body: specColumnAliasSchema,
53241
+ /** The day it is filed under, and read in the order of. */
53242
+ when: specColumnAliasSchema,
53243
+ /** The member who made it, where the child names one. */
53244
+ author: specColumnAliasSchema.optional(),
53245
+ ...sectionActs
53246
+ }).strict(),
52956
53247
  zod_default.object({ kind: zod_default.literal("prose"), key: zod_default.string().min(1), heading: zod_default.string().min(1), field: specColumnAliasSchema, ...sectionActs }).strict(),
52957
53248
  zod_default.object({
52958
53249
  kind: zod_default.literal("charge"),
@@ -52984,6 +53275,7 @@ function sectionChild2(section) {
52984
53275
  case "desk":
52985
53276
  case "timeline":
52986
53277
  case "thread":
53278
+ case "journal":
52987
53279
  return section.child;
52988
53280
  default:
52989
53281
  return void 0;
@@ -53104,6 +53396,12 @@ var appSpecSchema = zod_default.object({
53104
53396
  records: zod_default.record(contractAliasSchema, specRecordSchema),
53105
53397
  creates: zod_default.array(specCreateSchema).optional()
53106
53398
  }).strict();
53399
+ function routedRecords(spec) {
53400
+ const opened = [spec.screen.fields, ...Object.values(spec.records).map((record2) => record2.fields)].flatMap(
53401
+ (fields) => Object.values(fields).flatMap((field) => field.opens === void 0 ? [] : [field.opens])
53402
+ );
53403
+ return /* @__PURE__ */ new Set([spec.screen.entity, ...opened]);
53404
+ }
53107
53405
  function referencedComponents(spec) {
53108
53406
  return [
53109
53407
  .../* @__PURE__ */ new Set([
@@ -53242,8 +53540,8 @@ function declaredLimit(entry, roles, fieldAlias, read2) {
53242
53540
  const limit = limitAlias === void 0 ? void 0 : entry.fields.get(limitAlias);
53243
53541
  return limit === void 0 ? void 0 : { against: read2(limit.alias), constant: false, ...limit.percent === true ? { percent: true } : {}, alert: decl.alert, ...says };
53244
53542
  }
53245
- const stated2 = viewStatedLimit(entry.screen.entity, fieldAlias);
53246
- return stated2 === void 0 ? void 0 : { against: String(stated2.limit), constant: true, alert: stated2.alert };
53543
+ const stated3 = viewStatedLimit(entry.screen.entity, fieldAlias);
53544
+ return stated3 === void 0 ? void 0 : { against: String(stated3.limit), constant: true, alert: stated3.alert };
53247
53545
  }
53248
53546
  function captionField(entry, roles) {
53249
53547
  const slotIdentity = entry.screen.slots.find((slot2) => slot2.role === "identity" && slot2.field !== null)?.field ?? null;
@@ -53273,17 +53571,25 @@ function filledByBody(entry, roles, mounted) {
53273
53571
  function planCreates(entry, roles) {
53274
53572
  if (planWrites(entry) === void 0) return [];
53275
53573
  const plan = planCreate(entry, roles);
53276
- return [...plan === void 0 ? [] : [plan], ...childCreates(entry, roles)];
53574
+ return [
53575
+ ...plan === void 0 ? [] : [plan],
53576
+ ...childCreates(entry, roles),
53577
+ ...[...entry.parties.values()].flatMap((party) => childCreates(party.surface, roles))
53578
+ ];
53277
53579
  }
53278
53580
  function childCreates(entry, roles) {
53279
53581
  return entry.sections.flatMap(({ section }) => {
53280
53582
  const relation = sectionRelation(section);
53281
- if (relation === void 0 || relation.via !== "parent") return [];
53583
+ if (relation === void 0 || !recordAddsChild(entry.screen.entity, section, entry.mounts)) return [];
53282
53584
  const child = entry.children.get(childKey(relation.child.alias, relation.link.alias));
53283
53585
  if (child === void 0) return [];
53284
- if (section.kind === "thread") {
53285
- const bound = child.fields.get(section.body.alias) ?? child.operands.get(section.body.alias);
53286
- if (bound === void 0) return [];
53586
+ if (section.kind === "thread" || section.kind === "journal") {
53587
+ const typed = section.kind === "thread" ? [section.body] : composedEntry(section);
53588
+ const inputs = typed.flatMap((field) => {
53589
+ const bound = child.fields.get(field.alias) ?? child.operands.get(field.alias);
53590
+ return bound === void 0 ? [] : [{ name: bound.alias, field, bound, label: bound.label, required: field.alias === typed[0].alias, into: "row" }];
53591
+ });
53592
+ if (inputs.length === 0) return [];
53287
53593
  return [
53288
53594
  {
53289
53595
  entry,
@@ -53291,9 +53597,10 @@ function childCreates(entry, roles) {
53291
53597
  table: { id: child.table.id, alias: child.tableAlias },
53292
53598
  options: child.alias,
53293
53599
  parent: { bound: child.link, screen: entry, param: recordParam(entry.screen.entity.alias) },
53600
+ ...section.kind === "journal" ? { day: child.fields.get(section.when.alias)?.alias ?? child.operands.get(section.when.alias)?.alias } : {},
53294
53601
  reads: [],
53295
53602
  unique: [],
53296
- inputs: [{ name: bound.alias, field: section.body, bound, label: bound.label, required: true, into: "row" }],
53603
+ inputs,
53297
53604
  mount: { kind: "section", key: sectionKey(child.entity.alias, child.linkAlias) }
53298
53605
  }
53299
53606
  ];
@@ -53303,6 +53610,14 @@ function childCreates(entry, roles) {
53303
53610
  return plan === void 0 ? [] : [plan];
53304
53611
  });
53305
53612
  }
53613
+ function composedEntry(section) {
53614
+ const asked = /* @__PURE__ */ new Set([section.body.alias, section.when.alias]);
53615
+ return [
53616
+ section.body,
53617
+ section.when,
53618
+ ...section.fields.filter((field) => field.type === "select" && field.multi !== true && !asked.has(field.alias) && isEditable(field))
53619
+ ];
53620
+ }
53306
53621
  function planCreate(entry, roles, on = entry) {
53307
53622
  const entity = entry.screen.entity;
53308
53623
  const later = filledLater(entry, roles);
@@ -53496,9 +53811,9 @@ function factOrder(screen, roles, fields) {
53496
53811
  const chosen = new Set(decided.map((field) => field.alias));
53497
53812
  return [...decided, ...fields.filter((field) => !chosen.has(field.alias))];
53498
53813
  }
53499
- function factsPlan(screen, roles, fields) {
53814
+ function factsPlan(screen, archetype, roles, fields) {
53500
53815
  const derived = (over) => {
53501
- if (recordArchetype(screen.screen.shape, screen.entity, roles) === "evidence") {
53816
+ if (archetype === "evidence") {
53502
53817
  const door = (field) => {
53503
53818
  const role = roleOf(roles, screen.entity.alias, field.alias)?.role;
53504
53819
  return role === "parent" || role === "party";
@@ -53615,11 +53930,15 @@ function specFields(fields, declared, extras = () => ({})) {
53615
53930
  function screenExtras(entry, roles) {
53616
53931
  const over = surfaceOf(entry.fields);
53617
53932
  const declared = new Map(entry.screen.entity.fields.map((field) => [field.alias, field]));
53618
- return (modelAlias) => {
53933
+ const opens = new Map(
53934
+ [...entry.parties].flatMap(([party, bound]) => bound.links.map((link) => [link.alias, party]))
53935
+ );
53936
+ return (modelAlias, bound) => {
53619
53937
  const field = declared.get(modelAlias);
53620
53938
  const decl = roleOf(roles, entry.screen.entity.alias, modelAlias);
53621
53939
  const role = decl?.role;
53622
53940
  return {
53941
+ ...opens.get(bound.alias) === void 0 ? {} : { opens: opens.get(bound.alias) },
53623
53942
  ...signOf(entry.screen.entity, roles, modelAlias, over) === void 0 ? {} : { sign: signOf(entry.screen.entity, roles, modelAlias, over) },
53624
53943
  ...role === "measure" && levelOf(entry, roles, modelAlias) !== void 0 ? { level: levelOf(entry, roles, modelAlias) } : {},
53625
53944
  // A DATE IS A DEADLINE BECAUSE THE MODEL SAID SO. Carried on the column so
@@ -53781,11 +54100,11 @@ var LENS_OPERATORS2 = [
53781
54100
  "is_empty",
53782
54101
  "is_not_empty"
53783
54102
  ];
53784
- function lensType(stated2) {
53785
- return LENS_TYPES.find((type) => type === stated2);
54103
+ function lensType(stated3) {
54104
+ return LENS_TYPES.find((type) => type === stated3);
53786
54105
  }
53787
- function lensOperator(stated2) {
53788
- return LENS_OPERATORS2.find((operator) => operator === stated2);
54106
+ function lensOperator(stated3) {
54107
+ return LENS_OPERATORS2.find((operator) => operator === stated3);
53789
54108
  }
53790
54109
  function lensValue(field, type, value) {
53791
54110
  if (type === "select") {
@@ -53805,6 +54124,11 @@ function specLens(entry, lens) {
53805
54124
  const bound = entry.fields.get(lens.field.alias);
53806
54125
  return bound === void 0 ? [] : [bound.alias];
53807
54126
  }
54127
+ if (lens.kind === "member") {
54128
+ const mine = entry.mine;
54129
+ if (mine === void 0 || mine.field.alias !== entry.fields.get(lens.field.alias)?.alias) return [];
54130
+ return [{ member: mine.field.alias, param: mine.param, ...mine.first ? { default: "mine" } : {} }];
54131
+ }
53808
54132
  const predicates = lens.predicates.flatMap((one) => {
53809
54133
  const where = one.where.flatMap((condition) => {
53810
54134
  const bound = entry.fields.get(condition.field.alias);
@@ -53881,8 +54205,15 @@ function specScreen(entry, roles, templates, inbound) {
53881
54205
  ];
53882
54206
  });
53883
54207
  const columns = screen.columns.flatMap((field) => {
53884
- const bound = ref(field);
53885
- return bound === void 0 ? [] : [bound];
54208
+ const alias2 = ref(field);
54209
+ if (alias2 === void 0) return [];
54210
+ if (!columnCountsRows(field)) return [alias2];
54211
+ const counted = countedThrough(screen.entity, field);
54212
+ const listed = counted !== void 0 && entry.sections.some(({ draw, section }) => {
54213
+ const relation = sectionRelation(section);
54214
+ return draw !== "related" && relation?.child.alias === counted.child && relation.link.alias === counted.link;
54215
+ });
54216
+ return [{ field: alias2, counts: "rows", ...listed ? { opens: true } : {} }];
53886
54217
  });
53887
54218
  const outcomes = {};
53888
54219
  for (const [fieldAlias, named2] of Object.entries(screen.outcomes)) {
@@ -53909,7 +54240,7 @@ function specScreen(entry, roles, templates, inbound) {
53909
54240
  if (satisfiedBy !== void 0) return [{ label: owed.label, due, satisfiedBy }];
53910
54241
  return owed.satisfiedBy === void 0 && untilOf(entry, roles, owed.field) !== void 0 ? [{ label: owed.label, due }] : [];
53911
54242
  });
53912
- const runs = entry.day === void 0 || entry.runSlot === void 0 ? void 0 : { day: entry.day.alias, slot: entry.runSlot.alias };
54243
+ const runs = entry.day === void 0 || entry.runSlot === void 0 ? void 0 : { day: entry.day.field.alias, slot: entry.runSlot.alias };
53913
54244
  const acts = specActs(entry, templates);
53914
54245
  const summary = specSummary(entry, roles);
53915
54246
  const tabs = ref(screen.tabs);
@@ -53944,14 +54275,14 @@ function specScreen(entry, roles, templates, inbound) {
53944
54275
  };
53945
54276
  }
53946
54277
  function specPresentation(entry) {
53947
- const stated2 = entry.screen.screen.presentation;
53948
- if (stated2 === void 0 || Object.values(stated2).every((clause) => clause === void 0)) return {};
53949
- const until = stated2.until === void 0 ? void 0 : entry.fields.get(stated2.until)?.alias;
54278
+ const stated3 = entry.screen.screen.presentation;
54279
+ if (stated3 === void 0 || Object.values(stated3).every((clause) => clause === void 0)) return {};
54280
+ const until = stated3.until === void 0 ? void 0 : entry.fields.get(stated3.until)?.alias;
53950
54281
  return {
53951
54282
  presentation: {
53952
- ...stated2.lead === void 0 ? {} : { lead: stated2.lead },
53953
- ...stated2.density === void 0 ? {} : { density: stated2.density },
53954
- ...stated2.layout === void 0 ? {} : { layout: stated2.layout },
54283
+ ...stated3.lead === void 0 ? {} : { lead: stated3.lead },
54284
+ ...stated3.density === void 0 ? {} : { density: stated3.density },
54285
+ ...stated3.layout === void 0 ? {} : { layout: stated3.layout },
53955
54286
  ...until === void 0 ? {} : { until }
53956
54287
  }
53957
54288
  };
@@ -53981,12 +54312,7 @@ function specContacts(entry, roles) {
53981
54312
  const bound = entry.fields.get(field.alias);
53982
54313
  return bound === void 0 ? [] : [{ kind: "party", field: bound.alias }];
53983
54314
  });
53984
- const reached = recordContacts(
53985
- entry.screen.screen.shape,
53986
- entry.screen.entity,
53987
- roles,
53988
- entry.screen.record
53989
- ).flatMap((field) => {
54315
+ const reached = recordContacts(entry.screen.entity, roles, entry.screen.record).flatMap((field) => {
53990
54316
  const bound = entry.fields.get(field.alias);
53991
54317
  const reach = contactReach(field);
53992
54318
  return bound === void 0 || reach === void 0 ? [] : [{ kind: "reach", field: bound.alias, reach }];
@@ -54122,7 +54448,7 @@ function specFactSections(entry, roles, fields, stands) {
54122
54448
  }
54123
54449
  function specFactGroups(entry, roles, fields) {
54124
54450
  const grouped = groupedFacts(entry.screen);
54125
- return factsPlan(entry.screen, roles, fields).map((band) => ({
54451
+ return factsPlan(entry.screen, entry.archetype, roles, fields).map((band) => ({
54126
54452
  ...band.caption === void 0 ? {} : { caption: band.caption },
54127
54453
  facts: band.fields.flatMap((field) => {
54128
54454
  const bound = entry.fields.get(field.alias);
@@ -54145,8 +54471,7 @@ function specFilesOwed(entry, roles, held) {
54145
54471
  const asserted = filesVerdict(entry.screen.entity, roles, held) ?? bySlot;
54146
54472
  const bound = asserted === void 0 ? void 0 : entry.fields.get(asserted.alias);
54147
54473
  if (bound !== void 0) return { short: bound.alias };
54148
- const archetype = recordArchetype(entry.screen.screen.shape, entry.screen.entity, roles);
54149
- return archetype === "evidence" ? { count: 1 } : void 0;
54474
+ return entry.archetype === "evidence" ? { count: 1 } : void 0;
54150
54475
  }
54151
54476
  function specHistory(entry, section) {
54152
54477
  const plan = section.history;
@@ -54171,10 +54496,9 @@ function specHistory(entry, section) {
54171
54496
  function specRecord(entry, roles, templates) {
54172
54497
  const entity = entry.screen.entity.alias;
54173
54498
  const page = entry.screen.record === "page";
54174
- const archetype = entry.screen.record === "expand" ? "line" : recordArchetype(entry.screen.screen.shape, entry.screen.entity, roles);
54499
+ const archetype = drawnArchetype(entry.archetype, entry.screen.record);
54175
54500
  const ref = (field) => field === void 0 ? void 0 : entry.fields.get(field.alias)?.alias;
54176
54501
  const mark = entry.mark === void 0 ? void 0 : entry.fields.get(entry.mark)?.alias;
54177
- const led = page ? mark : void 0;
54178
54502
  const operable = entry.screen.screen.writes !== false;
54179
54503
  const sections = [];
54180
54504
  const related = [];
@@ -54245,8 +54569,8 @@ function specRecord(entry, roles, templates) {
54245
54569
  case "children": {
54246
54570
  const child = entry.children.get(childKey(section.child.alias, section.link.alias));
54247
54571
  if (child === void 0) break;
54572
+ const door = entry.mounts && child.entity.alias === entity;
54248
54573
  if (draw === "related") {
54249
- const door = entry.mounts && child.entity.alias === entity;
54250
54574
  related.push({
54251
54575
  key: sectionKey(child.entity.alias, child.linkAlias),
54252
54576
  heading: child.heading,
@@ -54256,6 +54580,18 @@ function specRecord(entry, roles, templates) {
54256
54580
  });
54257
54581
  break;
54258
54582
  }
54583
+ if (draw === "capped") {
54584
+ sections.push({
54585
+ kind: "children",
54586
+ key: sectionKey(child.entity.alias, child.linkAlias),
54587
+ heading: child.heading,
54588
+ draw: "capped",
54589
+ child: specChild(child, roles, archetype, slot2, entry, section.expected),
54590
+ ...door ? { opens: registerFilterParam(child.linkAlias) } : {},
54591
+ ...stands
54592
+ });
54593
+ break;
54594
+ }
54259
54595
  const ledger = slot2 === "ledger" && section.via === "parent";
54260
54596
  const sheet = planWorksheets(entry).find((one) => one.child === child);
54261
54597
  const key = sectionKey(child.entity.alias, child.linkAlias);
@@ -54349,10 +54685,32 @@ function specRecord(entry, roles, templates) {
54349
54685
  });
54350
54686
  break;
54351
54687
  }
54688
+ // A LOG — the entry and the day it is filed under, named rather than left
54689
+ // to the columns: both are read WITH the rows and neither is one.
54690
+ case "journal": {
54691
+ const child = entry.children.get(childKey(section.child.alias, section.link.alias));
54692
+ if (child === void 0) break;
54693
+ const reads = childReads(child);
54694
+ const body = reads.get(section.body.alias)?.alias;
54695
+ const when = reads.get(section.when.alias)?.alias;
54696
+ if (body === void 0 || when === void 0) break;
54697
+ const author = section.author === void 0 ? void 0 : reads.get(section.author.alias)?.alias;
54698
+ sections.push({
54699
+ kind: "journal",
54700
+ key: sectionKey(child.entity.alias, child.linkAlias),
54701
+ heading: child.heading,
54702
+ child: specChild(child, roles, archetype, slot2, entry, void 0),
54703
+ body,
54704
+ when,
54705
+ ...author === void 0 ? {} : { author },
54706
+ ...stands
54707
+ });
54708
+ break;
54709
+ }
54352
54710
  case "files": {
54353
54711
  const held = section.fields.flatMap((field) => {
54354
54712
  const bound = entry.fields.get(field.alias);
54355
- return bound === void 0 || bound.alias === led ? [] : [{ field, bound }];
54713
+ return bound === void 0 ? [] : [{ field, bound }];
54356
54714
  });
54357
54715
  if (held.length === 0) break;
54358
54716
  const attach = operable ? editablePile(
@@ -54438,7 +54796,7 @@ function specCreate(plan) {
54438
54796
  function bindAppSpec(app, entry, roles, templates = /* @__PURE__ */ new Map()) {
54439
54797
  const creates = planCreates(entry, roles);
54440
54798
  const screen = specScreen(entry, roles, templates, [...registerFilters(entry).keys()]);
54441
- const records = [entry, ...childSurfaces(entry).values()].map((surface) => [surface.screen.entity.alias, specRecord(surface, roles, templates)]);
54799
+ const records = appSurfaces(entry).map((surface) => [surface.screen.entity.alias, specRecord(surface, roles, templates)]);
54442
54800
  return {
54443
54801
  version: APP_SPEC_VERSION,
54444
54802
  app: {
@@ -54531,9 +54889,12 @@ function itineraryReads(plan) {
54531
54889
  function checkRecord(spec, key, record2, manifest) {
54532
54890
  const at2 = `records.${key}`;
54533
54891
  const findings = [];
54534
- const mounted = key !== spec.screen.entity;
54892
+ const mounted = !routedRecords(spec).has(key);
54535
54893
  if (mounted && record2.door === "page") {
54536
- findings.push({ at: at2, message: `opens as a page, and the one page this app routes is the "${spec.screen.entity}" record's \u2014 a child record is a drawer on it` });
54894
+ findings.push({
54895
+ at: at2,
54896
+ message: `opens as a page, and this app routes an address only for "${[...routedRecords(spec)].join('", "')}" \u2014 a record reached from a section is a drawer on the record that lists it`
54897
+ });
54537
54898
  }
54538
54899
  if (record2.acts !== void 0 && record2.door !== "page") {
54539
54900
  findings.push({
@@ -54601,6 +54962,7 @@ function checkRecord(spec, key, record2, manifest) {
54601
54962
  ...section.official === void 0 ? [] : [section.official],
54602
54963
  ...section.awaiting === void 0 ? [] : [section.awaiting]
54603
54964
  ] : [],
54965
+ ...section.kind === "journal" ? [section.body, section.when, ...section.author === void 0 ? [] : [section.author]] : [],
54604
54966
  ...itineraryReads(child.itinerary)
54605
54967
  ];
54606
54968
  for (const alias of reads) {
@@ -54709,7 +55071,7 @@ function checkAppSpec(spec, manifest, components) {
54709
55071
  const bound = new Set(screen.slots.map((slot2) => slot2.role));
54710
55072
  const lead = screen.presentation?.lead;
54711
55073
  if (lead !== void 0) {
54712
- const refused = leadRefusal(screen.shape, bound, lead);
55074
+ const refused = leadRefusal(spec.records[screen.entity]?.archetype, bound, lead);
54713
55075
  if (refused !== void 0) findings.push({ at: at2, message: refused });
54714
55076
  }
54715
55077
  const drawnColumns4 = screen.slots.map((slot2) => {
@@ -54776,12 +55138,19 @@ function checkAppSpec(spec, manifest, components) {
54776
55138
  } else if (columns.length > 0 && layout !== void 0 && layout !== "table") {
54777
55139
  findings.push({ at: at2, message: `names columns beside \`layout: "${layout}"\`, which draws the rows with a device of its own instead of the register's columns` });
54778
55140
  }
54779
- for (const alias of columns) {
55141
+ for (const column of columns) {
55142
+ const alias = typeof column === "string" ? column : column.field;
54780
55143
  if (Object.hasOwn(screen.fields, alias)) continue;
54781
55144
  findings.push({ at: at2, message: `draws the column "${alias}", which this register does not project` });
54782
55145
  }
54783
55146
  for (const lens of screen.lenses ?? []) {
54784
55147
  if (typeof lens === "string") continue;
55148
+ if ("member" in lens) {
55149
+ if (!Object.hasOwn(screen.fields, lens.member)) {
55150
+ findings.push({ at: at2, message: `narrows by "${lens.member}", which this register does not project` });
55151
+ }
55152
+ continue;
55153
+ }
54785
55154
  for (const predicate of lens.predicates) {
54786
55155
  for (const condition of predicate.where) {
54787
55156
  if (Object.hasOwn(screen.fields, condition.field)) continue;
@@ -54815,10 +55184,10 @@ function checkAppSpec(spec, manifest, components) {
54815
55184
  for (const { message: message2 } of ctaRefusals(screen.acts)) findings.push({ at: at2, message: message2 });
54816
55185
  for (const act of specActsOf(screen)) findings.push(...checkAct(at2, act, screen.fields, manifest, "register"));
54817
55186
  for (const [key, record2] of Object.entries(spec.records)) findings.push(...checkRecord(spec, key, record2, manifest));
54818
- const register = spec.records[screen.entity];
54819
55187
  const mounts = /* @__PURE__ */ new Set();
54820
55188
  for (const create of spec.creates ?? []) {
54821
55189
  const mount = create.mount;
55190
+ const carrying = mount.kind === "register" ? void 0 : Object.values(spec.records).find((one) => one.sections.some((section) => section.key === mount.key));
54822
55191
  const at3 = mount.kind === "register" ? `creates.${create.entity}` : `creates.${create.entity} (on ${mount.key})`;
54823
55192
  const where = mount.kind === "register" ? "the register" : `"${mount.key}"`;
54824
55193
  const slot2 = mount.kind === "register" ? `register ${create.entity}` : `section ${mount.key}`;
@@ -54835,15 +55204,16 @@ function checkAppSpec(spec, manifest, components) {
54835
55204
  if (create.parent === void 0) {
54836
55205
  findings.push({ at: at3, message: `is mounted on ${where} and names no parent \u2014 a row added from a record's section hangs under that record` });
54837
55206
  }
54838
- if (register !== void 0) {
54839
- const section = register.sections.find((one) => one.key === mount.key);
55207
+ {
55208
+ const section = carrying?.sections.find((one) => one.key === mount.key);
54840
55209
  const listed = section === void 0 ? void 0 : sectionChild2(section);
54841
55210
  if (listed === void 0) {
54842
- findings.push({ at: at3, message: `is mounted on ${where}, which is not a section of the "${screen.entity}" record listing rows` });
55211
+ findings.push({ at: at3, message: `is mounted on ${where}, which is not a section of any record this app opens listing rows` });
54843
55212
  } else if (listed.entity !== create.entity) {
54844
55213
  findings.push({ at: at3, message: `is mounted on ${where}, whose rows are "${listed.entity}" and not "${create.entity}"` });
54845
55214
  } else {
54846
- const reopened = listed.opens !== void 0 || create.entity === screen.entity || section?.kind === "thread";
55215
+ const composed = section !== void 0 && COMPOSED_SECTIONS.some((kind) => kind === section.kind);
55216
+ const reopened = listed.opens !== void 0 || create.entity === screen.entity || composed;
54847
55217
  if (!reopened) {
54848
55218
  findings.push({
54849
55219
  at: at3,
@@ -54988,7 +55358,7 @@ function planWorkflows(entry, roles, templates = /* @__PURE__ */ new Map()) {
54988
55358
  for (const field of fields) held.add(field);
54989
55359
  written.set(table, held);
54990
55360
  };
54991
- for (const surface of [entry, ...childEditors(entry).values()]) {
55361
+ for (const surface of appEditors(entry).values()) {
54992
55362
  const operable = planWrites(surface);
54993
55363
  if (operable === void 0) continue;
54994
55364
  declared[writeAlias(operable)] = {
@@ -55537,7 +55907,7 @@ export const components: RuntimeComponents = {};
55537
55907
  `;
55538
55908
  function buildPlanFiles(app, entry, roles, templates = /* @__PURE__ */ new Map()) {
55539
55909
  const creates = planCreates(entry, roles);
55540
- const editors = [entry, ...childEditors(entry).values()].flatMap((surface) => {
55910
+ const editors = [...appEditors(entry).values()].flatMap((surface) => {
55541
55911
  const operable = planWrites(surface);
55542
55912
  return operable === void 0 ? [] : [{ path: `src/workflows/${writeAlias(operable)}.ts`, content: writeSource(surface) }];
55543
55913
  });
@@ -56132,7 +56502,7 @@ Captured ${totalRows} row${totalRows === 1 ? "" : "s"} across ${result.captured.
56132
56502
  }
56133
56503
 
56134
56504
  // src/model_reference.md
56135
- var model_reference_default = '# The Lotics workspace model (`model.json`)\n\nOne JSON file describing the tables, fields, options, views, roles and first rows\na workspace starts with. `lotics scaffold check model.json` proves it offline \u2014\nno account, no network. `lotics setup model.json --email you@company.com` creates\nthe account and applies it. `lotics scaffold apply model.json` applies it again,\ninto the workspace the credential names.\n\n**There are two forms of this file.** The full one, below, spells the model out.\nThe `from` one names a published preset and carries only what this business\ndiffers by \u2014 see \xA7 Starting from a preset, and prefer it whenever a preset fits\nthe trade.\n\nApps are PLANNED here and built afterwards: `apps` names each app\'s screens as a\nshape over an entity, checked against the roles `field_roles` gives its fields,\nso the plan is refused before anyone builds a screen (\xA7 Apps and screens). The\nbuilt app lives in the workspace; publishing that workspace as a package is how\nit ships.\n\n## The rules\n\n- **At least one entity, at most 50.** More tables than that is a data model\n being designed, not scaffolded \u2014 scaffold the rest in a second call.\n- **Adoption is explicit.** `lotics setup` REFUSES an entity whose `label`\n already names a table in the workspace, naming every colliding label at once.\n `lotics scaffold apply` adopts those tables and adds the fields, options and\n views they are missing. Nothing is ever modified or deleted, so applying the\n same model twice creates nothing the second time.\n- **Adoption is by LABEL, not alias.** Change an entity\'s `label` and the next\n run asks for a NEW table beside the old one. Renaming a FIELD is\n `lotics field rename <table> <field> "<new label>" --model <this file>`, which\n moves the platform, this file and every app bound to it together; deleting is\n `lotics run delete_table`. Neither goes through the file.\n- **The file\'s own majority is the language.** A model names no locale \u2014 which\n language it is in is what it mostly says, and `scaffold check` notes the label\n written the other way. The generated screens read the kit\'s pack, and a\n generated WRITE cannot: its refusals run on the server, so they are worded in\n that same majority. Mix the two and the workspace answers in two languages.\n- **`lotics scaffold diff model.json` says where the file and the workspace have\n come apart**, joined on label, entity then field \u2014 the join adoption itself\n makes. It exits 1 on any difference, so a model that is about to be published\n as a preset carries the labels in use rather than the ones it was written with.\n- **Rows land only where every bound table is empty.** One table already holding\n records and no rows are written anywhere, and the result says\n `rows_skipped: true`: sample rows landing among a customer\'s real ones cannot\n be told apart from them.\n- **After the first run the WORKSPACE is the source of truth.** The file is an\n authoring input, not a mirror \u2014 scaffold never deletes what the file stopped\n naming.\n- **`lotics scaffold check` decides all of it offline**, and reports every\n problem in one run rather than the first: an alias that resolves to nothing, a\n link whose pair is not symmetric, and the rows themselves \u2014 a field the entity\n does not declare, an option alias the field does not declare, a link naming no\n row in the file, a `ref` used twice, a date that is not one, a value on a\n platform-computed field, and a files cell that is neither a relative path\n beside this file nor a `fil_` id.\n\n## Top level\n\n```jsonc\n{\n "entities": [ /* the tables */ ],\n "roles": [ /* workspace groups to create */ ], // optional\n "templates":[ /* inline html / email templates */ ], // optional\n "rows": { /* first records, keyed by entity alias */ }, // optional\n "field_roles": { /* the reporting role each field plays, keyed by entity then field */ }, // optional\n "write_rules": { /* what a CREATE finds, defaults and refuses, keyed by entity */ }, // optional\n "apps": [ /* the screens each app will have, as shapes over entities */ ], // optional\n "apply": [ /* published packages to copy in afterwards */ ], // optional\n "preset": { /* a trade\'s branches, for a PUBLISHED model */ } // optional\n}\n```\n\nThe other form names a preset instead of restating one:\n\n```jsonc\n{\n "from": "field_service", // the preset this model starts from, by slug\n "variants": ["crews"], // optional \u2014 its branches to merge in, in order\n "rename": { // optional \u2014 what THIS business calls each table\n "job": { "label": "\u0110\u01A1n h\xE0ng", "fields": { "code": "M\xE3 \u0111\u01A1n" } }\n },\n "entities": [ /* tables the preset does not declare */ ], // optional\n "rows": { /* first records, keyed by entity alias */ }, // optional\n "field_roles": { /* roles on the preset\'s fields and this business\'s own */ }, // optional\n "write_rules": { /* create-time clauses on the preset\'s entities and its own */ }, // optional\n "apps": [ /* the screens each app will have */ ], // optional\n "apply": [ /* published packages to copy in afterwards */ ] // optional\n}\n```\n\n**A model may not carry** `fixtures`, `knowledge` or `knowledge_expects`, and no\n`excel` / `word` / `pdf-form` template: each of those is content that lives in a\npublished bundle, which a model has none of. `apps` here is a plan of screens,\nnever built code. An unknown top-level key is an error, never ignored.\n\n### Aliases\n\nEvery `alias` is a lowercase slug \u2014 a letter, then letters, digits and\nunderscores (`unit_price`, `so_1001`). Aliases are how the file cross-references\nitself; they are never shown to anyone. `label` is what a person sees.\n\nLabels must be unique within their namespace \u2014 two entities, two fields on one\nentity, two options on one field, two views on one entity, two roles or two\ntemplates cannot share a label, because scaffold matches by label.\n\n## Entity\n\n```jsonc\n{\n "alias": "order",\n "label": "Orders", // the table\'s name, which names the SET it holds\n "singular": "Order", // optional \u2014 ONE of them, for the act that opens one\n "description": "\u2026", // optional\n "fields": [ /* at least one */ ],\n "views": [ /* optional; an entity with none still gets the default grid */ ],\n "read_scope": { /* optional; absent, everyone with access to the table reads every row */\n "any": [\n { "member_of": "sales" }, // a role alias this model declares\n { "field": "scope", "is": ["shared"] } // a single select on this entity, by option alias\n ]\n }\n}\n```\n\n**`singular` is what a create says.** A register\'s own act and the panel it\nopens name the row being made \u2014 `New Order`, `H\u1ED3 s\u01A1 m\u1EDBi` \u2014 while `label` names\nthe table, so without it the button reads `New Orders`. Nothing derives it\n(English plurals are irregular), and most models need none: a Vietnamese noun is\nthe same word either way. `scaffold check` prints it beside the table under *Who\nwrites what* and NOTES a table that will name the set. An act on a child section\nkeeps the label: it adds a line to the register under the record the reader is\nalready standing in.\n\n**`read_scope` is a ROW rule, enforced by the platform.** A row is readable when\nANY clause holds: the reader is in that role\'s group, or the named select carries\none of those options. It is resolved at scaffold into the table\'s own row\nfilters, so an app, a workflow reading for a viewer, and the API all answer the\nsame rows \u2014 a per-record visibility field the app merely honours is a convention,\nnot a gate. `any` may not be empty (a rule nobody satisfies hides the table), and\nevery role alias and option alias in it must be one this model declares.\n\n## Field\n\nEvery field carries `alias`, `label`, an optional `description`, and an optional\n`required` \u2014 advisory only, read by app forms and workflows; the table itself has\nno required constraint. `label` may not contain `{` or `}` (formulas reference\nfields by label at the platform level).\n\n`default` is the value pre-filled into a NEW record. It applies on create only;\nexisting records are never backfilled. Only the types listed below accept one.\n\n### `text`\n\n```jsonc\n{ "alias": "name", "label": "Name", "type": "text",\n "unique": false, // optional \u2014 require distinct values\n "format": "text", // optional \u2014 "text" | "link" | "markdown"\n "default": "" } // optional\n```\n\n### `number`\n\n```jsonc\n{ "alias": "amount", "label": "Amount", "type": "number",\n "format": "currency", // optional \u2014 "number" | "currency" | "percentage"\n "currency": "VND", // optional \u2014 ISO 4217\n "default": 0 } // optional\n```\n\n`format` is what the number IS, and every surface reads it: `currency` prints as\nmoney in the code the row or the field states, `percentage` as a whole percent\nwith its sign. An ABSENT number is drawn absent \u2014 the one exception is a\n`sum` or count rollup the plan reads as a **`measure`**: that is the thing\naccumulated toward a bound, so nothing accumulated yet is zero and the meter\ndraws it. The same rollup read as an `amount` keeps its blank, and so does every\nother role: nothing added to what a row is WORTH means unpriced, not free. A\n`min`, an `avg`, a percentage of nothing and every FORMULA stay blank in any\nrole, because none of them has an answer to give. This is why the pair on one\nscreen reads two ways \u2014 what has come in against what is owed \u2014 and why a\nmeasure\'s own LIMIT, an amount, leaves an unquoted row out of the count rather\nthan reporting it as nothing collected. **AND WHERE THAT LIMIT IS ABSENT THERE IS\nNO LEVEL AT ALL**: a level is a reading AGAINST a bound, so a row that states no\nbound draws nothing \u2014 cell, fact and all \u2014 rather than a numerator whose whole\nmeaning was the comparison. "Collected 0" beside a blank total reads as money\nagainst a job worth nothing. A measure the model gives no limit is a plain figure\nand is unaffected. A share is stored in percent units \u2014 68.1 is 68.1 % \u2014 and the\ncolumn, the fact behind it, the meter it is judged by and the figure over the\nregister all say so.\n\n### `date`\n\n```jsonc\n{ "alias": "placed_on", "label": "Placed on", "type": "date",\n "format": "date", // optional \u2014 "date" | "datetime" | "date_range" | "datetime_range"\n "timezone": "Asia/Ho_Chi_Minh", // optional \u2014 IANA name\n "derive_from": "created_at", // optional \u2014 "created_at" | "updated_at"; makes the field read-only\n "default": "2026-01-01" } // optional; refused together with derive_from\n```\n\n### `boolean`\n\n```jsonc\n{ "alias": "paid", "label": "Paid", "type": "boolean", "default": false }\n```\n\n### `select`\n\n```jsonc\n{ "alias": "tier", "label": "Tier", "type": "select",\n "options": [ // at least one\n { "alias": "standard", "label": "Standard", "color": "slate" },\n { "alias": "gold", "label": "Gold", "color": "amber" }\n ],\n "multi": false, // optional\n "default": ["standard"] } // optional \u2014 option ALIASES; one unless multi\n```\n\n`color` is one of: `red`, `orange`, `amber`, `yellow`, `lime`, `green`,\n`emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`, `violet`, `purple`,\n`fuchsia`, `pink`, `rose`, `slate`, `gray`, `zinc`, `neutral`, `stone`.\n\n### `select_member`\n\nA person picker over the workspace\'s members. No default: a model cannot name\nmembers of a workspace that does not exist yet.\n\n```jsonc\n{ "alias": "owner", "label": "Owner", "type": "select_member", "multi": false }\n```\n\n### `select_record_link`\n\n```jsonc\n{ "alias": "customer", "label": "Customer", "type": "select_record_link",\n "target_entity": "customer", // an entity alias this model declares\n "cardinality": "one", // optional \u2014 "one" | "many" (default "many")\n "sync_both_ways": true, // optional \u2014 keep a paired field on the target\n "paired_field_alias": "orders", // the partner field ON THE TARGET entity\n "display_field_aliases": ["name"] } // optional \u2014 what the link shows / the picker\'s columns\n```\n\nA two-way link is declared on BOTH sides, each naming the other as its\n`paired_field_alias`; the pair must be symmetric or the model is refused.\n\n**A single-valued link needs no partner.** `"cardinality": "one"` on its own is a\nlink that holds one row \u2014 one customer on an invoice, one project on a device \u2014\nand nothing is created on the target. The mirror invariant belongs to a PAIRED\nlink: pair a link when the target\'s own record should list what points at it, and\nleave it unpaired when it should not. Either way the record plan draws the\nrelation as a section on the side it points at, so an unpaired link costs the\ntarget nothing.\n\n### `files`\n\n```jsonc\n{ "alias": "attachments", "label": "Attachments", "type": "files" }\n```\n\n### `formula`\n\n```jsonc\n{ "alias": "total", "label": "Total", "type": "formula",\n "formula": {\n "expression": "{amount} * 1.1", // fields on THIS entity, by alias, in braces\n "output_type": "number", // optional \u2014 what it YIELDS: "number" | "text" | "date" | "datetime" | "boolean"\n "format": "currency", // optional \u2014 how that result is DRAWN: "number" | "currency" | "percentage" | "link"\n "currency": "VND" // optional\n } }\n```\n\n`output_type` is what the expression answers WITH; `format` is how it is printed.\nThe platform infers the result at write time and ignores what you declare, so\nthis is a statement the offline checks read \u2014 which is what lets a role or a\nscreen clause accept a computed value: a caption over a derived name\n(`output_type: "text"`), a period over a settled date (`"date"`). A formula\ndeclaring neither says nothing about its result, and every rule that needs one\nrefuses it by name. `lotics scaffold export` writes the result a live workspace\ncomputed, so exporting a workspace fills these in.\n\n### `rollup`\n\nAggregates the records reached through a link on this entity.\n\n```jsonc\n{ "alias": "total_ordered", "label": "Total ordered", "type": "rollup",\n "source_field_alias": "orders", // a select_record_link field on THIS entity\n "aggregate_option": {\n "operation": "sum", // count | sum | avg | median | min | max | range |\n // empty | filled | percent_empty | percent_filled |\n // unique | percent_unique |\n // earliest | latest | date_range |\n // checked | unchecked | percent_checked |\n // percent_unchecked\n "field_key": "amount" // a field ALIAS on the linked entity ("count" may omit it)\n },\n "filter": { /* optional \u2014 see Views; every field_key is an alias on the LINKED entity */ } }\n```\n\nThe operation must be one the aggregated field\'s type allows \u2014 `sum` over a\nnumber, `earliest` over a date, `filled` over anything.\n\n### `lookup`\n\nDisplays a field from the linked records.\n\n```jsonc\n{ "alias": "customer_tier", "label": "Customer tier", "type": "lookup",\n "source_field_alias": "customer", // a select_record_link field on THIS entity\n "lookup_field_alias": "tier", // a field alias on the linked entity\n "order_by": { "field_key": "placed_on", "direction": "desc" } } // optional \u2014 pick the single extreme row\n```\n\n### `autonumber`\n\n```jsonc\n{ "alias": "seq", "label": "No.", "type": "autonumber",\n "prefix": "SO-", // optional \u2014 ignored when template is set\n "padding": 4, // optional \u2014 1..20, zero-pads the integer\n "template": "SO-{YEAR}-{N:4}" } // optional \u2014 {N}, {N:W}, {YEAR}, {YEAR:2}, {MONTH}, {DAY}\n```\n\n## Views\n\nSaved views live under the entity they belong to. Every field reference is a\nfield ALIAS on that entity.\n\n```jsonc\n{\n "alias": "gold",\n "label": "Gold customers",\n "description": "\u2026", // optional\n "columns": [ // optional \u2014 omit to show every field\n { "field_alias": "name", "visibility": "visible", "width": 240 },\n { "field_alias": "tier", "visibility": "hidden" }\n ],\n "filters": { // optional\n "node_type": "group",\n "logic": "and", // "and" | "or"\n "children": [\n { "node_type": "condition", "type": "select", "field_key": "tier",\n "operator": "has_any_of", "value": ["gold"] }\n ]\n },\n "sort": [ { "field_key": "name", "order": "asc" } ], // optional; order is "asc" | "desc" | null\n "summary": { "amount": "sum" }, // optional \u2014 field alias \u2192 footer operation\n "frozen_columns": 1 // optional\n}\n```\n\nA condition\'s `type` is the field\'s type and its `operator` is one that type\nadmits \u2014 `has_any_of` / `has_none_of` / `has_all_of` / `is_empty` /\n`is_not_empty` for a select, `equals` / `greater_than` / `less_than` for a\nnumber, `on` / `before` / `after` / `between` for a date, `contains` /\n`is_any_of` for text. A select condition\'s `value` names option ALIASES.\n\n`columns`, when present, is exhaustive and must not be empty: a view renders\nexactly the entries it holds. Omit the key to show every field.\n\n## Roles\n\nA role becomes a workspace group. Members are added afterwards, in the app.\n\n```jsonc\n{ "alias": "sales", "label": "Sales" }\n```\n\n## Templates\n\nOnly inline `html` and `email` templates \u2014 the rest are file-backed and a model\nhas no bytes. An `html` template renders to a PDF when a workflow generates\nfrom it; `{{name}}` is filled from the workflow\'s data.\n\n```jsonc\n{ "alias": "order_ack", "label": "Order acknowledgement", "type": "email",\n "content": "<p>Hello {{customer}}\u2026</p>" }\n```\n\nA paper that has to look like a counterparty produced it \u2014 an official letter,\nan acceptance minute, a supplier\'s bill \u2014 is the same `html` template with a\nshell around the body: a letterhead, a reference line, a seal and a signature\nblock, and paper grain over everything. One shell, many bodies; the data is the\nonly thing that changes, so a workflow can re-issue it over any record.\n\n```jsonc\n{ "alias": "cong_van", "label": "C\xF4ng v\u0103n", "type": "html",\n "content": "\u2026the page below, as one JSON string\u2026" }\n```\n\n```html\n<style>\n .sheet{position:relative;width:718px;padding:44px 58px 30px;background:#fbfaf6;color:#111;font:14.2px/1.5 \'Liberation Serif\',serif}\n .grain{position:absolute;inset:0;opacity:.34;mix-blend-mode:multiply;background:url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'140\' height=\'140\'><filter id=\'f\'><feTurbulence baseFrequency=\'.9\' numOctaves=\'2\'/><feColorMatrix values=\'0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0\'/></filter><rect width=\'140\' height=\'140\' filter=\'url(%23f)\'/></svg>")}\n .top{display:flex;text-align:center;font-size:13.4px} .top>div{flex:1} .u{display:inline-block;border-bottom:1px solid #111;font-weight:700}\n .ref{display:flex;text-align:center;font-size:13.4px;margin-top:6px} .ref>div{flex:1} .ref .r{font-style:italic}\n h1{text-align:center;font-size:15.6px;margin:26px 0 18px} p{text-align:justify;text-indent:26px;margin:0 0 9px}\n .sig{display:flex;margin-top:20px} .sig .l{flex:1} .sig .r{width:290px;text-align:center;position:relative}\n .sig .nm{font-weight:700;margin-top:96px} .seal{position:absolute;left:4px;top:8px;width:166px;height:166px;opacity:.66;mix-blend-mode:multiply;transform:rotate(-17deg)}\n </style>\n <div class=\'sheet\'><div class=\'grain\'></div>\n <div class=\'top\'><div><b>{{issuer_parent}}</b><br><span class=\'u\'>{{issuer}}</span></div>\n <div><b>C\u1ED8NG H\xD2A X\xC3 H\u1ED8I CH\u1EE6 NGH\u0128A VI\u1EC6T NAM</b><br><span class=\'u\'>\u0110\u1ED9c l\u1EADp - T\u1EF1 do - H\u1EA1nh ph\xFAc</span></div></div>\n <div class=\'ref\'><div>S\u1ED1: {{number}}</div><div class=\'r\'>{{place}}, ng\xE0y {{day}} th\xE1ng {{month}} n\u0103m {{year}}</div></div>\n <h1>{{title}}</h1>\n <p>K\xEDnh g\u1EEDi: {{recipient}}.</p>\n {{{body}}}\n <div class=\'sig\'><div class=\'l\'><b>N\u01A1i nh\u1EADn:</b><br>- Nh\u01B0 tr\xEAn;<br>- L\u01B0u VT.</div>\n <div class=\'r\'><img class=\'seal\' src=\'{{seal_url}}\'><b>{{signer_title}}</b><div class=\'nm\'>{{signer}}</div></div></div>\n </div>\n```\n\n`lotics preview <file.html>` renders any such page to a PNG the way a demo\'s\nprops are made, sized to its content, so a paper can be looked at before it is\nput in a template.\n\n## Rows\n\nFirst records, keyed by entity alias. Up to 200 rows per entity and 2000 across\nthe model, attaching at most 2000 documents between them \u2014 a real data set\nbelongs in an import, not a model.\n\n```jsonc\n"rows": {\n "customer": [\n { "ref": "acme", "fields": { "name": "Acme Trading", "tier": "gold" } }\n ]\n}\n```\n\n`ref` is a local handle (lowercase letters, digits, underscores) that other rows\'\nlink fields address. It is never persisted.\n\nA `files` cell attaches documents: paths relative to this file (no `..`, never\nabsolute), which `check` proves exist and `apply` uploads into the workspace\nbefore any row is written \u2014 a paperwork business seeds its papers with its\nrows. The server accepts only `fil_` ids of files this workspace owns, which is\nwhat the upload leaves behind. After a run that wrote rows, `apply` writes the\nrecord ids beside the file (`<model>.last_run.json`): `delete_records` over\nthem is how a seeded set is reset, and applying again re-dates it.\n\n`fields` is keyed by field alias, and every value is read against the field\'s\nDECLARED type:\n\n| Field type | Value |\n|---|---|\n| `text` / `number` / `boolean` | the value itself |\n| `date` | `"2026-03-14"`, or a relative expression (below) |\n| `select` | the option ALIAS \u2014 `"gold"`, or `["gold","vip"]` for a multi-select |\n| `select_record_link` | `"<entity-alias>:<ref>"` naming another row in this file \u2014 `"customer:acme"`, or an array for several |\n| `select_member` | `"self"` only \u2014 the person applying the model |\n| `files` | paths beside this file \u2014 `["scans/pccc_letter.png"]` \u2014 uploaded by `apply`/`setup` before the rows are posted; or `fil_` ids of files already in this workspace |\n| `formula`, `rollup`, `lookup`, `autonumber` | not allowed \u2014 the platform writes these |\n\n**Documents can be attached on their own, afterwards.** Rows land only into empty\ntables, so a model whose binaries were added after the first apply has no second\napply to carry them: `lotics scaffold apply model.json --documents` writes ONLY\nthe `files` cells, onto the records the first run created, joined through the\n`<model>.last_run.json` beside the file. Running it twice attaches nothing the\nsecond time \u2014 the same path keeps the same file, and a cell is a set.\n\n### Relative dates\n\nA date cell holds a literal `YYYY-MM-DD`, or an expression relative to the day\nthe model is applied, so a screen that opens on "this month" is not empty a month\nlater:\n\n- `@today` \u2014 the day of the run, in the workspace\'s timezone\n- `@month-start` \u2014 the 1st of that month\n- either with a whole-day offset: `@today-14`, `@month-start+9`\n\n`@month-start` exists because `@today-N` cannot promise a month: applied on the\n2nd, `@today-3` lands in the previous one.\n\n## Field roles\n\n`field_roles` names the reporting role a field plays on its entity \u2014 keyed by\nentity alias, then field alias \u2014 so every screen over the entity agrees on\nwhich column names the row and which select is the stage. A shape\'s slot binds\nto it (\xA7 Apps and screens). Like `rows` and `apps`, it is this file\'s: `check`\nproves it and the workspace never sees it. Each role sits on the types that can\nanswer it:\n\n| Role | On | Meaning |\n|---|---|---|\n| `identity` | `text`, `select_record_link`, `formula` | what a PERSON calls the row \u2014 the register\'s first column; a link where the row is "the product, at this branch"; a formula where the name is computed, and then it may not be `format`ted as a figure. NEVER an autonumber: a minted code is a `reference`. One per entity |\n| `reference` | `text`, `autonumber`, `formula` | the key the SYSTEM files the row under \u2014 an order number, a container code \u2014 drawn as the supporting line under the name rather than as a column of its own, and leading where the entity has no `identity` at all. One per entity |\n| `mark` | `files`, or a `lookup`/`rollup` that resolves to one | the row\'s picture \u2014 its own, or the linked record\'s. NEVER A COLUMN: a register draws words, so a mark is projected only where a surface leads with one \u2014 the subject rung of a picture-led grid, and a record\'s itinerary. A child entity\'s mark reaches a record\'s run and nothing else. One per entity |\n| `lifecycle` | single `select` | the ordered stages a row walks; option order is the order. Which of them END the flow is `outcomes`, which parts of the flow they group into is `phases`, and `history` keeps the day each one was reached. One per entity |\n| `category` | single `select`, or a `lookup` that resolves to one | what the row IS \u2014 a kind, a service, a book. One badge in the field\'s own colour, with no ladder behind it and no flow to advance. Often a fact about the thing the row books rather than about the row, and then it is the lookup that reads it. `icons` gives each kind the glyph a run draws it with. Repeats: a row can be of two kinds of thing |\n| `measure` | `number`, `formula`, `rollup` | a level read against a limit \u2014 see `against` and `alert`. Money where the model says so, and then it prints as money |\n| `expected_set` | `select` | its OPTIONS are the required set (documents, checks, services); an option no row has is a gap to show, not nothing. A multi-select draws as a ring and a fraction wherever it is drawn \u2014 absence is the information, and a list of what IS there says nothing about what is missing |\n| `amount` | `number`, `formula`, `rollup` | THE money of a ledger row; `signed_by` says which way it moved, `against` names the reference it is quoted off. One per entity |\n| `when` | `date`, or a `formula`/`rollup`/`lookup` that yields one | the ledger or timeline date \u2014 stated, or derived: the day money MOVED is a formula over the two columns that could hold it. `due` makes it a DEADLINE; without it the date is the plain day it is. `until` names the stage of this entity\'s own `lifecycle` at which the countdown is spent, and says `due` by saying so. One per entity |\n| `slot` | single `select`, or a `datetime` `date` | where in the DAY a row sits \u2014 the run it is read in under its day\'s heading on an itinerary. A select\'s option order IS the run\'s order; a time is ordered by the clock. A plain `date` is refused: that is the day itself. One per entity |\n| `party` | `select_record_link` | the counterparty. One per entity \u2014 and left off where the `identity` IS the link to them: the row is then NAMED by that record, and a strip under the title would state them twice |\n| `parent` | `select_record_link` | the record this row belongs to \u2014 a line\'s order, a paper\'s case. The parent\'s record shows these rows; the row shows the parent as a fact. One per entity, and it links to an entity this model declares |\n| `contact` | `text` | a way to reach a party \u2014 an address, a number, the town it is in. The record draws them as ONE row of links under the name, so the role sits on every field that is one of them. Repeats |\n| `currency` | single `select` whose option LABELS are ISO 4217 codes | the money THIS ROW\'s figures are in. Every amount and every money measure on the entity is then printed per row rather than in one code for the whole column, and the select is not drawn as a fact of its own. One per entity |\n| `verdict` | `boolean`, `formula` | a settled pass/fail \u2014 ticked, or computed. TRUE is the PASSING side wherever it is drawn, a register\'s risk flag included, so a field whose true means trouble is the same fact asked the other way round. One per entity |\n| `obligation` | `date` | a day something is OWED by \u2014 a cut-off, a permit expiry, a payment due. It counts down by definition. `satisfied_by` names what CLOSES it (or `until`, the stage the record stops owing it at), `label` what is owed. Repeats: a row owes several things, and a shape that fans them draws one row each |\n\n**`due` is what makes a `when` a deadline.** A date a row is merely filed by \u2014 the\nday a lead arrived, the day a movement happened \u2014 is neither early nor late,\nhowever long ago it was. Without the clause every desk drew every `when` as a\ncountdown and a two-month-old lead read "40 days overdue" on a record nobody was\nlate on. So a bare `when` is a plain date, and `{ "role": "when", "due": true }`\nis the one that counts down. An `obligation` needs no clause: a day something is\nowed by is a deadline already.\n\n**`until` stops a countdown where the work is DONE.** A deadline counts down so\nsomebody acts on it, and a row that has arrived needs nothing: without the clause\na delivered order is tinted for a date it met, and every settled row past its day\njoins the urgent ones in the reader\'s glance. It names one option of the entity\'s\n`lifecycle`; at that stage, at every stage past it and at every `outcome`, the\ndate is drawn as the plain day it is. On a `when` it also says the date is `due`.\n\n"One per entity" is one COLUMN, never one value on screen. A second counterparty\nor a second parent stays a ROLELESS `select_record_link`: which field fills a\nslot is the screen\'s answer (\xA7 Apps and screens), and the extra link is a fact on\nthe row with its own section on the record, headed by that link\'s own label. A\nrole naming two fields would move the ambiguity into every shape that reads it.\n\nA COMPUTED field is admitted where its RESULT is what the role needs, and\nrefused where it is not: `identity` and `reference` need `text`, `when` a `date`,\n`mark` `files`. A formula\'s result is its `output_type`; a rollup\'s and a\nlookup\'s is read through the walk. So a formula yielding a number is refused in a\nname\'s place, a lookup landing on anything but `files` is refused as a `mark`, and\na formula declaring NO result is refused by all four \u2014 naming `output_type` as\nthe remedy, because a value drawn as a type nobody stated is the wrong cell with\nnothing saying so. The result also decides the DEVICE every screen draws the value\nwith: a rollup taking the `latest` of a set of dates is drawn as a date, a lookup\nof a select as the words it holds.\n\nA bare role name is the common form. A role that is read against a SECOND field\ntakes the object form:\n\n- **`measure`** names its limit: `against` \u2014 a constant, or a field on the same\n entity the row states as a number (a `number`, or a formula or rollup whose\n result is one) \u2014 and `alert`, which side of it needs attention, `over` a\n capacity or `under` a minimum. The two come together.\n- **`measure`** names what its number COUNTS, where the unit changes how the row\n is DRAWN rather than how the figure reads: `counts: "days"` spans a stop across\n that many days of a run, so a three-night stay fills three of its days instead\n of only the one it starts on, and `counts: "hours"` is how long a stop takes\n INSIDE its day, stated beside it. Stated, never inferred \u2014 nothing about a `3`\n says whether it is nights, pallets or hours, and a quantity drawn across a week\n is a run nobody can read.\n- **`lifecycle`** names the stages that END the flow: `outcomes`, option aliases\n of that select. A row in one has ARRIVED \u2014 delivered, cancelled, written off \u2014\n so a desk draws them apart from the ladder instead of chaining them after each\n other. Not every option may be an outcome, and terminal-ness belongs here, never\n written into a stage\'s label.\n- **`lifecycle`** groups its stages into the parts of the flow they belong to:\n `phases`, each a `label` and the `stages` under it. Nine rungs down one column\n is a list nobody reads as a flow; the same rungs under three headings are three\n pieces of work, and which belong together is the business\'s answer. Every stage\n but an `outcome` falls in exactly one \u2014 a stage in two is drawn twice, a stage\n in none vanishes off the ladder \u2014 and the outcomes may be placed in a phase or\n left out, and are then read as a last part of their own.\n- **`lifecycle`** keeps every stage the row reached: `history: true`, or\n `history: "<alias>"` to name the table. A ladder with no history reports where\n a row IS and nothing about how it got there, which is the whole of what a\n reader asks a pipeline. It is declared BESIDE `phases`, and refused without\n them: the rungs a ladder draws are the live select\'s options, which nothing\n reading a file or an app\'s spec can see, so `phases` is the one statement of\n what the dates have to cover \u2014 and without it a rung the history cannot reach\n draws undated on every record with nothing anywhere saying so. The flag is the\n ONE statement: the model DERIVES a\n child table from it \u2014 the link back to this record, the stage, the moment it\n was reached and who moved it \u2014 and `check`, `apply`, `diff` and the app\n generator all see that table exactly as they see a written one. Nothing else\n declares it, and a file that also writes it by hand is refused. The generated\n create stamps the rung the flow opens at and the generated editor stamps every\n move after it; a stage changed anywhere ELSE is a rung with no date\n (`docs/platform_gaps.md`). **A first apply backfills nothing** \u2014 `apply` writes\n rows only into empty tables, and rows that existed before the flag walked their\n stages before that table existed. The honest backfill is ONE opening row per\n existing parent, at its FIRST stage, dated when that parent was created (true\n by construction); the stage it stands on NOW is not dated unless that is also\n the first. It is a create per parent \u2014 `lotics run create_records` \u2014 and\n `scaffold apply` prints it as the work it did not do.\n- **`category`** gives each kind its glyph: `icons`, option alias \u2192 a lucide icon\n name. A run\'s node is a dot the width of a word, so a stop with no picture of\n its own reads as every other stop. Nothing derives a glyph from an option\n written in the business\'s own language, and a kind the map leaves out draws the\n neutral one. A name lucide does not have at all is refused; one lucide ships\n and the kit has not imported is a NOTE \u2014 it draws the neutral glyph, and the\n fix is either another name or one more glyph in the kit.\n- **`amount`** names the REFERENCE it is read against: `against`, a field on the\n same entity the row states as a number. A price against the list it is quoted\n off, a rate against the going one \u2014 and the catalogue item\'s record draws the\n pair on one axis with the gap said in words. Never a constant (a price typed\n into the model ages with nothing to update it) and never an `alert`: a limit is\n a ceiling a row can pass, and beating a reference is the point.\n- **`amount`** names the select that SIGNS it: `signed_by`, a select on the same\n entity, and `outflow`, the options of that select under which the amount is\n money going out. Without it every shape over the ledger adds both directions\n together: a month whose net was small reads as the total of everything that\n moved, and the trend plots one rising line. The two come together, and\n `outflow` is some of that select\'s options, never all.\n- **`expected_set`** names what CONDITIONS the set: `required_by`, a field on the\n same entity, and `options`, which of that field\'s values require which entries.\n A row whose value is not named requires nothing. Without it the denominator is\n every option, so a set whose entries are mutually exclusive by kind reads\n `1 of 4` on every complete row \u2014 a denominator no row can reach is worse than\n no role. The field is a single `select`, keyed by its option aliases \u2014 or a\n YES/NO the row answers itself (a `boolean`, or a formula resolving to one),\n keyed by `"true"` and `"false"`: a check that FAILED owes its consequence \u2014 the\n photograph, the owner, the day it is due \u2014 and there is no select of the record\n that says so. `from: "parent"` reads that field off the record these rows hang\n under instead, through this entity\'s own `parent` link: which documents an order\n owes is the ORDER\'s type, and the papers carry no column that says it. Which of\n the two a set takes is the set\'s own shape and not a choice \u2014 a multi-select\n holds the whole set on one row and is narrowed by that row (`from` omitted), a\n single select is one entry per row and takes `from: "parent"` \u2014 and the other\n way round is refused rather than left conditioning nothing.\n- **`obligation`** names what ENDS it: `satisfied_by`, a `date` or a `files` field\n on the same entity \u2014 the day it was done, or the paper that proves it \u2014 or,\n where the business stamps nothing, `until`, the stage of this entity\'s\n `lifecycle` at which the record stops owing it: a deposit is owed until the\n order is paid, and nobody records the act of paying twice. One or the other,\n never neither \u2014 without one every obligation the business ever met stays on the\n desk. Optionally `label`, what is OWED as the reader says it ("G\u1EEDi SI"), which\n is not what the column holding the date is called ("SI cut-off").\n\n```jsonc\n"field_roles": {\n "product": { "name": "identity", "photo": "mark" },\n "stock": { "on_hand": { "role": "measure", "against": "minimum", "alert": "under" },\n "uptime": { "role": "measure", "against": 80, "alert": "under" } },\n "order": { "stage": { "role": "lifecycle", "outcomes": ["delivered", "cancelled"],\n // Two pieces of work, and every step dated.\n "phases": [{ "label": "Taking it on", "stages": ["placed", "confirmed"] },\n { "label": "Getting it out", "stages": ["picked", "shipped"] }],\n "history": true },\n // A DEADLINE COUNTS DOWN \u2014 `payment.paid_on` below is a plain day.\n "ship_by": { "role": "when", "due": true },\n // The day the papers are owed by, and the day they went.\n "papers_due": { "role": "obligation", "label": "File the papers", "satisfied_by": "papers_sent" },\n // Nothing stamps a deposit paid \u2014 the order\'s own stage ends it.\n "deposit_due": { "role": "obligation", "label": "Take the deposit", "until": "delivered" } },\n // WHICH PAPERS THIS ONE OWES IS THE ORDER\'S OWN TYPE, and no document says it.\n "document": { "order": "parent",\n "kind": { "role": "expected_set",\n "required_by": { "from": "parent", "field": "kind",\n "options": { "export": ["invoice", "customs"] } } } },\n // `kind` is the direction select \u2014 options `received` and `paid_out`, no role of its own.\n // Every figure on a quotation is in the currency that row names.\n "quote": { "unit": "currency", "total": "amount" },\n // What the price is quoted off, so the item\'s page reads one against the other.\n "service": { "price": { "role": "amount", "against": "list_price" },\n // What each kind of service looks like on a run\'s node.\n "kind": { "role": "category", "icons": { "install": "wrench", "collection": "truck" } } },\n // The day the money moved is neither early nor late, so it stays a bare `when`.\n "payment": { "paid_on": "when",\n "value": { "role": "amount", "signed_by": "kind", "outflow": ["paid_out"] },\n // A receipt owes a receipt voucher; a payment owes an invoice and a payment voucher.\n "papers": { "role": "expected_set",\n "required_by": { "field": "kind",\n "options": { "received": ["receipt_voucher"],\n "paid_out": ["invoice", "payment_voucher"] } } } },\n // A CHECK THAT FAILED OWES ITS CONSEQUENCE \u2014 keyed by the row\'s own answer,\n // and the answer that owes nothing is omitted rather than named with an empty list.\n "check": { "passed": "verdict",\n "evidence": { "role": "expected_set",\n "required_by": { "field": "passed",\n "options": { "false": ["photo", "owner", "due"] } } } }\n}\n```\n\nIn a file that starts from a preset (\xA7 Starting from a preset), `field_roles`\nmay name the preset\'s fields as well as this business\'s own; a role the preset\ndeclares itself is kept unless this file names the same field, and `null`\nclears it.\n\n## Write rules\n\n`write_rules` is what only a CREATE meets \u2014 keyed by entity alias, like\n`field_roles`, and this file\'s in the same way: `check` proves it and the\nworkspace never sees it. An update names one field that moved; a create takes a\ndraft whole, so it has to know which row a name already belongs to, where a\nvalue comes from when nobody types it, and what a figure or a picker may hold.\nThe generator writes one `create_<entity>` workflow and one `New<Entity>Dialog`\nper entity an app can operate, from these clauses and the fields\' own\n`required`.\n\n```jsonc\n"write_rules": {\n // A customer is RECOGNISED by their address. Where an entity names a customer\n // as its `party`, the create takes the email instead of a picker, reuses the\n // row it matches and mints one only where nothing does \u2014 so the book never\n // grows a second Acme because somebody typed the name differently.\n "customer": { "natural_key": ["email"] },\n "order_line": {\n "fields": {\n // A line of nothing is not a line. Refused on create and on update, at\n // the control the figure was typed into.\n "quantity": { "min": 1, "max": 9999 },\n // The price is fixed at the moment of ordering \u2014 COPIED off the product,\n // not looked up for ever after, so the price list moving next week does\n // not silently reprice an order already placed.\n "unit_price": { "default_from": "product.price" },\n // And nothing is sold off an empty shelf. The picker reads only the rows\n // that answer this, and the write refuses the same rows again \u2014 a caller\n // who never opened the picker is bound by it too.\n "product": {\n "options_where": {\n "node_type": "group", "logic": "and",\n "children": [{ "node_type": "condition", "type": "number",\n "field_key": "in_stock", "operator": "greater_than", "value": 0 }]\n }\n }\n }\n }\n}\n```\n\n| Clause | On | Meaning |\n|---|---|---|\n| `natural_key` | the entity | the field aliases a row is recognised by. A `text` key declares `unique: true` on the field itself \u2014 two rows sharing it would make find-or-create pick whichever the read answered first \u2014 and a key is `text` or `number`, because a person types it back |\n| `default_from` | a field | `"<link alias>.<field alias>"` \u2014 the value is copied from the linked row when the row is created, never asked. The link is a one-row link on this entity and `required`, because there has to be a row to read, and the two field types must match |\n| `min` / `max` | a `number` | the figure is refused outside them, on create and on update |\n| `options_where` | a `select_record_link` | an `and` group of plain conditions over the TARGET\'s own fields, each `field_key` a field alias. It narrows the picker\'s read and is refused again where the write lands, so the link is `required` |\n\nA field\'s own `required` is not here: the contract carries it, every write path\nrefuses the row by field name from it, and the generated panel stands its commit\ndown until the same set is filled. `unique` is the text field\'s own clause\n(\xA7 `text`) \u2014 the create says so at the control before the column does.\n\nWhat a create asks is what a person STATES. A `default_from` field is not drawn,\na `lifecycle` opens at its first rung, the stamp an obligation\'s `satisfied_by`\nnames is not asked (the row is only now taking that on), and files are attached\nto the row afterwards \u2014 one fact, one place. `scaffold check` prints every clause\nunder its entity in **Who writes what**.\n\n**The `parent` is prefilled only in the door that mounts the act.** A row opened\nfrom the record it hangs under takes that record from the door it was pressed\nin, so the link is neither asked for nor drawn. The same entity\'s act on its own\nregister has no such row, so there the parent is an ordinary picker the draft\ncannot be committed without \u2014 a payment opened from a money app belongs to a\ncase either way.\n\n## Apps and screens\n\n`apps` is the plan: each app the reader will build, as ONE REGISTER \u2014 a SHAPE\nover an ENTITY \u2014 under `screen`. Nothing here is built by the scaffold: the plan\nis what `lotics scaffold check` prints back, register by register with the field\nin every slot, so it is read and corrected before a screen exists.\n\n**THREE THINGS DECIDE EVERY SCREEN AND EVERY RECORD**: the SHAPE, whose slots are\nthe table below; the ROLES the entities declare (\xA7 Field roles), which fill those\nslots and decide what each child\'s rows become; and the CLAUSES, which are where\nthe plan overrides what the two would answer. This index says which is which, so\na clause is reached for only where the first two have no answer.\n\n**What a child\'s rows become.** One section per LINK into the record, and what\nthe CHILD declares decides its kind \u2014 the first line it answers wins.\n\n| Printed as | The child declares | The reader gets |\n|---|---|---|\n| `documents:` | an `expected_set` select, one entry per row | the desk of what is owed, each row\'s files attached to it |\n| `timeline:` | an `obligation` closed by a DATE | the ordered stops, the promised day against the day it happened |\n| `thread:` | a `markdown` body, a `party` and a `when` | the correspondence, its answer, and whose move it is |\n| `itinerary:` | a `when` and a `lifecycle`, on rows a JOB\'s record OWNS | the day heads the run, one line per stop, the sum under it |\n| `lines:` | anything else the record owns (`parent`) | the register of the rows it is made of |\n| `history:` | anything else naming it as their `party` | the same rows read as that party\'s own history |\n| `via <link>:` | a link carrying neither role | the register, headed by that link\'s own label |\n| `related:` | rows of an entity this app lists NOWHERE | one counted line, and a press that opens their register |\n\nA child carrying the BODY and one of the other two is a plain register, and\n`scaffold check` names the declaration it is one short of rather than letting it\nfall through silently. A `party` beside a `when` and no body is not a near miss \u2014\nthat is every ledger line there is.\n\n**The clauses, by name.** On the APP: `scope`. On the `screen`: `record`, `tabs`,\n`slots` (`roles` on a `custom` one), `columns`, `writes`, `period`, `filters`,\n`summary` (`above`, `totals`, `ageing`, `trend`), `facts`, `presentation`\n(`lead`, `density`, `layout`, `until`), `acts` (`row`, `record`, `selection`,\n`export`, `import`), `section_acts`, `sections`. Every one is optional, every one\nis printed back by `scaffold check`, and a screen that states none gets what its\nshape and its roles answer by themselves.\n\n**ONE APP IS ONE REGISTER AND THE RECORDS IT OPENS.** A second register beside\nit is a second job on one page: the reader arrives on whichever the nav listed\nfirst and decides, every time, which of the two they came for. So an app has one\ndestination and everything else about a row is DISCLOSED by opening it \u2014 the\nfacts by tier, the children as lists, the related as counts, one primary act, and\na filter or a group where a strip of destinations would have been. What used to\nbe a second screen is a section of the record, or another app; a model still\nsaying `screens` is refused by name.\n\n**The unit of an app is a JOB, not a person and not a table.** A job has its\nown outcome (something exists or is settled when it is done), its own subject\n(the record it advances), and an end that does not wait on the rest of the\nwork. Two tasks are ONE job when neither finishes without the other and both\nadvance the same record. One app per job, and that is what makes an app a\nwrite-ownership boundary: what the job settles is its app\'s alone to write,\nplus everything it must read to settle it well. A person holding several jobs\nopens several apps \u2014 one app for everything one person does is the dump. A step\nof the job is a section of the record, never a register beside it; a reference\nthe job needs at hand is read inside the record it is about.\n\n**Two people signing is two jobs**, because the outcome belongs to the signer:\nthe desk that prepares against the gate that releases. So is a different\ncadence \u2014 reference data edited monthly and read by the public site, beside a\ndaily desk \u2014 and a different reader, the owner\'s read-only questions. Device,\nplace and step never split a job. A super app holds more than one job; an\nover-split holds less than one, a job cut by device, place or step. The count\nper workspace falls out of the jobs, typically two to six, and is never the\ninput: review the plan app by app, naming who holds it, the job in one\nsentence, what it writes and what it reads.\n\n*A two-van appliance repair shop.* The technician\'s job is the call-out: the\noutcome is a visit done, the subject is the call-out record, and quoting it and\nscheduling it are one job, because neither finishes without the other and both\nadvance that record. The owner holds two of his own \u2014 billing the month\n(outcome invoiced, subject the invoice, settled against visits already closed)\nand the price list the booking page quotes from, edited monthly. Three jobs,\nthree apps, and the owner opens two of them.\n\n**Inside a job the caps hold**: six flow stages on a desk, seven facts before a\nrecord\'s fold. Past them, look for the second job hiding inside. And a job\'s app\nis DENSE: every create the job needs lives in it, so its user never leaves it to\ncorrect a figure the screen in front of them is stating \u2014 three workflows is a\nscreen, not a desk.\n\n**A handoff is a stage change.** Where one job ends the record moves stage and\nthe next job\'s desk opens on it; a field two jobs must both write is declared\nshared at the split, naming the stage each may write it in.\n\n**Name an app for the JOB, in the trade\'s own words, never for who it is for.**\nA title on the door says nothing about what the person who opened it came to\ndo, and it is wrong the day the org chart moves.\n\n```jsonc\n"apps": [\n {\n "alias": "sales", "name": "Sales",\n "description": "\u2026", "icon": "briefcase", "theme": { "color": "blue" }, // optional\n "screen":\n { "alias": "orders", "label": "Orders", "shape": "lifecycle_desk", "entity": "order",\n "record": "drawer", // optional \u2014 "drawer" | "page"; absent, the shape decides\n "tabs": "stage", // optional \u2014 a select on the entity, or null; absent, the shape decides\n "writes": false, // optional \u2014 default TRUE; false makes this screen a reader\n "period": "due_date", // optional \u2014 any field whose value is a date, derived ones included\n "filters": ["kind", // optional \u2014 a single-select, or a lens the model states itself\n { "label": "Qu\xE1 h\u1EA1n l\u01B0u", "predicates": [\n { "label": "\u0110\xE3 qu\xE1", "tone": "red",\n "where": { "node_type": "group", "logic": "and", "children": [\n { "node_type": "condition", "field_key": "owed", "operator": "greater_than", "value": 0 }] } }] }],\n "summary": { "totals": ["total"], "above": ["total", { "field": "owed", "at": "end" }],\n "ageing": { "amount": "owed", "due": "due_date", "buckets": [30, 60, 90] },\n "trend": { "field": "total", "direction": "up" } }, // optional \u2014 see below\n "facts": { "groups": [{ "caption": "Pricing", "fields": ["rate", "surcharge"] }] }, // optional \u2014 the record\'s named bands\n "presentation": { "lead": "none", "density": "dense" }, // optional \u2014 how it is DRAWN; absent, what the rows are decides\n "acts": { "row": [{ "label": "Issue the note", "template": "debit_note", "place": "cta" },\n { "kind": "agent", "label": "Read the papers", "agent": "reader", "fills": ["ref", "due_date"] },\n { "kind": "workflow", "label": "Hand it to dispatch", "workflow": "hand_to_dispatch",\n "inputs": { "order_id": "record", "owed_by": "due_date" } }],\n "record": [{ "label": "Print the file", "template": "dossier" }], // optional \u2014 the record\'s own header menu\n "selection": [{ "label": "Statement", "template": "statement" }], // optional \u2014 the work it hands on\n "export": true, // optional \u2014 the rows in view, saved\n "import": { "kind": "import", "label": "Upload the sheet", // optional \u2014 a file turned into rows\n "entity": "order", "key": "code", "columns": ["rate"] } },\n "section_acts": { "line": [{ "label": "Chase the lines", "template": "chaser" }] }, // optional \u2014 a verb on one section\n "sections": { "line": { "draw": "worksheet", "cost": "buy_rate", "sell": "rate" }, // optional \u2014 priced lines, worked down in place\n "payment": { "draw": "ledger", "summary": ["total", "paid", "outstanding"] } }, // optional \u2014 a book headed by what it comes to\n "slots": { "identity": "code", // optional \u2014 slot \u2192 field, where the roles cannot decide alone\n "subject": ["customer", "project"], // \u2026or the TIERS a fold walks down, outermost first\n "stage": { "field": "state", "quick": true } }, // \u2026or the field AND the reader\'s own control for it\n "columns": ["source", "owner"] } // optional \u2014 extra facts after the slots, shed first at narrow width\n }\n]\n```\n\nA shape is a proven screen with named SLOTS, each filled by a field carrying a\nrole (\xA7 Field roles). A slot with exactly one candidate on the entity binds by itself;\ntwo candidates need naming in `slots`; a field fills one slot; a required slot\nwith none is refused \u2014 a lifecycle desk over an entity with no `lifecycle`\nselect cannot be built.\n\n**A LIST IS A HIERARCHY, not a set of columns.** A group register\'s `subject`\ntakes one \u2014 `"subject": ["customer", "project", "order"]`, outermost first \u2014 and\nthe register becomes one the reader walks DOWN: it folds by the first tier, a\nnode narrows to the tier inside it, the last tier opens the set behind the\nfigure, and a trail says where they are. Every tier is a field of this entity\ncarrying a role that slot accepts, and none of them fills a second slot. It is\nthe slot\'s own answer that decides: a list on any other is refused, because two\ncolumns in one cell is not a fold. Without it the same business needs a register\nper depth, and the same money is folded twice with nothing saying it is the same\nmoney.\n\n**A QUICK SLOT IS FOR A DECISION THE READER MAKES FROM THE ROW ALONE.** A slot\'s\nvalue in `slots` is normally the field\'s alias; `{"field": \u2026, "quick": true}`\nsays the column is not a reading of that value but the CONTROL for it \u2014 pressed,\nit writes that one field as a diff through the record\'s own update, so the\nregister and the page behind it land the same write. THREE roles are such a\ndecision, and `quick` on any other is refused: a `lifecycle`, which rests as the\nstage\'s own dot and label, takes a rule under it on hover and focus, and opens\nthe field\'s stages with the ones that END the flow last \u2014 ONE control, which IS\nthe reading;\na `verdict`, which is the switch; and a `measure`, which is the figure typed in\nits own cell \u2014 a reading taken per row IS the row, which is what a timesheet\'s\nhours and a count sheet\'s tally are. Everything else is decided against what the\nrecord holds, and the record has to be open. All three carry the record\'s own\nblockers \u2014 a move the ladder holds is a move the cell holds, and it names the\nentries the row still owes \u2014 and an outcome asks before it commits. Add `"order": "sequence"`\nwhere the stages are a WALK rather than a set of destinations: the picker is then\nordered as the walk and the step the row takes next is MARKED in it. It never\nadds a second control \u2014 a column that answered with a reading in some rows and a\nverb in others is two columns about one value. A screen stating `writes: false`\nrefuses `quick`: a reader who may operate nothing has no decision to take.\n\n**THE SLOTS ARE THE ROW\'S ANSWER; `columns` IS ITS CONTEXT.** `"columns":\n["nguon", "phu_trach", "nhu_cau"]` names extra fields of the entity, drawn AFTER\nevery slot and in this order, each by what its column IS \u2014 a chip for a select,\nthe person\'s name for a member, the day for a date, the figure for a number, a\ntick for a boolean, the words for everything else. They are ranked BENEATH every\nslot, so a phone sheds all of them before it sheds any of the shape\'s own\ncolumns. At most four, and refused where one would say what a slot already says,\nover a files field (files are read, so they are a section of the record), over a\ncell holding several (a column of comma lists compares nothing), on a shape whose\nrows are not the entity\'s records in a table, and beside a `presentation.layout`\nthat draws the rows with a device of its own. A fifth fact worth the width is a\nslot the shape is missing \u2014 say so rather than widening this clause.\n\n| Shape | Answers | Required | Also fills | Record | Tabs |\n|---|---|---|---|---|---|\n| `lifecycle_desk` | what is stuck, what do I move next | `lifecycle`, `identity` | `mark`, `party`, `amount`, `measure` (level), `when` | page, or drawer where the entity carries `parent` | the lifecycle\'s stages |\n| `party_register` | who is this, our history, is there a risk | `identity` | `mark`, `contact`, `measure` (worth), `verdict` (risk) | page | none |\n| `offering_register` | what do we offer, at what price, can I sell it | `identity` | `mark`, `amount` (price), `measure` (availability) | page | none |\n| `transaction_ledger` | does this period reconcile, what is unexplained | `when`, `amount` | `identity` (reference \u2014 the line\'s own number), `party`, `lifecycle` (classification), `expected_set` (document) | drawer | none |\n| `monitored_asset_set` | what needs attention, is that number normal | `identity`, `measure` (level) | `mark`, `lifecycle` | drawer | none |\n| `obligation_desk` | what is due next, and has it been done | `identity`, and at least one `obligation` on the entity | `when` (runway) | page | none |\n| `trend_deep_dive` | how did the period go, and why | `when` | `measure`, `amount` | drawer | none |\n| `reconciliation_desk` | what does not match, and by how much | `identity` (reference), and two figures \u2014 `ours` and `theirs`, each an `amount` or a `measure` | `category` (reason), `verdict`, `when` | drawer, on the PAIR | the dated runs, where the model names a select |\n| `entry_matrix` | one value per subject per period | `identity` (subject), `across` \u2014 a `when`, or a `category` for a fixed column set | `measure` (value), `lifecycle` (state), `category` (note) | drawer, on the cell\'s row | none |\n| `guided_run` | complete an ordered sequence, a step at a time | `identity` (step) | `slot` (sequence), `capture` \u2014 a `measure`, `verdict` or `expected_set` \u2014 `verdict` (gate), `mark` (media) | page: the run IS the record | none |\n| `live_board` | is everything OK, right now | `lifecycle` (state), `identity` | `verdict` (exception), `when` (since), `measure` (level), `category` (where) | drawer | none |\n| `group_register` | what does each group come to, and what is behind it | `subject` \u2014 a `category`, `party` or `when` | `amount`, `measure`, `identity` (member) | page: a row is an aggregate, and the door is the SET behind it | none |\n| `media_set` | scan a body of pictures by where they belong | `mark` (picture), `identity` | `category` or `party` (group), `when`, `verdict` (current against superseded) | drawer | none |\n| `day_sheet` | what happened on each day | `when` (the day) | `lifecycle` (state), `measure` (level), `amount`, `category` (note) | page: a day composes several child logs | none |\n| `resource_schedule` | what is on each resource, in what order, under what ceiling | `lane` \u2014 a `party` or a `parent` \u2014 `identity`, `when` (the start) | `measure` (duration), and `load` and `bulk`, each a `measure` read against a ceiling of the LANE\'s \u2014 a vehicle fills by weight and by room and stops at whichever runs out first; `lifecycle` (stage) | drawer, over the lanes | none |\n| `worksheet` | priced lines the reader edits, totalling to one figure | `identity` | `category` (group), `measure` (quantity), and `cost` and `sell`, each an `amount` or a `measure` | drawer, per line | none |\n\n**A record is one of five KINDS, and the shape plus the roles decide which.**\nEvery one of them is ONE READING COLUMN, and the ORDER of that column is the\nwhole of what the kind means.\n\n| Kind | The column, top to bottom |\n|---|---|\n| WORK RECORD \u2014 a `lifecycle_desk` over rows belonging to nothing | the one act that moves it \xB7 what it IS \xB7 the papers it owes \xB7 the rows it is made of \xB7 the book of what it came to |\n| LINE \u2014 the same shape over rows carrying `parent` | its ladder \xB7 the arithmetic behind its amount \xB7 the rows and papers under it \xB7 its particulars, last (the key it is filed by is the line under its title) |\n| PROFILE \u2014 a `party_register` | its history, OPEN, grouped by year \xB7 the rest of its registers \xB7 its facts (the ways to reach it are under its name, its settlement is the band) |\n| CATALOGUE ITEM \u2014 an `offering_register` | its own words (the picture leads the header at media scale, the price is read against its reference in the band) \xB7 what uses it \xB7 its facts |\n| EVIDENCE \u2014 a `transaction_ledger` | the PROOF \xB7 what the paper is, compactly \xB7 the rest \xB7 the links to the record it settles and the party it was with |\n\nNothing in the file states the kind: a clause that could say it could say the\nwrong one, and `parent` already says whether a row stands alone. `record`\noverrides the DOOR where the shape\'s own answer is not the one wanted \u2014 and its\nthird value, `"expand"`, is not a door at all: the row REVEALS what it holds in\nplace, where there is nothing behind it worth navigating to. A row read that way\nreads as a LINE whatever the shape would have opened: its ladder, the arithmetic\nbehind its amount, then its particulars, because there is no header above it to\nhave stated the name first. It is REFUSED for two reasons, and they are not the\nsame refusal. On a shape whose record is a page by nature \u2014 a `guided_run`, a\n`group_register`, a `day_sheet`, an `obligation_desk` \u2014 because each of those\nstates the opposite where its door is declared: what its row leads to is read\nwhole, not as four more columns than the register had room for. And on a shape\nthat draws its rows with a device of its OWN \u2014 an `entry_matrix`, a `media_set` \u2014\nbecause a cell of a grid and a tile on a wall have no band under them for the row\nto reveal into. For the same reason a revealed register is drawn as a TABLE: a\n`presentation.layout` of anything else is refused, and the reader is not offered\nthe arrangement either, since it would take away the only door the register has.\n\n**`scope` \u2014 the one subject every read of the app narrows to.** Stated on the\nAPP rather than on its screen, because it is not a filter: a record opened under\nit stays under it, the pick survives closing the app, and every app declaring the\nsame `entity` shares one pick per viewer \u2014 which is the whole value, and what\nstops a construction workspace asking which project twelve times. `entity` is the\nmodel\'s entity whose one row the app is read inside, and `param` is what the\napp\'s reads take that row by.\n\n```jsonc\n{ "alias": "site_work", "name": "Site work",\n "scope": { "entity": "project", "param": "project_id" },\n "screen": { \u2026 } }\n```\n\nThe register\'s own entity has to REACH it \u2014 its own rows, or rows that name one\nthrough a link \u2014 or the switcher is a control that changes nothing. Until a\nsubject is picked the app reads NOTHING and says which one it is waiting for: an\nunscoped read over a scoped app is every row in the workspace drawn as one\nproject\'s work, which looks correct.\n\n**ONE RECORD SURFACE PER ENTITY, AND ITS KIND IS THE ENTITY\'S.** An app is one\nregister, so the record its rows open is the register\'s own and the kind comes\nfrom that register\'s shape. Another app over the same entity opens the same kind\nof record: a payment read from a cash book and one read from a trend are both\nmovements, and both read proof first. A shape with no kind of its own (a trend, a\nmonitored set, a `custom` screen) says only where the record opens.\n\n**Two things a register states about a row beyond which field fills which slot.**\nA `measure` is read AGAINST its limit (`against`/`alert`) where the shape\'s slot\ntakes one \u2014 `level`, on a lifecycle desk and a monitored set, and every slot of a\n`custom` screen, which composes the frame\'s own column; `worth`, `availability`\nand a trend\'s headline are plain figures, and a limit there would read as a meter\nin the record over a number the row printed bare. And the name carries a\nSUPPORTING LINE where the entity states a key to file the row under: the `parent`\nit belongs to, its `reference`, an `autonumber`, a text formula \u2014 in that order,\nfirst hit wins, never a field a person types prose into. Every record heads with\nthat same key, so the register and the door it opens name one row one way.\n\n**The act that opens a row belongs to a register that LISTS the entity\'s rows**\n\u2014 a desk, a register, a ledger, a monitored set, or a `custom` screen. A shape\nwhose rows are not records has neither that act nor the door a counted line\nelsewhere leads to: an obligation desk\'s rows are deadlines and a trend\'s are\nperiods, so a create pressed there would open a row the screen cannot show. An\nentity whose only app is one of those has no create at all \u2014 give it an app whose\nregister its rows are read in.\n\n**An `obligation_desk`\'s rows are not its entity\'s rows.** The shape fans the\nentity\'s `obligation` fields out \u2014 one row per thing still owed, which is one\nwhose date is SET and whose `satisfied_by` is empty \u2014 so a l\xF4 with four cut-offs\nis four rows, and the three it has met are not there at all. The row\'s name is\nthe obligation\'s, its supporting line the record\'s `identity`, and the door is\nthat record. A `when` bound to `runway` is what the countdown\'s ring is measured\nfrom. Over an entity declaring no `obligation` the shape is refused: there is\nnothing to count down to.\n\n**What a register carries beyond its columns.** Six clauses, each emitted as\nthe prop the kit draws it with; every one is optional and a screen that states\nnone gets a register of columns and nothing else.\n\n- **`period`** \u2014 a field on the entity whose value is a DATE. The toolbar gains a\n date-range control (this month to start), and the rows it keeps are what the\n register AND every figure below are computed over, so a band can never be over a\n different window than the rows under it. Any such field, not only the `when`\n role, and however the date got there: one table is read two ways (a cost ledger\n by the day a line arose, the cash book over the same table by the day it\n settled), a role is one field\'s, and the day money MOVED is often a formula over\n the two columns that could hold it \u2014 which then declares `output_type: "date"`.\n A `trend_deep_dive` brings its own period and takes none here; a `live_board`\n is PERIODLESS and takes none either, for the opposite reason \u2014 it answers what\n is true NOW, and a date range over it draws what was true in the window in the\n live state\'s own colours.\n- **`filters`** \u2014 the chips beside the search. A single-`select` field\'s alias\n offers that field\'s own live options; it is the lens a register is read through\n over and above the one band its strip gives, so the strip\'s own field is\n refused here (one dimension, one control) and so is a multi-select (a row would\n answer the chip several ways at once). The rows the register and every figure\n below are computed over are what the chips AND the period kept.\n A DERIVED LENS is the other form \u2014 `{"label": \u2026, "predicates": [{"label": \u2026,\n "tone": \u2026, "where": \u2026}]}` \u2014 where the sets a reader narrows by are ones the\n MODEL names and no column holds: rate validity, plan urgency, free-time\n overrun. Each `where` is an `and` group of plain conditions over the entity\'s\n own fields, each `field_key` a field alias, and it is read off the row, so the\n operators are the comparisons a value answers \u2014 `number` and `text` equality,\n `number` ordering, `boolean` equality, `select` `has_any_of`/`has_none_of`, and\n `is_empty`/`is_not_empty` on any of them. Nothing DATED: a relative point needs\n a clock, and a screen states one date control (`period`), so a second beside it\n would be two windows with nothing saying which a figure was computed over \u2014 a\n date question is asked as a column the model derives and read here as a number\n or a yes/no. `tone` is the option palette\'s, because the chip draws these\n exactly as it draws a select\'s options.\n- **`summary`** \u2014 what the rows in view come to. `above` is a band OVER the\n register: `"counts"` for how many rows are in view and, for the FIRST\n `measure` the model gives a limit, how many are past it (accented only when\n one is) \u2014 one such set, because a band naming three is the dashboard a\n register is not; a list of number-field aliases for what they add up to, and a\n `percentage` named there is refused, since a share summed over the rows in\n view is a figure of no kind (draw it as a column, whose own total reads the\n mean). A figure written `{"field": \u2026, "at": "end"}` is a STOCK instead: the\n reading standing at the END of the window rather than the sum of the readings\n in it, which is the only way opening + in \u2212 out = closing reconciles \u2014 a month\n of daily closing stocks added together is thirty warehouses. The band labels it\n as the snapshot it is, and it is refused on a screen that states no `period`,\n since there is then no window for it to stand at the end of.\n `ageing` stands in that same\n band: an `amount` split by how many days past its `due` date each row is,\n drawn as a `Breakdown` of the edges in `buckets` (30, 60 and 90 days unless the\n model states its own, ascending). The ladder is the kit\'s \u2014 its boundary, its\n words and its ramp \u2014 and it opens with what is NOT YET DUE, because a bar of\n overdue bands alone is full at every input: a book with one late invoice and a\n book that has gone entirely bad would paint the same solid width. Against the\n current money the bar\'s own shape is the reading. A row whose date is empty is\n in no band. `totals` is what the whole\n view adds up, and it is drawn in that SAME band above the rows: a register\n states one aggregate, over the rows the reader can see, in one place, and a\n closing line under them is a second place to look and a second question about\n which rows it covers. A closing line belongs to the one device that IS a\n statement \u2014 a record\'s `Ledger`, whose balance is what it is read for, labelled\n by its amount\'s own word. Where a shape has no band above (a trend, whose own\n band is the chart) the figure stands under the register instead. A\n `transaction_ledger` sums its amount column itself and takes `above` alone. An\n `obligation_desk`\'s rows are DEADLINES and not records, so its band states\n `"counts"` \u2014 how many are open \u2014 and a figure list, an `ageing` or a `trend`\n over it is\n refused: a l\xF4 with three cut-offs is three rows, and its freight added over\n them is three times the freight.\n `trend` is `{"field": \u2026, "direction": "up"|"down"}` and states WHICH WAY that\n figure moved across the window: the rows in view are cut into the window\'s own\n buckets \u2014 days over a month, weeks over half a year, months beyond \u2014 and the\n later half of the CLOSED ones is read against the earlier half, drawn beside\n the figures as one line, so a window the reader is still inside states the\n movement of the days that have run rather than a fall into the ones that have\n not. `direction` is which way is GOOD, which nothing about the number\n says: a book wants its takings rising and a backlog wants its days falling, and\n the same arrow is a win on one and an alarm on the other. It needs a `period`\n to be a window of, and it is refused on a shape that draws its own (a\n `trend_deep_dive` already draws the series) or that reads none at all (a\n `live_board` answers what is true now). A window whose earlier half took\n nothing draws no line: there is no base for a percentage, and 0 % would claim a\n steadiness nobody measured.\n- **`facts`** \u2014 how the RECORD\'s facts are banded. `groups` is a list of\n `{caption, fields}`: what a set of facts has in common is a sentence about the\n business and nothing derives it, so a plan that states one gets exactly those\n bands, in its own order, captioned. EACH BAND IS A SECTION of the record \u2014 its\n own heading, its own entry in the rail, its own place in the column: under one\n heading the reader is handed every particular at once, in a caption weight that\n cannot out-rank the heading above it, with nothing in the rail to reach any of\n them by. Everything the plan leaves unnamed is the LAST section and carries no\n heading, since there is no sentence to head "whatever no group claimed" with \u2014\n ONE section, even where the record\'s own recipe bands what was left in two (an\n evidence record reads its particulars before the record and the party it was\n with): both are groups inside it, because the word the kit heads "the rest"\n with cannot name two entries in the rail.\n A band of more than eight facts is NOTED: a section that long is two. A field the header, the band, the ladder, a required\n set, the files or a register below already draws is refused: it is not a fact,\n so a band naming it would either state it twice or draw nothing. Naming any\n band IS the answer to which facts fold \u2014 see the TIERS below.\n- **`presentation`** \u2014 how the screen and the record it opens are DRAWN, where\n what the rows are is not the answer wanted. `lead` is what each row leads\n with: `"mark"` the subject\'s own mark, always spent because a party\'s initials\n stand in for a picture nobody uploaded; `"picture"` the photograph, spent only\n on the rows that carry one and, on the record, at media scale above the name;\n `"paper"` the row\'s own files, drawn as the cards a pile of documents is read\n as; `"figure"` the amount, with no gutter at all; `"none"` neither. `density` is\n how many lines a row\'s subject may take \u2014 `"roomy"` two, `"dense"` one.\n Both default, and the DEFAULT is what the rows are: a party register leads\n with the mark, an offering register with the picture, a ledger with its\n figure, and a desk \u2014 rows that are work still to do, scanned \u2014 stands its rows\n one line each while a record\'s own rows are read roomy. So state it only to\n differ, and a plan that states nothing still gets screens that vary. A lead\n the rows cannot carry is refused: a mark, a picture or a paper where no column\n is drawn as the rows\' mark, a\n figure where no column is the amount, and the other subject\'s mark (which of\n the two a row wears is the shape\'s, so the register and the record it opens\n cannot call one row two kinds of thing).\n `layout` is how the rows are ARRANGED \u2014 `"table"`, `"list"`, `"cards"`,\n `"gallery"`, `"board"`, `"calendar"`, `"timeline"`, `"gantt"` \u2014 and it is\n AFFORDED by what the rows carry, not by the shape: every register affords a\n table and a list, a `mark` affords the two picture-led grids, a `lifecycle`\n affords a board, a `when` affords a calendar and a timeline, and a `when`\n beside a `measure` that `counts` DAYS affords a gantt, because a bar with no\n length is a calendar drawn sideways and a bar measured in money or litres is a\n length of another kind. `until` names the date field a bar ENDS on, where the\n rows state one, and the days measure is what the bar runs for without it. A\n layout the bound roles do not afford is refused, naming the ones they do.\n- **`acts`** \u2014 where this screen hands work on: `row` is the \u22EF menu on every row,\n `record` is the \u22EF on the RECORD\'s own page header \u2014 the same reach as a row\'s,\n standing where the work is open instead of while a list is scanned, and refused\n on a record that opens as a drawer, which has no header of its own and whose\n row already carries the register\'s menu \u2014 and `selection` is the bar over the\n TICKED rows. `export` is the third reach \u2014\n the WHOLE VIEW, saved in one press: `true` writes the rows as the register drew\n them, in the columns it drew, as an `.xlsx`, and\n `{"template": "\u2026"}` says the layout is the trade\'s and makes the paper with a\n workflow like any other. It is never a list of columns: which columns the\n export carries is what the screen already draws, and a second statement of it\n disagrees the moment a slot moves \u2014 the generator reads them off the drawn\n slots and writes them into the app, so the sheet\'s headings are the labels the\n register drew them under.\n `import` is the reach OPPOSITE it \u2014 a file turned into rows:\n `{"kind": "import", "label": \u2026, "entity": \u2026, "key": \u2026, "columns": [...]}`. The\n file is mapped column by column, each row is validated, what would change is\n previewed, and the commit UPSERTS by `key` \u2014 which is why a sheet sent twice\n moves no counts. That key is one of the entity\'s own `natural_key` fields\n (\xA7 Write rules), and an entity declaring none is refused: without a key the\n second run is a second set of the same rows. `entity` is the register\'s own \u2014\n an app is one register, and rows filed into another entity are a count nobody\n on this screen can check. `columns` is what the sheet may fill, in that order;\n absent, it is every column a person states IN WORDS. A computed one is refused\n because the workspace writes it, and a link, a member or a files column is\n refused because a cell of a sheet is words and those hold a row of another\n table or bytes \u2014 a file reaches another table through the party pattern (a\n `natural_key` on the target, named rather than picked), which is a create\'s.\n The generator writes the whole verb, as it does for a paper: an\n `import_<entity>` workflow that finds the row by `key` and then changes it or\n opens it, answering which of the two, and the staged run over it \u2014 drop, map,\n the per-row verdict, the commit. A line whose cell the column cannot hold is\n refused with the reason and the rest of the sheet still lands.\n Both spreadsheet reaches are read and written IN THE BROWSER, so the generated\n `src/main.tsx` imports `@lotics/app-runtime/sheets` wherever the plan states\n one of them and not otherwise; an app that has neither carries no spreadsheet\n engine at all. An act names ONE of three things, never two:\n - **`template`** \u2014 an `html` template this model declares (\xA7 Templates). The\n paper is filled from ONE row in `row`, and from the whole ticked set in\n `selection`. The generator writes the whole verb \u2014 a `generate_<template>`\n workflow that reads the row and hands the file back, and a menu item that\n opens it \u2014 so there is nothing left to bind. An `email` template is sent\n rather than opened and is refused here; a file-backed template (`excel`,\n `word`, `pdf-form`) is bytes a model has none of, so those stay the author\'s\n own `lotics app workflow set`. Two screens over DIFFERENT entities cannot\n name one template: one paper is filled from one kind of row.\n - **`{"kind": "agent", \u2026}`** \u2014 a run over ONE row. `agent` is an alias the APP\n declares (`package.json#lotics.agents`), because an agent is prose and tools\n rather than anything a workspace model can state \u2014 `lotics app check` refuses\n one nothing declares, exactly as it refuses a workflow nothing bound. `fills`\n is the fields the run may write: pressed, the reader watches the run, reviews\n what it proposes field by field against what the row holds now, and applies\n the ones they kept as ONE write through the record\'s own update. A run can\n reach nothing outside `fills`, a computed column there is refused (the\n workspace writes those), and a screen stating `writes: false` refuses an\n agent act outright. It belongs in `row`; the selection bar makes ONE paper\n from many rows, and a run per ticked row is the row\'s own act many times.\n - **`{"kind": "workflow", "workflow": "\u2026", "inputs": {\u2026}}`** \u2014 the work HANDED\n ON: a lead becomes an opportunity, an order is split into the orders placed\n on its suppliers, a request is closed. `workflow` is an alias the APP binds\n (`package.json#lotics.workflows`), because the rule behind it is the\n business\'s and no model states one \u2014 so the generator writes NO body and\n `lotics app check` refuses an alias nothing bound, exactly as it refuses an\n agent nothing declares. `inputs` is what the press hands that body: the\n workflow\'s own input name \u2192 `"record"` for the row it was pressed on, or a\n field of this entity for a value off that row. The value is what the\n workspace HOLDS \u2014 an option\'s key, a linked row\'s id, the figure \u2014 never the\n rendering. A files column is refused (the body reads the row\'s files off the\n row it is handed), a column that is not a field of the entity is refused by\n name, and one input short of the declaration is refused at the press, so the\n whole act is dropped rather than shipped half-bound. It runs ON the press:\n there is nothing to review first, which is the agent arm\'s law, and the\n body\'s own sentence is what the reader is told either way. It stands in\n `row`, in `record` and on a `section_acts` band \u2014 each reaches ONE row \u2014 and\n is refused over the ticked set, where one act makes one paper from many.\n\n **`"when"` stands an act down until the work is ready.** `{ "field": "<the\n entity\'s lifecycle>", "in": ["<stage>", \u2026] }` offers the verb only while the\n row stands at one of those stages. A verb that cannot work yet is worse than\n no verb: the reader presses it, the body refuses, and nothing on the screen\n ever said the work was not ready. Readiness is what a lifecycle states, so the\n field named is this entity\'s `lifecycle` and nothing else \u2014 a category says\n what a row is and a verdict answers a question, and neither moves. Refused: a\n field that is not the lifecycle, a stage it does not declare, and every stage\n at once, which is the act with no condition.\n\n **`"place": "cta"` draws an act ON the row** instead of in its \u22EF \u2014 the one verb\n a reader presses without opening a menu first. At most one per screen and every\n other act stays in the menu, because the trailing gutter is paid for by every\n row: a second is refused with *one verb on the row, the rest in its menu*. The\n ticked set has no row of its own, so `cta` is refused there.\n\n A hand-off\'s BODY is still the author\'s: `lotics app workflow set <alias>`\n binds it, and `scaffold check` prints the act as `"<label>" \u2192 <alias>(\u2026) [you\n write the body]` so it is read as work owed rather than as a verb already\n wired.\n\n A `selection` act is a `template` and nothing else: an act over many rows makes\n ONE paper from them. The generator turns the register\'s checkbox gutter\n on, emits a `generate_<template>` workflow taking the ticked ids, and the body\n reads each row and passes them as `rows` \u2014 which is what the template iterates\n (`{{#each rows}}`). One template is one paper AND one reach: naming the same\n one from a row\'s \u22EF and from the bar is refused, because those are two bodies.\n A shape whose rows are DERIVED rather than records \u2014 an `obligation_desk` \u2014\n has no set to tick and refuses the clause. The paper is handed BACK, never\n filed: a ticked set can hold rows of three different parents, so there is no\n record on which "this document belongs here" is true.\n\n**`section_acts` puts a verb WHERE ITS EFFECT LANDS.** "Chase the paperwork"\nbelongs on the papers, not in the register\'s \u22EF two surfaces away. It is keyed by\nthe alias each section is DERIVED from \u2014 a field\'s (its progress, its prose, its\nrequired set, its charge, one of its files) or a CHILD ENTITY\'s (its register,\nits desk, its run, its thread) \u2014 because the sections come off the roles and the\nkey the app addresses one by does not exist until it is built. An alias naming no\nsection is refused, listing the ones that do; the facts band is what every other\nsection left over, so nothing addresses it. Each act is a `template`, an `agent`\nor a `workflow`, exactly as a row\'s is \u2014 the reach is the same one row \u2014 and\n`place: "cta"` is refused: a section is a band with a heading and has no row to\ndraw a verb on. `scaffold check` prints\nwhich section each alias landed on, which is the half an author cannot see in\ntheir own file.\n\n**`sections` says HOW one of those sections is DRAWN**, keyed by the same\naliases. It carries two readings.\n\n`"draw": "ledger"` heads a book of movements with what the record it is against\ncomes to: `summary`, number fields of THIS record, in the order they read. A\nsection with nothing in it is otherwise a heading, a verb and a void \u2014 and the\nemptiness is exactly when the reader most needs to be told what the rows would\nbe for, so the statement is drawn at nought rows too. The figures are the\nRECORD\'s rather than the child\'s for the same reason: a sum of the rows under it\nis the one statement a book with no rows cannot make.\n\n`"draw": "worksheet"`: the child\'s rows\nare PRICED LINES the reader works down in place, each part of the job footed and\nthe sheet closing under them. `cost` and `sell` name the child\'s two figures,\nwhich is the one thing the roles cannot decide \u2014 an entity carries one `amount`,\nand a line that is costed and sold carries two. Everything else is read off the\nchild\'s own roles: what a line is FOR is its `identity`, how many it is for is\nthe `measure` the pair left, and the part it falls under is its `category`. The\nMARGIN is on none of them, because it is arithmetic over the pair.\n\nA sheet is the WRITE side of a price, so it is the one child section whose cells\nare editors: a figure typed into a cell is written as a diff through the child\'s\nown update, which is the same editor the line\'s own drawer saves through. Every\nother child section is read where it is drawn and edited in the row\'s drawer. A\nline is ADDED from the section\'s heading as every child\'s row is, with the record\nit hangs under as the act\'s own context.\n\nRefused: an alias naming no register of this record, rows the record is merely\nthe `party` or `link` of (a line added to a history belongs to the job it is\nabout, not to what is reading it), a figure that is not a field of the child or\nwhose role is neither `amount` nor `measure`, a sheet naming neither figure, one\nfigure priced as both, and a book headed by anything but a number field of the\nrecord.\n\n**A CHILD NOBODY REGISTERS IS A NOTE, not a refusal.** Where a record lists a\nchild entity no app is a register of, `scaffold check` says `"<entity>" has no\nregister \u2014 its rows are read here and created nowhere` and the plan printout\nmarks that entity `(no app)`. Rows can arrive from an import or a workflow, so\nit is a reading rather than a rule; what it catches is the register somebody\nmeant to plan and did not. A thread is exempt \u2014 a reply is written where it is\nread \u2014 and so is a sheet, which opens its own lines.\n\n`scaffold check` prints every clause a screen states, on its own line under the\nslots, spelling the screen\'s `writes` clause `operable` \u2014 the app manifest\'s\n`lotics.writes` keeps that word, and the two are different facts: `app create`\nSEEDS the manifest from the fields the screens\' own editors write, and from then\non the app owns the declaration `lotics app check` holds its bodies to.\n\nEach shape is a `@lotics/ui` component of the same name (`LifecycleDesk`,\n`PartyRegister`, \u2026) whose props are these slots, so once the tables exist\n`lotics app create <name> --from <this file>#<app alias>` scaffolds the app with\none screen per entry, each slot reading the field the plan bound.\n\n`"shape": "custom"` is the screen no registry row covers: it declares its own\n`roles` (slot name \u2192 role), and it is emitted on `ShapeFrame` \u2014 the one anatomy\nthe six shapes above are each a configuration of \u2014 so its strip, search,\nordinal, fit budget, empty and waiting states and record door are the same ones\nthey have. It opens the record its `record` says, drawer or page, like any other.\nA bound `lifecycle` slot IS its strip, the stages in the field\'s order as on a\ndesk, so such a screen names no `tabs`; a `tabs` select is the flat strip a\nscreen with no lifecycle gets.\n\n**An app IS its `app.json`.** `create --from` writes the bound plan \u2014 every\nscreen with its shape and slots, the record each row opens with its sections in\nthe archetype\'s order, the create panels, the acts \u2014 as one JSON document, plus\na five-line `src/main.tsx` that mounts `@lotics/app-runtime` over it and one\n`src/workflows/<alias>.ts` per write. There is no screen source: the runtime\ndraws the spec, so a kit correction reaches every app with its next install.\nWhere the plan has no word for what a screen or a section IS \u2014 or for what a\npaper act should ASK before it is made \u2014 the spec names one of the app\'s own\ncomponents and `src/components/index.ts` registers it, the one file under `src/`\na regeneration never rewrites. `lotics app eject <screen|<section key>|<act\nlabel>>` writes each of those, starting from what the runtime already drew.\n\n**How a spec reads a row.** Each query projects its columns under the alias the\nworkspace mints from the field\'s LABEL \u2014 never the alias this file keys it\nunder, which is the model\'s own namespace and which the workspace never saw. So\na field this file calls `partner` and labels `\u0110\u1ED1i t\xE1c` is referenced as\n`doi_tac` throughout the spec. Every id in it is live: the `tbl_` a screen is\nover, the `fld_` of each column, and the `opt_` of every option a role names.\n\n**Every query is described, in the model\'s own language.** The line an agent\nchooses between aliases by is written from this file\'s nouns \u2014 the entity\'s\nlabel, the screen\'s, the link\'s \u2014 and the sentence around them is the language\nthe file is mostly written in, decided the same way a generated write\'s refusals\nare. Hand-editing one is erased by the next regeneration; `lotics app check`\nrefuses an alias that carries none.\n\nA screen is that list and the RECORD it opens, and the record comes off the same\nroles \u2014 nothing to declare for it. It opens with a **header**: the entity\'s\n`identity` as the record\'s name \u2014 whether or not the list has a column for it, so\na ledger\'s and a trend\'s records are named too \u2014 the `when` this screen reads\nunder it, and ONE headline\nfigure (the `amount` the screen reads, else its `measure`). BOTH DOORS state the\nname: which door a screen uses is a layout answer, and what the record is ABOUT\nis not.\n\n**A JOB\'S HEADER ALSO STATES WHO IT IS FOR.** Where the record is the work itself\n\u2014 a desk\'s rows that belong to nothing, opened on a page \u2014 its `party` is a link\nunder the name, beside the ways to reach the subject, and it is then not a fact\nas well: a page headed by a code alone said nothing about whose work it is, and\nthe one thing a reader arriving from the desk already knows the row by sat in the\ngrid below as a row among forty. A record opening in a DRAWER has no row of links\nto hang it on, so its party stays a fact; so does a LINE\'s, whose register files\nit under the thing it belongs to and whose party is that parent\'s, restated per\nrow.\n\n**A record whose figures are a SENTENCE states them under the header, in a\nband**, and the header then states neither of them: a job reads what it comes to,\nhow far through it is (the `measure` against its limit), what is left of it (a\nformula that is exactly `{amount} - {measure}`) and how long there is (an\n`obligation`, else its `when`, counted down); a party reads its settlement, the\n`amount` and `measure` roles it carries in the order the model declares them; a\ncatalogue item reads its `amount` against the reference that amount names. Two\nfigures are the floor and four the ceiling \u2014 under two, the header keeps its one.\nA band is a PAGE\'s strip, so a screen whose `record` is a drawer keeps every\nfigure where a drawer reads them. Each figure is drawn exactly once: the limit a\nmeter states is not a fact beside it, and the day a countdown counts to is not\nthe provenance line above it. The `lifecycle` is not badged there, because the progress section is the\nrung it stands on. Then its sections, in the order its KIND reads them: the\n**facts** (every field neither the header, the band nor another section owns, the\nrow\'s own `parent` among them \u2014 led by the ones THIS screen\'s slots bound, then\nthe key it is filed under, then the order the model declares them in \u2014 a\n`markdown` field among them, drawn across the grid\'s whole row rather than\nwrapped to a third of it), the record\'s own **body** (that same markdown, taken\nas a section instead, ONLY where the kind leads with it: a catalogue item IS its\ndescription, and a job is not its notes), the **charge** (where the `amount` is a formula over exactly one\nquantity and one money field, the line states `quantity \xD7 unit price = amount`\nand neither figure is typed twice \u2014 the section is headed by the amount\'s own\nlabel and the closing row says what the figure IS, so the word is said once),\nthe **progress** (the `lifecycle`\'s stages as a ladder the reader ticks a rung of\nto move the record on, grouped into its `phases` where the model states them, and\neach rung carrying the day it was reached where the lifecycle keeps a\n`history`), a\n**required set** (a multi-select `expected_set`, or a child entity whose rows\ncarry one entry of it each \u2014 that child\'s `files` field is what a paper attaches\nto), the record\'s **own rows** (any other child, its role-bound fields as\ncolumns), and its **files** (every `files` field, the `mark` first \u2014 a section of\nthe column like any other, straight after the facts it is the evidence for,\nexcept on an EVIDENCE record, which OPENS on the paper it exists for; the\nheading carries the Add verb, and stands it down while the pile is empty, where\nthe drop well is already the door; and a `verdict` whose FORMULA reads one of\nthose files fields is the pile\'s OWN state rather than a fact row \u2014 the file it\nis short, drawn as a ghost, and the mark the rail sends a reader to). A child is\nan entity that LINKS here, ONE SECTION PER LINK: the rows it owns (`parent`), the\nrows that name it (`party` \u2014 so a party\'s record is its history), and the rows\nreaching it through a link carrying neither role, headed by that link\'s own\nlabel. A child hanging off two records therefore declares one `parent` and\nleaves the second relationship a plain link, which still gets its section.\n\n**THE ROWS A RECORD OWNS ARE ADDED AND OPENED FROM THEIR SECTION.** A `parent`\nsection\'s heading carries the Add for its rows, handing the record as the\nparent \u2014 filled, never asked. Every row opens its own record \u2014 a line of a book,\na paper on a desk, a stop on a timeline alike: where this app already routes a\npage for those rows (the register\'s own, under one of them) it is navigated to;\notherwise it is a DRAWER mounted on the record it belongs to, stepped \u25C0 \u25B6 over\nthe section\'s rows as they are drawn, with the row\'s framed editors, its ladder\nand its files, saving through `update_<child>` \u2014 the one editor those rows have,\nwhich any control the section draws over a row writes through too. Never the\n`parent` link itself: it is the key the row is FILED under, stated by the record\nthe drawer was opened from, so it is neither a fact of the drawer nor an input\nof that editor. ONE LEVEL, and only from a PAGE: a child\'s own children draw as\nthe kit\'s panel of the row, with no drawer and no Add, and a register whose own\nrecord is a DRAWER is the same for the children it owns \u2014 a drawer mounts no\ndrawer. **A ROW IS ADDED WHERE IT CAN BE OPENED AGAIN**, so those sections lose\ntheir Add with their drawer; a row of the register\'s OWN kind keeps it, because\nthe register\'s list opens it. A correspondence\'s entries are the one owned row\nthat opens nothing anywhere: the composer under them is the section\'s Add\nwhatever door the record has, and the answer mark is one field of the reply\'s\nown editor. The rows a `party`\'s record lists, and those reaching a record\nthrough a roleless link, are read only \u2014 a history, never a place to open or\nadd.\n\n**TWO CHILDREN ARE READ AS A RUN RATHER THAN AS A REGISTER**, and the model says\nwhich by the roles it declares on them. A child carrying an `obligation` whose\n`satisfied_by` is a DATE is a **timeline**: its rows are the ordered stops, each\nstating the day it was promised for and the day it happened, with the delta named\nwhere the rung was late \u2014 drawn as a register those are two date columns and the\nreader subtracts them by eye, which is exactly what "three days late at\ndischarge" costs to learn. An obligation closed by a FILE says nothing about\nwhen, so those rows stay the register they were. A child carrying a `markdown`\ntext field beside a `party` and a `when` is a **thread**: the entry is the body,\nthe author and the day lead it, and a `verdict` on the child is the yes/no one\nreply is marked the ANSWER with \u2014 a register of messages is a table whose one\nuseful column is the one it cannot draw. A SECOND `party` on those rows is who\nthe entry was left WITH, and the latest one names the ball in court: while\nnothing answers, the record says whose move it is and counts its own deadline\n(an `obligation`, else its `when`) against them. Both are read only under the\nrecord that OWNS the messages \u2014 under the party who wrote them the same rows are\nthat party\'s history, several questions at once, and the last of them says\nnothing about any. That record also REPLIES: the section\'s Add is a composer \u2014\nthe message is all a reply asks \u2014 and the answer mark is one field of the\nreply\'s own editor.\n\n**NOTHING SITS BESIDE THE RECORD.** A page is ONE reading column \u2014 its fields,\nits files, the rows it owns, its notes, all sections of it in the archetype\'s\norder \u2014 over a reserved left gutter holding a floating NAVIGATION RAIL: the way\nback, then one line per section with that section\'s category mark, and nothing\nelse. No files, no counts, no group headings. Too narrow to seat the rail, it is\none pinned bar of the same list across the top. A section HEADING never wears\nthe mark; the rail\'s line for it does.\n\n**A RELATION THE RECORD NEVER ACTS ON CLOSES THE COLUMN.** Every register that\nmerely NAMES the record is one counted line of a single last section: its label,\nhow many rows name this record (a COUNT, never a page of rows measured), and a\npress that opens the register owning them narrowed to this record. An entity\nthis app lists nowhere is a count with no door, and where every count is zero\nthe section is not drawn at all. The one exception is a PROFILE, whose history\nIS its body and stands open in the column.\n\n**Rows the record owns whose `amount` is `signed_by` a direction are a\nBOOK**, drawn as a statement \u2014 each line dated and signed, the balance under\nthem where there is more than one line to add up, labelled by the amount\'s own\nword \u2014 where the same rows on the party they\nwere transacted with stay that party\'s history, which is scanned for the line\nshort of its paperwork rather than struck to a balance. **Rows that carry a\n`when` read as RUNS**: a party\'s history under the year \u2014 and only where the rows\nin hand span more than one, since a subhead over every line of a book names the\nyear and separates nothing \u2014 and a job\'s own rows under the day they fall on,\nwhich, where those rows also carry a `lifecycle`, is an ITINERARY rather than a\ngrouped table: the day heads the run, each row is one line (its `slot`, its name,\nits party, its stage, its `category` and `reference`, its amount), the figures end\non one edge and the run closes with their sum \u2014 unless the record\'s own BAND is a\nsum rollup over exactly these rows, which states it once already. A `category`\npaints the node the run is read down, in the option\'s own colour; a `reference`\ncloses the line with the code somebody quotes on the phone. **A `mark` LEADS the\nline with the stop\'s own picture** \u2014 a venue, a vehicle, a machine \u2014 and it is the one\nplace on a record where a child entity\'s mark is drawn at all, since no register\ncolumn is ever a picture; a line whose subject holds none is marked with its\n`category`\'s glyph instead, so the run keeps one left edge. All three are\nPROJECTED for the run whether or not the register\'s column budget would have\ndrawn them, and a mark is projected NOWHERE ELSE.\nA line\'s mark is most often the SUBJECT\'s rather than the line\'s own \u2014 the\nservice, the product, the asset it is a line of \u2014 which is a `lookup` through\nthat link onto the subject\'s own `files`, given the role on the line.\n**EACH DAY\'S HEAD CARRIES THE SECTION\'S OWN ADD** as well, handing the panel that\nday, so a line made from Tuesday opens with Tuesday answered; the heading keeps\nthe verb too, for the first line and for a day nothing is planned on yet. **THE\nKEY LEAVES THE COLUMNS where the head states the whole of it** \u2014 a day head does,\na year head states four digits of the date and the day is what the column is\nstill there to carry.\n**A run is READ FROM THE END THE READER WANTS**: a job\'s own rows and an itinerary\nascending, a book and a history descending.\n\n**A DESK OVER AN ENTITY THAT CARRIES A `slot` IS ITSELF A DAY\'S RUN.** Its own\nregister is drawn under one subhead per day, sorted by that day and then by the\npart of it, and the date column goes \u2014 the subhead states it once for the whole\nrun, and a column repeating it down every line is the same value twice. Without\nit an itinerary was one flat list in whatever order the rows arrived.\nA document desk keeps its head either way \u2014 the entries it owes are its\ncontent, filed or not. The name and whatever figure is left to it are the header\'s\nalone \u2014 it states them in full, so a fact for either would be the same sentence\ntwice.\n\n**A FACT IS PRIMARY OR IT IS PROVENANCE.** An `autonumber`, a date the platform\nstamps (`derive_from`) and a date a formula works out that no role names are what\nthe SYSTEM wrote; they fold, with every optional field this record does not\nstate, behind the grid\'s ONE link. Everything a person types or picks is primary\nand is shown, empty or not, because absence is work somebody owes. **A screen\nthat named `facts.groups` has already said which:** a field in a group is\nprimary, and one in none folds \u2014 grouping says what the reader decides with, and\nby saying so says the rest are not. A `tier` on a `facts` entry exists only for\nthe case that derivation gets provably wrong.\n\n**A `contact` field whose kind the\nmodel decides** \u2014 an email, a number, a place, a `link`-formatted text, or a\nMESSAGING APP its label names (WhatsApp, Zalo, Telegram, Viber, WeChat, Line,\nMessenger) \u2014 leaves the facts too, for the row of links under the name on a\nrecord that opens as a page; one whose kind nothing decides stays a labelled\nfact, because a scheme nobody stated is a link that opens nothing. A handle is\ndrawn under its app\'s name \u2014 the app is what identifies the person there, and a\nbare number beside an envelope says the wrong thing \u2014 and it dials only where its\nvalue IS a number.\n`check` prints the record under each screen\'s slots:\n\n```\n Orders \u2014 lifecycle desk over Orders (12 rows) \xB7 page \xB7 tabs: Stage (New \u2192 Quoted \u2192 Confirmed \u2192 Shipped \u2192 Done)\n stage Stage \xB7 identity Order no. \xB7 mark Photo \xB7 party Customer \xB7 amount Total \xB7 level (none \u2014 no field declares "measure") \xB7 when Due\n record: header (Order no. \xB7 Customer) \xB7 band (Total \xB7 Shipped against Lines \xB7 Due counting down) \xB7 progress: Stage (5 stages) \xB7 facts (Ship to \xB7 \u2026 2 filed) \xB7 files: Photos \xB7 documents: Papers (Kind: 4 required) \xB7 itinerary: Order lines by Ship by at Window, kind Handling, ref Waybill (Product \xB7 Quantity \xB7 Line total) \xB7 related: Visits (count via Order)\n```\n\nThe ORDER of that line is the record\'s own, top to bottom, and it is the KIND\'s,\nand every entry of it is a section of the one column. `related:` is the counted\nline that closes it \u2014 a register the record never acts on, named and counted \u2014\nand `\u2026 N filed` is how many facts fold behind the grid\'s one link.\nA child register whose `amount` is `signed_by` a direction is a BOOK of movements\n\u2014 what the record came to rather than what it is made of \u2014 so it closes the\ncolumn rather than standing among the rows the job is made of.\n\n**A section over a child is named by the CHILD\'s own label**, because the reader\nalready knows which record they are on: "\u0110\u01A1n h\xE0ng", not "\u0110\u01A1n h\xE0ng \u2014 Kh\xE1ch h\xE0ng".\nWhere two links from one entity reach this record, that label names two sections\nand each takes its own link\'s label as a qualifier \u2014 `H\u1ED3 s\u01A1 (\u0110\u01A1n h\xE0ng)` and\n`H\u1ED3 s\u01A1 (\u0110\u01A1n g\u1ED1c)`.\n\nIn that line `documents:` is a `RecordExpectedSet`, and `lines:` a `RecordChildren` over the rows\nthis record owns \u2014 `history:` where they name it as their `party` instead; a required set\nwhose entries are a CHILD entity carrying files takes `kind="files"`, and the entity\'s own\nmulti-select takes `kind="items"`, since nothing attaches to an option.\n\n**A section that knows its size says so.** Where a `measure` on the record is a\n`count` rollup over the very link a rows section hangs on, the limit it is read\n`against` is how many rows that section is OWED: the printout adds `\u2014 expects\n<limit>` and the screen draws that many ghost rows until the first one lands,\ninstead of "nothing here" two bands under a count saying three are outstanding.\n\nA figure printed as `Total (USD)` is MONEY in the currency named \u2014 a `formula`\nstates it in `formula.currency`, and a `rollup` or a `lookup` inherits it from the\nfield it reads, so read those brackets: a rate that should be in dollars and is\nprinted bare will be drawn in the workspace\'s own money. Where the entity carries\na `currency` role, the ROW\'s code outranks the field\'s on every line that states\none, and a line stating none falls back to the field\'s.\n\n**A record surface can be OPERATED, and that is the default.** Every screen with\na record gets a workflow that writes its editable facts \u2014 every field a person\nstates \u2014 so the record\'s values are edited in place and its stage is advanced\nfrom the progress section. `"writes": false` makes one screen a reader: use it\nfor a screen over rows another desk owns, never as the default. A desk nobody\ncan act on is a viewer of state somebody must go and set somewhere else.\n\n**Which facts those are is the FIELD\'s answer.** Text, number, date, yes/no and\nselect are typed or picked. A `"cardinality": "one"` link is RE-POINTED, through\na picker over the target entity named by its `display_field_aliases` \u2014 else the\ntarget\'s `identity` \u2014 narrowed by what the reader types and carrying that\nentity\'s own `read_scope`, so a link the plan gives neither column is read\ninstead of offering an empty list. A files field is ATTACHED TO and DETACHED\nFROM, as the delta rather than the pile, so two readers filing at once each keep\ntheir file. A many-link, an `autonumber` and every computed field are read: the\nfirst is a list a fact cannot state, and the rest are the platform\'s to write.\n\n**A one-link is that fact WHATEVER its sync.** `sync_both_ways` is one relation\nwith a field on each side, and the sides are not the same surface: the record\nthat names ONE row states it as a fact, and the MANY side is the register on the\nother entity\'s record. Declaring both directions does not give this record a\nregister of the single row its own fact already names.\n\n**The write is the record SURFACE\'s.** Its inputs are the fields that surface\noffers to save \u2014 the facts with an editor, the lifecycle its ladder advances, and\na files section over exactly one stated field \u2014 never every field a person could\nin principle type. What the header states, a limit a meter folds in, a required\nset with a section of its own and the pile a page\'s mark draws are read there, so\nno input is declared for them. A second screen over the same entity draws no\nsurface of its own and adds nothing.\n\nWhere two operable screens of one plan reach the same entity, `scaffold check`\nnames them and the apps they belong to: two desks writing one record is a\ndecision, and the split is stated on the FIELD in each app\'s\n`package.json#lotics.writes` rather than left to whoever edits second.\n\nThat workflow lands in the app as source, like every other: its body in\n`src/workflows/update_<entity>.ts` and its declaration in\n`package.json#lotics.workflows`. The two together are the binding \u2014 `lotics app\ndeploy` pushes whatever differs from what it last saw live \u2014 so the write is\nversion-controlled and travels with the app rather than being bound by hand\nafterwards.\n\nA `custom` screen declares its slots under `roles` (slot \u2192 role) and they bind\nthe same way:\n\n```jsonc\n{ "alias": "readings", "label": "Readings", "shape": "custom", "entity": "reading",\n "roles": { "subject": "identity", "reading": "measure" } }\n```\n\n## Applying packages\n\n`apply` copies published packages into the workspace AFTER the model\'s own\ntables exist \u2014 apps over the tables you just described, and any tables of their\nown they still need. Ordered, and run by `lotics setup` and `lotics scaffold\napply` alike.\n\n```jsonc\n"apply": [\n {\n "package": "apg_k3nf82ldpq",\n "bind": { // optional \u2014 which of YOUR tables each entity is\n "company": { "label": "Customers", "fields": { "name": "Company name" } }\n },\n "no_sample_data": true // optional\n }\n]\n```\n\n`bind` is keyed by the package\'s entity alias and holds the LABELS this\nworkspace uses: scaffold adopts by label, so binding points the package at the\ntables the model created instead of a second set beside them. Only naming\nmoves \u2014 a bound field must be the TYPE the package declares, or the copy is\nrefused. `lotics library list` is the shelf, and `lotics library show <apg_id>`\nlists the aliases to bind.\n\nEntries run in the order they are written, because a later one may bind onto a\ntable an earlier one created. **A refused entry stops the run and the entries\nbefore it stay** \u2014 they are separate copies, committed as they land, so the\nrefusal names them rather than leaving a caller to re-run the file and copy them\ntwice.\n\n## Presets\n\nA preset is a trade\'s model, published to be READ. An assistant reads it, asks\nat most two questions, picks a variant and writes a `model.json` from it \u2014\nnothing is copied, and a preset is a file rather than anything a workspace\ninstalls.\n\n```jsonc\n"preset": {\n "name": "Field service",\n "description": "Jobs, the crew that runs them, and what each one billed.",\n "questions": ["Do you dispatch crews, or one person per job?"], // at most 2\n "variants": {\n "crews": {\n "when": "work is dispatched to crews rather than to one person",\n "entities": [ /* tables this branch ADDS */ ],\n "fields": { "job": [ /* fields this branch ADDS to `job` */ ] }\n }\n }\n}\n```\n\nVariants are **additive only**: a branch adds entities and fields and never\nremoves them, so the base is a model in its own right rather than a draft.\n`lotics scaffold check` proves the base AND every variant merged onto it, so a\npreset ships with every branch already proven \u2014 the branch nobody took is the\none that fails in the workspace of whoever takes it.\n\n`preset` is not scaffolded. `lotics setup` and `lotics scaffold apply` ignore\nit and create the base model\'s tables.\n\n`lotics scaffold export` prints a workspace that already works as one of these\nfiles \u2014 the starting point for a preset or for another business\'s model, never a\nsource of truth: it carries one business\'s words and stops describing that\nworkspace the moment either changes.\n\n## Starting from a preset\n\n`lotics library list` is the shelf of them and `lotics library show <slug>`\nprints one whole: its questions, every table as `alias \xB7 label` with each field\nas `alias:type`, and each variant as `slug \xB7 when` followed by the tables and\nfields that branch adds. When one of them is the trade in front of you, do not\ntranscribe it \u2014 name it:\n\n```jsonc\n{\n "from": "field_service",\n "variants": ["crews"],\n "rename": { "job": { "label": "\u0110\u01A1n h\xE0ng", "fields": { "code": "M\xE3 \u0111\u01A1n" } } },\n "entities": [ /* a table this business has that the preset does not */ ],\n "rows": { "job": [ { "ref": "j1", "fields": { "code": "J-1" } } ] },\n "field_roles": { "job": { "code": "identity" } },\n "write_rules": { "customer": { "natural_key": ["email"] } },\n "apps": [ /* the screens this business\'s apps will have */ ]\n}\n```\n\n- **`from`** is the preset\'s SLUG \u2014 its own file name, a lowercase slug. Naming\n it is what makes `entities` optional; every other rule on this page is\n unchanged, because the file is resolved into the full form and then checked and\n applied exactly as one. A slug nothing serves is refused with the ones there\n are, never resolved against something else.\n- **`variants`** names the branches to merge onto the base, in order. Pick the\n one whose `when` describes what the person said; a slug the preset does not\n declare is refused rather than ignored.\n- **`rename`** is keyed by the preset\'s entity alias and holds the labels this\n business uses \u2014 the same shape `apply[].bind` takes, and the same rule: only\n naming moves. An alias the preset does not declare, and a label that is\n already another table\'s, are both refused.\n- **`entities`** are added after the rename, already in this business\'s own\n words.\n- **`rows`**, **`field_roles`**, **`write_rules`**, **`apps`** and **`apply`**\n mean exactly what they mean in the full form \u2014 `"rows"` are this business\'s\n real first records,\n `"field_roles"` may name the preset\'s fields as well as its own (a role the\n preset declares itself is kept unless this file names the same field, or\n clears it with `null`), `"write_rules"` the create-time clauses on either\n (an entity this file names replaces the preset\'s whole entry for it),\n `"apps"` the screens it will have (a preset carries none), `"apply"` the\n packages copied in once its tables exist.\n\nThis is the ONE thing on this page that needs the network: `check` reads the\npreset it names, once. Everything after that read is the same offline check.\n\nWrite the full form when no preset is the trade.\n\n## A complete model\n\n```json\n{\n "entities": [\n {\n "alias": "customer",\n "label": "Customers",\n "singular": "Customer",\n "fields": [\n { "alias": "name", "label": "Name", "type": "text", "required": true },\n {\n "alias": "tier",\n "label": "Tier",\n "type": "select",\n "options": [\n { "alias": "standard", "label": "Standard", "color": "slate" },\n { "alias": "gold", "label": "Gold", "color": "amber" }\n ],\n "default": ["standard"]\n },\n {\n "alias": "orders",\n "label": "Orders",\n "type": "select_record_link",\n "target_entity": "order",\n "cardinality": "many",\n "sync_both_ways": true,\n "paired_field_alias": "customer",\n "display_field_aliases": ["code"]\n },\n {\n "alias": "total_ordered",\n "label": "Total ordered",\n "type": "rollup",\n "source_field_alias": "orders",\n "aggregate_option": { "operation": "sum", "field_key": "amount" }\n }\n ],\n "views": [\n {\n "alias": "gold",\n "label": "Gold customers",\n "filters": {\n "node_type": "condition",\n "type": "select",\n "field_key": "tier",\n "operator": "has_any_of",\n "value": ["gold"]\n },\n "sort": [{ "field_key": "name", "order": "asc" }]\n }\n ]\n },\n {\n "alias": "order",\n "label": "Orders",\n "singular": "Order",\n "fields": [\n { "alias": "code", "label": "Order no.", "type": "text", "unique": true },\n { "alias": "placed_on", "label": "Placed on", "type": "date", "format": "date" },\n {\n "alias": "amount",\n "label": "Amount",\n "type": "number",\n "format": "currency",\n "currency": "VND"\n },\n {\n "alias": "total",\n "label": "Total with VAT",\n "type": "formula",\n "formula": { "expression": "{amount} * 1.1", "format": "currency", "currency": "VND" }\n },\n {\n "alias": "customer",\n "label": "Customer",\n "type": "select_record_link",\n "target_entity": "customer",\n "cardinality": "one",\n "sync_both_ways": true,\n "paired_field_alias": "orders",\n "display_field_aliases": ["name"]\n }\n ]\n }\n ],\n "roles": [{ "alias": "sales", "label": "Sales" }],\n "field_roles": {\n "customer": { "name": "identity" },\n "order": { "code": "identity", "placed_on": "when", "amount": "amount", "customer": "party" }\n },\n "apps": [\n {\n "alias": "customers",\n "name": "Customers",\n "screen": { "alias": "customers", "label": "Customers", "shape": "party_register", "entity": "customer" }\n },\n {\n "alias": "orders",\n "name": "Orders",\n "screen": { "alias": "orders", "label": "Orders", "shape": "transaction_ledger", "entity": "order" }\n }\n ],\n "rows": {\n "customer": [\n { "ref": "acme", "fields": { "name": "Acme Trading", "tier": "gold" } },\n { "ref": "bluebird", "fields": { "name": "Bluebird Foods", "tier": "standard" } }\n ],\n "order": [\n {\n "ref": "so_1001",\n "fields": {\n "code": "SO-1001",\n "placed_on": "@month-start+2",\n "amount": 4200000,\n "customer": "customer:acme"\n }\n },\n {\n "ref": "so_1002",\n "fields": {\n "code": "SO-1002",\n "placed_on": "@today-3",\n "amount": 1150000,\n "customer": "customer:bluebird"\n }\n }\n ]\n }\n}\n```\n\n`lotics scaffold check` on this file reports\n`2 tables, 9 fields, 2 links, 1 view, 1 role, 4 rows, 2 apps`, then\nthe plan:\n\n```\nCustomers\n Customers \u2014 party register over Customers (2 rows) \xB7 page \xB7 tabs: none\n identity Name \xB7 mark (none \u2014 no field declares "mark") \xB7 contact (none \u2014 no field declares "contact") \xB7 worth (none \u2014 no field declares "measure") \xB7 risk (none \u2014 no field declares "verdict")\n above: rows (default)\n record: header (Name) \xB7 history: Orders (Order no. \xB7 Placed on \xB7 Amount (VND)) \xB7 facts (Tier \xB7 Total ordered (VND))\nOrders\n Orders \u2014 transaction ledger over Orders (2 rows) \xB7 drawer \xB7 tabs: none\n when Placed on \xB7 amount Amount (VND) \xB7 reference Order no. \xB7 party Customer \xB7 classification (none \u2014 no field declares "lifecycle") \xB7 document (none \u2014 no field declares "expected_set" or "verdict")\n above: Amount (VND) (default)\n record: header (Order no. \xB7 Placed on \xB7 Amount (VND)) \xB7 facts (Placed on \xB7 Total with VAT (VND) \xB7 Customer)\nWho writes what:\n Customers (customer, one: Customer): Customers\n Orders (order, one: Order): Orders\n```\n\nThe last block is the WRITERS matrix \u2014 one line per record surface the plan\nleaves operable, the word one of its rows is called, and the app whose register\nopens it. Part of the verdict rather than a diagnostic beside it: which desk\nchanges a table is answerable from the plan, and two apps on one line is the\nsplit to state in each of their `package.json#lotics.writes`.\n\nEvery `(none)` is a slot no field fills, and it says WHY: no field declares the\nrole, or several could and the plan named none of them (`(none \u2014 a, b; name\none)`). Read it as the screen a person will see. `above: \u2026 (default)` is the band\nnobody stated \u2014 the shape sums the amount its slot draws, and a plan naming its\nown figures loses the word. Neither\nentity carries a stage, a required set or files, so the rest is facts \u2014 except\nthe sections neither entity declares: the customer\'s `history:` is the orders\nthat name it as their party, and the order\'s `via Orders:` is the customers whose\n`Orders` link names it. **A link is a section, not a fact**, on the side it\npoints AT and on the side that holds it: `Customers.Orders` therefore leaves the\ncustomer\'s facts, because the section below already lists the same relation and\na link fact can only ever show the first of them. Both records state their name\nin the header and nowhere else \u2014 a ledger\'s columns are the date and the figure,\nso `Order no.` is on no column of that list and is still what the drawer behind\na line is called. `Total ordered (VND)` is the rollup inheriting the currency of\nthe column it sums: money is read off the model, never off the field\'s own line.\n';
56505
+ var model_reference_default = '# The Lotics workspace model (`model.json`)\n\nOne JSON file describing the tables, fields, options, views, roles and first rows\na workspace starts with. `lotics scaffold check model.json` proves it offline \u2014\nno account, no network. `lotics setup model.json --email you@company.com` creates\nthe account and applies it. `lotics scaffold apply model.json` applies it again,\ninto the workspace the credential names.\n\n**There are two forms of this file.** The full one, below, spells the model out.\nThe `from` one names a published preset and carries only what this business\ndiffers by \u2014 see \xA7 Starting from a preset, and prefer it whenever a preset fits\nthe trade.\n\nApps are PLANNED here and built afterwards: `apps` names each app\'s screens as a\nshape over an entity, checked against the roles `field_roles` gives its fields,\nso the plan is refused before anyone builds a screen (\xA7 Apps and screens). The\nbuilt app lives in the workspace; publishing that workspace as a package is how\nit ships.\n\n## The rules\n\n- **At least one entity, at most 50.** More tables than that is a data model\n being designed, not scaffolded \u2014 scaffold the rest in a second call.\n- **Adoption is explicit.** `lotics setup` REFUSES an entity whose `label`\n already names a table in the workspace, naming every colliding label at once.\n `lotics scaffold apply` adopts those tables and adds the fields, options and\n views they are missing. Nothing is ever modified or deleted, so applying the\n same model twice creates nothing the second time.\n- **Adoption is by LABEL, not alias.** Change an entity\'s `label` and the next\n run asks for a NEW table beside the old one. Renaming a FIELD is\n `lotics field rename <table> <field> "<new label>" --model <this file>`, which\n moves the platform, this file and every app bound to it together; deleting is\n `lotics run delete_table`. Neither goes through the file.\n- **The file\'s own majority is the language.** A model names no locale \u2014 which\n language it is in is what it mostly says, and `scaffold check` notes the label\n written the other way. The generated screens read the kit\'s pack, and a\n generated WRITE cannot: its refusals run on the server, so they are worded in\n that same majority. Mix the two and the workspace answers in two languages.\n- **`lotics scaffold diff model.json` says where the file and the workspace have\n come apart**, joined on label, entity then field \u2014 the join adoption itself\n makes. It exits 1 on any difference, so a model that is about to be published\n as a preset carries the labels in use rather than the ones it was written with.\n- **Rows land only where every bound table is empty.** One table already holding\n records and no rows are written anywhere, and the result says\n `rows_skipped: true`: sample rows landing among a customer\'s real ones cannot\n be told apart from them.\n- **After the first run the WORKSPACE is the source of truth.** The file is an\n authoring input, not a mirror \u2014 scaffold never deletes what the file stopped\n naming.\n- **`lotics scaffold check` decides all of it offline**, and reports every\n problem in one run rather than the first: an alias that resolves to nothing, a\n link whose pair is not symmetric, and the rows themselves \u2014 a field the entity\n does not declare, an option alias the field does not declare, a link naming no\n row in the file, a `ref` used twice, a date that is not one, a value on a\n platform-computed field, and a files cell that is neither a relative path\n beside this file nor a `fil_` id.\n\n## Top level\n\n```jsonc\n{\n "entities": [ /* the tables */ ],\n "roles": [ /* workspace groups to create */ ], // optional\n "templates":[ /* inline html / email templates */ ], // optional\n "rows": { /* first records, keyed by entity alias */ }, // optional\n "field_roles": { /* the reporting role each field plays, keyed by entity then field */ }, // optional\n "write_rules": { /* what a CREATE finds, defaults and refuses, keyed by entity */ }, // optional\n "apps": [ /* the screens each app will have, as shapes over entities */ ], // optional\n "apply": [ /* published packages to copy in afterwards */ ], // optional\n "preset": { /* a trade\'s branches, for a PUBLISHED model */ } // optional\n}\n```\n\nThe other form names a preset instead of restating one:\n\n```jsonc\n{\n "from": "field_service", // the preset this model starts from, by slug\n "variants": ["crews"], // optional \u2014 its branches to merge in, in order\n "rename": { // optional \u2014 what THIS business calls each table\n "job": { "label": "\u0110\u01A1n h\xE0ng", "fields": { "code": "M\xE3 \u0111\u01A1n" } }\n },\n "entities": [ /* tables the preset does not declare */ ], // optional\n "rows": { /* first records, keyed by entity alias */ }, // optional\n "field_roles": { /* roles on the preset\'s fields and this business\'s own */ }, // optional\n "write_rules": { /* create-time clauses on the preset\'s entities and its own */ }, // optional\n "apps": [ /* the screens each app will have */ ], // optional\n "apply": [ /* published packages to copy in afterwards */ ] // optional\n}\n```\n\n**A model may not carry** `fixtures`, `knowledge` or `knowledge_expects`, and no\n`excel` / `word` / `pdf-form` template: each of those is content that lives in a\npublished bundle, which a model has none of. `apps` here is a plan of screens,\nnever built code. An unknown top-level key is an error, never ignored.\n\n### Aliases\n\nEvery `alias` is a lowercase slug \u2014 a letter, then letters, digits and\nunderscores (`unit_price`, `so_1001`). Aliases are how the file cross-references\nitself; they are never shown to anyone. `label` is what a person sees.\n\nLabels must be unique within their namespace \u2014 two entities, two fields on one\nentity, two options on one field, two views on one entity, two roles or two\ntemplates cannot share a label, because scaffold matches by label.\n\n## Entity\n\n```jsonc\n{\n "alias": "order",\n "label": "Orders", // the table\'s name, which names the SET it holds\n "singular": "Order", // optional \u2014 ONE of them, for the act that opens one\n "description": "\u2026", // optional\n "fields": [ /* at least one */ ],\n "views": [ /* optional; an entity with none still gets the default grid */ ],\n "read_scope": { /* optional; absent, everyone with access to the table reads every row */\n "any": [\n { "member_of": "sales" }, // a role alias this model declares\n { "field": "scope", "is": ["shared"] } // a single select on this entity, by option alias\n ]\n }\n}\n```\n\n**`singular` is what a create says.** A register\'s own act and the panel it\nopens name the row being made \u2014 `New Order`, `H\u1ED3 s\u01A1 m\u1EDBi` \u2014 while `label` names\nthe table, so without it the button reads `New Orders`. Nothing derives it\n(English plurals are irregular), and most models need none: a Vietnamese noun is\nthe same word either way. `scaffold check` prints it beside the table under *Who\nwrites what* and NOTES a table that will name the set. An act on a child section\nkeeps the label: it adds a line to the register under the record the reader is\nalready standing in.\n\n**`read_scope` is a ROW rule, enforced by the platform.** A row is readable when\nANY clause holds: the reader is in that role\'s group, or the named select carries\none of those options. It is resolved at scaffold into the table\'s own row\nfilters, so an app, a workflow reading for a viewer, and the API all answer the\nsame rows \u2014 a per-record visibility field the app merely honours is a convention,\nnot a gate. `any` may not be empty (a rule nobody satisfies hides the table), and\nevery role alias and option alias in it must be one this model declares.\n\n## Field\n\nEvery field carries `alias`, `label`, an optional `description`, and an optional\n`required` \u2014 advisory only, read by app forms and workflows; the table itself has\nno required constraint. `label` may not contain `{` or `}` (formulas reference\nfields by label at the platform level).\n\n`default` is the value pre-filled into a NEW record. It applies on create only;\nexisting records are never backfilled. Only the types listed below accept one.\n\n### `text`\n\n```jsonc\n{ "alias": "name", "label": "Name", "type": "text",\n "unique": false, // optional \u2014 require distinct values\n "format": "text", // optional \u2014 "text" | "link" | "markdown"\n "default": "" } // optional\n```\n\n### `number`\n\n```jsonc\n{ "alias": "amount", "label": "Amount", "type": "number",\n "format": "currency", // optional \u2014 "number" | "currency" | "percentage"\n "currency": "VND", // optional \u2014 ISO 4217\n "default": 0 } // optional\n```\n\n`format` is what the number IS, and every surface reads it: `currency` prints as\nmoney in the code the row or the field states, `percentage` as a whole percent\nwith its sign. An ABSENT number is drawn absent \u2014 the one exception is a\n`sum` or count rollup the plan reads as a **`measure`**: that is the thing\naccumulated toward a bound, so nothing accumulated yet is zero and the meter\ndraws it. The same rollup read as an `amount` keeps its blank, and so does every\nother role: nothing added to what a row is WORTH means unpriced, not free. A\n`min`, an `avg`, a percentage of nothing and every FORMULA stay blank in any\nrole, because none of them has an answer to give. This is why the pair on one\nscreen reads two ways \u2014 what has come in against what is owed \u2014 and why a\nmeasure\'s own LIMIT, an amount, leaves an unquoted row out of the count rather\nthan reporting it as nothing collected. **AND WHERE THAT LIMIT IS ABSENT THERE IS\nNO LEVEL AT ALL**: a level is a reading AGAINST a bound, so a row that states no\nbound draws nothing \u2014 cell, fact and all \u2014 rather than a numerator whose whole\nmeaning was the comparison. "Collected 0" beside a blank total reads as money\nagainst a job worth nothing. A measure the model gives no limit is a plain figure\nand is unaffected. A share is stored in percent units \u2014 68.1 is 68.1 % \u2014 and the\ncolumn, the fact behind it, the meter it is judged by and the figure over the\nregister all say so.\n\n### `date`\n\n```jsonc\n{ "alias": "placed_on", "label": "Placed on", "type": "date",\n "format": "date", // optional \u2014 "date" | "datetime" | "date_range" | "datetime_range"\n "timezone": "Asia/Ho_Chi_Minh", // optional \u2014 IANA name\n "derive_from": "created_at", // optional \u2014 "created_at" | "updated_at"; makes the field read-only\n "default": "2026-01-01" } // optional; refused together with derive_from\n```\n\n### `boolean`\n\n```jsonc\n{ "alias": "paid", "label": "Paid", "type": "boolean", "default": false }\n```\n\n### `select`\n\n```jsonc\n{ "alias": "tier", "label": "Tier", "type": "select",\n "options": [ // at least one\n { "alias": "standard", "label": "Standard", "color": "slate" },\n { "alias": "gold", "label": "Gold", "color": "amber" }\n ],\n "multi": false, // optional\n "default": ["standard"] } // optional \u2014 option ALIASES; one unless multi\n```\n\n`color` is one of: `red`, `orange`, `amber`, `yellow`, `lime`, `green`,\n`emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`, `violet`, `purple`,\n`fuchsia`, `pink`, `rose`, `slate`, `gray`, `zinc`, `neutral`, `stone`.\n\n### `select_member`\n\nA person picker over the workspace\'s members. No default: a model cannot name\nmembers of a workspace that does not exist yet.\n\n```jsonc\n{ "alias": "owner", "label": "Owner", "type": "select_member", "multi": false }\n```\n\n### `select_record_link`\n\n```jsonc\n{ "alias": "customer", "label": "Customer", "type": "select_record_link",\n "target_entity": "customer", // an entity alias this model declares\n "cardinality": "one", // optional \u2014 "one" | "many" (default "many")\n "sync_both_ways": true, // optional \u2014 keep a paired field on the target\n "paired_field_alias": "orders", // the partner field ON THE TARGET entity\n "display_field_aliases": ["name"] } // optional \u2014 what the link shows / the picker\'s columns\n```\n\nA two-way link is declared on BOTH sides, each naming the other as its\n`paired_field_alias`; the pair must be symmetric or the model is refused.\n\n**A single-valued link needs no partner.** `"cardinality": "one"` on its own is a\nlink that holds one row \u2014 one customer on an invoice, one project on a device \u2014\nand nothing is created on the target. The mirror invariant belongs to a PAIRED\nlink: pair a link when the target\'s own record should list what points at it, and\nleave it unpaired when it should not. Either way the record plan draws the\nrelation as a section on the side it points at, so an unpaired link costs the\ntarget nothing.\n\n### `files`\n\n```jsonc\n{ "alias": "attachments", "label": "Attachments", "type": "files" }\n```\n\n### `formula`\n\n```jsonc\n{ "alias": "total", "label": "Total", "type": "formula",\n "formula": {\n "expression": "{amount} * 1.1", // fields on THIS entity, by alias, in braces\n "output_type": "number", // optional \u2014 what it YIELDS: "number" | "text" | "date" | "datetime" | "boolean"\n "format": "currency", // optional \u2014 how that result is DRAWN: "number" | "currency" | "percentage" | "link"\n "currency": "VND" // optional\n } }\n```\n\n`output_type` is what the expression answers WITH; `format` is how it is printed.\nThe platform infers the result at write time and ignores what you declare, so\nthis is a statement the offline checks read \u2014 which is what lets a role or a\nscreen clause accept a computed value: a caption over a derived name\n(`output_type: "text"`), a period over a settled date (`"date"`). A formula\ndeclaring neither says nothing about its result, and every rule that needs one\nrefuses it by name. `lotics scaffold export` writes the result a live workspace\ncomputed, so exporting a workspace fills these in.\n\n### `rollup`\n\nAggregates the records reached through a link on this entity.\n\n```jsonc\n{ "alias": "total_ordered", "label": "Total ordered", "type": "rollup",\n "source_field_alias": "orders", // a select_record_link field on THIS entity\n "aggregate_option": {\n "operation": "sum", // count | sum | avg | median | min | max | range |\n // empty | filled | percent_empty | percent_filled |\n // unique | percent_unique |\n // earliest | latest | date_range |\n // checked | unchecked | percent_checked |\n // percent_unchecked\n "field_key": "amount" // a field ALIAS on the linked entity ("count" may omit it)\n },\n "filter": { /* optional \u2014 see Views; every field_key is an alias on the LINKED entity */ } }\n```\n\nThe operation must be one the aggregated field\'s type allows \u2014 `sum` over a\nnumber, `earliest` over a date, `filled` over anything.\n\n### `lookup`\n\nDisplays a field from the linked records.\n\n```jsonc\n{ "alias": "customer_tier", "label": "Customer tier", "type": "lookup",\n "source_field_alias": "customer", // a select_record_link field on THIS entity\n "lookup_field_alias": "tier", // a field alias on the linked entity\n "order_by": { "field_key": "placed_on", "direction": "desc" } } // optional \u2014 pick the single extreme row\n```\n\n### `autonumber`\n\n```jsonc\n{ "alias": "seq", "label": "No.", "type": "autonumber",\n "prefix": "SO-", // optional \u2014 ignored when template is set\n "padding": 4, // optional \u2014 1..20, zero-pads the integer\n "template": "SO-{YEAR}-{N:4}" } // optional \u2014 {N}, {N:W}, {YEAR}, {YEAR:2}, {MONTH}, {DAY}\n```\n\n## Views\n\nSaved views live under the entity they belong to. Every field reference is a\nfield ALIAS on that entity.\n\n```jsonc\n{\n "alias": "gold",\n "label": "Gold customers",\n "description": "\u2026", // optional\n "columns": [ // optional \u2014 omit to show every field\n { "field_alias": "name", "visibility": "visible", "width": 240 },\n { "field_alias": "tier", "visibility": "hidden" }\n ],\n "filters": { // optional\n "node_type": "group",\n "logic": "and", // "and" | "or"\n "children": [\n { "node_type": "condition", "type": "select", "field_key": "tier",\n "operator": "has_any_of", "value": ["gold"] }\n ]\n },\n "sort": [ { "field_key": "name", "order": "asc" } ], // optional; order is "asc" | "desc" | null\n "summary": { "amount": "sum" }, // optional \u2014 field alias \u2192 footer operation\n "frozen_columns": 1 // optional\n}\n```\n\nA condition\'s `type` is the field\'s type and its `operator` is one that type\nadmits \u2014 `has_any_of` / `has_none_of` / `has_all_of` / `is_empty` /\n`is_not_empty` for a select, `equals` / `greater_than` / `less_than` for a\nnumber, `on` / `before` / `after` / `between` for a date, `contains` /\n`is_any_of` for text. A select condition\'s `value` names option ALIASES.\n\n`columns`, when present, is exhaustive and must not be empty: a view renders\nexactly the entries it holds. Omit the key to show every field.\n\n## Roles\n\nA role becomes a workspace group. Members are added afterwards, in the app.\n\n```jsonc\n{ "alias": "sales", "label": "Sales" }\n```\n\n## Templates\n\nOnly inline `html` and `email` templates \u2014 the rest are file-backed and a model\nhas no bytes. An `html` template renders to a PDF when a workflow generates\nfrom it; `{{name}}` is filled from the workflow\'s data.\n\n```jsonc\n{ "alias": "order_ack", "label": "Order acknowledgement", "type": "email",\n "content": "<p>Hello {{customer}}\u2026</p>" }\n```\n\nA paper that has to look like a counterparty produced it \u2014 an official letter,\nan acceptance minute, a supplier\'s bill \u2014 is the same `html` template with a\nshell around the body: a letterhead, a reference line, a seal and a signature\nblock, and paper grain over everything. One shell, many bodies; the data is the\nonly thing that changes, so a workflow can re-issue it over any record.\n\n```jsonc\n{ "alias": "cong_van", "label": "C\xF4ng v\u0103n", "type": "html",\n "content": "\u2026the page below, as one JSON string\u2026" }\n```\n\n```html\n<style>\n .sheet{position:relative;width:718px;padding:44px 58px 30px;background:#fbfaf6;color:#111;font:14.2px/1.5 \'Liberation Serif\',serif}\n .grain{position:absolute;inset:0;opacity:.34;mix-blend-mode:multiply;background:url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'140\' height=\'140\'><filter id=\'f\'><feTurbulence baseFrequency=\'.9\' numOctaves=\'2\'/><feColorMatrix values=\'0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0\'/></filter><rect width=\'140\' height=\'140\' filter=\'url(%23f)\'/></svg>")}\n .top{display:flex;text-align:center;font-size:13.4px} .top>div{flex:1} .u{display:inline-block;border-bottom:1px solid #111;font-weight:700}\n .ref{display:flex;text-align:center;font-size:13.4px;margin-top:6px} .ref>div{flex:1} .ref .r{font-style:italic}\n h1{text-align:center;font-size:15.6px;margin:26px 0 18px} p{text-align:justify;text-indent:26px;margin:0 0 9px}\n .sig{display:flex;margin-top:20px} .sig .l{flex:1} .sig .r{width:290px;text-align:center;position:relative}\n .sig .nm{font-weight:700;margin-top:96px} .seal{position:absolute;left:4px;top:8px;width:166px;height:166px;opacity:.66;mix-blend-mode:multiply;transform:rotate(-17deg)}\n </style>\n <div class=\'sheet\'><div class=\'grain\'></div>\n <div class=\'top\'><div><b>{{issuer_parent}}</b><br><span class=\'u\'>{{issuer}}</span></div>\n <div><b>C\u1ED8NG H\xD2A X\xC3 H\u1ED8I CH\u1EE6 NGH\u0128A VI\u1EC6T NAM</b><br><span class=\'u\'>\u0110\u1ED9c l\u1EADp - T\u1EF1 do - H\u1EA1nh ph\xFAc</span></div></div>\n <div class=\'ref\'><div>S\u1ED1: {{number}}</div><div class=\'r\'>{{place}}, ng\xE0y {{day}} th\xE1ng {{month}} n\u0103m {{year}}</div></div>\n <h1>{{title}}</h1>\n <p>K\xEDnh g\u1EEDi: {{recipient}}.</p>\n {{{body}}}\n <div class=\'sig\'><div class=\'l\'><b>N\u01A1i nh\u1EADn:</b><br>- Nh\u01B0 tr\xEAn;<br>- L\u01B0u VT.</div>\n <div class=\'r\'><img class=\'seal\' src=\'{{seal_url}}\'><b>{{signer_title}}</b><div class=\'nm\'>{{signer}}</div></div></div>\n </div>\n```\n\n`lotics preview <file.html>` renders any such page to a PNG the way a demo\'s\nprops are made, sized to its content, so a paper can be looked at before it is\nput in a template.\n\n## Rows\n\nFirst records, keyed by entity alias. Up to 200 rows per entity and 2000 across\nthe model, attaching at most 2000 documents between them \u2014 a real data set\nbelongs in an import, not a model.\n\n```jsonc\n"rows": {\n "customer": [\n { "ref": "acme", "fields": { "name": "Acme Trading", "tier": "gold" } }\n ]\n}\n```\n\n`ref` is a local handle (lowercase letters, digits, underscores) that other rows\'\nlink fields address. It is never persisted.\n\nA `files` cell attaches documents: paths relative to this file (no `..`, never\nabsolute), which `check` proves exist and `apply` uploads into the workspace\nbefore any row is written \u2014 a paperwork business seeds its papers with its\nrows. The server accepts only `fil_` ids of files this workspace owns, which is\nwhat the upload leaves behind. After a run that wrote rows, `apply` writes the\nrecord ids beside the file (`<model>.last_run.json`): `delete_records` over\nthem is how a seeded set is reset, and applying again re-dates it.\n\n`fields` is keyed by field alias, and every value is read against the field\'s\nDECLARED type:\n\n| Field type | Value |\n|---|---|\n| `text` / `number` / `boolean` | the value itself |\n| `date` | `"2026-03-14"`, or a relative expression (below) |\n| `select` | the option ALIAS \u2014 `"gold"`, or `["gold","vip"]` for a multi-select |\n| `select_record_link` | `"<entity-alias>:<ref>"` naming another row in this file \u2014 `"customer:acme"`, or an array for several |\n| `select_member` | `"self"` only \u2014 the person applying the model |\n| `files` | paths beside this file \u2014 `["scans/pccc_letter.png"]` \u2014 uploaded by `apply`/`setup` before the rows are posted; or `fil_` ids of files already in this workspace |\n| `formula`, `rollup`, `lookup`, `autonumber` | not allowed \u2014 the platform writes these |\n\n**Documents can be attached on their own, afterwards.** Rows land only into empty\ntables, so a model whose binaries were added after the first apply has no second\napply to carry them: `lotics scaffold apply model.json --documents` writes ONLY\nthe `files` cells, onto the records the first run created, joined through the\n`<model>.last_run.json` beside the file. Running it twice attaches nothing the\nsecond time \u2014 the same path keeps the same file, and a cell is a set.\n\n### Relative dates\n\nA date cell holds a literal `YYYY-MM-DD`, or an expression relative to the day\nthe model is applied, so a screen that opens on "this month" is not empty a month\nlater:\n\n- `@today` \u2014 the day of the run, in the workspace\'s timezone\n- `@month-start` \u2014 the 1st of that month\n- either with a whole-day offset: `@today-14`, `@month-start+9`\n\n`@month-start` exists because `@today-N` cannot promise a month: applied on the\n2nd, `@today-3` lands in the previous one.\n\n## Field roles\n\n`field_roles` names the reporting role a field plays on its entity \u2014 keyed by\nentity alias, then field alias \u2014 so every screen over the entity agrees on\nwhich column names the row and which select is the stage. A shape\'s slot binds\nto it (\xA7 Apps and screens). Like `rows` and `apps`, it is this file\'s: `check`\nproves it and the workspace never sees it. Each role sits on the types that can\nanswer it:\n\n| Role | On | Meaning |\n|---|---|---|\n| `identity` | `text`, `select_record_link`, `formula` | what a PERSON calls the row \u2014 the register\'s first column; a link where the row is "the product, at this branch"; a formula where the name is computed, and then it may not be `format`ted as a figure. NEVER an autonumber: a minted code is a `reference`. One per entity |\n| `reference` | `text`, `autonumber`, `formula` | the key the SYSTEM files the row under \u2014 an order number, a container code \u2014 drawn as the supporting line under the name rather than as a column of its own, and leading where the entity has no `identity` at all. One per entity |\n| `mark` | `files`, or a `lookup`/`rollup` that resolves to one | the row\'s picture \u2014 its own, or the linked record\'s. NEVER A COLUMN: a register draws words, so a mark is projected only where a surface leads with one \u2014 the subject rung of a picture-led grid, and a record\'s itinerary. A child entity\'s mark reaches a record\'s run and nothing else. One per entity |\n| `lifecycle` | single `select` | the ordered stages a row walks; option order is the order. Which of them END the flow is `outcomes`, which parts of the flow they group into is `phases`, and `history` keeps the day each one was reached. One per entity |\n| `category` | single `select`, or a `lookup` that resolves to one | what the row IS \u2014 a kind, a service, a book. One badge in the field\'s own colour, with no ladder behind it and no flow to advance. Often a fact about the thing the row books rather than about the row, and then it is the lookup that reads it. `icons` gives each kind the glyph a run draws it with. Repeats: a row can be of two kinds of thing |\n| `measure` | `number`, `formula`, `rollup` | a level read against a limit \u2014 see `against` and `alert`. Money where the model says so, and then it prints as money |\n| `expected_set` | `select` | its OPTIONS are the required set (documents, checks, services); an option no row has is a gap to show, not nothing. A multi-select draws as a ring and a fraction wherever it is drawn \u2014 absence is the information, and a list of what IS there says nothing about what is missing |\n| `amount` | `number`, `formula`, `rollup` | THE money of a ledger row; `signed_by` says which way it moved, `against` names the reference it is quoted off. One per entity |\n| `when` | `date`, or a `formula`/`rollup`/`lookup` that yields one | the ledger or timeline date \u2014 stated, or derived: the day money MOVED is a formula over the two columns that could hold it. `due` makes it a DEADLINE; without it the date is the plain day it is. `until` names the stage of this entity\'s own `lifecycle` at which the countdown is spent, and says `due` by saying so. One per entity |\n| `slot` | single `select`, or a `datetime` `date` | where in the DAY a row sits \u2014 the run it is read in under its day\'s heading on an itinerary. A select\'s option order IS the run\'s order; a time is ordered by the clock. A plain `date` is refused: that is the day itself. One per entity |\n| `party` | `select_record_link` | the counterparty. One per entity \u2014 and left off where the `identity` IS the link to them: the row is then NAMED by that record, and a strip under the title would state them twice |\n| `parent` | `select_record_link` | the record this row belongs to \u2014 a line\'s order, a paper\'s case. The parent\'s record shows these rows; the row shows the parent as a fact. One per entity, and it links to an entity this model declares |\n| `contact` | `text` | a way to reach a party \u2014 an address, a number, the town it is in. The record draws them as ONE row of links under the name, so the role sits on every field that is one of them. Repeats |\n| `currency` | single `select` whose option LABELS are ISO 4217 codes | the money THIS ROW\'s figures are in. Every amount and every money measure on the entity is then printed per row rather than in one code for the whole column, and the select is not drawn as a fact of its own. One per entity |\n| `verdict` | `boolean`, `formula` | a settled pass/fail \u2014 ticked, or computed. TRUE is the PASSING side wherever it is drawn, a register\'s risk flag included, so a field whose true means trouble is the same fact asked the other way round. One per entity |\n| `obligation` | `date` | a day something is OWED by \u2014 a cut-off, a permit expiry, a payment due. It counts down by definition. `satisfied_by` names what CLOSES it (or `until`, the stage the record stops owing it at), `label` what is owed. Repeats: a row owes several things, and a shape that fans them draws one row each |\n\n**`due` is what makes a `when` a deadline.** A date a row is merely filed by \u2014 the\nday a lead arrived, the day a movement happened \u2014 is neither early nor late,\nhowever long ago it was. Without the clause every desk drew every `when` as a\ncountdown and a two-month-old lead read "40 days overdue" on a record nobody was\nlate on. So a bare `when` is a plain date, and `{ "role": "when", "due": true }`\nis the one that counts down. An `obligation` needs no clause: a day something is\nowed by is a deadline already.\n\n**`until` stops a countdown where the work is DONE.** A deadline counts down so\nsomebody acts on it, and a row that has arrived needs nothing: without the clause\na delivered order is tinted for a date it met, and every settled row past its day\njoins the urgent ones in the reader\'s glance. It names one option of the entity\'s\n`lifecycle`; at that stage, at every stage past it and at every `outcome`, the\ndate is drawn as the plain day it is. On a `when` it also says the date is `due`.\n\n"One per entity" is one COLUMN, never one value on screen. A second counterparty\nor a second parent stays a ROLELESS `select_record_link`: which field fills a\nslot is the screen\'s answer (\xA7 Apps and screens), and the extra link is a fact on\nthe row with its own section on the record, headed by that link\'s own label. A\nrole naming two fields would move the ambiguity into every shape that reads it.\n\nA COMPUTED field is admitted where its RESULT is what the role needs, and\nrefused where it is not: `identity` and `reference` need `text`, `when` a `date`,\n`mark` `files`. A formula\'s result is its `output_type`; a rollup\'s and a\nlookup\'s is read through the walk. So a formula yielding a number is refused in a\nname\'s place, a lookup landing on anything but `files` is refused as a `mark`, and\na formula declaring NO result is refused by all four \u2014 naming `output_type` as\nthe remedy, because a value drawn as a type nobody stated is the wrong cell with\nnothing saying so. The result also decides the DEVICE every screen draws the value\nwith: a rollup taking the `latest` of a set of dates is drawn as a date, a lookup\nof a select as the words it holds.\n\nA bare role name is the common form. A role that is read against a SECOND field\ntakes the object form:\n\n- **`measure`** names its limit: `against` \u2014 a constant, or a field on the same\n entity the row states as a number (a `number`, or a formula or rollup whose\n result is one) \u2014 and `alert`, which side of it needs attention, `over` a\n capacity or `under` a minimum. The two come together.\n- **`measure`** names what its number COUNTS, where the unit changes how the row\n is DRAWN rather than how the figure reads: `counts: "days"` spans a stop across\n that many days of a run, so a three-night stay fills three of its days instead\n of only the one it starts on, and `counts: "hours"` is how long a stop takes\n INSIDE its day, stated beside it. Stated, never inferred \u2014 nothing about a `3`\n says whether it is nights, pallets or hours, and a quantity drawn across a week\n is a run nobody can read.\n- **`lifecycle`** names the stages that END the flow: `outcomes`, option aliases\n of that select. A row in one has ARRIVED \u2014 delivered, cancelled, written off \u2014\n so a desk draws them apart from the ladder instead of chaining them after each\n other. Not every option may be an outcome, and terminal-ness belongs here, never\n written into a stage\'s label.\n- **`lifecycle`** groups its stages into the parts of the flow they belong to:\n `phases`, each a `label` and the `stages` under it. Nine rungs down one column\n is a list nobody reads as a flow; the same rungs under three headings are three\n pieces of work, and which belong together is the business\'s answer. Every stage\n but an `outcome` falls in exactly one \u2014 a stage in two is drawn twice, a stage\n in none vanishes off the ladder \u2014 and the outcomes may be placed in a phase or\n left out, and are then read as a last part of their own.\n- **`lifecycle`** keeps every stage the row reached: `history: true`, or\n `history: "<alias>"` to name the table. A ladder with no history reports where\n a row IS and nothing about how it got there, which is the whole of what a\n reader asks a pipeline. It is declared BESIDE `phases`, and refused without\n them: the rungs a ladder draws are the live select\'s options, which nothing\n reading a file or an app\'s spec can see, so `phases` is the one statement of\n what the dates have to cover \u2014 and without it a rung the history cannot reach\n draws undated on every record with nothing anywhere saying so. The flag is the\n ONE statement: the model DERIVES a\n child table from it \u2014 the link back to this record, the stage, the moment it\n was reached and who moved it \u2014 and `check`, `apply`, `diff` and the app\n generator all see that table exactly as they see a written one. Nothing else\n declares it, and a file that also writes it by hand is refused. The generated\n create stamps the rung the flow opens at and the generated editor stamps every\n move after it; a stage changed anywhere ELSE is a rung with no date\n (`docs/platform_gaps.md`). **A first apply backfills nothing** \u2014 `apply` writes\n rows only into empty tables, and rows that existed before the flag walked their\n stages before that table existed. The honest backfill is ONE opening row per\n existing parent, at its FIRST stage, dated when that parent was created (true\n by construction); the stage it stands on NOW is not dated unless that is also\n the first. It is a create per parent \u2014 `lotics run create_records` \u2014 and\n `scaffold apply` prints it as the work it did not do.\n- **`category`** gives each kind its glyph: `icons`, option alias \u2192 a lucide icon\n name. A run\'s node is a dot the width of a word, so a stop with no picture of\n its own reads as every other stop. Nothing derives a glyph from an option\n written in the business\'s own language, and a kind the map leaves out draws the\n neutral one. A name lucide does not have at all is refused; one lucide ships\n and the kit has not imported is a NOTE \u2014 it draws the neutral glyph, and the\n fix is either another name or one more glyph in the kit.\n- **`amount`** names the REFERENCE it is read against: `against`, a field on the\n same entity the row states as a number. A price against the list it is quoted\n off, a rate against the going one \u2014 and the catalogue item\'s record draws the\n pair on one axis with the gap said in words. Never a constant (a price typed\n into the model ages with nothing to update it) and never an `alert`: a limit is\n a ceiling a row can pass, and beating a reference is the point.\n- **`amount`** names the select that SIGNS it: `signed_by`, a select on the same\n entity, and `outflow`, the options of that select under which the amount is\n money going out. Without it every shape over the ledger adds both directions\n together: a month whose net was small reads as the total of everything that\n moved, and the trend plots one rising line. The two come together, and\n `outflow` is some of that select\'s options, never all.\n- **`expected_set`** names what CONDITIONS the set: `required_by`, a field on the\n same entity, and `options`, which of that field\'s values require which entries.\n A row whose value is not named requires nothing. Without it the denominator is\n every option, so a set whose entries are mutually exclusive by kind reads\n `1 of 4` on every complete row \u2014 a denominator no row can reach is worse than\n no role. The field is a single `select`, keyed by its option aliases \u2014 or a\n YES/NO the row answers itself (a `boolean`, or a formula resolving to one),\n keyed by `"true"` and `"false"`: a check that FAILED owes its consequence \u2014 the\n photograph, the owner, the day it is due \u2014 and there is no select of the record\n that says so. `from: "parent"` reads that field off the record these rows hang\n under instead, through this entity\'s own `parent` link: which documents an order\n owes is the ORDER\'s type, and the papers carry no column that says it. Which of\n the two a set takes is the set\'s own shape and not a choice \u2014 a multi-select\n holds the whole set on one row and is narrowed by that row (`from` omitted), a\n single select is one entry per row and takes `from: "parent"` \u2014 and the other\n way round is refused rather than left conditioning nothing.\n- **`obligation`** names what ENDS it: `satisfied_by`, a `date` or a `files` field\n on the same entity \u2014 the day it was done, or the paper that proves it \u2014 or,\n where the business stamps nothing, `until`, the stage of this entity\'s\n `lifecycle` at which the record stops owing it: a deposit is owed until the\n order is paid, and nobody records the act of paying twice. One or the other,\n never neither \u2014 without one every obligation the business ever met stays on the\n desk. Optionally `label`, what is OWED as the reader says it ("G\u1EEDi SI"), which\n is not what the column holding the date is called ("SI cut-off").\n\n```jsonc\n"field_roles": {\n "product": { "name": "identity", "photo": "mark" },\n "stock": { "on_hand": { "role": "measure", "against": "minimum", "alert": "under" },\n "uptime": { "role": "measure", "against": 80, "alert": "under" } },\n "order": { "stage": { "role": "lifecycle", "outcomes": ["delivered", "cancelled"],\n // Two pieces of work, and every step dated.\n "phases": [{ "label": "Taking it on", "stages": ["placed", "confirmed"] },\n { "label": "Getting it out", "stages": ["picked", "shipped"] }],\n "history": true },\n // A DEADLINE COUNTS DOWN \u2014 `payment.paid_on` below is a plain day.\n "ship_by": { "role": "when", "due": true },\n // The day the papers are owed by, and the day they went.\n "papers_due": { "role": "obligation", "label": "File the papers", "satisfied_by": "papers_sent" },\n // Nothing stamps a deposit paid \u2014 the order\'s own stage ends it.\n "deposit_due": { "role": "obligation", "label": "Take the deposit", "until": "delivered" } },\n // WHICH PAPERS THIS ONE OWES IS THE ORDER\'S OWN TYPE, and no document says it.\n "document": { "order": "parent",\n "kind": { "role": "expected_set",\n "required_by": { "from": "parent", "field": "kind",\n "options": { "export": ["invoice", "customs"] } } } },\n // `kind` is the direction select \u2014 options `received` and `paid_out`, no role of its own.\n // Every figure on a quotation is in the currency that row names.\n "quote": { "unit": "currency", "total": "amount" },\n // What the price is quoted off, so the item\'s page reads one against the other.\n "service": { "price": { "role": "amount", "against": "list_price" },\n // What each kind of service looks like on a run\'s node.\n "kind": { "role": "category", "icons": { "install": "wrench", "collection": "truck" } } },\n // The day the money moved is neither early nor late, so it stays a bare `when`.\n "payment": { "paid_on": "when",\n "value": { "role": "amount", "signed_by": "kind", "outflow": ["paid_out"] },\n // A receipt owes a receipt voucher; a payment owes an invoice and a payment voucher.\n "papers": { "role": "expected_set",\n "required_by": { "field": "kind",\n "options": { "received": ["receipt_voucher"],\n "paid_out": ["invoice", "payment_voucher"] } } } },\n // A CHECK THAT FAILED OWES ITS CONSEQUENCE \u2014 keyed by the row\'s own answer,\n // and the answer that owes nothing is omitted rather than named with an empty list.\n "check": { "passed": "verdict",\n "evidence": { "role": "expected_set",\n "required_by": { "field": "passed",\n "options": { "false": ["photo", "owner", "due"] } } } }\n}\n```\n\nIn a file that starts from a preset (\xA7 Starting from a preset), `field_roles`\nmay name the preset\'s fields as well as this business\'s own; a role the preset\ndeclares itself is kept unless this file names the same field, and `null`\nclears it.\n\n## Write rules\n\n`write_rules` is what only a CREATE meets \u2014 keyed by entity alias, like\n`field_roles`, and this file\'s in the same way: `check` proves it and the\nworkspace never sees it. An update names one field that moved; a create takes a\ndraft whole, so it has to know which row a name already belongs to, where a\nvalue comes from when nobody types it, and what a figure or a picker may hold.\nThe generator writes one `create_<entity>` workflow and one `New<Entity>Dialog`\nper entity an app can operate, from these clauses and the fields\' own\n`required`.\n\n```jsonc\n"write_rules": {\n // A customer is RECOGNISED by their address. Where an entity names a customer\n // as its `party`, the create takes the email instead of a picker, reuses the\n // row it matches and mints one only where nothing does \u2014 so the book never\n // grows a second Acme because somebody typed the name differently.\n "customer": { "natural_key": ["email"] },\n "order_line": {\n "fields": {\n // A line of nothing is not a line. Refused on create and on update, at\n // the control the figure was typed into.\n "quantity": { "min": 1, "max": 9999 },\n // The price is fixed at the moment of ordering \u2014 COPIED off the product,\n // not looked up for ever after, so the price list moving next week does\n // not silently reprice an order already placed.\n "unit_price": { "default_from": "product.price" },\n // And nothing is sold off an empty shelf. The picker reads only the rows\n // that answer this, and the write refuses the same rows again \u2014 a caller\n // who never opened the picker is bound by it too.\n "product": {\n "options_where": {\n "node_type": "group", "logic": "and",\n "children": [{ "node_type": "condition", "type": "number",\n "field_key": "in_stock", "operator": "greater_than", "value": 0 }]\n }\n }\n }\n }\n}\n```\n\n| Clause | On | Meaning |\n|---|---|---|\n| `natural_key` | the entity | the field aliases a row is recognised by. A `text` key declares `unique: true` on the field itself \u2014 two rows sharing it would make find-or-create pick whichever the read answered first \u2014 and a key is `text` or `number`, because a person types it back |\n| `default_from` | a field | `"<link alias>.<field alias>"` \u2014 the value is copied from the linked row when the row is created, never asked. The link is a one-row link on this entity and `required`, because there has to be a row to read, and the two field types must match |\n| `min` / `max` | a `number` | the figure is refused outside them, on create and on update |\n| `options_where` | a `select_record_link` | an `and` group of plain conditions over the TARGET\'s own fields, each `field_key` a field alias. It narrows the picker\'s read and is refused again where the write lands, so the link is `required` |\n\nA field\'s own `required` is not here: the contract carries it, every write path\nrefuses the row by field name from it, and the generated panel stands its commit\ndown until the same set is filled. `unique` is the text field\'s own clause\n(\xA7 `text`) \u2014 the create says so at the control before the column does.\n\nWhat a create asks is what a person STATES. A `default_from` field is not drawn,\na `lifecycle` opens at its first rung, the stamp an obligation\'s `satisfied_by`\nnames is not asked (the row is only now taking that on), and files are attached\nto the row afterwards \u2014 one fact, one place. `scaffold check` prints every clause\nunder its entity in **Who writes what**.\n\n**The `parent` is prefilled only in the door that mounts the act.** A row opened\nfrom the record it hangs under takes that record from the door it was pressed\nin, so the link is neither asked for nor drawn. The same entity\'s act on its own\nregister has no such row, so there the parent is an ordinary picker the draft\ncannot be committed without \u2014 a payment opened from a money app belongs to a\ncase either way.\n\n## Apps and screens\n\n`apps` is the plan: each app the reader will build, as ONE REGISTER \u2014 a SHAPE\nover an ENTITY \u2014 under `screen`. Nothing here is built by the scaffold: the plan\nis what `lotics scaffold check` prints back, register by register with the field\nin every slot, so it is read and corrected before a screen exists.\n\n**THREE THINGS DECIDE EVERY SCREEN AND EVERY RECORD**: the SHAPE, whose slots are\nthe table below; the ROLES the entities declare (\xA7 Field roles), which fill those\nslots and decide what each child\'s rows become; and the CLAUSES, which are where\nthe plan overrides what the two would answer. This index says which is which, so\na clause is reached for only where the first two have no answer.\n\n**What a child\'s rows become.** One section per LINK into the record, and what\nthe CHILD declares decides its kind \u2014 the first line it answers wins.\n\n| Printed as | The child declares | The reader gets |\n|---|---|---|\n| `documents:` | an `expected_set` select, one entry per row | the desk of what is owed, each row\'s files attached to it |\n| `timeline:` | an `obligation` closed by a DATE, on rows with no `lifecycle` of their own | the ordered stops, the promised day against the day it happened |\n| `thread:` | a `markdown` body, a `party` and a `when` | the correspondence, its answer, and whose move it is |\n| `journal:` | a `markdown` body and a day, on rows a record OWNS (`parent`) with no `lifecycle` | the log \u2014 each entry read in full under its day, its selects beside it, and a composer that writes the next one |\n| `itinerary:` | a `when` and a `lifecycle`, on rows a JOB\'s record OWNS | the day heads the run, one line per stop, the sum under it |\n| `lines:` | anything else the record owns (`parent`) | the register of the rows it is made of |\n| `history:` | anything else NAMED BY it \u2014 the link is their `party` or their `identity` | the same rows read as that record\'s own history \u2014 on a PROFILE, every one of them stands open at its latest 5, headed by how many there are in all, with the rest a press away |\n| `via <link>:` | a link carrying neither role | the register, headed by that link\'s own label |\n| `related:` | rows of an entity this app lists NOWHERE | one counted line, and a press that opens their register |\n\nA child carrying the BODY and the party who wrote it, and no day, is a plain\nregister, and `scaffold check` names the declaration it is one short of rather\nthan letting it fall through silently. A `party` beside a `when` and no body is\nnot a near miss \u2014 that is every ledger line there is.\n\n**A LOG\'S DAY is the child\'s `when`, unless that `when` counts down** (`due`,\n`until`): a deadline is the day an answer is OWED, so a log stacked on it would\nput the entries nobody has chased at the top. Then \u2014 and where the child declares\nno `when` at all \u2014 the day is the first `date` no role claims. A child carrying a\n`lifecycle` is never a log, on the same rule a run of stops reads: it is a thing\nbeing WORKED, and the prose on it is a note about the job.\n\n**A child\'s columns read, and are given up, in one order**: identity \xB7 when \xB7\nlifecycle \xB7 category \xB7 amount \xB7 measure \xB7 expected_set \xB7 party \xB7 contact \xB7\nverdict. The DAY outranks the counterparty because a list of rows belonging to\none record is scanned by when \u2014 the counterparty repeats on every row, and on a\nlog there is none. Ranked the other way, a narrow register shed the date and kept\na column that said the same thing on every line.\n\n**A section names its link where two of them would read alike.** One child can\nreach a record through several links and land under the same heading twice, which\nis the same sentence with nothing saying which rows either holds \u2014 so each of\nthose says the link it is read through (`timeline: Stops via Billed to`), and a\nchild reaching the record once is named by the rows it lists.\n\n**The clauses, by name.** On the APP: `scope`. On the `screen`: `record`, `tabs`,\n`slots` (`roles` on a `custom` one), `columns`, `writes`, `period`, `filters`,\n`summary` (`above`, `totals`, `ageing`, `trend`), `facts`, `presentation`\n(`lead`, `density`, `layout`, `until`), `acts` (`row`, `record`, `selection`,\n`export`, `import`), `section_acts`, `sections`. Every one is optional, every one\nis printed back by `scaffold check`, and a screen that states none gets what its\nshape and its roles answer by themselves.\n\n**ONE APP IS ONE REGISTER AND THE RECORDS IT OPENS.** A second register beside\nit is a second job on one page: the reader arrives on whichever the nav listed\nfirst and decides, every time, which of the two they came for. So an app has one\ndestination and everything else about a row is DISCLOSED by opening it \u2014 the\nfacts by tier, the children as lists, the related as counts, one primary act, and\na filter or a group where a strip of destinations would have been. What used to\nbe a second screen is a section of the record, or another app; a model still\nsaying `screens` is refused by name.\n\n**The unit of an app is a JOB, not a person and not a table.** A job has its\nown outcome (something exists or is settled when it is done), its own subject\n(the record it advances), and an end that does not wait on the rest of the\nwork. Two tasks are ONE job when neither finishes without the other and both\nadvance the same record. One app per job, and that is what makes an app a\nwrite-ownership boundary: what the job settles is its app\'s alone to write,\nplus everything it must read to settle it well. A person holding several jobs\nopens several apps \u2014 one app for everything one person does is the dump. A step\nof the job is a section of the record, never a register beside it; a reference\nthe job needs at hand is read inside the record it is about.\n\n**Two people signing is two jobs**, because the outcome belongs to the signer:\nthe desk that prepares against the gate that releases. So is a different\ncadence \u2014 reference data edited monthly and read by the public site, beside a\ndaily desk \u2014 and a different reader, the owner\'s read-only questions. Device,\nplace and step never split a job. A super app holds more than one job; an\nover-split holds less than one, a job cut by device, place or step. The count\nper workspace falls out of the jobs, typically two to six, and is never the\ninput: review the plan app by app, naming who holds it, the job in one\nsentence, what it writes and what it reads.\n\n**A party is not a job.** The people and companies a job\'s rows name \u2014 the\ncustomers, the suppliers, the carriers \u2014 are not a job of their own, however\nmany rows name them: nobody\'s day is "the customer book". They live inside the\napp whose rows name them: a create takes the party by its natural key, the row\'s\nname opens the party\'s own record (a profile \u2014 how to reach them, what is live\nwith them, their history, their journal), and its facts are edited there. A\nparty earns an app of its own only where someone\'s job IS the relationship, with\nan outcome of its own \u2014 an account plan signed, a supplier qualified \u2014 never\n"keeping the book". Two apps for one seller, the deals and the customers, is the\ndump cut in two.\n\n*A two-van appliance repair shop.* The technician\'s job is the call-out: the\noutcome is a visit done, the subject is the call-out record, and quoting it and\nscheduling it are one job, because neither finishes without the other and both\nadvance that record. The owner holds two of his own \u2014 billing the month\n(outcome invoiced, subject the invoice, settled against visits already closed)\nand the price list the booking page quotes from, edited monthly. Three jobs,\nthree apps, and the owner opens two of them.\n\n**Inside a job the caps hold**: six flow stages on a desk, seven facts before a\nrecord\'s fold. Past them, look for the second job hiding inside. And a job\'s app\nis DENSE: every create the job needs lives in it, so its user never leaves it to\ncorrect a figure the screen in front of them is stating \u2014 three workflows is a\nscreen, not a desk.\n\n**A handoff is a stage change.** Where one job ends the record moves stage and\nthe next job\'s desk opens on it; a field two jobs must both write is declared\nshared at the split, naming the stage each may write it in.\n\n**Name an app for the JOB, in the trade\'s own words, never for who it is for.**\nA title on the door says nothing about what the person who opened it came to\ndo, and it is wrong the day the org chart moves.\n\n```jsonc\n"apps": [\n {\n "alias": "sales", "name": "Sales",\n "description": "\u2026", "icon": "briefcase", "theme": { "color": "blue" }, // optional\n "screen":\n { "alias": "orders", "label": "Orders", "shape": "lifecycle_desk", "entity": "order",\n "record": "drawer", // optional \u2014 "drawer" | "page"; absent, the shape decides\n "tabs": "stage", // optional \u2014 a select on the entity, or null; absent, the shape decides\n "writes": false, // optional \u2014 default TRUE; false makes this screen a reader\n "period": "due_date", // optional \u2014 any field whose value is a date, derived ones included\n "filters": ["kind", // optional \u2014 a single-select, or a lens the model states itself\n { "label": "Qu\xE1 h\u1EA1n l\u01B0u", "predicates": [\n { "label": "\u0110\xE3 qu\xE1", "tone": "red",\n "where": { "node_type": "group", "logic": "and", "children": [\n { "node_type": "condition", "field_key": "owed", "operator": "greater_than", "value": 0 }] } }] }],\n "summary": { "totals": ["total"], "above": ["total", { "field": "owed", "at": "end" }],\n "ageing": { "amount": "owed", "due": "due_date", "buckets": [30, 60, 90] },\n "trend": { "field": "total", "direction": "up" } }, // optional \u2014 see below\n "facts": { "groups": [{ "caption": "Pricing", "fields": ["rate", "surcharge"] }] }, // optional \u2014 the record\'s named bands\n "presentation": { "lead": "none", "density": "dense" }, // optional \u2014 how it is DRAWN; absent, what the rows are decides\n "acts": { "row": [{ "label": "Issue the note", "template": "debit_note", "place": "cta" },\n { "kind": "agent", "label": "Read the papers", "agent": "reader", "fills": ["ref", "due_date"] },\n { "kind": "workflow", "label": "Hand it to dispatch", "workflow": "hand_to_dispatch",\n "inputs": { "order_id": "record", "owed_by": "due_date" } }],\n "record": [{ "label": "Print the file", "template": "dossier" }], // optional \u2014 the record\'s own header menu\n "selection": [{ "label": "Statement", "template": "statement" }], // optional \u2014 the work it hands on\n "export": true, // optional \u2014 the rows in view, saved\n "import": { "kind": "import", "label": "Upload the sheet", // optional \u2014 a file turned into rows\n "entity": "order", "key": "code", "columns": ["rate"] } },\n "section_acts": { "line": [{ "label": "Chase the lines", "template": "chaser" }] }, // optional \u2014 a verb on one section\n "sections": { "line": { "draw": "worksheet", "cost": "buy_rate", "sell": "rate" }, // optional \u2014 priced lines, worked down in place\n "payment": { "draw": "ledger", "summary": ["total", "paid", "outstanding"] } }, // optional \u2014 a book headed by what it comes to\n "slots": { "identity": "code", // optional \u2014 slot \u2192 field, where the roles cannot decide alone\n "subject": ["customer", "project"], // \u2026or the TIERS a fold walks down, outermost first\n "stage": { "field": "state", "quick": true } }, // \u2026or the field AND the reader\'s own control for it\n "columns": ["source", "owner"] } // optional \u2014 extra facts after the slots, shed first at narrow width\n }\n]\n```\n\nA shape is a proven screen with named SLOTS, each filled by a field carrying a\nrole (\xA7 Field roles). A slot with exactly one candidate on the entity binds by itself;\ntwo candidates need naming in `slots`; a field fills one slot; a required slot\nwith none is refused \u2014 a lifecycle desk over an entity with no `lifecycle`\nselect cannot be built.\n\n**A LIST IS A HIERARCHY, not a set of columns.** A group register\'s `subject`\ntakes one \u2014 `"subject": ["customer", "project", "order"]`, outermost first \u2014 and\nthe register becomes one the reader walks DOWN: it folds by the first tier, a\nnode narrows to the tier inside it, the last tier opens the set behind the\nfigure, and a trail says where they are. Every tier is a field of this entity\ncarrying a role that slot accepts, and none of them fills a second slot. It is\nthe slot\'s own answer that decides: a list on any other is refused, because two\ncolumns in one cell is not a fold. Without it the same business needs a register\nper depth, and the same money is folded twice with nothing saying it is the same\nmoney.\n\n**A QUICK SLOT IS FOR A DECISION THE READER MAKES FROM THE ROW ALONE.** A slot\'s\nvalue in `slots` is normally the field\'s alias; `{"field": \u2026, "quick": true}`\nsays the column is not a reading of that value but the CONTROL for it \u2014 pressed,\nit writes that one field as a diff through the record\'s own update, so the\nregister and the page behind it land the same write. THREE roles are such a\ndecision, and `quick` on any other is refused: a `lifecycle`, which rests as the\nstage\'s own dot and label, takes a rule under it on hover and focus, and opens\nthe field\'s stages with the ones that END the flow last \u2014 ONE control, which IS\nthe reading;\na `verdict`, which is the switch; and a `measure`, which is the figure typed in\nits own cell \u2014 a reading taken per row IS the row, which is what a timesheet\'s\nhours and a count sheet\'s tally are. Everything else is decided against what the\nrecord holds, and the record has to be open. All three carry the record\'s own\nblockers \u2014 a move the ladder holds is a move the cell holds, and it names the\nentries the row still owes \u2014 and an outcome asks before it commits. Add `"order": "sequence"`\nwhere the stages are a WALK rather than a set of destinations: the picker is then\nordered as the walk and the step the row takes next is MARKED in it. It never\nadds a second control \u2014 a column that answered with a reading in some rows and a\nverb in others is two columns about one value. A screen stating `writes: false`\nrefuses `quick`: a reader who may operate nothing has no decision to take.\n\n**THE SLOTS ARE THE ROW\'S ANSWER; `columns` IS ITS CONTEXT.** `"columns":\n["nguon", "phu_trach", "nhu_cau"]` names extra fields of the entity, drawn AFTER\nevery slot and in this order, each by what its column IS \u2014 a chip for a select,\nthe person\'s name for a member, the day for a date, the figure for a number, a\ntick for a boolean, the words for everything else. They are ranked BENEATH every\nslot, so a phone sheds all of them before it sheds any of the shape\'s own\ncolumns. **A COUNT IS NOT A COLUMN**: an entry whose field is a `rollup` that\nCOUNTS rows is read as the thing it counts \u2014 `3 b\xE1o gi\xE1 \u0111ang m\u1EDF`, the number then\nthe column\'s own label \u2014 on the name\'s supporting line at every width, so it\ntakes no seat and a count of nothing draws no run at all. Where the record LISTS\nthose rows, the reading is the press that opens it. At most four, and refused\nwhere one would say what a slot already says,\nover a files field (files are read, so they are a section of the record), over a\ncell holding several (a column of comma lists compares nothing), on a shape whose\nrows are not the entity\'s records in a table, and beside a `presentation.layout`\nthat draws the rows with a device of its own. A fifth fact worth the width is a\nslot the shape is missing \u2014 say so rather than widening this clause.\n\n| Shape | Answers | Required | Also fills | Record | Tabs |\n|---|---|---|---|---|---|\n| `lifecycle_desk` | what is stuck, what do I move next | `lifecycle`, `identity` | `mark`, `party`, `amount`, `measure` (level), `when` | page, or drawer where the entity carries `parent` | the lifecycle\'s stages |\n| `party_register` | who is this, our history, is there a risk | `identity` | `mark`, `contact`, `measure` (worth), `verdict` (risk) | page | none |\n| `offering_register` | what do we offer, at what price, can I sell it | `identity` | `mark`, `amount` (price), `measure` (availability) | page | none |\n| `transaction_ledger` | does this period reconcile, what is unexplained | `when`, `amount` | `identity` (reference \u2014 the line\'s own number), `party`, `lifecycle` (classification), `expected_set` (document) | drawer | none |\n| `monitored_asset_set` | what needs attention, is that number normal | `identity`, `measure` (level) | `mark`, `lifecycle` | drawer | none |\n| `obligation_desk` | what is due next, and has it been done | `identity`, and at least one `obligation` on the entity | `when` (runway) | page | none |\n| `trend_deep_dive` | how did the period go, and why | `when` | `measure`, `amount` | drawer | none |\n| `reconciliation_desk` | what does not match, and by how much | `identity` (reference), and two figures \u2014 `ours` and `theirs`, each an `amount` or a `measure` | `category` (reason), `verdict`, `when` | drawer, on the PAIR | the dated runs, where the model names a select |\n| `entry_matrix` | one value per subject per period | `identity` (subject), `across` \u2014 a `when`, or a `category` for a fixed column set | `measure` (value), `lifecycle` (state), `category` (note) | drawer, on the cell\'s row | none |\n| `guided_run` | complete an ordered sequence, a step at a time | `identity` (step) | `slot` (sequence), `capture` \u2014 a `measure`, `verdict` or `expected_set` \u2014 `verdict` (gate), `mark` (media) | page: the run IS the record | none |\n| `live_board` | is everything OK, right now | `lifecycle` (state), `identity` | `verdict` (exception), `when` (since), `measure` (level), `category` (where) | drawer | none |\n| `group_register` | what does each group come to, and what is behind it | `subject` \u2014 a `category`, `party` or `when` | `amount`, `measure`, `identity` (member) | page: a row is an aggregate, and the door is the SET behind it | none |\n| `media_set` | scan a body of pictures by where they belong | `mark` (picture), `identity` | `category` or `party` (group), `when`, `verdict` (current against superseded) | drawer | none |\n| `day_sheet` | what happened on each day | `when` (the day) | `lifecycle` (state), `measure` (level), `amount`, `category` (note) | page: a day composes several child logs | none |\n| `resource_schedule` | what is on each resource, in what order, under what ceiling | `lane` \u2014 a `party` or a `parent` \u2014 `identity`, `when` (the start) | `measure` (duration), and `load` and `bulk`, each a `measure` read against a ceiling of the LANE\'s \u2014 a vehicle fills by weight and by room and stops at whichever runs out first; `lifecycle` (stage) | drawer, over the lanes | none |\n| `worksheet` | priced lines the reader edits, totalling to one figure | `identity` | `category` (group), `measure` (quantity), and `cost` and `sell`, each an `amount` or a `measure` | drawer, per line | none |\n\n**A record is one of five KINDS, and the shape plus the roles decide which.**\nEvery one of them is ONE READING COLUMN, and the ORDER of that column is the\nwhole of what the kind means.\n\n| Kind | The column, top to bottom |\n|---|---|\n| WORK RECORD \u2014 a `lifecycle_desk` over rows that belong to nothing and that nothing transacts with | the one act that moves it \xB7 what it IS \xB7 the papers it owes \xB7 the rows it is made of \xB7 the book of what it came to |\n| LINE \u2014 the same shape over rows carrying `parent` | its ladder \xB7 the arithmetic behind its amount \xB7 the rows and papers under it \xB7 its particulars, last (the key it is filed by is the line under its title) |\n| PROFILE \u2014 a `party_register`, and any shape over an entity whose rows other entities are NAMED by (their `party` or their `identity`) | where it stands \xB7 its history, OPEN, grouped by year \xB7 the rest of its registers \xB7 its facts (the ways to reach it are under its name, its settlement is the band, and a `when` it owes closes that band as a countdown) |\n| CATALOGUE ITEM \u2014 an `offering_register` | its own words (the picture leads the header at media scale, the price is read against its reference in the band) \xB7 what uses it \xB7 its facts |\n| EVIDENCE \u2014 a `transaction_ledger` | the PROOF \xB7 what the paper is, compactly \xB7 the rest \xB7 the links to the record it settles and the party it was with |\n\nNothing in the file states the kind: a clause that could say it could say the\nwrong one, and the model already says it \u2014 `parent` says whether a row stands\nalone, and a link NAMING this record (`party`, `identity`) says whether other\nrows are ABOUT it. So a desk over accounts\nwalking their own stages opens a PROFILE: the quotes and the invoices naming\neach account are what its record is read for, and a work record would have\ncounted them in one line at the foot. `record`\noverrides the DOOR where the shape\'s own answer is not the one wanted \u2014 and its\nthird value, `"expand"`, is not a door at all: the row REVEALS what it holds in\nplace, where there is nothing behind it worth navigating to. A row read that way\nreads as a LINE whatever the shape would have opened: its ladder, the arithmetic\nbehind its amount, then its particulars, because there is no header above it to\nhave stated the name first. It is REFUSED for two reasons, and they are not the\nsame refusal. On a shape whose record is a page by nature \u2014 a `guided_run`, a\n`group_register`, a `day_sheet`, an `obligation_desk` \u2014 because each of those\nstates the opposite where its door is declared: what its row leads to is read\nwhole, not as four more columns than the register had room for. And on a shape\nthat draws its rows with a device of its OWN \u2014 an `entry_matrix`, a `media_set` \u2014\nbecause a cell of a grid and a tile on a wall have no band under them for the row\nto reveal into. For the same reason a revealed register is drawn as a TABLE: a\n`presentation.layout` of anything else is refused, and the reader is not offered\nthe arrangement either, since it would take away the only door the register has.\n\n**`scope` \u2014 the one subject every read of the app narrows to.** Stated on the\nAPP rather than on its screen, because it is not a filter: a record opened under\nit stays under it, the pick survives closing the app, and every app declaring the\nsame `entity` shares one pick per viewer \u2014 which is the whole value, and what\nstops a construction workspace asking which project twelve times. `entity` is the\nmodel\'s entity whose one row the app is read inside, and `param` is what the\napp\'s reads take that row by.\n\n```jsonc\n{ "alias": "site_work", "name": "Site work",\n "scope": { "entity": "project", "param": "project_id" },\n "screen": { \u2026 } }\n```\n\nThe register\'s own entity has to REACH it \u2014 its own rows, or rows that name one\nthrough a link \u2014 or the switcher is a control that changes nothing. Until a\nsubject is picked the app reads NOTHING and says which one it is waiting for: an\nunscoped read over a scoped app is every row in the workspace drawn as one\nproject\'s work, which looks correct.\n\n**ONE RECORD SURFACE PER ENTITY, AND ITS KIND IS THE ENTITY\'S.** An app is one\nregister, so the record its rows open is the register\'s own and the kind comes\nfrom that register\'s shape. Another app over the same entity opens the same kind\nof record: a payment read from a cash book and one read from a trend are both\nmovements, and both read proof first. A shape with no kind of its own (a trend, a\nmonitored set, a `custom` screen) says only where the record opens.\n\n**A NAMED PARTY HAS A RECORD SURFACE IN THE APP.** One register, but the party\nits rows name \u2014 by `identity` or by `party` \u2014 opens a record of its own, a\nPROFILE, from the cell that names it and from the record\'s header: the ways to\nreach them, what is live with them, every register that names them at its latest\nfive, their journal, their facts. It is the app\'s to write as far as the job\nneeds \u2014 the party\'s facts and its journal \u2014 and the writers matrix says so; the\nregister\'s own record stays the register\'s. A party named through a link\ncarrying no role opens nothing.\n\n**Two things a register states about a row beyond which field fills which slot.**\nA `measure` is read AGAINST its limit (`against`/`alert`) where the shape\'s slot\ntakes one \u2014 `level`, on a lifecycle desk and a monitored set, and every slot of a\n`custom` screen, which composes the frame\'s own column; `worth`, `availability`\nand a trend\'s headline are plain figures, and a limit there would read as a meter\nin the record over a number the row printed bare. And the name carries a\nSUPPORTING LINE where the entity states a key to file the row under: the `parent`\nit belongs to, its `reference`, an `autonumber`, a text formula \u2014 in that order,\nfirst hit wins, never a field a person types prose into. Every record heads with\nthat same key, so the register and the door it opens name one row one way.\n\n**The act that opens a row belongs to a register that LISTS the entity\'s rows**\n\u2014 a desk, a register, a ledger, a monitored set, or a `custom` screen. A shape\nwhose rows are not records has neither that act nor the door a counted line\nelsewhere leads to: an obligation desk\'s rows are deadlines and a trend\'s are\nperiods, so a create pressed there would open a row the screen cannot show. An\nentity whose only app is one of those has no create at all \u2014 give it an app whose\nregister its rows are read in.\n\n**An `obligation_desk`\'s rows are not its entity\'s rows.** The shape fans the\nentity\'s `obligation` fields out \u2014 one row per thing still owed, which is one\nwhose date is SET and whose `satisfied_by` is empty \u2014 so a l\xF4 with four cut-offs\nis four rows, and the three it has met are not there at all. The row\'s name is\nthe obligation\'s, its supporting line the record\'s `identity`, and the door is\nthat record. A `when` bound to `runway` is what the countdown\'s ring is measured\nfrom. Over an entity declaring no `obligation` the shape is refused: there is\nnothing to count down to.\n\n**What a register carries beyond its columns.** Six clauses, each emitted as\nthe prop the kit draws it with; every one is optional and a screen that states\nnone gets a register of columns and nothing else.\n\n- **`period`** \u2014 a field on the entity whose value is a DATE. The toolbar gains a\n date-range control (this month to start), and the rows it keeps are what the\n register AND every figure below are computed over, so a band can never be over a\n different window than the rows under it. Any such field, not only the `when`\n role, and however the date got there: one table is read two ways (a cost ledger\n by the day a line arose, the cash book over the same table by the day it\n settled), a role is one field\'s, and the day money MOVED is often a formula over\n the two columns that could hold it \u2014 which then declares `output_type: "date"`.\n A `trend_deep_dive` brings its own period and takes none here; a `live_board`\n is PERIODLESS and takes none either, for the opposite reason \u2014 it answers what\n is true NOW, and a date range over it draws what was true in the window in the\n live state\'s own colours.\n- **`filters`** \u2014 the chips beside the search. A single-`select` field\'s alias\n offers that field\'s own live options; it is the lens a register is read through\n over and above the one band its strip gives, so the strip\'s own field is\n refused here (one dimension, one control) and so is a multi-select (a row would\n answer the chip several ways at once). The rows the register and every figure\n below are computed over are what the chips AND the period kept.\n A `select_member` field\'s alias is the third form and asks one question \u2014 whose\n rows these are: two peers, MINE and ALL, read against the person looking rather\n than a directory of everybody. `{"field": \u2026, "default": "mine"}` opens the\n register on the reader\'s own; that form on any other type is refused. Alone of\n the chips it narrows the READ (a `member` param on the register\'s query), so a\n desk that opens on the reader\'s work opens on all of it rather than on\n whichever of their rows the first page happened to hold.\n A DERIVED LENS is the other form \u2014 `{"label": \u2026, "predicates": [{"label": \u2026,\n "tone": \u2026, "where": \u2026}]}` \u2014 where the sets a reader narrows by are ones the\n MODEL names and no column holds: rate validity, plan urgency, free-time\n overrun. Each `where` is an `and` group of plain conditions over the entity\'s\n own fields, each `field_key` a field alias, and it is read off the row, so the\n operators are the comparisons a value answers \u2014 `number` and `text` equality,\n `number` ordering, `boolean` equality, `select` `has_any_of`/`has_none_of`, and\n `is_empty`/`is_not_empty` on any of them. Nothing DATED: a relative point needs\n a clock, and a screen states one date control (`period`), so a second beside it\n would be two windows with nothing saying which a figure was computed over \u2014 a\n date question is asked as a column the model derives and read here as a number\n or a yes/no. `tone` is the option palette\'s, because the chip draws these\n exactly as it draws a select\'s options.\n- **`summary`** \u2014 what the rows in view come to. `above` is a band OVER the\n register: `"counts"` for how many rows are in view and, for the FIRST\n `measure` the model gives a limit, how many are past it (accented only when\n one is) \u2014 one such set, because a band naming three is the dashboard a\n register is not; a list of number-field aliases for what they add up to, and a\n `percentage` named there is refused, since a share summed over the rows in\n view is a figure of no kind (draw it as a column, whose own total reads the\n mean). A figure written `{"field": \u2026, "at": "end"}` is a STOCK instead: the\n reading standing at the END of the window rather than the sum of the readings\n in it, which is the only way opening + in \u2212 out = closing reconciles \u2014 a month\n of daily closing stocks added together is thirty warehouses. The band labels it\n as the snapshot it is, and it is refused on a screen that states no `period`,\n since there is then no window for it to stand at the end of.\n `ageing` stands in that same\n band: an `amount` split by how many days past its `due` date each row is,\n drawn as a `Breakdown` of the edges in `buckets` (30, 60 and 90 days unless the\n model states its own, ascending). The ladder is the kit\'s \u2014 its boundary, its\n words and its ramp \u2014 and it opens with what is NOT YET DUE, because a bar of\n overdue bands alone is full at every input: a book with one late invoice and a\n book that has gone entirely bad would paint the same solid width. Against the\n current money the bar\'s own shape is the reading. A row whose date is empty is\n in no band. `totals` is what the whole\n view adds up, and it is drawn in that SAME band above the rows: a register\n states one aggregate, over the rows the reader can see, in one place, and a\n closing line under them is a second place to look and a second question about\n which rows it covers. A closing line belongs to the one device that IS a\n statement \u2014 a record\'s `Ledger`, whose balance is what it is read for, labelled\n by its amount\'s own word. Where a shape has no band above (a trend, whose own\n band is the chart) the figure stands under the register instead. A\n `transaction_ledger` sums its amount column itself and takes `above` alone. An\n `obligation_desk`\'s rows are DEADLINES and not records, so its band states\n `"counts"` \u2014 how many are open \u2014 and a figure list, an `ageing` or a `trend`\n over it is\n refused: a l\xF4 with three cut-offs is three rows, and its freight added over\n them is three times the freight.\n `trend` is `{"field": \u2026, "direction": "up"|"down"}` and states WHICH WAY that\n figure moved across the window: the rows in view are cut into the window\'s own\n buckets \u2014 days over a month, weeks over half a year, months beyond \u2014 and the\n later half of the CLOSED ones is read against the earlier half, drawn beside\n the figures as one line, so a window the reader is still inside states the\n movement of the days that have run rather than a fall into the ones that have\n not. `direction` is which way is GOOD, which nothing about the number\n says: a book wants its takings rising and a backlog wants its days falling, and\n the same arrow is a win on one and an alarm on the other. It needs a `period`\n to be a window of, and it is refused on a shape that draws its own (a\n `trend_deep_dive` already draws the series) or that reads none at all (a\n `live_board` answers what is true now). A window whose earlier half took\n nothing draws no line: there is no base for a percentage, and 0 % would claim a\n steadiness nobody measured.\n- **`facts`** \u2014 how the RECORD\'s facts are banded. `groups` is a list of\n `{caption, fields}`: what a set of facts has in common is a sentence about the\n business and nothing derives it, so a plan that states one gets exactly those\n bands, in its own order, captioned. EACH BAND IS A SECTION of the record \u2014 its\n own heading, its own entry in the rail, its own place in the column: under one\n heading the reader is handed every particular at once, in a caption weight that\n cannot out-rank the heading above it, with nothing in the rail to reach any of\n them by. Everything the plan leaves unnamed is the LAST section and carries no\n heading, since there is no sentence to head "whatever no group claimed" with \u2014\n ONE section, even where the record\'s own recipe bands what was left in two (an\n evidence record reads its particulars before the record and the party it was\n with): both are groups inside it, because the word the kit heads "the rest"\n with cannot name two entries in the rail.\n A band of more than eight facts is NOTED: a section that long is two. A field the header, the band, the ladder, a required\n set, the files or a register below already draws is refused: it is not a fact,\n so a band naming it would either state it twice or draw nothing. Naming any\n band IS the answer to which facts fold \u2014 see the TIERS below.\n- **`presentation`** \u2014 how the screen and the record it opens are DRAWN, where\n what the rows are is not the answer wanted. `lead` is what each row leads\n with: `"mark"` the subject\'s own mark, always spent because a party\'s initials\n stand in for a picture nobody uploaded; `"picture"` the photograph, spent only\n on the rows that carry one and, on the record, at media scale above the name;\n `"paper"` the row\'s own files, drawn as the cards a pile of documents is read\n as; `"figure"` the amount, with no gutter at all; `"none"` neither. `density` is\n how many lines a row\'s subject may take \u2014 `"roomy"` two, `"dense"` one.\n Both default, and the DEFAULT is what the rows are: a party register leads\n with the mark, an offering register with the picture, a ledger with its\n figure, and a desk \u2014 rows that are work still to do, scanned \u2014 stands its rows\n one line each while a record\'s own rows are read roomy. So state it only to\n differ, and a plan that states nothing still gets screens that vary. A lead\n the rows cannot carry is refused: a mark, a picture or a paper where no column\n is drawn as the rows\' mark, a\n figure where no column is the amount, and the other subject\'s mark (which of\n the two a row wears is the shape\'s, so the register and the record it opens\n cannot call one row two kinds of thing).\n `layout` is how the rows are ARRANGED \u2014 `"table"`, `"list"`, `"cards"`,\n `"gallery"`, `"board"`, `"calendar"`, `"timeline"`, `"gantt"` \u2014 and it is\n AFFORDED by what the rows carry, not by the shape: every register affords a\n table and a list, a `mark` affords the two picture-led grids, a `lifecycle`\n affords a board, a `when` affords a calendar and a timeline, and a `when`\n beside a `measure` that `counts` DAYS affords a gantt, because a bar with no\n length is a calendar drawn sideways and a bar measured in money or litres is a\n length of another kind. `until` names the date field a bar ENDS on, where the\n rows state one, and the days measure is what the bar runs for without it. A\n layout the bound roles do not afford is refused, naming the ones they do.\n- **`acts`** \u2014 where this screen hands work on: `row` is the \u22EF menu on every row,\n `record` is the \u22EF on the RECORD\'s own page header \u2014 the same reach as a row\'s,\n standing where the work is open instead of while a list is scanned, and refused\n on a record that opens as a drawer, which has no header of its own and whose\n row already carries the register\'s menu \u2014 and `selection` is the bar over the\n TICKED rows. `export` is the third reach \u2014\n the WHOLE VIEW, saved in one press: `true` writes the rows as the register drew\n them, in the columns it drew, as an `.xlsx`, and\n `{"template": "\u2026"}` says the layout is the trade\'s and makes the paper with a\n workflow like any other. It is never a list of columns: which columns the\n export carries is what the screen already draws, and a second statement of it\n disagrees the moment a slot moves \u2014 the generator reads them off the drawn\n slots and writes them into the app, so the sheet\'s headings are the labels the\n register drew them under.\n `import` is the reach OPPOSITE it \u2014 a file turned into rows:\n `{"kind": "import", "label": \u2026, "entity": \u2026, "key": \u2026, "columns": [...]}`. The\n file is mapped column by column, each row is validated, what would change is\n previewed, and the commit UPSERTS by `key` \u2014 which is why a sheet sent twice\n moves no counts. That key is one of the entity\'s own `natural_key` fields\n (\xA7 Write rules), and an entity declaring none is refused: without a key the\n second run is a second set of the same rows. `entity` is the register\'s own \u2014\n an app is one register, and rows filed into another entity are a count nobody\n on this screen can check. `columns` is what the sheet may fill, in that order;\n absent, it is every column a person states IN WORDS. A computed one is refused\n because the workspace writes it, and a link, a member or a files column is\n refused because a cell of a sheet is words and those hold a row of another\n table or bytes \u2014 a file reaches another table through the party pattern (a\n `natural_key` on the target, named rather than picked), which is a create\'s.\n The generator writes the whole verb, as it does for a paper: an\n `import_<entity>` workflow that finds the row by `key` and then changes it or\n opens it, answering which of the two, and the staged run over it \u2014 drop, map,\n the per-row verdict, the commit. A line whose cell the column cannot hold is\n refused with the reason and the rest of the sheet still lands.\n Both spreadsheet reaches are read and written IN THE BROWSER, so the generated\n `src/main.tsx` imports `@lotics/app-runtime/sheets` wherever the plan states\n one of them and not otherwise; an app that has neither carries no spreadsheet\n engine at all. An act names ONE of three things, never two:\n - **`template`** \u2014 an `html` template this model declares (\xA7 Templates). The\n paper is filled from ONE row in `row`, and from the whole ticked set in\n `selection`. The generator writes the whole verb \u2014 a `generate_<template>`\n workflow that reads the row and hands the file back, and a menu item that\n opens it \u2014 so there is nothing left to bind. An `email` template is sent\n rather than opened and is refused here; a file-backed template (`excel`,\n `word`, `pdf-form`) is bytes a model has none of, so those stay the author\'s\n own `lotics app workflow set`. Two screens over DIFFERENT entities cannot\n name one template: one paper is filled from one kind of row.\n - **`{"kind": "agent", \u2026}`** \u2014 a run over ONE row. `agent` is an alias the APP\n declares (`package.json#lotics.agents`), because an agent is prose and tools\n rather than anything a workspace model can state \u2014 `lotics app check` refuses\n one nothing declares, exactly as it refuses a workflow nothing bound. `fills`\n is the fields the run may write: pressed, the reader watches the run, reviews\n what it proposes field by field against what the row holds now, and applies\n the ones they kept as ONE write through the record\'s own update. A run can\n reach nothing outside `fills`, a computed column there is refused (the\n workspace writes those), and a screen stating `writes: false` refuses an\n agent act outright. It belongs in `row`; the selection bar makes ONE paper\n from many rows, and a run per ticked row is the row\'s own act many times.\n - **`{"kind": "workflow", "workflow": "\u2026", "inputs": {\u2026}}`** \u2014 the work HANDED\n ON: a lead becomes an opportunity, an order is split into the orders placed\n on its suppliers, a request is closed. `workflow` is an alias the APP binds\n (`package.json#lotics.workflows`), because the rule behind it is the\n business\'s and no model states one \u2014 so the generator writes NO body and\n `lotics app check` refuses an alias nothing bound, exactly as it refuses an\n agent nothing declares. `inputs` is what the press hands that body: the\n workflow\'s own input name \u2192 `"record"` for the row it was pressed on, or a\n field of this entity for a value off that row. The value is what the\n workspace HOLDS \u2014 an option\'s key, a linked row\'s id, the figure \u2014 never the\n rendering. A files column is refused (the body reads the row\'s files off the\n row it is handed), a column that is not a field of the entity is refused by\n name, and one input short of the declaration is refused at the press, so the\n whole act is dropped rather than shipped half-bound. It runs ON the press:\n there is nothing to review first, which is the agent arm\'s law, and the\n body\'s own sentence is what the reader is told either way. It stands in\n `row`, in `record` and on a `section_acts` band \u2014 each reaches ONE row \u2014 and\n is refused over the ticked set, where one act makes one paper from many.\n\n **`"when"` stands an act down until the work is ready.** `{ "field": "<the\n entity\'s lifecycle>", "in": ["<stage>", \u2026] }` offers the verb only while the\n row stands at one of those stages. A verb that cannot work yet is worse than\n no verb: the reader presses it, the body refuses, and nothing on the screen\n ever said the work was not ready. Readiness is what a lifecycle states, so the\n field named is this entity\'s `lifecycle` and nothing else \u2014 a category says\n what a row is and a verdict answers a question, and neither moves. Refused: a\n field that is not the lifecycle, a stage it does not declare, and every stage\n at once, which is the act with no condition.\n\n **`"place": "cta"` draws an act ON the row** instead of in its \u22EF \u2014 the one verb\n a reader presses without opening a menu first. At most one per screen and every\n other act stays in the menu, because the trailing gutter is paid for by every\n row: a second is refused with *one verb on the row, the rest in its menu*. The\n ticked set has no row of its own, so `cta` is refused there.\n\n A hand-off\'s BODY is still the author\'s: `lotics app workflow set <alias>`\n binds it, and `scaffold check` prints the act as `"<label>" \u2192 <alias>(\u2026) [you\n write the body]` so it is read as work owed rather than as a verb already\n wired.\n\n A `selection` act is a `template` and nothing else: an act over many rows makes\n ONE paper from them. The generator turns the register\'s checkbox gutter\n on, emits a `generate_<template>` workflow taking the ticked ids, and the body\n reads each row and passes them as `rows` \u2014 which is what the template iterates\n (`{{#each rows}}`). One template is one paper AND one reach: naming the same\n one from a row\'s \u22EF and from the bar is refused, because those are two bodies.\n A shape whose rows are DERIVED rather than records \u2014 an `obligation_desk` \u2014\n has no set to tick and refuses the clause. The paper is handed BACK, never\n filed: a ticked set can hold rows of three different parents, so there is no\n record on which "this document belongs here" is true.\n\n**`section_acts` puts a verb WHERE ITS EFFECT LANDS.** "Chase the paperwork"\nbelongs on the papers, not in the register\'s \u22EF two surfaces away. It is keyed by\nthe alias each section is DERIVED from \u2014 a field\'s (its progress, its prose, its\nrequired set, its charge, one of its files) or a CHILD ENTITY\'s (its register,\nits desk, its run, its thread) \u2014 because the sections come off the roles and the\nkey the app addresses one by does not exist until it is built. An alias naming no\nsection is refused, listing the ones that do; the facts band is what every other\nsection left over, so nothing addresses it. Each act is a `template`, an `agent`\nor a `workflow`, exactly as a row\'s is \u2014 the reach is the same one row \u2014 and\n`place: "cta"` is refused: a section is a band with a heading and has no row to\ndraw a verb on. `scaffold check` prints\nwhich section each alias landed on, which is the half an author cannot see in\ntheir own file.\n\n**`sections` says HOW one of those sections is DRAWN**, keyed by the same\naliases. It carries two readings.\n\n`"draw": "ledger"` heads a book of movements with what the record it is against\ncomes to: `summary`, number fields of THIS record, in the order they read. A\nsection with nothing in it is otherwise a heading, a verb and a void \u2014 and the\nemptiness is exactly when the reader most needs to be told what the rows would\nbe for, so the statement is drawn at nought rows too. The figures are the\nRECORD\'s rather than the child\'s for the same reason: a sum of the rows under it\nis the one statement a book with no rows cannot make.\n\n`"draw": "worksheet"`: the child\'s rows\nare PRICED LINES the reader works down in place, each part of the job footed and\nthe sheet closing under them. `cost` and `sell` name the child\'s two figures,\nwhich is the one thing the roles cannot decide \u2014 an entity carries one `amount`,\nand a line that is costed and sold carries two. Everything else is read off the\nchild\'s own roles: what a line is FOR is its `identity`, how many it is for is\nthe `measure` the pair left, and the part it falls under is its `category`. The\nMARGIN is on none of them, because it is arithmetic over the pair.\n\nA sheet is the WRITE side of a price, so it is the one child section whose cells\nare editors: a figure typed into a cell is written as a diff through the child\'s\nown update, which is the same editor the line\'s own drawer saves through. Every\nother child section is read where it is drawn and edited in the row\'s drawer. A\nline is ADDED from the section\'s heading as every child\'s row is, with the record\nit hangs under as the act\'s own context.\n\nRefused: an alias naming no register of this record, rows the record does not\nOWN (a line added to a history belongs to the job it is about, not to what is\nreading it), a figure that is not a field of the child or whose role is neither\n`amount` nor `measure`, a sheet naming neither figure, one figure priced as both,\nand a book headed by anything but a number field of the record.\n\n**A CHILD NOBODY REGISTERS IS A NOTE, not a refusal.** Where a record lists a\nchild entity no app is a register of, `scaffold check` says `"<entity>" has no\nregister \u2014 its rows are read here and created nowhere` and the plan printout\nmarks that entity `(no app)`. Rows can arrive from an import or a workflow, so\nit is a reading rather than a rule; what it catches is the register somebody\nmeant to plan and did not. A section the record ADDS to is exempt, because its\nheading is where those rows are typed: the rows a record owns on a PAGE, a\nthread on any door \u2014 a reply is written where it is read \u2014 and a sheet, which\nopens its own lines. A record opening in a DRAWER adds none of them, so its\nowned rows are noted like anybody else\'s.\n\n`scaffold check` prints every clause a screen states, on its own line under the\nslots, spelling the screen\'s `writes` clause `operable` \u2014 the app manifest\'s\n`lotics.writes` keeps that word, and the two are different facts: `app create`\nSEEDS the manifest from the fields the screens\' own editors write, and from then\non the app owns the declaration `lotics app check` holds its bodies to.\n\nEach shape is a `@lotics/ui` component of the same name (`LifecycleDesk`,\n`PartyRegister`, \u2026) whose props are these slots, so once the tables exist\n`lotics app create <name> --from <this file>#<app alias>` scaffolds the app with\none screen per entry, each slot reading the field the plan bound.\n\n`"shape": "custom"` is the screen no registry row covers: it declares its own\n`roles` (slot name \u2192 role), and it is emitted on `ShapeFrame` \u2014 the one anatomy\nthe six shapes above are each a configuration of \u2014 so its strip, search,\nordinal, fit budget, empty and waiting states and record door are the same ones\nthey have. It opens the record its `record` says, drawer or page, like any other.\nA bound `lifecycle` slot IS its strip, the stages in the field\'s order as on a\ndesk, so such a screen names no `tabs`; a `tabs` select is the flat strip a\nscreen with no lifecycle gets.\n\n**An app IS its `app.json`.** `create --from` writes the bound plan \u2014 every\nscreen with its shape and slots, the record each row opens with its sections in\nthe archetype\'s order, the create panels, the acts \u2014 as one JSON document, plus\na five-line `src/main.tsx` that mounts `@lotics/app-runtime` over it and one\n`src/workflows/<alias>.ts` per write. There is no screen source: the runtime\ndraws the spec, so a kit correction reaches every app with its next install.\nWhere the plan has no word for what a screen or a section IS \u2014 or for what a\npaper act should ASK before it is made \u2014 the spec names one of the app\'s own\ncomponents and `src/components/index.ts` registers it, the one file under `src/`\na regeneration never rewrites. `lotics app eject <screen|<section key>|<act\nlabel>>` writes each of those, starting from what the runtime already drew.\n\n**How a spec reads a row.** Each query projects its columns under the alias the\nworkspace mints from the field\'s LABEL \u2014 never the alias this file keys it\nunder, which is the model\'s own namespace and which the workspace never saw. So\na field this file calls `partner` and labels `\u0110\u1ED1i t\xE1c` is referenced as\n`doi_tac` throughout the spec. Every id in it is live: the `tbl_` a screen is\nover, the `fld_` of each column, and the `opt_` of every option a role names.\n\n**Every query is described, in the model\'s own language.** The line an agent\nchooses between aliases by is written from this file\'s nouns \u2014 the entity\'s\nlabel, the screen\'s, the link\'s \u2014 and the sentence around them is the language\nthe file is mostly written in, decided the same way a generated write\'s refusals\nare. Hand-editing one is erased by the next regeneration; `lotics app check`\nrefuses an alias that carries none.\n\nA screen is that list and the RECORD it opens, and the record comes off the same\nroles \u2014 nothing to declare for it. It opens with a **header**: the entity\'s\n`identity` as the record\'s name \u2014 whether or not the list has a column for it, so\na ledger\'s and a trend\'s records are named too \u2014 the `mark` beside it on a PAGE,\nwhich is what the subject is recognised by (so the pile below is the papers that\nare left, and a `presentation.lead` spending that gutter on something else leaves\nthe picture in the pile), the `when` this screen reads\nunder it, and ONE headline\nfigure (the `amount` the screen reads, else its `measure`). BOTH DOORS state the\nname: which door a screen uses is a layout answer, and what the record is ABOUT\nis not.\n\n**A JOB\'S HEADER ALSO STATES WHO IT IS FOR.** Where the record is the work itself\n\u2014 a desk\'s rows that belong to nothing, opened on a page \u2014 its `party` is a link\nunder the name, beside the ways to reach the subject, and it is then not a fact\nas well: a page headed by a code alone said nothing about whose work it is, and\nthe one thing a reader arriving from the desk already knows the row by sat in the\ngrid below as a row among forty. A record opening in a DRAWER has no row of links\nto hang it on, so its party stays a fact; so does a LINE\'s, whose register files\nit under the thing it belongs to and whose party is that parent\'s, restated per\nrow.\n\n**A record whose figures are a SENTENCE states them under the header, in a\nband**, and the header then states neither of them: a job reads what it comes to,\nhow far through it is (the `measure` against its limit), what is left of it (a\nformula that is exactly `{amount} - {measure}`) and how long there is (an\n`obligation`, else its `when`, counted down); a party reads its settlement, the\n`amount` and `measure` roles it carries in the order the model declares them; a\ncatalogue item reads its `amount` against the reference that amount names. Two\nfigures are the floor and four the ceiling \u2014 under two, the header keeps its one.\nA band is a PAGE\'s strip, so a screen whose `record` is a drawer keeps every\nfigure where a drawer reads them. Each figure is drawn exactly once: the limit a\nmeter states is not a fact beside it, and the day a countdown counts to is not\nthe provenance line above it. The `lifecycle` is not badged there, because the progress section is the\nrung it stands on. Then its sections, in the order its KIND reads them: the\n**facts** (every field neither the header, the band nor another section owns, the\nrow\'s own `parent` among them \u2014 led by the ones THIS screen\'s slots bound, then\nthe key it is filed under, then the order the model declares them in \u2014 a\n`markdown` field among them, drawn across the grid\'s whole row rather than\nwrapped to a third of it), the record\'s own **body** (that same markdown, taken\nas a section instead, ONLY where the kind leads with it: a catalogue item IS its\ndescription, and a job is not its notes), the **charge** (where the `amount` is a formula over exactly one\nquantity and one money field, the line states `quantity \xD7 unit price = amount`\nand neither figure is typed twice \u2014 the section is headed by the amount\'s own\nlabel and the closing row says what the figure IS, so the word is said once),\nthe **progress** (the `lifecycle`\'s stages as a ladder the reader ticks a rung of\nto move the record on, grouped into its `phases` where the model states them, and\neach rung carrying the day it was reached where the lifecycle keeps a\n`history`), a\n**required set** (a multi-select `expected_set`, or a child entity whose rows\ncarry one entry of it each \u2014 that child\'s `files` field is what a paper attaches\nto), the record\'s **own rows** (any other child, its role-bound fields as\ncolumns), and its **files** (every `files` field the header does not lead with,\nthe `mark` first where it keeps one \u2014 a section of\nthe column like any other, straight after the facts it is the evidence for,\nexcept on an EVIDENCE record, which OPENS on the paper it exists for; the\nheading carries the Add verb, and stands it down while the pile is empty, where\nthe drop well is already the door; and a `verdict` whose FORMULA reads one of\nthose files fields is the pile\'s OWN state rather than a fact row \u2014 the file it\nis short, drawn as a ghost, and the mark the rail sends a reader to). A child is\nan entity that LINKS here, ONE SECTION PER LINK: the rows it owns (`parent`), the\nrows NAMED by it (their `party` or their `identity` \u2014 so this record\'s history),\nand the rows reaching it through a link carrying neither role, headed by that\nlink\'s own label. A child hanging off two records therefore declares one `parent` and\nleaves the second relationship a plain link, which still gets its section.\n\n**THE ROWS A RECORD OWNS ARE ADDED AND OPENED FROM THEIR SECTION.** A `parent`\nsection\'s heading carries the Add for its rows, handing the record as the\nparent \u2014 filled, never asked. Every row opens its own record \u2014 a line of a book,\na paper on a desk, a stop on a timeline alike: where this app already routes a\npage for those rows (the register\'s own, under one of them) it is navigated to;\notherwise it is a DRAWER mounted on the record it belongs to, stepped \u25C0 \u25B6 over\nthe section\'s rows as they are drawn, with the row\'s framed editors, its ladder\nand its files, saving through `update_<child>` \u2014 the one editor those rows have,\nwhich any control the section draws over a row writes through too. Never the\n`parent` link itself: it is the key the row is FILED under, stated by the record\nthe drawer was opened from, so it is neither a fact of the drawer nor an input\nof that editor. ONE LEVEL, and only from a PAGE: a child\'s own children draw as\nthe kit\'s panel of the row, with no drawer and no Add, and a register whose own\nrecord is a DRAWER is the same for the children it owns \u2014 a drawer mounts no\ndrawer. **A ROW IS ADDED WHERE IT CAN BE OPENED AGAIN**, so those sections lose\ntheir Add with their drawer; a row of the register\'s OWN kind keeps it, because\nthe register\'s list opens it. A correspondence\'s entries are the one owned row\nthat opens nothing anywhere: the composer under them is the section\'s Add\nwhatever door the record has, and the answer mark is one field of the reply\'s\nown editor. The rows a record is merely NAMED by, and those reaching it\nthrough a roleless link, are read only \u2014 a history, never a place to open or\nadd.\n\n**TWO CHILDREN ARE READ AS A RUN RATHER THAN AS A REGISTER**, and the model says\nwhich by the roles it declares on them. A child carrying an `obligation` whose\n`satisfied_by` is a DATE \u2014 and no `lifecycle`, because an entity with stages of\nits own is a JOB being worked and its rows under another record are that record\'s\nlines or its history \u2014 is a **timeline**: its rows are the ordered stops, each\nstating the day it was promised for and the day it happened, with the delta named\nwhere the rung was late \u2014 drawn as a register those are two date columns and the\nreader subtracts them by eye, which is exactly what "three days late at\ndischarge" costs to learn. An obligation closed by a FILE says nothing about\nwhen, so those rows stay the register they were. A child carrying a `markdown`\ntext field beside a `party` and a `when` is a **thread**: the entry is the body,\nthe author and the day lead it, and a `verdict` on the child is the yes/no one\nreply is marked the ANSWER with \u2014 a register of messages is a table whose one\nuseful column is the one it cannot draw. A SECOND `party` on those rows is who\nthe entry was left WITH, and the latest one names the ball in court: while\nnothing answers, the record says whose move it is and counts its own deadline\n(an `obligation`, else its `when`) against them. Both are read only under the\nrecord that OWNS the messages \u2014 under the party who wrote them the same rows are\nthat party\'s history, several questions at once, and the last of them says\nnothing about any. That record also REPLIES: the section\'s Add is a composer \u2014\nthe message is all a reply asks \u2014 and the answer mark is one field of the\nreply\'s own editor.\n\n**A body and a day, under a record that OWNS the rows, is a LOG** \u2014 what was\ndone, when, and the entry in the words somebody wrote. It is the same register a\nthread cannot be, with nobody on the other side of it: no answer to mark and no\nmove outstanding, so the selects on the row are facts ABOUT the entry and a\n`select_member` on it is who made it. A NAMED row is a log entry, not a message:\na visit or an inspection is a thing in its own right, which is what keeps it out\nof the thread. Its Add is a composer too, taking the entry, the day (opening on\ntoday) and the entry\'s own selects; the record it hangs under is not asked.\n\n**A PROFILE LEADS WITH ITS LADDER.** An account walks stages like any other work,\nso a profile carrying a `lifecycle` reads `progress` first \u2014 right under the\nband, the same place a job leads with the act that moves it \u2014 and its histories\nfollow. Under them the ladder was seven bands down a page nobody scrolls that\nfar.\n\n**NOTHING SITS BESIDE THE RECORD.** A page is ONE reading column \u2014 its fields,\nits files, the rows it owns, its notes, all sections of it in the archetype\'s\norder \u2014 over a reserved left gutter holding a floating NAVIGATION RAIL: the way\nback, then one line per section with that section\'s category mark, and nothing\nelse. No files, no counts, no group headings. Too narrow to seat the rail, it is\none pinned bar of the same list across the top. A section HEADING never wears\nthe mark; the rail\'s line for it does.\n\n**A RELATION THE RECORD NEVER ACTS ON CLOSES THE COLUMN.** Every register that\nmerely NAMES the record is one counted line of a single last section: its label,\nhow many rows name this record (a COUNT, never a page of rows measured), and a\npress that opens the register owning them narrowed to this record. An entity\nthis app lists nowhere is a count with no door, and where every count is zero\nthe section is not drawn at all. The one exception is a PROFILE, whose history\nIS its body and stands open in the column.\n\n**Rows the record owns whose `amount` is `signed_by` a direction are a\nBOOK**, drawn as a statement \u2014 each line dated and signed, the balance under\nthem where there is more than one line to add up, labelled by the amount\'s own\nword \u2014 where the same rows on the party they\nwere transacted with stay that party\'s history, which is scanned for the line\nshort of its paperwork rather than struck to a balance. **Rows that carry a\n`when` read as RUNS**: a party\'s history under the year \u2014 and only where the rows\nin hand span more than one, since a subhead over every line of a book names the\nyear and separates nothing \u2014 and a job\'s own rows under the day they fall on,\nwhich, where those rows also carry a `lifecycle`, is an ITINERARY rather than a\ngrouped table: the day heads the run, each row is one line (its `slot`, its name,\nits party, its stage, its `category` and `reference`, its amount), the figures end\non one edge and the run closes with their sum \u2014 unless the record\'s own BAND is a\nsum rollup over exactly these rows, which states it once already. A `category`\npaints the node the run is read down, in the option\'s own colour; a `reference`\ncloses the line with the code somebody quotes on the phone. **A `mark` LEADS the\nline with the stop\'s own picture** \u2014 a venue, a vehicle, a machine \u2014 and it is the one\nplace on a record where a child entity\'s mark is drawn at all, since no register\ncolumn is ever a picture; a line whose subject holds none is marked with its\n`category`\'s glyph instead, so the run keeps one left edge. All three are\nPROJECTED for the run whether or not the register\'s column budget would have\ndrawn them, and a mark is projected NOWHERE ELSE.\nA line\'s mark is most often the SUBJECT\'s rather than the line\'s own \u2014 the\nservice, the product, the asset it is a line of \u2014 which is a `lookup` through\nthat link onto the subject\'s own `files`, given the role on the line.\n**EACH DAY\'S HEAD CARRIES THE SECTION\'S OWN ADD** as well, handing the panel that\nday, so a line made from Tuesday opens with Tuesday answered; the heading keeps\nthe verb too, for the first line and for a day nothing is planned on yet. **THE\nKEY LEAVES THE COLUMNS where the head states the whole of it** \u2014 a day head does,\na year head states four digits of the date and the day is what the column is\nstill there to carry.\n**A run is READ FROM THE END THE READER WANTS**: a job\'s own rows and an itinerary\nascending, a book, a history and a log descending.\n**A REGISTER WHOSE `when` IS A DEADLINE IS READ FROM THE NEAR END** whatever its\nshape does \u2014 `due` (or an `until` that says where the countdown stops) makes the\ndate a promise, so the rows in breach of it lead and a row nobody dated falls\nlast. A plain `when` keeps the shape\'s own end. `scaffold check` prints the\npromise (`order: Theo d\xF5i ti\u1EBFp, overdue first`).\n\n**A DESK OVER AN ENTITY THAT CARRIES A `slot` IS ITSELF A DAY\'S RUN.** Its own\nregister is drawn under one subhead per day, sorted by that day and then by the\npart of it, and the date column goes \u2014 the subhead states it once for the whole\nrun, and a column repeating it down every line is the same value twice. Without\nit an itinerary was one flat list in whatever order the rows arrived.\nA document desk keeps its head either way \u2014 the entries it owes are its\ncontent, filed or not. The name and whatever figure is left to it are the header\'s\nalone \u2014 it states them in full, so a fact for either would be the same sentence\ntwice.\n\n**A FACT IS PRIMARY OR IT IS PROVENANCE.** An `autonumber`, a date the platform\nstamps (`derive_from`) and a date a formula works out that no role names are what\nthe SYSTEM wrote; they fold, with every optional field this record does not\nstate, behind the grid\'s ONE link. Everything a person types or picks is primary\nand is shown, empty or not, because absence is work somebody owes. **A screen\nthat named `facts.groups` has already said which:** a field in a group is\nprimary, and one in none folds \u2014 grouping says what the reader decides with, and\nby saying so says the rest are not. A `tier` on a `facts` entry exists only for\nthe case that derivation gets provably wrong.\n\n**A `contact` field whose kind the\nmodel decides** \u2014 an email, a number, a place, a `link`-formatted text, or a\nMESSAGING APP its label names (WhatsApp, Zalo, Telegram, Viber, WeChat, Line,\nMessenger) \u2014 leaves the facts too, for the row of links under the name on a\nrecord that opens as a page; one whose kind nothing decides stays a labelled\nfact, because a scheme nobody stated is a link that opens nothing. A handle is\ndrawn under its app\'s name \u2014 the app is what identifies the person there, and a\nbare number beside an envelope says the wrong thing \u2014 and it dials only where its\nvalue IS a number.\n`check` prints the record under each screen\'s slots:\n\n```\n Orders \u2014 lifecycle desk over Orders (12 rows) \xB7 page \xB7 tabs: Stage (New \u2192 Quoted \u2192 Confirmed \u2192 Shipped \u2192 Done)\n stage Stage \xB7 identity Order no. \xB7 mark Photo \xB7 party Customer \xB7 amount Total \xB7 level (none \u2014 no field declares "measure") \xB7 when Due\n record: header (Order no. \xB7 Customer) \xB7 band (Total \xB7 Shipped against Lines \xB7 Due counting down) \xB7 progress: Stage (5 stages) \xB7 facts (Ship to \xB7 \u2026 2 filed) \xB7 files: Photos \xB7 documents: Papers (Kind: 4 required) \xB7 itinerary: Order lines by Ship by at Window, kind Handling, ref Waybill (Product \xB7 Quantity \xB7 Line total) \xB7 related: Visits (count via Order)\n```\n\nThe ORDER of that line is the record\'s own, top to bottom, and it is the KIND\'s,\nand every entry of it is a section of the one column. `related:` is the counted\nline that closes it \u2014 a register the record never acts on, named and counted \u2014\nand `\u2026 N filed` is how many facts fold behind the grid\'s one link.\nA child register whose `amount` is `signed_by` a direction is a BOOK of movements\n\u2014 what the record came to rather than what it is made of \u2014 so it closes the\ncolumn rather than standing among the rows the job is made of.\n\n**A section over a child is named by the CHILD\'s own label**, because the reader\nalready knows which record they are on: "\u0110\u01A1n h\xE0ng", not "\u0110\u01A1n h\xE0ng \u2014 Kh\xE1ch h\xE0ng".\nWhere two links from one entity reach this record, that label names two sections\nand each takes its own link\'s label as a qualifier \u2014 `H\u1ED3 s\u01A1 (\u0110\u01A1n h\xE0ng)` and\n`H\u1ED3 s\u01A1 (\u0110\u01A1n g\u1ED1c)`.\n\nIn that line `documents:` is a `RecordExpectedSet`, and `lines:` a `RecordChildren` over the rows\nthis record owns \u2014 `history:` where they NAME it instead, as their `party` or their `identity`, capped at its latest 5\nwhere the record is a profile (`latest 5 of N by <day>`, the whole of them behind the foot); a required set\nwhose entries are a CHILD entity carrying files takes `kind="files"`, and the entity\'s own\nmulti-select takes `kind="items"`, since nothing attaches to an option.\n\n**A section that knows its size says so.** Where a `measure` on the record is a\n`count` rollup over the very link a rows section hangs on, the limit it is read\n`against` is how many rows that section is OWED: the printout adds `\u2014 expects\n<limit>` and the screen draws that many ghost rows until the first one lands,\ninstead of "nothing here" two bands under a count saying three are outstanding.\n\nA figure printed as `Total (USD)` is MONEY in the currency named \u2014 a `formula`\nstates it in `formula.currency`, and a `rollup` or a `lookup` inherits it from the\nfield it reads, so read those brackets: a rate that should be in dollars and is\nprinted bare will be drawn in the workspace\'s own money. Where the entity carries\na `currency` role, the ROW\'s code outranks the field\'s on every line that states\none, and a line stating none falls back to the field\'s.\n\n**A record surface can be OPERATED, and that is the default.** Every screen with\na record gets a workflow that writes its editable facts \u2014 every field a person\nstates \u2014 so the record\'s values are edited in place and its stage is advanced\nfrom the progress section. `"writes": false` makes one screen a reader: use it\nfor a screen over rows another desk owns, never as the default. A desk nobody\ncan act on is a viewer of state somebody must go and set somewhere else.\n\n**Which facts those are is the FIELD\'s answer.** Text, number, date, yes/no and\nselect are typed or picked. A `"cardinality": "one"` link is RE-POINTED, through\na picker over the target entity named by its `display_field_aliases` \u2014 else the\ntarget\'s `identity` \u2014 narrowed by what the reader types and carrying that\nentity\'s own `read_scope`, so a link the plan gives neither column is read\ninstead of offering an empty list. A files field is ATTACHED TO and DETACHED\nFROM, as the delta rather than the pile, so two readers filing at once each keep\ntheir file. A many-link, an `autonumber` and every computed field are read: the\nfirst is a list a fact cannot state, and the rest are the platform\'s to write.\n\n**A one-link is that fact WHATEVER its sync.** `sync_both_ways` is one relation\nwith a field on each side, and the sides are not the same surface: the record\nthat names ONE row states it as a fact, and the MANY side is the register on the\nother entity\'s record. Declaring both directions does not give this record a\nregister of the single row its own fact already names.\n\n**The write is the record SURFACE\'s.** Its inputs are the fields that surface\noffers to save \u2014 the facts with an editor, the lifecycle its ladder advances, and\na files section over exactly one stated field \u2014 never every field a person could\nin principle type. What the header states, a limit a meter folds in, a required\nset with a section of its own and the pile a page\'s mark draws are read there, so\nno input is declared for them. A second screen over the same entity draws no\nsurface of its own and adds nothing.\n\nWhere two operable screens of one plan reach the same entity, `scaffold check`\nnames them and the apps they belong to: two desks writing one record is a\ndecision, and the split is stated on the FIELD in each app\'s\n`package.json#lotics.writes` rather than left to whoever edits second.\n\nThat workflow lands in the app as source, like every other: its body in\n`src/workflows/update_<entity>.ts` and its declaration in\n`package.json#lotics.workflows`. The two together are the binding \u2014 `lotics app\ndeploy` pushes whatever differs from what it last saw live \u2014 so the write is\nversion-controlled and travels with the app rather than being bound by hand\nafterwards.\n\nA `custom` screen declares its slots under `roles` (slot \u2192 role) and they bind\nthe same way:\n\n```jsonc\n{ "alias": "readings", "label": "Readings", "shape": "custom", "entity": "reading",\n "roles": { "subject": "identity", "reading": "measure" } }\n```\n\n## Applying packages\n\n`apply` copies published packages into the workspace AFTER the model\'s own\ntables exist \u2014 apps over the tables you just described, and any tables of their\nown they still need. Ordered, and run by `lotics setup` and `lotics scaffold\napply` alike.\n\n```jsonc\n"apply": [\n {\n "package": "apg_k3nf82ldpq",\n "bind": { // optional \u2014 which of YOUR tables each entity is\n "company": { "label": "Customers", "fields": { "name": "Company name" } }\n },\n "no_sample_data": true // optional\n }\n]\n```\n\n`bind` is keyed by the package\'s entity alias and holds the LABELS this\nworkspace uses: scaffold adopts by label, so binding points the package at the\ntables the model created instead of a second set beside them. Only naming\nmoves \u2014 a bound field must be the TYPE the package declares, or the copy is\nrefused. `lotics library list` is the shelf, and `lotics library show <apg_id>`\nlists the aliases to bind.\n\nEntries run in the order they are written, because a later one may bind onto a\ntable an earlier one created. **A refused entry stops the run and the entries\nbefore it stay** \u2014 they are separate copies, committed as they land, so the\nrefusal names them rather than leaving a caller to re-run the file and copy them\ntwice.\n\n## Presets\n\nA preset is a trade\'s model, published to be READ. An assistant reads it, asks\nat most two questions, picks a variant and writes a `model.json` from it \u2014\nnothing is copied, and a preset is a file rather than anything a workspace\ninstalls.\n\n```jsonc\n"preset": {\n "name": "Field service",\n "description": "Jobs, the crew that runs them, and what each one billed.",\n "questions": ["Do you dispatch crews, or one person per job?"], // at most 2\n "variants": {\n "crews": {\n "when": "work is dispatched to crews rather than to one person",\n "entities": [ /* tables this branch ADDS */ ],\n "fields": { "job": [ /* fields this branch ADDS to `job` */ ] }\n }\n }\n}\n```\n\nVariants are **additive only**: a branch adds entities and fields and never\nremoves them, so the base is a model in its own right rather than a draft.\n`lotics scaffold check` proves the base AND every variant merged onto it, so a\npreset ships with every branch already proven \u2014 the branch nobody took is the\none that fails in the workspace of whoever takes it.\n\n`preset` is not scaffolded. `lotics setup` and `lotics scaffold apply` ignore\nit and create the base model\'s tables.\n\n`lotics scaffold export` prints a workspace that already works as one of these\nfiles \u2014 the starting point for a preset or for another business\'s model, never a\nsource of truth: it carries one business\'s words and stops describing that\nworkspace the moment either changes.\n\n## Starting from a preset\n\n`lotics library list` is the shelf of them and `lotics library show <slug>`\nprints one whole: its questions, every table as `alias \xB7 label` with each field\nas `alias:type`, and each variant as `slug \xB7 when` followed by the tables and\nfields that branch adds. When one of them is the trade in front of you, do not\ntranscribe it \u2014 name it:\n\n```jsonc\n{\n "from": "field_service",\n "variants": ["crews"],\n "rename": { "job": { "label": "\u0110\u01A1n h\xE0ng", "fields": { "code": "M\xE3 \u0111\u01A1n" } } },\n "entities": [ /* a table this business has that the preset does not */ ],\n "rows": { "job": [ { "ref": "j1", "fields": { "code": "J-1" } } ] },\n "field_roles": { "job": { "code": "identity" } },\n "write_rules": { "customer": { "natural_key": ["email"] } },\n "apps": [ /* the screens this business\'s apps will have */ ]\n}\n```\n\n- **`from`** is the preset\'s SLUG \u2014 its own file name, a lowercase slug. Naming\n it is what makes `entities` optional; every other rule on this page is\n unchanged, because the file is resolved into the full form and then checked and\n applied exactly as one. A slug nothing serves is refused with the ones there\n are, never resolved against something else.\n- **`variants`** names the branches to merge onto the base, in order. Pick the\n one whose `when` describes what the person said; a slug the preset does not\n declare is refused rather than ignored.\n- **`rename`** is keyed by the preset\'s entity alias and holds the labels this\n business uses \u2014 the same shape `apply[].bind` takes, and the same rule: only\n naming moves. An alias the preset does not declare, and a label that is\n already another table\'s, are both refused.\n- **`entities`** are added after the rename, already in this business\'s own\n words.\n- **`rows`**, **`field_roles`**, **`write_rules`**, **`apps`** and **`apply`**\n mean exactly what they mean in the full form \u2014 `"rows"` are this business\'s\n real first records,\n `"field_roles"` may name the preset\'s fields as well as its own (a role the\n preset declares itself is kept unless this file names the same field, or\n clears it with `null`), `"write_rules"` the create-time clauses on either\n (an entity this file names replaces the preset\'s whole entry for it),\n `"apps"` the screens it will have (a preset carries none), `"apply"` the\n packages copied in once its tables exist.\n\nThis is the ONE thing on this page that needs the network: `check` reads the\npreset it names, once. Everything after that read is the same offline check.\n\nWrite the full form when no preset is the trade.\n\n## A complete model\n\n```json\n{\n "entities": [\n {\n "alias": "customer",\n "label": "Customers",\n "singular": "Customer",\n "fields": [\n { "alias": "name", "label": "Name", "type": "text", "required": true },\n {\n "alias": "tier",\n "label": "Tier",\n "type": "select",\n "options": [\n { "alias": "standard", "label": "Standard", "color": "slate" },\n { "alias": "gold", "label": "Gold", "color": "amber" }\n ],\n "default": ["standard"]\n },\n {\n "alias": "orders",\n "label": "Orders",\n "type": "select_record_link",\n "target_entity": "order",\n "cardinality": "many",\n "sync_both_ways": true,\n "paired_field_alias": "customer",\n "display_field_aliases": ["code"]\n },\n {\n "alias": "total_ordered",\n "label": "Total ordered",\n "type": "rollup",\n "source_field_alias": "orders",\n "aggregate_option": { "operation": "sum", "field_key": "amount" }\n }\n ],\n "views": [\n {\n "alias": "gold",\n "label": "Gold customers",\n "filters": {\n "node_type": "condition",\n "type": "select",\n "field_key": "tier",\n "operator": "has_any_of",\n "value": ["gold"]\n },\n "sort": [{ "field_key": "name", "order": "asc" }]\n }\n ]\n },\n {\n "alias": "order",\n "label": "Orders",\n "singular": "Order",\n "fields": [\n { "alias": "code", "label": "Order no.", "type": "text", "unique": true },\n { "alias": "placed_on", "label": "Placed on", "type": "date", "format": "date" },\n {\n "alias": "amount",\n "label": "Amount",\n "type": "number",\n "format": "currency",\n "currency": "VND"\n },\n {\n "alias": "total",\n "label": "Total with VAT",\n "type": "formula",\n "formula": { "expression": "{amount} * 1.1", "format": "currency", "currency": "VND" }\n },\n {\n "alias": "customer",\n "label": "Customer",\n "type": "select_record_link",\n "target_entity": "customer",\n "cardinality": "one",\n "sync_both_ways": true,\n "paired_field_alias": "orders",\n "display_field_aliases": ["name"]\n }\n ]\n }\n ],\n "roles": [{ "alias": "sales", "label": "Sales" }],\n "field_roles": {\n "customer": { "name": "identity" },\n "order": { "code": "identity", "placed_on": "when", "amount": "amount", "customer": "party" }\n },\n "apps": [\n {\n "alias": "customers",\n "name": "Customers",\n "screen": { "alias": "customers", "label": "Customers", "shape": "party_register", "entity": "customer" }\n },\n {\n "alias": "orders",\n "name": "Orders",\n "screen": { "alias": "orders", "label": "Orders", "shape": "transaction_ledger", "entity": "order" }\n }\n ],\n "rows": {\n "customer": [\n { "ref": "acme", "fields": { "name": "Acme Trading", "tier": "gold" } },\n { "ref": "bluebird", "fields": { "name": "Bluebird Foods", "tier": "standard" } }\n ],\n "order": [\n {\n "ref": "so_1001",\n "fields": {\n "code": "SO-1001",\n "placed_on": "@month-start+2",\n "amount": 4200000,\n "customer": "customer:acme"\n }\n },\n {\n "ref": "so_1002",\n "fields": {\n "code": "SO-1002",\n "placed_on": "@today-3",\n "amount": 1150000,\n "customer": "customer:bluebird"\n }\n }\n ]\n }\n}\n```\n\n`lotics scaffold check` on this file reports\n`2 tables, 9 fields, 2 links, 1 view, 1 role, 4 rows, 2 apps`, then\nthe plan:\n\n```\nCustomers\n Customers \u2014 party register over Customers (2 rows) \xB7 page \xB7 tabs: none\n identity Name \xB7 mark (none \u2014 no field declares "mark") \xB7 contact (none \u2014 no field declares "contact") \xB7 worth (none \u2014 no field declares "measure") \xB7 risk (none \u2014 no field declares "verdict")\n above: rows (default)\n record: header (Name) \xB7 history: Orders (latest 5 of N by Placed on) (Order no. \xB7 Placed on \xB7 Amount (VND)) \xB7 facts (Tier \xB7 Total ordered (VND))\nOrders\n Orders \u2014 transaction ledger over Orders (2 rows) \xB7 drawer \xB7 tabs: none\n when Placed on \xB7 amount Amount (VND) \xB7 reference Order no. \xB7 party Customer \xB7 classification (none \u2014 no field declares "lifecycle") \xB7 document (none \u2014 no field declares "expected_set" or "verdict")\n above: Amount (VND) (default)\n record: header (Order no. \xB7 Placed on \xB7 Amount (VND)) \xB7 facts (Placed on \xB7 Total with VAT (VND) \xB7 Customer)\n party: Customers \u2014 opens from Customer (profile: header (Name) \xB7 history: Orders (latest 5 of N by Placed on) (Order no. \xB7 Placed on \xB7 Amount (VND)) \xB7 facts (Tier \xB7 Total ordered (VND)))\nWho writes what:\n Customers (customer, one: Customer): Customers \xB7 written from the rows of Orders: facts\n Orders (order, one: Order): Orders\n```\n\nA `party:` line is the record a NAME on a row opens. A party is not a job, so it\ngets no app of its own \u2014 but a clerk reading the orders book presses the\ncustomer and corrects the phone number there, so the app whose rows name a party\ncarries that party\'s own record beside its register\'s. It is printed in the same\ngrammar the `record:` line is, because it is the same kind of surface: a profile,\non a page, its histories capped. Which cells are the door is what `opens from`\nsays \u2014 `the name` where the register\'s subject IS the party.\n\nThe last block is the WRITERS matrix \u2014 one line per record surface the plan\nleaves operable, the word one of its rows is called, and the app whose register\nopens it. Part of the verdict rather than a diagnostic beside it: which desk\nchanges a table is answerable from the plan, and two apps on one line is the\nsplit to state in each of their `package.json#lotics.writes`. A\n`written from the rows of \u2026` clause is the other reach: the party that register\nnames, and what the app can change on it \u2014 counted apart, because several\nregisters naming one account is the model working as designed rather than a\nsplit to declare.\n\nEvery `(none)` is a slot no field fills, and it says WHY: no field declares the\nrole, or several could and the plan named none of them (`(none \u2014 a, b; name\none)`). Read it as the screen a person will see. `above: \u2026 (default)` is the band\nnobody stated \u2014 the shape sums the amount its slot draws, and a plan naming its\nown figures loses the word. Neither\nentity carries a stage, a required set or files, so the rest is facts \u2014 except\nthe sections neither entity declares: the customer\'s `history:` is the orders\nthat name it as their party, and the order\'s `via Orders:` is the customers whose\n`Orders` link names it. **A link is a section, not a fact**, on the side it\npoints AT and on the side that holds it: `Customers.Orders` therefore leaves the\ncustomer\'s facts, because the section below already lists the same relation and\na link fact can only ever show the first of them. Both records state their name\nin the header and nowhere else \u2014 a ledger\'s columns are the date and the figure,\nso `Order no.` is on no column of that list and is still what the drawer behind\na line is called. `Total ordered (VND)` is the rollup inheriting the currency of\nthe column it sums: money is read off the model, never off the field\'s own line.\n';
56136
56506
 
56137
56507
  // src/scaffold_commands.ts
56138
56508
  function printModelReference() {
@@ -56297,12 +56667,13 @@ function fieldName(model, entity, field) {
56297
56667
  }
56298
56668
  function describeRecord(model, resolved) {
56299
56669
  const labels = (owner, fields) => fields.map((field) => fieldName(model, owner, field)).join(" \xB7 ");
56300
- const header = recordHeader(resolved, model.field_roles);
56301
- const stated2 = [header.title, ...header.party, header.subtitle, header.figure].filter(
56670
+ const header = recordHeader(resolved, model.contract.entities, model.field_roles);
56671
+ const stated3 = [header.title, header.mark, ...header.party, header.subtitle, header.figure].filter(
56302
56672
  (field) => field !== void 0
56303
56673
  );
56304
- const archetype = recordArchetype(resolved.screen.shape, resolved.entity, model.field_roles);
56305
- const sections = recordRecipe(resolved.screen.shape, resolved.entity, model.contract.entities, model.field_roles, header, resolved.record, resolved.screen.sections).map(({ draw, slot: recipeSlot, section }) => {
56674
+ const archetype = recordArchetype(resolved.screen.shape, resolved.entity, model.contract.entities, model.field_roles);
56675
+ const describe5 = ({ draw, slot: recipeSlot, section }, named2) => {
56676
+ const rows = (child, link) => named2 ? `${child.label} via ${link.label}` : child.label;
56306
56677
  switch (section.kind) {
56307
56678
  case "facts": {
56308
56679
  const fact = (field) => {
@@ -56312,7 +56683,7 @@ function describeRecord(model, resolved) {
56312
56683
  return `${name} against ${typeof level.limit === "number" ? level.limit : fieldName(model, resolved.entity, level.limit)}`;
56313
56684
  };
56314
56685
  const grouped = groupedFacts(resolved);
56315
- return factSections(factsPlan(resolved, model.field_roles, section.fields)).map((bands) => {
56686
+ return factSections(factsPlan(resolved, archetype, model.field_roles, section.fields)).map((bands) => {
56316
56687
  const fields = bands.flatMap((band2) => band2.fields);
56317
56688
  const primary = fields.filter((field) => factTier(field, resolved.entity, model.field_roles, grouped) === "primary");
56318
56689
  const filed = fields.length - primary.length;
@@ -56336,15 +56707,21 @@ function describeRecord(model, resolved) {
56336
56707
  }
56337
56708
  case "expected_set": {
56338
56709
  const required2 = section.source === "own" ? section.field : section.setField;
56339
- const name = section.source === "own" ? section.field.label : section.child.label;
56710
+ const name = section.source === "own" ? section.field.label : rows(section.child, section.link);
56340
56711
  if (required2.type !== "select") return `documents: ${name}`;
56341
56712
  const set2 = section.requiredBy === void 0 ? `${required2.options.length} required` : `${count(required2.options.length, "option")}, ${section.requiredBy.field.label}${section.requiredBy.from === "parent" ? " on this record" : ""} decides which`;
56342
56713
  return section.source === "own" ? `documents: ${name} (${set2})` : `documents: ${name} (${required2.label}: ${set2})`;
56343
56714
  }
56344
56715
  case "children": {
56345
56716
  if (draw === "related") return `related: ${section.child.label} (count via ${section.link.label})`;
56717
+ if (draw === "capped") {
56718
+ const dated = childWhen(section.child, model.field_roles);
56719
+ const by = dated === void 0 ? "" : ` by ${fieldName(model, section.child, dated)}`;
56720
+ const held = section.fields.length === 0 ? "none" : labels(section.child, section.fields);
56721
+ return `history: ${rows(section.child, section.link)} (latest ${HISTORY_ROWS} of N${by}) (${held})`;
56722
+ }
56346
56723
  if (resolved.screen.sections?.[section.child.alias]?.draw === "worksheet") {
56347
- return `sheet: ${section.child.label} (${labels(section.child, section.fields)})`;
56724
+ return `sheet: ${rows(section.child, section.link)} (${labels(section.child, section.fields)})`;
56348
56725
  }
56349
56726
  const run = recordItinerary(archetype, recipeSlot, section.child, model.field_roles);
56350
56727
  if (run !== void 0) {
@@ -56357,20 +56734,29 @@ function describeRecord(model, resolved) {
56357
56734
  const marked = run.mark === void 0 ? "" : `, marked ${fieldName(model, section.child, run.mark)}`;
56358
56735
  const quoted = run.reference === void 0 ? "" : `, ref ${fieldName(model, section.child, run.reference)}`;
56359
56736
  const over = run.span === void 0 ? "" : `, over ${fieldName(model, section.child, run.span)} days`;
56360
- return `itinerary: ${section.child.label} by ${fieldName(model, section.child, run.when)}${at2}${kind}${marked}${by}${lasting}${quoted}${over} (${labels(section.child, section.fields)})`;
56737
+ return `itinerary: ${rows(section.child, section.link)} by ${fieldName(model, section.child, run.when)}${at2}${kind}${marked}${by}${lasting}${quoted}${over} (${labels(section.child, section.fields)})`;
56361
56738
  }
56362
- const heading = section.via === "party" ? "history" : section.via === "link" ? `via ${section.link.label}` : "lines";
56739
+ const heading = section.via === "named" ? "history" : section.via === "link" ? `via ${section.link.label}` : "lines";
56363
56740
  const owed = section.expected === void 0 ? "" : ` \u2014 expects ${typeof section.expected === "number" ? section.expected : fieldName(model, resolved.entity, section.expected)}`;
56364
- return `${heading}: ${section.child.label} (${section.fields.length === 0 ? "none" : labels(section.child, section.fields)})${owed}`;
56741
+ return `${heading}: ${rows(section.child, section.link)} (${section.fields.length === 0 ? "none" : labels(section.child, section.fields)})${owed}`;
56365
56742
  }
56366
56743
  // WHERE THE RECORD IS AGAINST WHERE IT SHOULD BE — the promise per rung
56367
56744
  // and the day it was kept, named, because a reader approving the plan
56368
56745
  // would otherwise expect a register with two date columns.
56369
56746
  case "timeline":
56370
- return `timeline: ${section.child.label} \u2014 ${fieldName(model, section.child, section.planned)} against ${fieldName(model, section.child, section.actual)}`;
56747
+ return `timeline: ${rows(section.child, section.link)} \u2014 ${fieldName(model, section.child, section.planned)} against ${fieldName(model, section.child, section.actual)}`;
56371
56748
  case "thread": {
56372
56749
  const official = section.official === void 0 ? "" : `, ${fieldName(model, section.child, section.official)} answers`;
56373
- return `thread: ${section.child.label} \u2014 ${fieldName(model, section.child, section.body)} by ${fieldName(model, section.child, section.author)}${official}`;
56750
+ return `thread: ${rows(section.child, section.link)} \u2014 ${fieldName(model, section.child, section.body)} by ${fieldName(model, section.child, section.author)}${official}`;
56751
+ }
56752
+ // A LOG — the entry, the day it is filed under, and the facts beside it.
56753
+ // The day is named because the entries are read newest first BY it, and a
56754
+ // reader approving the plan cannot otherwise tell which of a row's dates
56755
+ // the log is stacked on.
56756
+ case "journal": {
56757
+ const by = section.author === void 0 ? "" : ` by ${fieldName(model, section.child, section.author)}`;
56758
+ const facts = labels(section.child, section.fields);
56759
+ return `journal: ${rows(section.child, section.link)} \u2014 ${fieldName(model, section.child, section.body)} on ${fieldName(model, section.child, section.when)}${by}${facts === "" ? "" : ` (${facts})`}`;
56374
56760
  }
56375
56761
  case "prose":
56376
56762
  return `body: ${fieldName(model, resolved.entity, section.field)}`;
@@ -56379,8 +56765,20 @@ function describeRecord(model, resolved) {
56379
56765
  case "files":
56380
56766
  return `files: ${labels(resolved.entity, section.fields)}`;
56381
56767
  }
56382
- });
56383
- const band = recordBand(resolved.screen.shape, resolved.entity, model.field_roles, resolved.record);
56768
+ };
56769
+ const entries2 = recordRecipe(
56770
+ resolved.screen.shape,
56771
+ resolved.entity,
56772
+ model.contract.entities,
56773
+ model.field_roles,
56774
+ header,
56775
+ resolved.record,
56776
+ resolved.screen.sections
56777
+ );
56778
+ const once = entries2.map((entry) => describe5(entry, false));
56779
+ const twice = new Set(once.filter((line, at2) => once.indexOf(line) !== at2));
56780
+ const sections = entries2.map((entry, at2) => twice.has(once[at2]) ? describe5(entry, true) : once[at2]);
56781
+ const band = recordBand(resolved.screen.shape, resolved.entity, model.contract.entities, model.field_roles, resolved.record);
56384
56782
  const drawn = band === void 0 ? [] : [
56385
56783
  band.kind === "comparison" ? `band (${fieldName(model, resolved.entity, band.value)} against ${fieldName(model, resolved.entity, band.reference)})` : `band (${band.cells.map((cell) => {
56386
56784
  const name = fieldName(model, resolved.entity, cell.field);
@@ -56390,7 +56788,7 @@ function describeRecord(model, resolved) {
56390
56788
  return cell.kind === "countdown" ? `${name} counting down` : name;
56391
56789
  }).join(" \xB7 ")})`
56392
56790
  ];
56393
- return [...stated2.length === 0 ? [] : [`header (${labels(resolved.entity, stated2)})`], ...drawn, ...sections].join(" \xB7 ");
56791
+ return [...stated3.length === 0 ? [] : [`header (${labels(resolved.entity, stated3)})`], ...drawn, ...sections].join(" \xB7 ");
56394
56792
  }
56395
56793
  function describePlan(model) {
56396
56794
  const lines = [];
@@ -56424,9 +56822,19 @@ function describePlan(model) {
56424
56822
  const carried = describeCarried(model, resolved);
56425
56823
  if (carried !== "") lines.push(` ${carried}`);
56426
56824
  lines.push(` record: ${describeRecord(model, resolved)}`);
56825
+ lines.push(...describeParties(model, resolved));
56427
56826
  }
56428
56827
  return lines;
56429
56828
  }
56829
+ function describeParties(model, resolved) {
56830
+ return partySurfaces(resolved, model.contract.entities, model.field_roles).map((party) => {
56831
+ const archetype = recordArchetype(party.screen.screen.shape, party.entity, model.contract.entities, model.field_roles);
56832
+ return ` party: ${party.entity.label} \u2014 opens from ${describeDoors(model, resolved, party)} (${archetype ?? "plain"}: ${describeRecord(model, party.screen)})`;
56833
+ });
56834
+ }
56835
+ function describeDoors(model, resolved, party) {
56836
+ return party.links.map((link) => roleOf(model.field_roles, resolved.entity.alias, link.alias)?.role === "identity" ? "the name" : fieldName(model, resolved.entity, link)).join(", ");
56837
+ }
56430
56838
  function describeCarried(model, resolved) {
56431
56839
  const { acts, summary, period } = resolved;
56432
56840
  const name = (field) => fieldName(model, resolved.entity, field);
@@ -56440,13 +56848,23 @@ function describeCarried(model, resolved) {
56440
56848
  return `"${entry.label}" \u2192 ${entry.template.label} (${entry.template.type})${where}`;
56441
56849
  };
56442
56850
  const runs = registerRuns(resolved, model.field_roles);
56851
+ const order = registerOrder(resolved, model.field_roles);
56443
56852
  const drawn = resolved.screen.presentation;
56444
56853
  const parts = [
56445
56854
  // THE CONTEXT, AFTER THE ANSWER — printed beside the slot line rather than
56446
56855
  // inside it, because the two are read differently: a slot is the shape's
56447
56856
  // question and a column is the author's own addition to the row.
56448
- ...resolved.columns.length === 0 ? [] : [`columns: ${resolved.columns.map(name).join(" \xB7 ")} (after the slots)`],
56857
+ ...resolved.columns.length === 0 ? [] : [
56858
+ // A COUNT IS NOT A COLUMN, and the plan says which of them are not:
56859
+ // an author reading back three columns on a register that seats one
56860
+ // learns nothing about where the other two went.
56861
+ `columns: ${resolved.columns.map((field) => `${name(field)}${columnCountsRows(field) ? " (a count under the name)" : ""}`).join(" \xB7 ")} (after the slots)`
56862
+ ],
56449
56863
  ...runs === void 0 ? [] : [`runs: by ${name(runs.when)} at ${name(runs.slot)}`],
56864
+ // WHICH END THE REGISTER IS READ FROM, where the day it is read by is a
56865
+ // DEADLINE: the rows in breach lead, whatever the shape would have opened
56866
+ // at, and a reader approving the plan is approving that promise.
56867
+ ...order === void 0 || !order.deadline ? [] : [`order: ${name(order.field)}, overdue first`],
56450
56868
  ...drawn === void 0 || Object.values(drawn).every((clause) => clause === void 0) ? [] : [
56451
56869
  `presentation: ${[
56452
56870
  ...drawn.lead === void 0 ? [] : [drawn.lead === "none" ? "leads with nothing" : `leads with the ${drawn.lead}`],
@@ -56470,10 +56888,12 @@ function describeCarried(model, resolved) {
56470
56888
  ],
56471
56889
  // A DERIVED LENS IS PRINTED BY ITS SETS, never by its label alone: what an
56472
56890
  // author has to check is that the predicates say what they meant, and the
56473
- // chip's own name is the one thing they already wrote down.
56891
+ // chip's own name is the one thing they already wrote down. A MEMBER LENS
56892
+ // says which of its two sets the register OPENS on, which is the difference
56893
+ // between a desk of the reader's work and a desk of everybody's.
56474
56894
  ...resolved.filters.length === 0 ? [] : [
56475
56895
  `lens: ${resolved.filters.map(
56476
- (lens) => lens.kind === "field" ? lens.field.label : `${lens.label} (${lens.predicates.map((one) => one.label).join(", ")})`
56896
+ (lens) => lens.kind === "field" ? lens.field.label : lens.kind === "member" ? `${lens.field.label} (${lens.mineFirst ? "mine first" : "mine or all"})` : `${lens.label} (${lens.predicates.map((one) => one.label).join(", ")})`
56477
56897
  ).join(" \xB7 ")}`
56478
56898
  ],
56479
56899
  // EVERY REGISTER STATES HOW MANY ROWS ARE IN VIEW, and a plan that names no
@@ -56531,6 +56951,7 @@ function sectionLabel(section) {
56531
56951
  case "children":
56532
56952
  case "timeline":
56533
56953
  case "thread":
56954
+ case "journal":
56534
56955
  return `${section.kind}: ${section.child.label}`;
56535
56956
  case "expected_set":
56536
56957
  return `documents: ${section.source === "own" ? section.field.label : section.child.label}`;
@@ -56565,8 +56986,8 @@ function aboveLine(model, resolved, name) {
56565
56986
  ...once.map((figure) => `${name(figure.field)}${figure.at === void 0 ? "" : " at the window's end"}`)
56566
56987
  ];
56567
56988
  if (above === null && figures.length === 0) return [];
56568
- const stated2 = resolved.screen.summary?.above !== void 0 || folded.length > 0;
56569
- return [`above: ${figures.length === 0 ? "rows" : figures.join(" \xB7 ")}${stated2 ? "" : " (default)"}`];
56989
+ const stated3 = resolved.screen.summary?.above !== void 0 || folded.length > 0;
56990
+ return [`above: ${figures.length === 0 ? "rows" : figures.join(" \xB7 ")}${stated3 ? "" : " (default)"}`];
56570
56991
  }
56571
56992
  function totalsUnder(model, resolved) {
56572
56993
  const named2 = [...resolved.summary.columnTotals, ...resolved.summary.bandTotals].filter(
@@ -56584,13 +57005,20 @@ function describeWriters(model) {
56584
57005
  const named2 = (entity) => appsByEntity.get(entity.alias) ?? {
56585
57006
  label: entity.label,
56586
57007
  ...entity.singular === void 0 ? {} : { singular: entity.singular },
56587
- apps: []
57008
+ apps: [],
57009
+ through: []
56588
57010
  };
56589
57011
  for (const screen of resolved) {
56590
57012
  if (screen.screen.writes === false) continue;
56591
57013
  const entry = named2(screen.entity);
56592
57014
  if (!entry.apps.includes(screen.app.name)) entry.apps.push(screen.app.name);
56593
57015
  appsByEntity.set(screen.entity.alias, entry);
57016
+ for (const party of partySurfaces(screen, model.contract.entities, model.field_roles)) {
57017
+ const reached = named2(party.entity);
57018
+ const line = `written from the rows of ${screen.app.name}: ${partyWrites(model, party).join(", ")}`;
57019
+ if (!reached.through.includes(line)) reached.through.push(line);
57020
+ appsByEntity.set(party.entity.alias, reached);
57021
+ }
56594
57022
  }
56595
57023
  const registered = new Set(resolved.map((screen) => screen.entity.alias));
56596
57024
  for (const screen of resolved) {
@@ -56602,13 +57030,28 @@ function describeWriters(model) {
56602
57030
  if (appsByEntity.size === 0) return [];
56603
57031
  const lines = [];
56604
57032
  for (const [alias, entry] of appsByEntity) {
57033
+ const writers = [...entry.apps.length === 0 ? [] : [entry.apps.join(", ")], ...entry.through];
56605
57034
  lines.push(
56606
- ` ${entry.label} (${alias}${entry.singular === void 0 ? "" : `, one: ${entry.singular}`}): ${entry.apps.length === 0 ? "(no app)" : entry.apps.join(", ")}` + (entry.apps.length > 1 ? ` \u2014 ${entry.apps.length} desks write this record; state the split in each app's package.json#lotics.writes` : "")
57035
+ ` ${entry.label} (${alias}${entry.singular === void 0 ? "" : `, one: ${entry.singular}`}): ${writers.length === 0 ? "(no app)" : writers.join(" \xB7 ")}` + (entry.apps.length > 1 ? ` \u2014 ${entry.apps.length} desks write this record; state the split in each app's package.json#lotics.writes` : "")
56607
57036
  );
56608
57037
  for (const clause of describeWriteRules(model, alias)) lines.push(` ${clause}`);
56609
57038
  }
56610
57039
  return lines;
56611
57040
  }
57041
+ function partyWrites(model, party) {
57042
+ const { entities } = model.contract;
57043
+ const roles = model.field_roles;
57044
+ const header = recordHeader(party.screen, entities, roles);
57045
+ const entries2 = recordRecipe(party.screen.screen.shape, party.entity, entities, roles, header, party.screen.record);
57046
+ const facts = entries2.some((entry) => entry.section.kind === "facts" && entry.section.fields.some(isEditable));
57047
+ const added = entries2.flatMap((entry) => {
57048
+ const relation = sectionRelation(entry.section);
57049
+ if (relation === void 0 || !recordAddsChild(party.entity, entry.section, party.screen.record === "page")) return [];
57050
+ return [relation.child.label];
57051
+ });
57052
+ const written = [...facts ? ["facts"] : [], ...added];
57053
+ return written.length === 0 ? ["nothing a person states"] : written;
57054
+ }
56612
57055
  function describeWriteRules(model, alias) {
56613
57056
  const rules = model.write_rules[alias];
56614
57057
  if (rules === void 0) return [];
@@ -60298,11 +60741,15 @@ function readWorkflowGlobalsStamp(projectDir, alias) {
60298
60741
  function staleWorkflowGlobals(projectDir, workflows) {
60299
60742
  const out = [];
60300
60743
  for (const [alias, raw] of Object.entries(workflows)) {
60301
- if (!fs14.existsSync(workflowGlobalsPath(projectDir, alias))) continue;
60302
60744
  const declaration = toWorkflowDtsDeclaration(raw);
60303
- if (readWorkflowGlobalsStamp(projectDir, alias) !== workflowDeclarationStamp(declaration)) {
60304
- out.push({ alias, declaration });
60745
+ if (readWorkflowGlobalsStamp(projectDir, alias) === workflowDeclarationStamp(declaration)) {
60746
+ continue;
60305
60747
  }
60748
+ out.push({
60749
+ alias,
60750
+ declaration,
60751
+ hadTypes: fs14.existsSync(workflowGlobalsPath(projectDir, alias))
60752
+ });
60306
60753
  }
60307
60754
  return out;
60308
60755
  }
@@ -61110,8 +61557,8 @@ function ensureAppVitestSetup(projectDir) {
61110
61557
  function namedImport(source, code, specifier) {
61111
61558
  for (const found of code.matchAll(/^import \{([^}]*)\} from[ \t]+;/gm)) {
61112
61559
  const end = found.index + found[0].length;
61113
- const stated2 = source.slice(found.index, end);
61114
- const quote2 = stated2.includes(`"${specifier}"`) ? '"' : stated2.includes(`'${specifier}'`) ? "'" : null;
61560
+ const stated3 = source.slice(found.index, end);
61561
+ const quote2 = stated3.includes(`"${specifier}"`) ? '"' : stated3.includes(`'${specifier}'`) ? "'" : null;
61115
61562
  if (quote2 === null) continue;
61116
61563
  return {
61117
61564
  start: found.index,
@@ -62093,7 +62540,7 @@ function reportPortabilityIds(findings) {
62093
62540
  }
62094
62541
  async function appDeploy(client, args) {
62095
62542
  const projectDir = path16.resolve(args.projectDir ?? process.cwd());
62096
- const meta3 = readAppMeta(projectDir);
62543
+ const priorMeta = readAppMeta(projectDir);
62097
62544
  const scripts = JSON.parse(fs14.readFileSync(path16.join(projectDir, "package.json"), "utf-8")).scripts;
62098
62545
  if (!scripts?.build) {
62099
62546
  fail(
@@ -62101,19 +62548,20 @@ async function appDeploy(client, args) {
62101
62548
  );
62102
62549
  }
62103
62550
  warnAboutDevLink(projectDir, "deploy");
62104
- const liveApp = await client.getApp(meta3.app_id);
62105
- assertProjectIsCurrent(meta3, liveApp);
62551
+ const liveApp = await client.getApp(priorMeta.app_id);
62552
+ assertProjectIsCurrent(priorMeta, liveApp);
62106
62553
  const pending = pendingBindings({
62107
62554
  projectDir,
62108
- meta: meta3,
62555
+ meta: priorMeta,
62109
62556
  synced: readSynced(projectDir).workflows,
62110
62557
  live: liveApp
62111
62558
  });
62112
62559
  let live = liveApp;
62113
62560
  if (!nothingPending(pending)) {
62114
62561
  await pushPendingBindings(client, projectDir, pending, args.acknowledgeBreakingApi);
62115
- live = await client.getApp(meta3.app_id);
62562
+ live = await client.getApp(priorMeta.app_id);
62116
62563
  }
62564
+ const meta3 = readAppMeta(projectDir);
62117
62565
  const sourceText = readAppSourceText(projectDir);
62118
62566
  const called = calledAppAliases(sourceText);
62119
62567
  warnIfDynamicAliases(called);
@@ -62202,11 +62650,12 @@ async function appDeploy(client, args) {
62202
62650
  if (result.origin !== void 0) note(`Address: ${result.origin}`);
62203
62651
  try {
62204
62652
  const drifted = staleWorkflowGlobals(projectDir, meta3.workflows ?? {});
62205
- for (const { alias, declaration } of drifted) {
62653
+ for (const { alias, declaration, hadTypes } of drifted) {
62206
62654
  const refreshed = await refreshWorkflowTypes(client, projectDir, meta3.app_id, alias, declaration);
62207
- if (refreshed.kind === "refreshed") {
62208
- note(`Refreshed workflow types for ${alias} \u2014 this deploy moved its declaration.`);
62209
- }
62655
+ if (refreshed.kind !== "refreshed") continue;
62656
+ note(
62657
+ hadTypes ? `Refreshed workflow types for ${alias} \u2014 this deploy moved its declaration.` : `Wrote workflow types for ${alias} \u2014 this project had none.`
62658
+ );
62210
62659
  }
62211
62660
  } catch (err) {
62212
62661
  warn(`(types not refreshed: ${err.message})`);