@skillstech/thunderlang 1.7.0 → 1.8.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +10 -3
  3. package/dist/core.cjs +234 -20
  4. package/dist/index.cjs +8853 -1045
  5. package/dist/learn.cjs +1339 -69
  6. package/package.json +1 -1
  7. package/src/cli-main.mjs +312 -115
  8. package/src/core/check.mjs +312 -6
  9. package/src/core/cli.mjs +60 -8
  10. package/src/core/csharp-run.mjs +2 -2
  11. package/src/core/diagnostics.mjs +9 -0
  12. package/src/core/engine-core.mjs +141 -19
  13. package/src/core/engine-values.mjs +1 -0
  14. package/src/core/engine.mjs +131 -7
  15. package/src/core/go-run.mjs +2 -2
  16. package/src/core/index.mjs +6 -2
  17. package/src/core/java-run.mjs +2 -2
  18. package/src/core/kind.mjs +3 -0
  19. package/src/core/lexer.mjs +16 -2
  20. package/src/core/parser.mjs +200 -15
  21. package/src/core/project-root.mjs +18 -0
  22. package/src/core/project.mjs +15 -18
  23. package/src/core/react-run.mjs +2 -2
  24. package/src/core/runtime-go/thunder_runtime.go +269 -1
  25. package/src/core/runtime-python.mjs +365 -3
  26. package/src/core/runtime-typescript.mjs +150 -5
  27. package/src/core/rust-run.mjs +2 -2
  28. package/src/core/serving.mjs +12 -0
  29. package/src/core/store-format.mjs +110 -0
  30. package/src/core/target-go.mjs +10 -3
  31. package/src/core/target-python.mjs +38 -5
  32. package/src/core/target-typescript.mjs +62 -6
  33. package/src/core/typescript-run.mjs +6 -4
  34. package/src/core-changes-fs.mjs +28 -0
  35. package/src/core-changes.d.mts +67 -0
  36. package/src/core-changes.mjs +603 -0
  37. package/src/core-rules.mjs +146 -0
  38. package/src/core-services.d.mts +4 -0
  39. package/src/core-services.mjs +49 -0
  40. package/src/emit.mjs +1 -1
  41. package/src/evidence.mjs +28 -0
  42. package/src/examples.d.mts +21 -0
  43. package/src/examples.mjs +175 -0
  44. package/src/index.d.ts +4 -0
  45. package/src/index.mjs +4 -0
  46. package/src/mcp.mjs +42 -3
  47. package/src/program.d.mts +4 -0
  48. package/src/program.mjs +4 -0
  49. package/src/read-repo-fs.mjs +2 -1
  50. package/src/review.mjs +69 -3
  51. package/src/system.mjs +1 -1
  52. package/src/trace-cli.mjs +8 -3
  53. package/src/trace-fs.mjs +29 -3
  54. package/src/trace.mjs +23 -7
package/src/review.mjs CHANGED
@@ -12,13 +12,14 @@ import { thunderModel, readLevel, modelText } from './model.mjs';
12
12
  import { comparePlainRules, nameKey } from './same.mjs';
13
13
  import { readableLanguage } from './read-repo.mjs';
14
14
  import { byText } from './text-order.mjs';
15
+ import { isCoreProgram } from './core/kind.mjs';
15
16
 
16
17
  export const REVIEW_SCHEMA = 'thunder-review-v1';
17
18
  export const REVIEW_MARKER = '<!-- thunder-review -->';
18
19
 
19
20
  const SEVERITY_ORDER = ['risk', 'meaning', 'form'];
20
21
  // Within a severity, what a reviewer should read first.
