@skillstech/thunderlang 1.4.0 → 1.4.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
+ # 1.4.2
2
+
3
+ **Upgrade note.** No command, flag, exit code, or JSON shape changed. New in `@skillstech/thunderlang/react`:
4
+ `IOBoxes`, `Flow`, and `Details` (`BigPicture` now draws the IO boxes when an action or rule is in focus). New in
5
+ `./core`: `flowEdgeLabel()` and `detailsLayout()`. `ioBoxes()` gains `getBack.items`; `getBack.text` is unchanged.
6
+
7
+ - **The drawing kit, second part: the IO boxes, Flow, and Details.** `@skillstech/thunderlang/react` now draws the
8
+ whole reading of one action or rule, so the three products show it the same way. `IOBoxes` ("You give it", "You get
9
+ back", "It can stop with" with each stop's line, and "Part of …" back to its Thing), which `BigPicture` now draws when
10
+ an action or rule is in focus. `Flow` (every step at the compiler's lane and row, its Yes / No / For each / Done / If
11
+ it fails edges, marks and colors from DOES, steps not read yet dashed, optional New / Gone marks for Thunder Diff).
12
+ `Details` (the counts at a glance, then You give it / You get back, When it stops, What it changes, Its answers,
13
+ Exact limits, Every step, It relies on, Used by, Questions the code cannot answer). The words come from
14
+ `./core`: `flowEdgeLabel(edge)` and `detailsLayout(readLevel(model, 'details', id))`, which keeps a section only when
15
+ the compiler gave it. Callbacks only (`onLine`, `onUse`, `onThing`); no buttons without them. The stylesheet gains
16
+ the matching `tl-` classes, all on the same color variables. `ioBoxes` gains `getBack.items`: the declared result,
17
+ else the Flow's end steps, so the Big Picture no longer says "Nothing it hands back" for a function whose returns
18
+ have no type (`getBack.text` is unchanged).
19
+
20
+ # 1.4.1
21
+
22
+ **Upgrade note.** No command, flag, exit code, or JSON shape changed. New: the drawing kit entry
23
+ `@skillstech/thunderlang/react` (with `react/reading.css`; React >=18 is an optional peer dependency) and
24
+ `readingLayout()` in `./core` (schema `thunder-reading-layout-v1`). One behavior fix: `thunder write <folder…>` now
25
+ lists, instead of changing, a rule with the same condition in a decision whose name shares no word with the chosen one.
26
+
27
+ - **The Thunder drawing kit, `@skillstech/thunderlang/react` (first part).** One set of components so OpenThunder,
28
+ thunderlang.dev, and the Skills Tech Talk course draw a reading the same way: `ThingCard` ("A Thing", "It knows",
29
+ the "It can" buttons, "How a new … starts"), `DataCard` (a record or choices), `BigPicture`, and `ThunderSymbol`.
30
+ Every word and its order come from `readingLayout(model, { focus })` in `./core` (`thunder-reading-layout-v1`),
31
+ which zooms with focus: the whole app or a file (Things, then records, then choices), a Thing (its card and its
32
+ file's Data), or an action or rule (`ioBoxes`: "You give it", "You get back", "It can stop with", "Part of …").
33
+ Styling is one stylesheet, `@skillstech/thunderlang/react/reading.css`: plain `tl-` classes, every color a CSS
34
+ variable (a dark and a light set; `--language-accent` is honored), one column under 560px, 44px touch targets.
35
+ React is an optional peer dependency; no Tailwind, no build step. thunderlang.dev now draws its Thing and Data
36
+ cards with it. The Flow and Details views and the drawn IO boxes join next.
37
+ - **Three lessons on changing real code, in `@skillstech/thunderlang/learn`.** "Does every route keep each
38
+ customer's records to them?" (`thunder read --access`), "Change one rule in every service at once"
39
+ (`thunder write <folder…>`), and "Keep the evidence for a change" (`thunder passport`, `passport check`). They are
40
+ write lessons (now 10, 22 lessons in all), and like every lesson, each quiz answer is worked out by the tool itself
41
+ on the lesson's files, so the build fails if a tool ever disagrees with what a lesson teaches.
42
+ - **Fix: `thunder write <folder…>` no longer changes a different rule that happens to share a condition.** A
43
+ decision with the same condition but a name that shares no word with the chosen one (`coupon_allowed` next to
44
+ `shippingFee`, both `subtotal >= 50`) is now listed as "check by hand" instead of being changed. Names are compared
45
+ as words, leaving out words like get, is, and calculate, so `shippingNote`, `ShippingFee`, and `get_shipping_fee`
46
+ still match.
47
+
1
48
  # 1.4.0
2
49
 
3
50
  **Upgrade note.** Every existing command, flag, exit code, and JSON output is unchanged. New: the Software Passport
package/dist/core.cjs CHANGED
@@ -89,6 +89,8 @@ __export(core_exports, {
89
89
  PROOF_SCHEMA: () => PROOF_SCHEMA,
90
90
  PROOF_STATUSES: () => PROOF_STATUSES,
91
91
  PROVENANCE: () => PROVENANCE2,
92
+ READING_LABELS: () => READING_LABELS,
93
+ READING_LAYOUT_SCHEMA: () => READING_LAYOUT_SCHEMA,
92
94
  READ_LANGUAGES: () => READ_LANGUAGES,
93
95
  READ_REPO_SCHEMA: () => READ_REPO_SCHEMA,
94
96
  READ_SCHEMA: () => READ_SCHEMA,
@@ -180,9 +182,11 @@ __export(core_exports, {
180
182
  confidenceFromClassification: () => confidenceFromClassification,
181
183
  contradictionsView: () => contradictionsView,
182
184
  coverageView: () => coverageView,
185
+ dataCard: () => dataCard,
183
186
  describeEdit: () => describeEdit,
184
187
  detailOf: () => detailOf,
185
188
  detailParts: () => detailParts,
189
+ detailsLayout: () => detailsLayout,
186
190
  detectLanguage: () => detectLanguage,
187
191
  diffGraphs: () => diffGraphs,
188
192
  displayLabel: () => displayLabel,
@@ -195,6 +199,7 @@ __export(core_exports, {
195
199
  explainPlain: () => explainPlain,
196
200
  exprCounts: () => exprCounts,
197
201
  findSameRule: () => findSameRule,
202
+ flowEdgeLabel: () => flowEdgeLabel,
198
203
  flowOf: () => flowOf,
199
204
  formatMoney: () => formatMoney,
200
205
  formatValue: () => formatValue,
@@ -216,6 +221,7 @@ __export(core_exports, {
216
221
  intentGraphJsonSchema: () => intentGraphJsonSchema,
217
222
  intentProofJsonSchema: () => intentProofJsonSchema,
218
223
  intentRefId: () => intentRefId,
224
+ ioBoxes: () => ioBoxes,
219
225
  isCaseResult: () => isCaseResult,
220
226
  isFactual: () => isFactual,
221
227
  isFactualProvenance: () => isFactualProvenance,
@@ -227,6 +233,7 @@ __export(core_exports, {
227
233
  linkSystem: () => linkSystem,
228
234
  makeEvent: () => makeEvent,
229
235
  makeScope: () => makeScope,
236
+ memberSymbolId: () => memberSymbolId,
230
237
  mergeGraphs: () => mergeGraphs,
231
238
  minorUnitsFor: () => minorUnitsFor,
232
239
  modelText: () => modelText,
@@ -258,6 +265,7 @@ __export(core_exports, {
258
265
  readScreens: () => readScreens,
259
266
  readableFile: () => readableFile,
260
267
  readableLanguage: () => readableLanguage,
268
+ readingLayout: () => readingLayout,
261
269
  readingOf: () => readingOf,
262
270
  recoverModel: () => recoverModel,
263
271
  renderExampleTable: () => renderExampleTable,
@@ -312,6 +320,7 @@ __export(core_exports, {
312
320
  subjectName: () => subjectName,
313
321
  summarize: () => summarize2,
314
322
  terminatorEffect: () => terminatorEffect,
323
+ thingCard: () => thingCard,
315
324
  thunderModel: () => thunderModel,
316
325
  thunderReview: () => thunderReview,
317
326
  thunderText: () => thunderText,
@@ -3813,9 +3822,9 @@ var Parser = class {
3813
3822
  }
3814
3823
  if (this.fam === "rs" && this.isOp(";")) {
3815
3824
  this.next();
3816
- const count = this.expr(0.6);
3825
+ const count2 = this.expr(0.6);
3817
3826
  this.eat("]");
3818
- return { kind: "array", items, repeat: count };
3827
+ return { kind: "array", items, repeat: count2 };
3819
3828
  }
3820
3829
  if (!this.isOp("]")) fail2("expected , or ]");
3821
3830
  }
@@ -13336,16 +13345,16 @@ function readTerraform(src, file = "main.tf") {
13336
13345
  const what = d.kind === "module" ? `the module ${name}${src2 ? ` (${valueText(src2.value, refWords).text})` : ""}` : named(typeWords2(type), name);
13337
13346
  const verb = d.kind === "data" ? "Looks up" : d.kind === "module" ? "Uses" : "Creates";
13338
13347
  let step = { kind: "call", says: `${verb} ${what}${inWords}`, code: head, line: b.line };
13339
- const count = attrOf(b.body, "count"), fe = attrOf(b.body, "for_each");
13340
- if (count) {
13341
- const c = count.value;
13348
+ const count2 = attrOf(b.body, "count"), fe = attrOf(b.body, "for_each");
13349
+ if (count2) {
13350
+ const c = count2.value;
13342
13351
  const cond = c.t === "cond" ? c : null;
13343
- if (cond && isZero2(cond.no)) step = { kind: "branch", says: question(conditionWords(cond.test, refWords)), code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count.line, children: [step] };
13344
- else if (cond && isZero2(cond.yes)) step = { kind: "branch", says: question(conditionWords({ t: "unary", op: "!", x: cond.test }, refWords)), code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count.line, children: [step] };
13352
+ if (cond && isZero2(cond.no)) step = { kind: "branch", says: question(conditionWords(cond.test, refWords)), code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count2.line, children: [step] };
13353
+ else if (cond && isZero2(cond.yes)) step = { kind: "branch", says: question(conditionWords({ t: "unary", op: "!", x: cond.test }, refWords)), code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count2.line, children: [step] };
13345
13354
  else if (c.t === "num") {
13346
13355
  if (c.v === 0) step.says += " (none: count is 0)";
13347
13356
  else if (c.v !== 1) step.says = `${verb} ${c.v} of ${what}${inWords}`;
13348
- } else step = { kind: "loop", says: `As many times as ${valueText(c, refWords).text.replace(` (${APPLIED})`, "")}`, code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count.line, children: [step] };
13357
+ } else step = { kind: "loop", says: `As many times as ${valueText(c, refWords).text.replace(` (${APPLIED})`, "")}`, code: `count = ${parsed.src.slice(c.s, c.e)}`, line: count2.line, children: [step] };
13349
13358
  } else if (fe) step = { kind: "loop", says: `For each ${forEachWords(fe.value, refWords).replace(/^one for each /, "")}`, code: `for_each = ${parsed.src.slice(fe.value.s, fe.value.e)}`, line: fe.line, children: [step] };
13350
13359
  steps.push(step);
13351
13360
  }
@@ -16337,13 +16346,13 @@ var CALLOC = new RegExp(String.raw`^${CAST}(?:z|x|je_|ck_)?calloc\(\s*([\w.]+)\s
16337
16346
  function memoryFor(value) {
16338
16347
  const v = String(value).trim().replace(/;$/, "");
16339
16348
  const ofType = (t) => words7(String(t).replace(/\b(?:struct|const|unsigned)\s+/g, "").replace(/\s*\*+$/, "").trim().split("::").pop());
16340
- const count = (n) => /^\d+$/.test(n.trim()) ? n.trim() : words7(n.trim());
16349
+ const count2 = (n) => /^\d+$/.test(n.trim()) ? n.trim() : words7(n.trim());
16341
16350
  let m;
16342
16351
  if (m = v.match(ALLOC_ONE)) return `memory for one ${ofType(m[1])}`;
16343
- if (m = v.match(ALLOC_N)) return `memory for ${count(m[1])} ${pluralOf(ofType(m[2]))}`;
16344
- if (m = v.match(ALLOC_N2)) return `memory for ${count(m[2])} ${pluralOf(ofType(m[1]))}`;
16345
- if (m = v.match(CALLOC)) return m[1].trim() === "1" ? `memory for one ${ofType(m[2])}` : `memory for ${count(m[1])} ${pluralOf(ofType(m[2]))}`;
16346
- if (m = v.match(/^new\s+([\w:<>]+)\s*\[\s*([^\]]+?)\s*\]$/)) return `memory for ${count(m[2])} ${pluralOf(ofType(m[1]))}`;
16352
+ if (m = v.match(ALLOC_N)) return `memory for ${count2(m[1])} ${pluralOf(ofType(m[2]))}`;
16353
+ if (m = v.match(ALLOC_N2)) return `memory for ${count2(m[2])} ${pluralOf(ofType(m[1]))}`;
16354
+ if (m = v.match(CALLOC)) return m[1].trim() === "1" ? `memory for one ${ofType(m[2])}` : `memory for ${count2(m[1])} ${pluralOf(ofType(m[2]))}`;
16355
+ if (m = v.match(/^new\s+([\w:<>]+)\s*\[\s*([^\]]+?)\s*\]$/)) return `memory for ${count2(m[2])} ${pluralOf(ofType(m[1]))}`;
16347
16356
  if (new RegExp(String.raw`^${CAST}(?:z|x|je_|ck_)?(?:malloc|calloc|alloca|aligned_alloc)\(`).test(v)) return "memory";
16348
16357
  return null;
16349
16358
  }
@@ -19398,7 +19407,7 @@ function notesSummary(ast) {
19398
19407
  byLens
19399
19408
  };
19400
19409
  }
19401
- var COMPILER_VERSION = "1.4.0";
19410
+ var COMPILER_VERSION = "1.4.2";
19402
19411
  var PROOF_SCHEMA_VERSION = "0.1.0";
19403
19412
  var SOURCE_PRODUCT = "skillstech-compiler";
19404
19413
  function buildContractGraph(ast, generatedAt) {
@@ -37026,11 +37035,11 @@ function accessFlow(files, { maxRoutes = 2e3 } = {}) {
37026
37035
  paths
37027
37036
  });
37028
37037
  }
37029
- const count = (v) => out.filter((x) => x.verdict === v).length;
37038
+ const count2 = (v) => out.filter((x) => x.verdict === v).length;
37030
37039
  return {
37031
37040
  schema: ACCESS_SCHEMA,
37032
37041
  routes: out,
37033
- summary: { routes: out.length, guarded: count("guarded"), unguarded: count("unguarded"), cannotTell: count("cannot tell"), noLookup: count(null) },
37042
+ summary: { routes: out.length, guarded: count2("guarded"), unguarded: count2("unguarded"), cannotTell: count2("cannot tell"), noLookup: count2(null) },
37034
37043
  unread: project.failures
37035
37044
  };
37036
37045
  }
@@ -38186,7 +38195,7 @@ function readLevel(model, level, focus, { full = false } = {}) {
38186
38195
  links: (model.links || []).filter((l) => l.from === t.id || l.to === t.id).map((l) => ({ from: l.from, to: l.to, kind: l.kind, ...l.line ? { line: l.line } : {} }))
38187
38196
  });
38188
38197
  const resource = thing?.kind === "resource" ? thing : null;
38189
- const thingCard = (t) => ({ id: t.id, label: t.label, ...t.doc ? { doc: t.doc } : {}, knows: t.knows.map((k) => ({ label: k.label, ...k.start ? { start: k.start } : {} })), can: model.members.filter((m) => m.owner === t.id && m.kind !== "setup" && !m.callback).map(short6) });
38198
+ const thingCard2 = (t) => ({ id: t.id, label: t.label, ...t.doc ? { doc: t.doc } : {}, knows: t.knows.map((k) => ({ label: k.label, ...k.start ? { start: k.start } : {} })), can: model.members.filter((m) => m.owner === t.id && m.kind !== "setup" && !m.callback).map(short6) });
38190
38199
  return {
38191
38200
  ...base2,
38192
38201
  ...about,
@@ -38195,7 +38204,7 @@ function readLevel(model, level, focus, { full = false } = {}) {
38195
38204
  const p = thing ? thing.doc ?? model.files.find((f) => f.path === thing.file)?.purpose : model.files.length === 1 ? model.files[0]?.purpose : null;
38196
38205
  return p ? { purpose: p } : {};
38197
38206
  })(),
38198
- things: (resource ? [] : thing ? [thing] : model.things.filter((t) => t.kind === "thing" && !t.screen)).map(thingCard),
38207
+ things: (resource ? [] : thing ? [thing] : model.things.filter((t) => t.kind === "thing" && !t.screen)).map(thingCard2),
38199
38208
  resources: (resource ? [resource] : thing ? [] : model.things.filter((t) => t.kind === "resource")).map(resourceCard),
38200
38209
  ...thing ? {} : { permissions: model.permissions ?? [], settings: model.settings ?? [], facts: model.facts ?? [] },
38201
38210
  data: thing ? [] : model.things.filter((t) => t.kind !== "thing" && t.kind !== "resource").map((t) => ({ id: t.id, label: t.label, symbol: SYMBOL_OF[t.kind], ...t.choices.length ? { choices: t.choices } : {}, knows: t.knows.map((k) => k.label) })),
@@ -40134,6 +40143,12 @@ var editable2 = (t) => t.t === "num" || t.t === "str" || t.t === "op" && ["<", "
40134
40143
  var keyOf = (t) => t.t === "id" ? `id:${words13(t.v)}` : t.t === "str" ? `str:${JSON.stringify(t.v)}` : `${t.t}:${t.v}`;
40135
40144
  var shapeOf = (t) => t.t === "id" ? "id" : editable2(t) ? t.t === "op" ? "cmp" : t.t : `${t.t}:${t.v}`;
40136
40145
  var join3 = (toks2) => toks2.map((t) => t.t === "str" ? JSON.stringify(t.v) : String(t.v)).join(" ");
40146
+ var FILLER = /* @__PURE__ */ new Set(["get", "is", "has", "can", "should", "calc", "calculate", "compute", "check", "find", "the", "a", "an", "of", "for", "to", "by"]);
40147
+ var nameWords2 = (name) => new Set(words13(name).split(" ").filter((w) => w && !FILLER.has(w)));
40148
+ var sharesWord = (a, b) => {
40149
+ const A = nameWords2(a);
40150
+ return [...nameWords2(b)].some((w) => A.has(w));
40151
+ };
40137
40152
  var toks = (when) => {
40138
40153
  try {
40139
40154
  return tokenize(when);
@@ -40183,7 +40198,8 @@ function findSameRule(files, { decision, rule }) {
40183
40198
  const k = x.toks.map(keyOf).join(" ");
40184
40199
  const said = sayCondition(x.when);
40185
40200
  if (k === key) {
40186
- same.push({ ...x, why: `the same condition: ${said} (names compared as words)` });
40201
+ if (sharesWord(x.decision, anchor.decision)) same.push({ ...x, why: `the same condition: ${said} (names compared as words)` });
40202
+ else notIncluded.push({ ...x, why: `the same condition (${said}) in ${x.decision}, whose name shares no word with ${anchor.decision}; it may be a different rule that happens to use the same limit` });
40187
40203
  continue;
40188
40204
  }
40189
40205
  if (x.toks.map(shapeOf).join(" ") !== shape) continue;
@@ -40288,11 +40304,11 @@ function fromTrace(trace) {
40288
40304
  const out = [];
40289
40305
  for (const [file, f] of Object.entries(trace?.files || {})) {
40290
40306
  for (const [L, d] of Object.entries(f.decisions || {})) {
40291
- for (const [k, count] of Object.entries(d.obs || {})) {
40307
+ for (const [k, count2] of Object.entries(d.obs || {})) {
40292
40308
  const [where2, nRaw] = k.split("|");
40293
40309
  const next = nRaw === "" || nRaw == null ? null : Number(nRaw);
40294
40310
  const side2 = d.kind === "handler" ? "handled" : where2.startsWith("case:") ? where2 : d.kind === "for" ? where2 === "body" ? "each" : "done" : where2 === "body" ? "held" : "not held";
40295
- out.push({ source: "trace", kind: "decision", file, line: Number(L), side: side2, count, question: d.kind, ...next != null ? { next } : {} });
40311
+ out.push({ source: "trace", kind: "decision", file, line: Number(L), side: side2, count: count2, question: d.kind, ...next != null ? { next } : {} });
40296
40312
  }
40297
40313
  }
40298
40314
  for (const [L, fn] of Object.entries(f.functions || {})) {
@@ -40498,8 +40514,8 @@ function parseStacks(text2) {
40498
40514
  }
40499
40515
  return out;
40500
40516
  }
40501
- function fromStack(text2, { count = 1 } = {}) {
40502
- return parseStacks(text2).map((s) => ({ source: "stack", kind: "raise", file: s.frames[0]?.file ?? null, line: s.frames[0]?.line ?? null, error: s.error, message: s.message, frames: s.frames, language: s.language, count, ends: true }));
40517
+ function fromStack(text2, { count: count2 = 1 } = {}) {
40518
+ return parseStacks(text2).map((s) => ({ source: "stack", kind: "raise", file: s.frames[0]?.file ?? null, line: s.frames[0]?.line ?? null, error: s.error, message: s.message, frames: s.frames, language: s.language, count: count2, ends: true }));
40503
40519
  }
40504
40520
  var LEVEL_NUM = { 10: "trace", 20: "debug", 30: "info", 40: "warn", 50: "error", 60: "fatal" };
40505
40521
  var pick = (o, keys) => {
@@ -40939,8 +40955,8 @@ function hotPath(m, r) {
40939
40955
  continue;
40940
40956
  }
40941
40957
  if (nr.sides) {
40942
- const [label, count] = Object.entries(nr.sides).sort((a, b2) => b2[1] - a[1])[0];
40943
- out.push({ id: n.id, text: n.text, side: label, count });
40958
+ const [label, count2] = Object.entries(nr.sides).sort((a, b2) => b2[1] - a[1])[0];
40959
+ out.push({ id: n.id, text: n.text, side: label, count: count2 });
40944
40960
  const key = label === "Yes" ? "yes" : label === "No" ? "no" : label === "For each" ? "each" : null;
40945
40961
  const next = key ? b[key] : (b.cases || []).find((c) => c.label === label)?.blocks;
40946
40962
  if (next?.length) {
@@ -41700,13 +41716,13 @@ function summaryOf(e) {
41700
41716
  function compareThings(A, B, items) {
41701
41717
  const key = (t) => `${stemKey2(t.file)}#${nameKey(t.name)}`;
41702
41718
  let pairs2 = pairBy(A.model.things, B.model.things, key);
41703
- const count = (list3) => {
41719
+ const count2 = (list3) => {
41704
41720
  const c = /* @__PURE__ */ new Map();
41705
41721
  for (const t of list3) c.set(nameKey(t.name), (c.get(nameKey(t.name)) || 0) + 1);
41706
41722
  return c;
41707
41723
  };
41708
41724
  const lonelyA = pairs2.filter(([a, b]) => a && !b).map(([a]) => a), lonelyB = pairs2.filter(([a, b]) => b && !a).map(([, b]) => b);
41709
- const ca = count(lonelyA), cb = count(lonelyB);
41725
+ const ca = count2(lonelyA), cb = count2(lonelyB);
41710
41726
  for (const a of lonelyA) {
41711
41727
  if (ca.get(nameKey(a.name)) !== 1 || cb.get(nameKey(a.name)) !== 1) continue;
41712
41728
  const b = lonelyB.find((t) => nameKey(t.name) === nameKey(a.name));
@@ -41935,8 +41951,8 @@ function thunderReview(oldFiles, newFiles) {
41935
41951
  }
41936
41952
  for (const x of items) if (x.also) x.subject = `${x.subject} and ${x.also.length} more`;
41937
41953
  items.sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity) || KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) || String(a.where.file).localeCompare(String(b.where.file)) || (a.where.line ?? 0) - (b.where.line ?? 0));
41938
- const count = (s) => items.filter((x) => x.severity === s).length;
41939
- const summary2 = { meaning: count("meaning"), risk: count("risk"), form: count("form"), unchanged, files: paths.filter((p) => A.sources.get(p) !== B.sources.get(p)).length };
41954
+ const count2 = (s) => items.filter((x) => x.severity === s).length;
41955
+ const summary2 = { meaning: count2("meaning"), risk: count2("risk"), form: count2("form"), unchanged, files: paths.filter((p) => A.sources.get(p) !== B.sources.get(p)).length };
41940
41956
  const onlyNotRead = !items.length && summary2.files && notRead.length === summary2.files;
41941
41957
  return { schema: REVIEW_SCHEMA, summary: summary2, says: onlyNotRead ? "Only files Thunder does not read changed." : summaryLine(summary2), items, notRead };
41942
41958
  }
@@ -44254,8 +44270,8 @@ function renderLensDoc(ast, lens) {
44254
44270
  };
44255
44271
  ruleSection("Guarantees", ast.guarantees, "guarantee");
44256
44272
  ruleSection("Never", ast.neverRules, "never");
44257
- const count = (ast.notes || []).filter((n) => n.lens === lens).length;
44258
- L.push("---", `${count} \`${lens}\` note${count === 1 ? "" : "s"} in this mission.`);
44273
+ const count2 = (ast.notes || []).filter((n) => n.lens === lens).length;
44274
+ L.push("---", `${count2} \`${lens}\` note${count2 === 1 ? "" : "s"} in this mission.`);
44259
44275
  return L.join("\n");
44260
44276
  }
44261
44277
  function renderMermaid(ast) {
@@ -44773,8 +44789,8 @@ function resolveObligations(ast) {
44773
44789
  ...(ast.guarantees || []).map((g) => build("guarantee", g)),
44774
44790
  ...(ast.neverRules || []).map((n) => build("prohibition", n))
44775
44791
  ];
44776
- const count = (s) => obligations.filter((o) => o.status === s).length;
44777
- return { obligations, tests, verified: count("verified"), declared: count("declared"), unverified: count("unverified"), failed: count("failed") };
44792
+ const count2 = (s) => obligations.filter((o) => o.status === s).length;
44793
+ return { obligations, tests, verified: count2("verified"), declared: count2("declared"), unverified: count2("unverified"), failed: count2("failed") };
44778
44794
  }
44779
44795
 
44780
44796
  // src/review-atlas.mjs
@@ -46183,6 +46199,170 @@ function renderPassportMarkdown(p) {
46183
46199
  L.push("", "## History", "", `- Base: ${p.history.base ?? "(none: a snapshot)"}`, `- Head: ${p.history.head ?? "(working tree)"}`, ...p.history.changedFiles.map((c) => `- ${c.status}: ${c.part}/${c.file}`), `- Built: ${p.history.builtAt}${p.history.thunder ? ` with Thunder ${p.history.thunder}` : ""}`, `- Fingerprint: ${p.fingerprint}`, "");
46184
46200
  return L.join("\n");
46185
46201
  }
46202
+
46203
+ // src/reading-layout.mjs
46204
+ var READING_LAYOUT_SCHEMA = "thunder-reading-layout-v1";
46205
+ var READING_LABELS = Object.freeze({
46206
+ thing: "A Thing",
46207
+ knows: "It knows",
46208
+ can: "It can",
46209
+ starts: (label) => `How a new ${label} starts`,
46210
+ startsWithKnows: (label) => `A new ${label} starts with what it knows above`,
46211
+ record: "Data: a record",
46212
+ choices: "Data: choices",
46213
+ recordSymbol: "Record",
46214
+ choicesSymbol: "Choices",
46215
+ things: "Things",
46216
+ data: "Data",
46217
+ give: "You give it",
46218
+ getBack: "You get back",
46219
+ stops: "It can stop with",
46220
+ givesNothing: "Nothing",
46221
+ getsNothing: "Nothing it hands back",
46222
+ partOf: (label) => `Part of ${label}`,
46223
+ io: "What goes in and out",
46224
+ // Flow: the words on each kind of edge. An edge label not listed here is shown as the compiler wrote it.
46225
+ edges: Object.freeze({ yes: "Yes", no: "No", each: "For each", done: "Done", error: "If it fails", nested: "Runs on its own", case: "When" }),
46226
+ openLine: (line) => `line ${line}`,
46227
+ openRule: "Open the rule",
46228
+ // Details: what each section is called.
46229
+ details: Object.freeze({
46230
+ stops: "When it stops",
46231
+ noStops: "Thunder found no place where it stops early.",
46232
+ noInputs: "Thunder found no inputs. Check Original if it reads a request or a file.",
46233
+ nothingBack: "Thunder found nothing it gives back.",
46234
+ changes: "What it changes, saves or sends",
46235
+ answers: "Its answers",
46236
+ limits: (fact) => `Exact limits for ${fact}`,
46237
+ limitsHow: "Found by running the rule on every whole number around each limit.",
46238
+ steps: "Every step, with its line",
46239
+ reliesOn: "It relies on",
46240
+ usedBy: "Used by",
46241
+ openQuestions: "Questions the code cannot answer",
46242
+ always: "Always",
46243
+ otherwise: "otherwise",
46244
+ when: (w) => `when ${w}`,
46245
+ usedOn: "used on",
46246
+ atAGlance: "At a glance"
46247
+ })
46248
+ });
46249
+ var memberSymbolId = (m) => m.kind === "action" || m.kind === "pipeline" ? "action" : m.kind === "rule" ? "rule" : m.kind === "setup" ? "setup" : m.kind === "not-read" ? "not-read" : "steps";
46250
+ var knowsLine = (k) => {
46251
+ const detail = [k.kind, k.start].filter(Boolean).join(", ");
46252
+ return { name: k.name, label: k.label, detail: detail || null, ...k.secret ? { secret: true } : {}, line: k.line ?? null };
46253
+ };
46254
+ function thingCard(model, thing) {
46255
+ const members = new Map(model.members.map((m) => [m.id, m]));
46256
+ const can = thing.can.map((id2) => members.get(id2)).filter(Boolean);
46257
+ const setup = can.find((m) => m.kind === "setup") ?? null;
46258
+ return {
46259
+ kind: "thing",
46260
+ id: thing.id,
46261
+ label: thing.label,
46262
+ doc: thing.doc ?? null,
46263
+ heading: READING_LABELS.thing,
46264
+ symbol: "thing",
46265
+ knows: { heading: READING_LABELS.knows, items: thing.knows.map(knowsLine) },
46266
+ can: { heading: READING_LABELS.can, items: can.filter((m) => m !== setup).map((m) => ({ id: m.id, label: `${m.label}${m.yesNo ? "?" : ""}`, symbol: memberSymbolId(m) })) },
46267
+ starts: setup ? { id: setup.id, text: READING_LABELS.starts(thing.label) } : { id: null, text: READING_LABELS.startsWithKnows(thing.label) }
46268
+ };
46269
+ }
46270
+ function dataCard(thing) {
46271
+ const record = thing.kind === "record";
46272
+ return {
46273
+ kind: record ? "record" : "choices",
46274
+ id: thing.id,
46275
+ label: thing.label,
46276
+ doc: thing.doc ?? null,
46277
+ heading: record ? READING_LABELS.record : READING_LABELS.choices,
46278
+ symbol: record ? "record" : "choices",
46279
+ symbolLabel: record ? READING_LABELS.recordSymbol : READING_LABELS.choicesSymbol,
46280
+ choices: [...thing.choices],
46281
+ knows: thing.knows.map(knowsLine)
46282
+ };
46283
+ }
46284
+ var givesBackOf = (member) => {
46285
+ const list3 = member.youGetBack ? [member.youGetBack] : (member.flow?.nodes ?? []).filter((n) => n.kind === "end").map((n) => n.text.replace(/^Gives back\s+/i, ""));
46286
+ return [...new Set(list3.filter(Boolean))];
46287
+ };
46288
+ function ioBoxes(model, member) {
46289
+ const owner = member.owner ? model.things.find((t) => t.id === member.owner) : null;
46290
+ const kinds = member.inputKinds ?? {};
46291
+ const stops = (member.flow?.nodes ?? []).filter((n) => n.kind === "stop").map((n) => ({ text: n.text.replace(/^Stop:\s*/, ""), line: n.line ?? null }));
46292
+ return {
46293
+ kind: "io",
46294
+ id: member.id,
46295
+ label: `${member.label}${member.yesNo ? "?" : ""}`,
46296
+ doc: member.doc ?? null,
46297
+ symbol: memberSymbolId(member),
46298
+ give: { heading: READING_LABELS.give, items: member.youGive.map((label) => ({ label, kind: kinds[label] ?? null })), empty: READING_LABELS.givesNothing },
46299
+ // What it gives back: what the code declares, else the Flow's end steps (the same facts Flow and Details show).
46300
+ getBack: { heading: READING_LABELS.getBack, text: member.youGetBack ?? null, items: givesBackOf(member), empty: READING_LABELS.getsNothing },
46301
+ stops: { heading: READING_LABELS.stops, items: stops },
46302
+ partOf: owner ? { id: owner.id, text: READING_LABELS.partOf(owner.label) } : null
46303
+ };
46304
+ }
46305
+ function flowEdgeLabel(edge) {
46306
+ if (!edge.label || edge.label === "next") return null;
46307
+ if (edge.label === "case") return edge.text ?? READING_LABELS.edges.case;
46308
+ return READING_LABELS.edges[edge.label] ?? edge.text ?? edge.label;
46309
+ }
46310
+ var count = (n, one, many) => ({ count: n, text: n === 1 ? one : many });
46311
+ function detailsLayout(view2) {
46312
+ const L = READING_LABELS.details;
46313
+ const inputs = view2.inputs ?? (view2.youGive ?? []).map((label) => ({ label, lines: [] }));
46314
+ const givesBack = view2.givesBack?.length ? view2.givesBack.map((g) => ({ text: g.text, line: g.line ?? null, when: g.when ?? null })) : view2.youGetBack ? [{ text: view2.youGetBack, line: null, when: null }] : (view2.flow?.nodes ?? []).filter((n) => n.kind === "end").map((n) => ({ text: n.text, line: n.line ?? null, when: null }));
46315
+ const steps = view2.steps ?? [];
46316
+ const stops = view2.stops ?? null;
46317
+ const changes = view2.changes ?? null;
46318
+ const reliesOn = view2.reliesOn ?? (view2.uses ?? []).map((u) => ({ id: u.id, label: u.label, symbol: "rule", says: "" }));
46319
+ const stats = [
46320
+ ...inputs.length ? [{ id: "inputs", ...count(inputs.length, "thing you give it", "things you give it") }] : [],
46321
+ { id: "steps", ...count(steps.length, "step", "steps") },
46322
+ ...stops ? [{ id: "stops", ...count(stops.length, "way to stop", "ways to stop") }] : [],
46323
+ ...changes ? [{ id: "changes", ...count(changes.length, "change", "changes") }] : [],
46324
+ ...reliesOn.length ? [{ id: "reliesOn", count: reliesOn.length, text: "relies on" }] : [],
46325
+ ...(view2.notExplained ?? 0) > 0 ? [{ id: "notExplained", count: view2.notExplained, text: "not explained yet" }] : []
46326
+ ];
46327
+ return {
46328
+ id: view2.id ?? null,
46329
+ title: view2.title ?? null,
46330
+ heading: L.atAGlance,
46331
+ stats,
46332
+ give: inputs.length || givesBack.length ? { heading: READING_LABELS.give, items: inputs.map((i) => ({ label: i.label, lines: i.lines ?? [] })), empty: L.noInputs } : null,
46333
+ getBack: inputs.length || givesBack.length ? { heading: READING_LABELS.getBack, items: givesBack, empty: L.nothingBack } : null,
46334
+ stops: stops ? { heading: L.stops, items: stops.map((s) => ({ error: s.error, message: s.message ?? null, line: s.line ?? null, when: s.when ?? [] })), empty: L.noStops } : null,
46335
+ changes: changes?.length ? { heading: L.changes, items: changes.map((c) => ({ text: c.text, does: c.does ?? null, line: c.line ?? null, when: c.when ?? [] })) } : null,
46336
+ answers: view2.answers?.length ? { heading: L.answers, items: view2.answers.map((a) => ({ answer: a.answer, when: a.when === "otherwise" ? L.otherwise : L.when(a.when) })) } : null,
46337
+ limits: view2.limits ? { heading: L.limits(view2.limits.fact), note: L.limitsHow, items: view2.limits.ranges.map((r) => ({ range: r.from == null ? `${r.to} or less` : r.to == null ? `${r.from} or more` : r.from === r.to ? `${r.from}` : `${r.from} to ${r.to}`, answer: r.answer })) } : null,
46338
+ steps: steps.length ? { heading: L.steps, items: steps.map((s) => ({ id: s.id, text: s.text, does: s.does ?? null, mark: s.mark ?? null, depth: s.depth ?? 0, line: s.line ?? null, notExplained: !!s.notExplained, via: s.via ?? null })) } : null,
46339
+ reliesOn: reliesOn.length ? { heading: L.reliesOn, items: reliesOn.map((r) => ({ id: r.id, label: r.label, symbol: r.symbol ?? "rule", says: r.says ?? "" })) } : null,
46340
+ usedBy: view2.usedBy?.length ? { heading: L.usedBy, items: view2.usedBy.map((u) => ({ id: u.id, label: u.label })) } : null,
46341
+ openQuestions: view2.openQuestions?.length ? { heading: L.openQuestions, items: [...view2.openQuestions] } : null,
46342
+ source: view2.source ?? null
46343
+ };
46344
+ }
46345
+ var sectionsFor = (model, things) => {
46346
+ const cards = things.filter((t) => t.kind === "thing").map((t) => thingCard(model, t));
46347
+ const data = [...things.filter((t) => t.kind === "record"), ...things.filter((t) => t.kind === "choices")].map(dataCard);
46348
+ return [
46349
+ ...cards.length ? [{ id: "things", heading: READING_LABELS.things, cards }] : [],
46350
+ ...data.length ? [{ id: "data", heading: READING_LABELS.data, cards: data }] : []
46351
+ ];
46352
+ };
46353
+ function readingLayout(model, { focus = null } = {}) {
46354
+ const base2 = { schema: READING_LAYOUT_SCHEMA };
46355
+ if (focus == null) return { ...base2, focus: { kind: "app", id: null }, sections: sectionsFor(model, model.things) };
46356
+ const member = model.members.find((m) => m.id === focus);
46357
+ if (member) return { ...base2, focus: { kind: "member", id: focus }, sections: [{ id: "io", heading: READING_LABELS.io, cards: [ioBoxes(model, member)] }] };
46358
+ const thing = model.things.find((t) => t.id === focus);
46359
+ if (thing) {
46360
+ const rest2 = model.things.filter((t) => t !== thing && t.file === thing.file && t.kind !== "thing");
46361
+ return { ...base2, focus: { kind: "thing", id: focus }, sections: sectionsFor(model, [thing, ...rest2]) };
46362
+ }
46363
+ if (model.files.some((f) => f.path === focus)) return { ...base2, focus: { kind: "file", id: focus }, sections: sectionsFor(model, model.things.filter((t) => t.file === focus)) };
46364
+ return { ...base2, focus: { kind: "unknown", id: focus }, sections: [] };
46365
+ }
46186
46366
  // Annotate the CommonJS export names for ESM import in node:
46187
46367
  0 && (module.exports = {
46188
46368
  ACCESSIBILITY_CLASSIFICATION,
@@ -46254,6 +46434,8 @@ function renderPassportMarkdown(p) {
46254
46434
  PROOF_SCHEMA,
46255
46435
  PROOF_STATUSES,
46256
46436
  PROVENANCE,
46437
+ READING_LABELS,
46438
+ READING_LAYOUT_SCHEMA,
46257
46439
  READ_LANGUAGES,
46258
46440
  READ_REPO_SCHEMA,
46259
46441
  READ_SCHEMA,
@@ -46345,9 +46527,11 @@ function renderPassportMarkdown(p) {
46345
46527
  confidenceFromClassification,
46346
46528
  contradictionsView,
46347
46529
  coverageView,
46530
+ dataCard,
46348
46531
  describeEdit,
46349
46532
  detailOf,
46350
46533
  detailParts,
46534
+ detailsLayout,
46351
46535
  detectLanguage,
46352
46536
  diffGraphs,
46353
46537
  displayLabel,
@@ -46360,6 +46544,7 @@ function renderPassportMarkdown(p) {
46360
46544
  explainPlain,
46361
46545
  exprCounts,
46362
46546
  findSameRule,
46547
+ flowEdgeLabel,
46363
46548
  flowOf,
46364
46549
  formatMoney,
46365
46550
  formatValue,
@@ -46381,6 +46566,7 @@ function renderPassportMarkdown(p) {
46381
46566
  intentGraphJsonSchema,
46382
46567
  intentProofJsonSchema,
46383
46568
  intentRefId,
46569
+ ioBoxes,
46384
46570
  isCaseResult,
46385
46571
  isFactual,
46386
46572
  isFactualProvenance,
@@ -46392,6 +46578,7 @@ function renderPassportMarkdown(p) {
46392
46578
  linkSystem,
46393
46579
  makeEvent,
46394
46580
  makeScope,
46581
+ memberSymbolId,
46395
46582
  mergeGraphs,
46396
46583
  minorUnitsFor,
46397
46584
  modelText,
@@ -46423,6 +46610,7 @@ function renderPassportMarkdown(p) {
46423
46610
  readScreens,
46424
46611
  readableFile,
46425
46612
  readableLanguage,
46613
+ readingLayout,
46426
46614
  readingOf,
46427
46615
  recoverModel,
46428
46616
  renderExampleTable,
@@ -46477,6 +46665,7 @@ function renderPassportMarkdown(p) {
46477
46665
  subjectName,
46478
46666
  summarize,
46479
46667
  terminatorEffect,
46668
+ thingCard,
46480
46669
  thunderModel,
46481
46670
  thunderReview,
46482
46671
  thunderText,
package/dist/index.cjs CHANGED
@@ -2585,7 +2585,7 @@ function notesSummary(ast) {
2585
2585
  byLens
2586
2586
  };
2587
2587
  }
2588
- var COMPILER_VERSION = "1.4.0";
2588
+ var COMPILER_VERSION = "1.4.2";
2589
2589
  var PROOF_SCHEMA_VERSION = "0.1.0";
2590
2590
  var SOURCE_PRODUCT = "skillstech-compiler";
2591
2591
  function buildContractGraph(ast, generatedAt) {