21
- const KIND_ORDER = ['unreadable', 'not-read', 'infrastructure', 'stop-removed', 'stop-changed', 'address', 'effect-added', 'stop-added',
22
+ const KIND_ORDER = ['unreadable', 'test-fails', 'callers', 'not-read', 'infrastructure', 'stop-removed', 'stop-changed', 'address', 'effect-added', 'stop-added',
22
23
  'rule-limit', 'rule-answer', 'rule-new-answer', 'rule-removed-answer', 'rule-facts', 'input-added', 'input-removed',
23
24
  'gives-back-added', 'gives-back-removed', 'gives-back-changed', 'effect-removed', 'effect-changed', 'relies-on', 'hidden',
24
25
  'steps', 'outside', 'added', 'removed', 'thing', 'renamed', 'moved', 'form'];
@@ -534,7 +535,13 @@ function mostlyIn(a, b) {
534
535
  return hit / want.length >= 0.75;
535
536
  }
536
537
 
537
- export function thunderReview(oldFiles, newFiles) {
538
+ /**
539
+ * Review two versions. Thunder Core programs are compared when `core` is given: coreChanges from
540
+ * @skillstech/thunderlang/program (it brings the Core compiler and engine, so this entry stays small without it).
541
+ * `context`: Thunder Core files that did not change but belong to a changed program's project ({ old, new }), so its
542
+ * tests can be run and what uses a change can be found (reviewGit reads them).
543
+ */
544
+ export function thunderReview(oldFiles, newFiles, { core = null, context = null } = {}) {
538
545
  detailsCache = new WeakMap();
539
546
  const A = side(oldFiles || []), B = side(newFiles || []);
540
547
  const items = [];
@@ -587,12 +594,17 @@ export function thunderReview(oldFiles, newFiles) {
587
594
  n.m.kind === 'not-read' ? "New function that Thunder cannot read yet: check the code itself." : `New ${KIND_WORD[n.m.kind] ?? 'function'}: ${subjectOf(n)}${summaryOf(n)}.`, { before: null, after: n.text }));
588
595
  compareThings(A, B, items);
589
596
 
597
+ // Thunder Core programs: rule by rule, with both versions run (core-changes.mjs).
598
+ const coreRead = core ? coreReview(core, oldFiles || [], newFiles || [], context, items) : { paths: new Set(), result: null };
599
+ const corePaths = coreRead.paths;
600
+
590
601
  // Files: code outside every action and rule, files Thunder could not read, and files it does not read.
591
602
  const paths = [...new Set([...A.sources.keys(), ...B.sources.keys()])];
592
603
  const notRead = [];
593
604
  for (const p of paths) {
594
605
  const before = A.sources.get(p), after = B.sources.get(p);
595
606
  if (before === after) continue;
607
+ if (corePaths.has(p)) continue;
596
608
  const lang = !isInfra(p) && readableLanguage(p);
597
609
  if (!lang) {
598
610
  if (isInfra(p)) items.push(item('infrastructure', 'risk', p, { file: p, line: 1 }, `${before == null ? 'New' : after == null ? 'Removed' : 'Changed'} infrastructure or pipeline file. Thunder does not read these in this version, so check it yourself.`, before != null && after != null ? lineChanges(before.split('\n'), after.split('\n')) : null));
@@ -654,7 +666,61 @@ export function thunderReview(oldFiles, newFiles) {
654
666
  const count = (s) => items.filter((x) => x.severity === s).length;
655
667
  const summary = { meaning: count('meaning'), risk: count('risk'), form: count('form'), unchanged, files: paths.filter((p) => A.sources.get(p) !== B.sources.get(p)).length };
656
668
  const onlyNotRead = !items.length && summary.files && notRead.length === summary.files;
657
- return { schema: REVIEW_SCHEMA, summary, says: onlyNotRead ? 'Only files Thunder does not read changed.' : summaryLine(summary), items, notRead };
669
+ const out = { schema: REVIEW_SCHEMA, summary, says: onlyNotRead ? 'Only files Thunder does not read changed.' : summaryLine(summary), items, notRead };
670
+ // The Thunder Core comparison itself (thunder-core-changes-v1), for callers that go on with it (review --services).
671
+ if (coreRead.result) Object.defineProperty(out, 'core', { value: coreRead.result, enumerable: false });
672
+ return out;
673
+ }
674
+
675
+ // The review kind for a Thunder Core change, so it sorts with the changes like it in other languages.
676
+ function coreKind(c) {
677
+ if (c.change === 'not-compiled') return 'unreadable';
678
+ if (c.kind === 'test' && c.severity === 'risk' && c.change !== 'removed') return 'test-fails';
679
+ if (c.change === 'added' || c.change === 'removed' || c.change === 'renamed') return c.kind === 'never' && c.change === 'removed' ? 'stop-removed' : c.change;
680
+ if (c.kind === 'keep') return 'rule-limit';
681
+ if (c.kind === 'function' && c.behaviour?.changed) return 'rule-answer';
682
+ if (c.kind === 'never') return 'stop-changed';
683
+ if (c.kind === 'record' || c.kind === 'store') return 'thing';
684
+ if (c.kind === 'main') return 'outside';
685
+ return 'steps';
686
+ }
687
+ const CORE_SUBJECT = { keep: (c) => `${c.subject} (kept value)`, main: (c) => c.subject };
688
+
689
+ /** Thunder Core changes as review items. Gives the paths it read, so they are not listed as "not read". */
690
+ function coreReview(coreChanges, oldFiles, newFiles, context, items) {
691
+ const core = (fs) => fs.filter((f) => f && isCoreProgram(f.path, f.source));
692
+ const merge = (changed, extra) => { const have = new Set(changed.map((f) => f.path)); return [...changed, ...core(extra ?? []).filter((f) => !have.has(f.path))]; };
693
+ const oldCore = core(oldFiles), newCore = core(newFiles);
694
+ if (!oldCore.length && !newCore.length) return { paths: new Set(), result: null };
695
+ const r = coreChanges(merge(oldCore, context?.old), merge(newCore, context?.new));
696
+ for (const c of r.changes) {
697
+ const look = (c.affects ?? []).slice(0, 6).map((x) => `${x.subject} (\`${x.file}:${x.line}\`${x.test ? `, ${x.test === 'fails' ? '**fails now**' : 'passes'}` : ''})`);
698
+ const more = (c.affects?.length ?? 0) > 6 ? `, and ${c.affects.length - 6} more` : '';
699
+ const says = look.length ? `${c.says} Look again at: ${look.join(', ')}${more}.` : c.says;
700
+ const evidence = c.before || c.after ? { before: c.before, after: c.after } : null;
701
+ items.push(item(coreKind(c), c.severity, (CORE_SUBJECT[c.kind] ?? ((x) => x.subject))(c), { file: c.file, line: c.line }, says, evidence));
702
+ }
703
+ return { paths: new Set([...oldCore, ...newCore].map((f) => f.path)), result: r };
704
+ }
705
+
706
+ /**
707
+ * Add other services to a review (thunder review --services): each Thunder Trace finding with callers in another
708
+ * repository becomes an item that names them, with what changes in the answers when Thunder Core said so. Mutates
709
+ * and gives back the review, with its summary counted again.
710
+ */
711
+ export function addServiceCallers(review, impact) {
712
+ for (const f of impact.findings) {
713
+ if (!f.dependents?.length) continue;
714
+ const who = f.dependents.slice(0, 6).map((d) => `${d.repo}: ${d.label} (\`${d.cite}\`)`).join(', ') + (f.dependents.length > 6 ? `, and ${f.dependents.length - 6} more` : '');
715
+ const what = (f.behaviour ?? []).map((x) => x.says).join(' ');
716
+ review.items.push(item('callers', f.risk === 'high' ? 'risk' : 'meaning', f.at.label, { file: f.at.file, line: f.at.line },
717
+ `${cap(f.says)}. Called from: ${who}.${what ? ` What changes: ${what}` : ''}`));
718
+ }
719
+ review.items.sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity) || KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind)
720
+ || byText(String(a.where.file), String(b.where.file)) || (a.where.line ?? 0) - (b.where.line ?? 0));
721
+ for (const s of ['meaning', 'risk', 'form']) review.summary[s] = review.items.filter((x) => x.severity === s).length;
722
+ review.says = summaryLine(review.summary);
723
+ return review;
658
724
  }
659
725
 
660
726
  const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
package/src/system.mjs CHANGED
@@ -927,7 +927,7 @@ export function serviceFacts(model, files) {
927
927
  return { routes, listeners, requests, publishes, unknown };
928
928
  }
929
929
 
930
- export { segsMatch };
930
+ export { segsMatch, routeSegs, requestTarget };
931
931
 
932
932
  // ── The app's map: which areas call which ────────────────────────────────────────────────────────────
933
933
 
package/src/trace-cli.mjs CHANGED
@@ -4,7 +4,8 @@
4
4
  // thunder trace impact --diff [--base <ref>] <folder…> what the current changes (branch + uncommitted) can affect
5
5
  import { writeFileSync } from 'node:fs';
6
6
  import { buildTrace, renderTrace, traceImpact, traceImpactOf, renderImpact } from './trace.mjs';
7
- import { readRepoDir, gitChanges } from './trace-fs.mjs';
7
+ import { readRepoDir, gitChanges, coreBehaviourOf } from './trace-fs.mjs';
8
+ import { withCoreBehaviour } from './core-changes.mjs';
8
9
 
9
10
  const USAGE = `usage: thunder trace <folder> <folder> … [--json] [--out graph.json]
10
11
  thunder trace impact "<POST /api/orders | event name | table:orders | setting:KEY | package:name | repo:file[:line]>" <folder> … [--json]
@@ -43,11 +44,15 @@ export function traceMain(argv) {
43
44
  return r.matched.length ? 0 : 1;
44
45
  }
45
46
  const changes = [], notes = [];
47
+ const behaviour = new Map();
46
48
  for (const repo of repos) {
47
49
  const g = gitChanges(repo, a.base);
48
- if (!g.base) notes.push(g.why); else changes.push(...g.changes);
50
+ if (!g.base) { notes.push(g.why); continue; }
51
+ changes.push(...g.changes);
52
+ const cc = coreBehaviourOf(repo, g);
53
+ if (cc) behaviour.set(repo.name, cc);
49
54
  }
50
- const r = traceImpact(trace, changes);
55
+ const r = withCoreBehaviour(traceImpact(trace, changes), behaviour);
51
56
  if (a.json) console.log(JSON.stringify({ ...r, notes }, null, 2));
52
57
  else {
53
58
  console.log(`${changes.length ? `${changes.length} changed file${changes.length === 1 ? '' : 's'} across ${new Set(changes.map((c) => c.repo)).size} of ${repos.length} repositories.` : 'No changes found.'}`);
package/src/trace-fs.mjs CHANGED
@@ -5,6 +5,8 @@ import { basename, resolve } from 'node:path';
5
5
  import { statSync } from 'node:fs';
6
6
  import { collectReadableFiles } from './read-repo-fs.mjs';
7
7
  import { thunderModel } from './model.mjs';
8
+ import { coreServiceFacts } from './core-services.mjs';
9
+ import { coreChanges } from './core-changes.mjs';
8
10
  import { serviceFacts } from './system.mjs';
9
11
  import { tablesIn } from './trace-data.mjs';
10
12
 
@@ -25,7 +27,9 @@ export function readRepoDir(dir, { maxFiles = 5000 } = {}) {
25
27
  const dirty = top ? !!git(root, ['status', '--porcelain'])?.trim() : false;
26
28
  // Manifests come too: package.json, go.mod, requirements.txt, and *.csproj say which packages a repository
27
29
  // publishes and depends on (they are not read as code).
28
- return { name: basename(root), root, sha, dirty, files: collectReadableFiles(root, { maxFiles, manifests: true, manifestNames: TRACE_MANIFESTS }) };
30
+ const files = collectReadableFiles(root, { maxFiles, manifests: true, manifestNames: TRACE_MANIFESTS, thunder: true });
31
+ // Thunder Core programs' endpoints and calls, read here so buildTrace (in the small /core entry) needs no compiler.
32
+ return { name: basename(root), root, sha, dirty, files, coreFacts: coreServiceFacts(files) };
29
33
  }
30
34
 
31
35
  /** The commit a branch started from: --base if given, else where HEAD left main/master (origin first), else HEAD. */
@@ -67,6 +71,7 @@ export function gitChanges(repo, base) {
67
71
  if (!byFile.has(file)) byFile.set(file, { file, ranges: [], status: 'added' });
68
72
  }
69
73
  const changes = [];
74
+ const oldSources = new Map();
70
75
  for (const c of byFile.values()) {
71
76
  if (!c.file.startsWith(prefix)) continue;
72
77
  const file = c.file.slice(prefix.length); // paths relative to the folder that was traced
@@ -74,10 +79,31 @@ export function gitChanges(repo, base) {
74
79
  if (c.status !== 'added') {
75
80
  const old = git(dir, ['show', `${b}:${c.file}`]);
76
81
  if (old != null) {
77
- try { const files = [{ path: file, source: old }]; const f = serviceFacts(thunderModel(files), files); before = { routes: f.routes, listeners: f.listeners, publishes: f.publishes, tables: tablesIn(files) }; } catch { before = null; }
82
+ const thunder = /\.thunder$/i.test(file);
83
+ try {
84
+ const files = [{ path: file, source: old }];
85
+ const f = thunder ? { ...coreServiceFacts(files), listeners: [], publishes: [] } : serviceFacts(thunderModel(files), files);
86
+ before = { routes: f.routes, listeners: f.listeners, publishes: f.publishes, tables: thunder ? [] : tablesIn(files) };
87
+ } catch { before = null; }
88
+ // A Thunder Core program's old text, so both versions can be compared (coreBehaviourOf).
89
+ if (thunder) oldSources.set(file, old);
78
90
  }
79
91
  }
80
92
  changes.push({ repo: repo.name, file, ranges: c.ranges, status: c.status, ...(before ? { before } : {}) });
81
93
  }
82
- return { base: b, changes };
94
+ return { base: b, changes, oldSources };
95
+ }
96
+
97
+ /**
98
+ * Both versions of a repository's Thunder Core programs compared (core-changes.mjs; this runs them on the Thunder
99
+ * engine), when any changed: the new side from the folder, the old side with the changed files as they were at the
100
+ * base. Null when no Thunder Core program changed.
101
+ */
102
+ export function coreBehaviourOf(repo, g) {
103
+ const changed = (g.changes ?? []).filter((c) => /\.thunder$/i.test(c.file));
104
+ if (!changed.length) return null;
105
+ const now = repo.files.filter((f) => /\.thunder$/i.test(f.path));
106
+ const gone = new Set(changed.map((c) => c.file));
107
+ const before = [...now.filter((f) => !gone.has(f.path)), ...changed.filter((c) => g.oldSources?.has(c.file)).map((c) => ({ path: c.file, source: g.oldSources.get(c.file) }))];
108
+ return coreChanges(before, now);
83
109
  }
package/src/trace.mjs CHANGED
@@ -49,18 +49,29 @@ const pathMatch = (a, b) => segsMatch(lower(a), lower(b));
49
49
  * Read each repository and link them. repos: [{ name, files: [{ path, source }], sha?, dirty? }].
50
50
  * Gives back thunder-trace-v1: { repos, links, notLinked, rules, fingerprint }.
51
51
  */
52
- export function buildTrace(repos) {
52
+ /**
53
+ * repos: [{ name, files, sha?, dirty?, coreFacts? }]. Thunder Core programs (.thunder) are read when their facts are
54
+ * given: each repository's `coreFacts`, or `core` (coreServiceFacts from core-services.mjs, which brings the Core
55
+ * compiler, so this module stays small without it). readRepoDir gives coreFacts.
56
+ */
57
+ export function buildTrace(repos, { core = null } = {}) {
53
58
  const names = new Set();
54
59
  const read = repos.map((r) => {
55
60
  if (!r.name || names.has(r.name)) throw new Error(`Each repository needs its own name; "${r.name}" is used twice.`);
56
61
  names.add(r.name);
57
- const model = thunderModel(r.files, { name: r.name });
58
- const facts = serviceFacts(model, r.files);
62
+ // .thunder files are read by core-services.mjs below, not as code in another language.
63
+ const other = r.files.filter((f) => !/\.thunder$/i.test(f.path));
64
+ const model = thunderModel(other, { name: r.name });
65
+ const facts = serviceFacts(model, other);
66
+ // Thunder Core programs (.thunder): their endpoints and calls to other services, read by core-services.mjs.
67
+ const cf = r.coreFacts ?? (core ? core(r.files) : { routes: [], requests: [], unknown: [], files: 0 });
68
+ for (const k of ['routes', 'requests', 'unknown']) facts[k] = [...facts[k], ...cf[k]];
69
+ const coreFiles = cf.files;
59
70
  // Test code is not how services talk to each other: a test's fake route or request is never a link.
60
71
  const real = (x) => !isTestFile(x.file);
61
- const data = dataFacts(r.files, model);
72
+ const data = dataFacts(other, model);
62
73
  const testItems = ['routes', 'listeners', 'requests', 'publishes'].reduce((n, k) => n + facts[k].filter((x) => !real(x)).length, 0) + data.testItems;
63
- return { name: r.name, sha: r.sha ?? null, dirty: !!r.dirty, files: model.files.length, languages: [...new Set(model.files.map((f) => f.language))].sort(),
74
+ return { name: r.name, sha: r.sha ?? null, dirty: !!r.dirty, files: model.files.length + coreFiles, languages: [...new Set([...model.files.map((f) => f.language), ...(coreFiles ? ['thunder'] : [])])].sort(),
64
75
  routes: facts.routes.filter(real), listeners: facts.listeners.filter(real), requests: facts.requests.filter(real), publishes: facts.publishes.filter(real), unknown: facts.unknown.filter(real),
65
76
  packages: data.packages, settings: data.settings, tables: data.tables, testItems };
66
77
  });
@@ -229,13 +240,17 @@ export function traceImpact(trace, changes) {
229
240
  if (!repo) continue;
230
241
  const found = findings.length;
231
242
  const hit = (x) => x.file === c.file && (c.status === 'added' || overlaps(x.lines, c.ranges) || within(x.line, c.ranges));
232
- const routes = repo.routes.filter(hit), listeners = repo.listeners.filter(hit);
243
+ // A Thunder Core route is also changed when something it reaches changed (a helper, a kept value): `through` names it.
244
+ const reachHit = (x) => (x.reach ?? []).filter((y) => y.file === c.file && (c.status === 'added' || overlaps(y.lines, c.ranges))).map((y) => y.subject);
245
+ const routes = repo.routes.filter((x) => hit(x) || reachHit(x).length).map((x) => (hit(x) ? x : { ...x, through: reachHit(x) }));
246
+ const listeners = repo.listeners.filter(hit);
233
247
  const requests = repo.requests.filter((x) => x.file === c.file && (c.status === 'added' || within(x.line, c.ranges) || overlaps(x.lines, c.ranges)));
234
248
  const publishes = repo.publishes.filter((x) => x.file === c.file && (c.status === 'added' || within(x.line, c.ranges) || overlaps(x.lines, c.ranges)));
235
249
 
236
250
  for (const r of routes) {
237
251
  const callers = trace.links.filter((l) => l.kind === 'http' && l.to.repo === repo.name && l.to.member === r.member);
238
- findings.push({ risk: callers.length ? 'high' : 'low', kind: 'route-changed', says: callers.length ? `${r.method} ${r.path} changed, and ${count(callers.length, 'caller')} in other repositories ${callers.length === 1 ? 'depends' : 'depend'} on it` : `${r.method} ${r.path} changed; no traced repository calls it`, at: end(repo, r), dependents: callers.map((l) => ({ ...l.from, how: l.base === 'computed' ? 'matched by path; the base address is set when it runs' : l.base === 'this app' ? 'same path from another app' : `through ${l.base}` })) });
252
+ const how = r.through ? ` (through ${r.through.join(', ')}, which changed)` : '';
253
+ findings.push({ risk: callers.length ? 'high' : 'low', kind: 'route-changed', says: callers.length ? `${r.method} ${r.path} changed${how}, and ${count(callers.length, 'caller')} in other repositories ${callers.length === 1 ? 'depends' : 'depend'} on it` : `${r.method} ${r.path} changed${how}; no traced repository calls it`, at: end(repo, r), ...(r.through ? { through: r.through } : {}), dependents: callers.map((l) => ({ ...l.from, how: l.base === 'computed' ? 'matched by path; the base address is set when it runs' : l.base === 'this app' ? 'same path from another app' : `through ${l.base}` })) });
239
254
  }
240
255
  for (const p of publishes) {
241
256
  const ls = trace.links.filter((l) => l.kind === 'event' && l.from.repo === repo.name && l.from.member === p.member && l.event === p.event);
@@ -447,6 +462,7 @@ export function renderImpact(r) {
447
462
  if (r.matched) out.push(`Read "${r.term}" as: ${r.matched.join('; ')}`);
448
463
  for (const f of r.findings) {
449
464
  out.push('', `${f.risk.toUpperCase().padEnd(6)} ${f.at.repo}: ${f.says}`, ` ${f.at.cite}`);
465
+ for (const x of f.behaviour ?? []) out.push(` what changes: ${x.says}`);
450
466
  for (const d of f.dependents) out.push(` ← ${d.repo}: ${d.label} (${d.how}) ${d.cite}`);
451
467
  }
452
468
  return out.join('\n');