@radicaltools/cli 0.4.0 → 0.5.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 (61) hide show
  1. package/README.md +54 -27
  2. package/dist/{chunk-3H4ISGOV.js → chunk-J5ULJOOY.js} +1 -1
  3. package/dist/{dist-5ZBGYT7R.js → dist-TKLLLHVM.js} +2 -2
  4. package/dist/hub-catalogue/concern/concern-api-collections.radical +24 -12
  5. package/dist/hub-catalogue/concern/concern-api-errors.radical +26 -13
  6. package/dist/hub-catalogue/concern/concern-api-evolution.radical +26 -13
  7. package/dist/hub-catalogue/concern/concern-api-idempotency.radical +28 -14
  8. package/dist/hub-catalogue/concern/concern-api-resource-design.radical +24 -12
  9. package/dist/hub-catalogue/concern/concern-api-style-guide.radical +26 -13
  10. package/dist/hub-catalogue/concern/concern-architecture-style.radical +26 -13
  11. package/dist/hub-catalogue/concern/concern-audit-trail.radical +26 -13
  12. package/dist/hub-catalogue/concern/concern-authentication.radical +18 -9
  13. package/dist/hub-catalogue/concern/concern-authorization.radical +34 -17
  14. package/dist/hub-catalogue/concern/concern-availability.radical +20 -10
  15. package/dist/hub-catalogue/concern/concern-backend-stack.radical +16 -8
  16. package/dist/hub-catalogue/concern/concern-backup-recovery.radical +30 -15
  17. package/dist/hub-catalogue/concern/concern-caching.radical +28 -14
  18. package/dist/hub-catalogue/concern/concern-capacity.radical +18 -9
  19. package/dist/hub-catalogue/concern/concern-code-documentation.radical +32 -16
  20. package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +30 -15
  21. package/dist/hub-catalogue/concern/concern-code-review-branching.radical +32 -16
  22. package/dist/hub-catalogue/concern/concern-code-style.radical +24 -12
  23. package/dist/hub-catalogue/concern/concern-communication-style.radical +28 -14
  24. package/dist/hub-catalogue/concern/concern-data-classification.radical +20 -10
  25. package/dist/hub-catalogue/concern/concern-data-consistency.radical +20 -10
  26. package/dist/hub-catalogue/concern/concern-data-store.radical +24 -12
  27. package/dist/hub-catalogue/concern/concern-decomposition.radical +28 -14
  28. package/dist/hub-catalogue/concern/concern-definition-of-done.radical +26 -13
  29. package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +22 -11
  30. package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +28 -14
  31. package/dist/hub-catalogue/concern/concern-deployment.radical +24 -12
  32. package/dist/hub-catalogue/concern/concern-encryption.radical +28 -14
  33. package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +28 -14
  34. package/dist/hub-catalogue/concern/concern-eu-dora.radical +26 -13
  35. package/dist/hub-catalogue/concern/concern-frontend-stack.radical +28 -14
  36. package/dist/hub-catalogue/concern/concern-incident-management.radical +26 -13
  37. package/dist/hub-catalogue/concern/concern-infrastructure.radical +34 -17
  38. package/dist/hub-catalogue/concern/concern-integration-resilience.radical +26 -13
  39. package/dist/hub-catalogue/concern/concern-messaging.radical +18 -9
  40. package/dist/hub-catalogue/concern/concern-module-boundaries.radical +18 -9
  41. package/dist/hub-catalogue/concern/concern-observability.radical +22 -11
  42. package/dist/hub-catalogue/concern/concern-operational-readiness.radical +28 -14
  43. package/dist/hub-catalogue/concern/concern-personal-data.radical +42 -21
  44. package/dist/hub-catalogue/concern/concern-quality-priorities.radical +24 -12
  45. package/dist/hub-catalogue/concern/concern-rate-limiting.radical +30 -15
  46. package/dist/hub-catalogue/concern/concern-release-versioning.radical +28 -14
  47. package/dist/hub-catalogue/concern/concern-retention.radical +28 -14
  48. package/dist/hub-catalogue/concern/concern-secrets.radical +32 -16
  49. package/dist/hub-catalogue/concern/concern-secure-coding.radical +28 -14
  50. package/dist/hub-catalogue/concern/concern-secure-development.radical +26 -13
  51. package/dist/hub-catalogue/concern/concern-security-detection.radical +22 -11
  52. package/dist/hub-catalogue/concern/concern-supply-chain.radical +28 -14
  53. package/dist/hub-catalogue/concern/concern-technical-debt.radical +30 -15
  54. package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +26 -13
  55. package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +26 -13
  56. package/dist/hub-catalogue/concern/concern-test-strategy.radical +26 -13
  57. package/dist/hub-catalogue/concern/concern-threat-modelling.radical +26 -13
  58. package/dist/index.js +1626 -284
  59. package/dist/{pdfjs-I4NKVZXV.js → pdfjs-SWTQBTNZ.js} +1 -1
  60. package/dist/{undici-4Q3DBBHR.js → undici-ZXQJUQQA.js} +1 -1
  61. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  define_RADICAL_BUILD_default,
4
4
  init_define_RADICAL_BUILD
5
- } from "./chunk-3H4ISGOV.js";
5
+ } from "./chunk-J5ULJOOY.js";
6
6
 
7
7
  // src/index.ts
8
8
  init_define_RADICAL_BUILD();
@@ -1082,6 +1082,18 @@ function builtInGovernanceMetamodel() {
1082
1082
  governance: true,
1083
1083
  builtin: true
1084
1084
  };
1085
+ const waives = {
1086
+ id: "waives",
1087
+ layout: { flow: "forward" },
1088
+ label: "Waives",
1089
+ description: "This model's decision says why a decision of a model it depends on does not apply to it.",
1090
+ inverseLabel: "Waived by",
1091
+ allowedPairs: [{ from: "adr", to: "adr" }],
1092
+ properties: [],
1093
+ color: "#f59e0b",
1094
+ governance: true,
1095
+ builtin: true
1096
+ };
1085
1097
  const implements_ = {
1086
1098
  id: "implements",
1087
1099
  layout: { flow: "side" },
@@ -1120,7 +1132,11 @@ function builtInGovernanceMetamodel() {
1120
1132
  { from: "requirement", to: "need" },
1121
1133
  { from: "need", to: "need" }
1122
1134
  ],
1123
- properties: [],
1135
+ properties: [
1136
+ // The words of the need the requirement rests on, verbatim, one fragment
1137
+ // per line (ADR Agents check requirements against the person's words).
1138
+ { key: "quote", label: "Quote", type: "textarea" }
1139
+ ],
1124
1140
  color: "#0d9488",
1125
1141
  governance: true,
1126
1142
  builtin: true
@@ -1593,6 +1609,7 @@ function builtInGovernanceMetamodel() {
1593
1609
  ...base.relationTypes,
1594
1610
  constrains,
1595
1611
  supersedes,
1612
+ waives,
1596
1613
  implements: implements_,
1597
1614
  satisfies,
1598
1615
  derives,
@@ -1652,9 +1669,9 @@ function migrateNodeType(def) {
1652
1669
  function migrateCategory(def) {
1653
1670
  if (def.id !== "fitness-fn" || !def.properties?.some((p) => p.key === "category")) return def;
1654
1671
  const at = def.properties.findIndex((p) => p.key === "category");
1655
- const kept = def.properties.filter((p) => p.key !== "category");
1656
- const missing2 = FITNESS_CLASSIFICATION_PROPERTIES.filter((p) => !kept.some((k) => k.key === p.key));
1657
- const properties2 = [...kept.slice(0, at), ...missing2, ...kept.slice(at)];
1672
+ const kept2 = def.properties.filter((p) => p.key !== "category");
1673
+ const missing2 = FITNESS_CLASSIFICATION_PROPERTIES.filter((p) => !kept2.some((k) => k.key === p.key));
1674
+ const properties2 = [...kept2.slice(0, at), ...missing2, ...kept2.slice(at)];
1658
1675
  const wizard = def.wizard && {
1659
1676
  ...def.wizard,
1660
1677
  steps: def.wizard.steps.map((step) => step.kind === "fields" && step.fields.includes("category") ? { ...step, fields: [...new Set(step.fields.map((f) => f === "category" ? "characteristic" : f))] } : step)
@@ -1664,9 +1681,9 @@ function migrateCategory(def) {
1664
1681
  function migrateOldKeys(def) {
1665
1682
  if (!CHECKED_TYPES.has(def.id) || !def.properties?.some((p) => OLD_KEYS.includes(p.key))) return def;
1666
1683
  const at = def.properties.findIndex((p) => OLD_KEYS.includes(p.key));
1667
- const kept = def.properties.filter((p) => !OLD_KEYS.includes(p.key));
1668
- const missing2 = METRICS_PROPERTIES.filter((p) => !kept.some((k) => k.key === p.key));
1669
- const properties2 = [...kept.slice(0, at), ...missing2, ...kept.slice(at)];
1684
+ const kept2 = def.properties.filter((p) => !OLD_KEYS.includes(p.key));
1685
+ const missing2 = METRICS_PROPERTIES.filter((p) => !kept2.some((k) => k.key === p.key));
1686
+ const properties2 = [...kept2.slice(0, at), ...missing2, ...kept2.slice(at)];
1670
1687
  const wizard = def.wizard && {
1671
1688
  ...def.wizard,
1672
1689
  steps: def.wizard.steps.map((step) => step.kind === "fields" && step.fields.some((f) => OLD_KEYS.includes(f)) ? { ...step, fields: [...new Set(step.fields.map((f) => OLD_KEYS.includes(f) ? "metrics" : f))] } : step)
@@ -2358,17 +2375,17 @@ function propertyText(def, value, nodes) {
2358
2375
  return String(value).trim();
2359
2376
  }
2360
2377
  function relationDetails(relation, def, nodes) {
2361
- const details = [];
2378
+ const details2 = [];
2362
2379
  const label = relation.label?.trim();
2363
- if (label) details.push(label);
2380
+ if (label) details2.push(label);
2364
2381
  const values = relation;
2365
2382
  for (const p of def?.properties ?? []) {
2366
2383
  if (p.type === "enum" && values[p.key] === p.default) continue;
2367
2384
  const text3 = propertyText(p, values[p.key], nodes);
2368
- if (text3) details.push(p.type === "number" ? `${p.label.toLowerCase()} ${text3}` : text3);
2385
+ if (text3) details2.push(p.type === "number" ? `${p.label.toLowerCase()} ${text3}` : text3);
2369
2386
  }
2370
- if (!def && relation.technology?.trim()) details.push(relation.technology.trim());
2371
- return details;
2387
+ if (!def && relation.technology?.trim()) details2.push(relation.technology.trim());
2388
+ return details2;
2372
2389
  }
2373
2390
  function typeNoun(label, plural2 = false) {
2374
2391
  const words = label.trim().split(/\s+/).map((w) => /^[A-Z][a-z]+$/.test(w) ? w.toLowerCase() : w);
@@ -2399,8 +2416,8 @@ function composeEarsSentence(node, subject, statePrecondition) {
2399
2416
  const unwanted = String(node.unwanted_condition ?? "").trim();
2400
2417
  const feature = String(node.feature ?? "").trim();
2401
2418
  const actionPart = action.replace(/\.+$/, "") || "\u2039action\u203A";
2402
- const ownClause = earsActionIsClause(actionPart);
2403
- const shallClause = ownClause ? actionPart.replace(/^(The|A|An)\b/, (w) => w.toLowerCase()) : `${subj} shall ${actionPart}`;
2419
+ const ownClause2 = earsActionIsClause(actionPart);
2420
+ const shallClause = ownClause2 ? actionPart.replace(/^(The|A|An)\b/, (w) => w.toLowerCase()) : `${subj} shall ${actionPart}`;
2404
2421
  let sentence;
2405
2422
  let complete = !!action;
2406
2423
  switch (earsType) {
@@ -2434,7 +2451,7 @@ function composeEarsSentence(node, subject, statePrecondition) {
2434
2451
  break;
2435
2452
  }
2436
2453
  default:
2437
- sentence = ownClause ? `${capitalize(actionPart)}.` : `${capitalize(subj)} shall ${actionPart}.`;
2454
+ sentence = ownClause2 ? `${capitalize(actionPart)}.` : `${capitalize(subj)} shall ${actionPart}.`;
2438
2455
  break;
2439
2456
  }
2440
2457
  return { sentence, complete };
@@ -2525,6 +2542,13 @@ function viewFolderPaths(views) {
2525
2542
  function viewShowsEveryNode(view) {
2526
2543
  return view.nodeIds.length === 0 && !view.empty;
2527
2544
  }
2545
+ var PLACED_FROM = /* @__PURE__ */ new WeakMap();
2546
+ var PLACED_ROOT = /* @__PURE__ */ new WeakMap();
2547
+ function notedPlacesOnly(a2, b) {
2548
+ if (a2 === b || PLACED_FROM.get(b) === a2) return true;
2549
+ const root = PLACED_ROOT.get(b);
2550
+ return root !== void 0 && (root === a2 || root === PLACED_ROOT.get(a2));
2551
+ }
2528
2552
 
2529
2553
  // ../../packages/common/src/model.ts
2530
2554
  init_define_RADICAL_BUILD();
@@ -2719,9 +2743,11 @@ function nodeList(nodes) {
2719
2743
  var nodeLists = /* @__PURE__ */ new WeakMap();
2720
2744
  function pipelineSource(view, ctx) {
2721
2745
  const all = nodeList(ctx.nodes);
2722
- if (!view || viewShowsEveryNode(view)) return all;
2746
+ const scope = view?.originScope;
2747
+ const ofScope = scope ? all.filter((n) => inOriginScope(scope, n)) : all;
2748
+ if (!view || viewShowsEveryNode(view)) return ofScope;
2723
2749
  const ids = new Set(view.nodeIds);
2724
- return all.filter((n) => ids.has(n.id));
2750
+ return ofScope.filter((n) => ids.has(n.id));
2725
2751
  }
2726
2752
  function runChain(source, raw, ctx) {
2727
2753
  const pipeline = readPipeline(raw);
@@ -2730,7 +2756,7 @@ function runChain(source, raw, ctx) {
2730
2756
  if (!levels.length) return { source, relationIds: /* @__PURE__ */ new Set(), levels: [], rows: null, nodes: sortNodes(source, sort, ctx) };
2731
2757
  const inSource = new Set(source.map((n) => n.id));
2732
2758
  const results = [];
2733
- const kept = [];
2759
+ const kept2 = [];
2734
2760
  let above = [];
2735
2761
  levels.forEach((level, i) => {
2736
2762
  const seen = /* @__PURE__ */ new Map();
@@ -2745,7 +2771,7 @@ function runChain(source, raw, ctx) {
2745
2771
  const candidates = [...seen.values()];
2746
2772
  const { nodes: nodes2, counts } = applyFilters(candidates, level.filters, ctx);
2747
2773
  results.push({ candidates: candidates.length, input: candidates, counts, shown: sortNodes(nodes2, sort, ctx) });
2748
- kept.push(new Set(nodes2.map((n) => n.id)));
2774
+ kept2.push(new Set(nodes2.map((n) => n.id)));
2749
2775
  above = nodes2;
2750
2776
  });
2751
2777
  const rows = [];
@@ -2755,7 +2781,7 @@ function runChain(source, raw, ctx) {
2755
2781
  const childrenOf2 = (node, at) => {
2756
2782
  const kids = /* @__PURE__ */ new Map();
2757
2783
  for (const way of levels[at]?.ways ?? []) {
2758
- for (const n of followWay(node, way, ctx)) if (kept[at].has(n.id)) kids.set(n.id, n);
2784
+ for (const n of followWay(node, way, ctx)) if (kept2[at].has(n.id)) kids.set(n.id, n);
2759
2785
  const via = way.via;
2760
2786
  if (via && "anyRelation" in via) {
2761
2787
  for (const r of index.out.get(node.id) ?? []) if (kids.has(r.targetId) && ofTypes(way, ctx.nodes[r.targetId])) relationIds.add(r.id);
@@ -2791,7 +2817,10 @@ function viewShownNodes(view, nodes, relations) {
2791
2817
  const cacheable = Object.isFrozen(nodes) && Object.isFrozen(relations) && Object.isFrozen(view.nodeIds);
2792
2818
  if (cacheable) {
2793
2819
  const hit = shownCache.get(view.nodeIds);
2794
- if (hit && hit.relations === relations && hit.pipeline === view.pipeline && hit.kind === view.kind && hit.empty === view.empty && sameForChain(hit.nodes, nodes, chainKeys(view.pipeline))) return hit.shown;
2820
+ if (hit && hit.relations === relations && hit.pipeline === view.pipeline && hit.kind === view.kind && hit.empty === view.empty && sameForChain(hit.nodes, nodes, chainKeys(view.pipeline))) {
2821
+ hit.nodes = nodes;
2822
+ return hit.shown;
2823
+ }
2795
2824
  }
2796
2825
  let shown3;
2797
2826
  if (view.originScope) {
@@ -2802,12 +2831,15 @@ function viewShownNodes(view, nodes, relations) {
2802
2831
  return shown3;
2803
2832
  }
2804
2833
  function scopedTo(scope, nodes, relations) {
2805
- const inScope = (item) => !!item.origin && scope.includes(item.origin.slice(0, item.origin.lastIndexOf("@")));
2834
+ const inScope = (item) => inOriginScope(scope, item);
2806
2835
  return [
2807
2836
  Object.fromEntries(Object.entries(nodes).filter(([, n]) => inScope(n))),
2808
2837
  Object.fromEntries(Object.entries(relations).filter(([, r]) => inScope(r)))
2809
2838
  ];
2810
2839
  }
2840
+ function inOriginScope(scope, item) {
2841
+ return !!item.origin && scope.includes(item.origin.slice(0, item.origin.lastIndexOf("@")));
2842
+ }
2811
2843
  var shownCache = /* @__PURE__ */ new WeakMap();
2812
2844
  function chainKeys(pipeline) {
2813
2845
  if (!pipeline || typeof pipeline !== "object") return BASE_KEYS;
@@ -2834,6 +2866,7 @@ var BASE_KEYS = "type,parentId";
2834
2866
  var keysOfChain = /* @__PURE__ */ new WeakMap();
2835
2867
  function sameForChain(a2, b, keys) {
2836
2868
  if (a2 === b) return true;
2869
+ if (!PLACE_KEY.test(keys) && notedPlacesOnly(a2, b)) return true;
2837
2870
  let byB = sameAnswers.get(a2);
2838
2871
  if (!byB) sameAnswers.set(a2, byB = /* @__PURE__ */ new WeakMap());
2839
2872
  let byKeys = byB.get(b);
@@ -2845,6 +2878,7 @@ function sameForChain(a2, b, keys) {
2845
2878
  return same;
2846
2879
  }
2847
2880
  var sameAnswers = /* @__PURE__ */ new WeakMap();
2881
+ var PLACE_KEY = /(^|,)(x|y|width|height)(,|$)/;
2848
2882
  function compareFor(a2, b, keys) {
2849
2883
  const listA = nodeList(a2);
2850
2884
  const listB = nodeList(b);
@@ -3507,9 +3541,17 @@ function dirname(path) {
3507
3541
  return idx === -1 ? "" : path.slice(0, idx);
3508
3542
  }
3509
3543
 
3544
+ // ../../packages/common/src/modelFolders.ts
3545
+ init_define_RADICAL_BUILD();
3546
+ var RADICAL_DIR = ".radical";
3547
+ var MODEL_FOLDER = `${RADICAL_DIR}/model`;
3548
+ var OLD_MODEL_FOLDER = "architecture";
3549
+
3510
3550
  // ../../packages/common/src/repositoryMapping.ts
3511
3551
  init_define_RADICAL_BUILD();
3512
3552
  var REPOSITORY_FILE = ".radical/radical.json";
3553
+ var others = (value, known) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter(([k]) => !known.includes(k))) : {};
3554
+ var TOP_KEYS = ["model", "tests", "ci", "implements", "verifies"];
3513
3555
  var strings = (v) => typeof v === "string" ? [v] : Array.isArray(v) && v.every((x) => typeof x === "string") ? v : null;
3514
3556
  function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
3515
3557
  let raw;
@@ -3528,7 +3570,7 @@ function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
3528
3570
  const value = raw?.[key];
3529
3571
  if (value === void 0) return void 0;
3530
3572
  if (!value || typeof value !== "object") throw new Error(`${file}: "${key}" is no object`);
3531
- const out = {};
3573
+ const out = others(value, lists);
3532
3574
  for (const list2 of lists) {
3533
3575
  const v = value[list2];
3534
3576
  if (v === void 0) continue;
@@ -3545,33 +3587,36 @@ function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
3545
3587
  throw new Error(`${file}: "model" needs "repo" (the address of the model's repository), and "ref" is a branch or tag`);
3546
3588
  }
3547
3589
  return {
3548
- ...model ? { model: { repo: model.repo, ...model.ref ? { ref: model.ref } : {} } } : {},
3590
+ ...others(raw, TOP_KEYS),
3591
+ ...model ? { model: { repo: model.repo, ...model.ref ? { ref: model.ref } : {}, ...others(model, ["repo", "ref"]) } } : {},
3549
3592
  ...tests ? { tests } : {},
3550
3593
  ...ci ? { ci } : {},
3551
3594
  implements: list("implements").map((e2, i) => {
3552
3595
  const paths = strings(e2?.paths);
3553
3596
  if (typeof e2?.element !== "string" || !e2.element || !paths) throw new Error(`${file}: implements[${i}] needs "element" (an id) and "paths" (a list of folders)`);
3554
- return { element: e2.element, ...name(e2), paths };
3597
+ return { element: e2.element, ...name(e2), paths, ...others(e2, ["element", "name", "paths"]) };
3555
3598
  }),
3556
3599
  verifies: list("verifies").map((e2, i) => {
3557
3600
  const tests2 = strings(e2?.tests);
3558
3601
  if (typeof e2?.element !== "string" || !e2.element || !tests2) throw new Error(`${file}: verifies[${i}] needs "element" (an id) and "tests" (a list of test ids)`);
3559
- return { element: e2.element, ...name(e2), tests: tests2 };
3602
+ return { element: e2.element, ...name(e2), tests: tests2, ...others(e2, ["element", "name", "tests"]) };
3560
3603
  })
3561
3604
  };
3562
3605
  }
3563
3606
  function serializeRepositoryFile(file) {
3607
+ const inline = (v) => Array.isArray(v) ? `[${v.map(inline).join(", ")}]` : v && typeof v === "object" ? Object.keys(v).length ? `{ ${Object.entries(v).filter(([, x]) => x !== void 0).map(([k, x]) => `${JSON.stringify(k)}: ${inline(x)}`).join(", ")} }` : "{}" : JSON.stringify(v);
3608
+ const more = (v, known) => Object.entries(others(v, known)).filter(([, x]) => x !== void 0).map(([k, x]) => `, ${JSON.stringify(k)}: ${inline(x)}`).join("");
3564
3609
  const head = (m) => `"element": ${JSON.stringify(m.element)}${m.name !== void 0 ? `, "name": ${JSON.stringify(m.name)}` : ""}`;
3565
- const implemented = file.implements.map((m) => ` { ${head(m)}, "paths": [${m.paths.map((p) => JSON.stringify(p)).join(", ")}] }`);
3610
+ const implemented = file.implements.map((m) => ` { ${head(m)}, "paths": [${m.paths.map((p) => JSON.stringify(p)).join(", ")}]${more(m, ["element", "name", "paths"])} }`);
3566
3611
  const verified = file.verifies.map((v) => ` { ${head(v)}, "tests": [${v.tests.length ? `
3567
3612
  ${v.tests.map((t) => ` ${JSON.stringify(t)}`).join(",\n")}
3568
- ` : ""}] }`);
3613
+ ` : ""}]${more(v, ["element", "name", "tests"])} }`);
3569
3614
  const section = (key, lines) => ` "${key}": [${lines.length ? `
3570
3615
  ${lines.join(",\n")}
3571
3616
  ` : ""}]`;
3572
- const inline = (v) => `{ ${Object.entries(v).map(([k, list]) => `${JSON.stringify(k)}: [${list.map((x) => JSON.stringify(x)).join(", ")}]`).join(", ")} }`;
3573
3617
  const settings = [
3574
- ...file.model ? [` "model": { ${Object.entries(file.model).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`).join(", ")} }`] : [],
3618
+ ...Object.entries(others(file, TOP_KEYS)).filter(([, v]) => v !== void 0).map(([k, v]) => ` ${JSON.stringify(k)}: ${inline(v)}`),
3619
+ ...file.model ? [` "model": ${inline(file.model)}`] : [],
3575
3620
  ...file.tests ? [` "tests": ${inline(file.tests)}`] : [],
3576
3621
  ...file.ci ? [` "ci": ${inline(file.ci)}`] : []
3577
3622
  ];
@@ -3635,9 +3680,6 @@ function repositoryPart(data, mapped) {
3635
3680
  }
3636
3681
 
3637
3682
  // ../../packages/node-files/src/repositoryLayout.ts
3638
- var RADICAL_DIR = ".radical";
3639
- var MODEL_FOLDER = `${RADICAL_DIR}/model`;
3640
- var OLD_MODEL_FOLDER = "architecture";
3641
3683
  var SENSORS_FILE = `${RADICAL_DIR}/sensors/sensors.json`;
3642
3684
  var OLD_SENSORS_FILE = "radical.sensors.json";
3643
3685
  var CRUCIBLE_FILE = `${RADICAL_DIR}/crucible/crucible.json`;
@@ -3701,6 +3743,12 @@ async function mappingRoot(folder) {
3701
3743
  const at = resolve(folder);
3702
3744
  return await repositoryRoot(at) ?? (basename(dirname2(at)) === RADICAL_DIR ? dirname2(dirname2(at)) : dirname2(at));
3703
3745
  }
3746
+ async function repositoryFileOf(folder) {
3747
+ const found = await findRepositoryFile(folder, REPOSITORY_FILE, REPOSITORY_FILE);
3748
+ if (found) return { file: found.path, root: repositoryFileRoot(found.path) };
3749
+ const root = await mappingRoot(folder);
3750
+ return { file: join(root, REPOSITORY_FILE), root };
3751
+ }
3704
3752
  async function readRepositoryMapping(from) {
3705
3753
  const found = await findRepositoryFile(from, REPOSITORY_FILE, REPOSITORY_FILE);
3706
3754
  if (!found) return null;
@@ -4251,6 +4299,20 @@ var FORGE_RUN_FILE = `${STATE_DIR}/forge-run.json`;
4251
4299
  var FORGE_RUN_STALE_MS = 30 * 60 * 1e3;
4252
4300
  var STAGE_IDS = new Set(FORGE_STAGES.map((s2) => s2.id));
4253
4301
 
4302
+ // ../../packages/common/src/formats/assayRunStatus.ts
4303
+ init_define_RADICAL_BUILD();
4304
+ var ASSAY_RUN_FILE = `${STATE_DIR}/assay-run.json`;
4305
+ var ASSAY_STAGES = [
4306
+ { id: "c4", title: "C4 model", short: "C4" },
4307
+ { id: "explore", title: "Explore", short: "Explore" },
4308
+ { id: "documents", title: "Documents", short: "Documents" },
4309
+ { id: "domain", title: "Domain", short: "Domain" },
4310
+ { id: "processes", title: "Processes", short: "Processes" },
4311
+ { id: "states", title: "State machines", short: "States" },
4312
+ { id: "scenarios", title: "Scenarios", short: "Scenarios" }
4313
+ ];
4314
+ var STAGE_IDS2 = new Set(ASSAY_STAGES.map((s2) => s2.id));
4315
+
4254
4316
  // ../../packages/common/src/check/index.ts
4255
4317
  init_define_RADICAL_BUILD();
4256
4318
 
@@ -4262,7 +4324,30 @@ init_define_RADICAL_BUILD();
4262
4324
 
4263
4325
  // ../../packages/common/src/check/reports.ts
4264
4326
  init_define_RADICAL_BUILD();
4327
+ var MESSAGE_LINES = 12;
4328
+ var MESSAGE_CHARS = 2e3;
4329
+ var ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
4330
+ function failureMessage(text3) {
4331
+ if (typeof text3 !== "string") return void 0;
4332
+ const lines = text3.replace(ANSI, "").replace(/\r\n?/g, "\n").split("\n");
4333
+ while (lines.length && !lines[0].trim()) lines.shift();
4334
+ while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
4335
+ if (!lines.length) return void 0;
4336
+ let kept2 = lines.slice(0, MESSAGE_LINES).join("\n");
4337
+ if (kept2.length > MESSAGE_CHARS) kept2 = kept2.slice(0, MESSAGE_CHARS);
4338
+ return kept2.length < lines.join("\n").length ? `${kept2}
4339
+ \u2026` : kept2;
4340
+ }
4341
+ var details = (message, durationMs, line) => {
4342
+ const m = failureMessage(message);
4343
+ return {
4344
+ ...m ? { message: m } : {},
4345
+ ...typeof durationMs === "number" && Number.isFinite(durationMs) && durationMs >= 0 ? { durationMs: Math.round(durationMs) } : {},
4346
+ ...typeof line === "number" && Number.isInteger(line) && line > 0 ? { line } : {}
4347
+ };
4348
+ };
4265
4349
  var SEPARATOR = /\s+›\s+/;
4350
+ var ASCII_SEPARATOR = /\s+>\s+/;
4266
4351
  var JUNIT_SEPARATOR = /\s+[›>]\s+/;
4267
4352
  var normalize = (path) => path.replace(/\\/g, "/").replace(/^\.\//, "");
4268
4353
  function parseTestReport(content, name) {
@@ -4283,10 +4368,14 @@ function parseJestJson(report) {
4283
4368
  const cases = [];
4284
4369
  for (const file of report.testResults) {
4285
4370
  for (const a2 of file.assertionResults ?? []) {
4371
+ const status = a2.status === "passed" ? "passed" : a2.status === "failed" ? "failed" : "skipped";
4372
+ const messages = Array.isArray(a2.failureMessages) ? a2.failureMessages.filter((m) => typeof m === "string") : [];
4286
4373
  cases.push({
4287
4374
  file: normalize(file.name),
4288
4375
  title: [...a2.ancestorTitles ?? [], a2.title],
4289
- status: a2.status === "passed" ? "passed" : a2.status === "failed" ? "failed" : "skipped"
4376
+ status,
4377
+ // Vitest writes the location only with includeTaskLocation.
4378
+ ...details(status === "failed" ? messages.join("\n") : void 0, a2.duration, a2.location?.line)
4290
4379
  });
4291
4380
  }
4292
4381
  }
@@ -4299,11 +4388,16 @@ function parsePlaywrightJson(report) {
4299
4388
  const walk = (suite, titles, file) => {
4300
4389
  for (const spec of suite.specs ?? []) {
4301
4390
  const statuses = (spec.tests ?? []).map((t) => t.status);
4391
+ const status = statuses.includes("unexpected") ? "failed" : statuses.length && statuses.every((s2) => s2 === "skipped") ? "skipped" : "passed";
4392
+ const last = (spec.tests ?? []).map((t) => t.results?.[t.results.length - 1]).filter((r) => !!r);
4393
+ const failedTry = (spec.tests ?? []).filter((t) => t.status === "unexpected").map((t) => t.results?.[t.results.length - 1]).find((r) => r);
4394
+ const message = failedTry ? failedTry.error?.message ?? failedTry.errors?.find((e2) => e2.message)?.message : void 0;
4395
+ const durations = last.map((r) => r.duration).filter((d) => typeof d === "number");
4302
4396
  cases.push({
4303
4397
  file: root ? `${root}/${normalize(spec.file ?? file)}` : normalize(spec.file ?? file),
4304
4398
  title: [...titles, spec.title],
4305
- // One test per project (browser); a spec fails when any of them did.
4306
- status: statuses.includes("unexpected") ? "failed" : statuses.length && statuses.every((s2) => s2 === "skipped") ? "skipped" : "passed"
4399
+ status,
4400
+ ...details(status === "failed" ? message : void 0, durations.length ? Math.max(...durations) : void 0, spec.line)
4307
4401
  });
4308
4402
  }
4309
4403
  for (const child of suite.suites ?? []) walk(child, [...titles, child.title], file);
@@ -4321,29 +4415,86 @@ function parseJUnit(xml2) {
4321
4415
  const body = m[3] ?? "";
4322
4416
  const file = attrs.file ?? attrs.classname ?? "";
4323
4417
  const title = (attrs.name ?? "").split(JUNIT_SEPARATOR);
4418
+ const failure = /<(failure|error)\b([^>]*?)(\/>|>([\s\S]*?)<\/\1>)/.exec(body);
4419
+ const raw = failure?.[4] ?? "";
4420
+ const text3 = /<!\[CDATA\[/.test(raw) ? raw.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1") : unescapeXml(raw);
4421
+ const message = failure ? text3.trim() ? text3 : attributes(failure[2]).message : void 0;
4422
+ const seconds = attrs.time !== void 0 ? Number(attrs.time) : void 0;
4423
+ const line = attrs.line !== void 0 ? Number(attrs.line) : void 0;
4324
4424
  cases.push({
4325
4425
  file: normalize(file),
4326
4426
  title,
4327
- status: /<(failure|error)\b/.test(body) ? "failed" : /<skipped\b/.test(body) ? "skipped" : "passed"
4427
+ status: failure ? "failed" : /<skipped\b/.test(body) ? "skipped" : "passed",
4428
+ ...details(message, seconds !== void 0 ? seconds * 1e3 : void 0, line)
4328
4429
  });
4329
4430
  }
4330
4431
  return cases;
4331
4432
  }
4433
+ var RUNNER_PREFIX = /^(?:(?:\[[^\]]*\]|\|[^|]*\|)(?:\s+|$))+/;
4434
+ var FILE_LOCATION = /:\d+(?::\d+)?$/;
4435
+ function testIdParts(raw) {
4436
+ const parts2 = raw.split(SEPARATOR.test(raw) ? SEPARATOR : ASCII_SEPARATOR).map((part) => part.trim());
4437
+ const file = parts2[0].replace(RUNNER_PREFIX, "");
4438
+ if (!file && parts2.length > 1) parts2.shift();
4439
+ else parts2[0] = file;
4440
+ parts2[0] = parts2[0].replace(FILE_LOCATION, "");
4441
+ return parts2;
4442
+ }
4443
+ var canonicalTestId = (raw) => testIdParts(raw.trim()).filter(Boolean).join(" \u203A ");
4444
+ function rebindTests(bound, adds, drops) {
4445
+ const dropped = new Set(drops.map(canonicalTestId));
4446
+ const seen = /* @__PURE__ */ new Set();
4447
+ const tests = [];
4448
+ for (const [test, id] of [...bound.map((t) => [t, canonicalTestId(t)]), ...adds.map((t) => [canonicalTestId(t), canonicalTestId(t)])]) {
4449
+ if (!id || dropped.has(id) || seen.has(id)) continue;
4450
+ seen.add(id);
4451
+ tests.push(test);
4452
+ }
4453
+ return tests;
4454
+ }
4332
4455
  function parseTestIds(text3) {
4333
4456
  if (typeof text3 !== "string") return [];
4334
4457
  return text3.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((raw) => {
4335
- const [file, ...title] = raw.split(SEPARATOR);
4458
+ const [file, ...title] = testIdParts(raw);
4336
4459
  return { raw, file: normalize(file), title };
4337
4460
  });
4338
4461
  }
4339
4462
  var fileMatches = (reportFile, idFile) => reportFile === idFile || reportFile.endsWith("/" + idFile) || idFile.endsWith("/" + reportFile);
4340
4463
  function findTests(id, cases) {
4464
+ let found = FOUND.get(cases);
4465
+ if (!found) {
4466
+ found = /* @__PURE__ */ new Map();
4467
+ FOUND.set(cases, found);
4468
+ }
4469
+ const key = `${id.file}\0${id.title.join("\0")}`;
4470
+ let result = found.get(key);
4471
+ if (!result) {
4472
+ result = findTestsIn(id, cases);
4473
+ found.set(key, result);
4474
+ }
4475
+ return result;
4476
+ }
4477
+ var FOUND = /* @__PURE__ */ new WeakMap();
4478
+ var BY_NAME = /* @__PURE__ */ new WeakMap();
4479
+ var baseName = (file) => file.slice(file.lastIndexOf("/") + 1);
4480
+ function findTestsIn(id, cases) {
4341
4481
  const n = id.title.length;
4342
4482
  if (!n) {
4343
4483
  const under = cases.filter((c) => fileMatches(c.file, id.file) || c.file.includes(`/${id.file.replace(/\/$/, "")}/`) || c.file.startsWith(`${id.file.replace(/\/$/, "")}/`));
4344
4484
  return { fileSeen: under.length > 0, matches: under };
4345
4485
  }
4346
- const inFile = cases.filter((c) => fileMatches(c.file, id.file));
4486
+ let byName = BY_NAME.get(cases);
4487
+ if (!byName) {
4488
+ byName = /* @__PURE__ */ new Map();
4489
+ for (const c of cases) {
4490
+ const name = baseName(c.file);
4491
+ const list = byName.get(name);
4492
+ if (list) list.push(c);
4493
+ else byName.set(name, [c]);
4494
+ }
4495
+ BY_NAME.set(cases, byName);
4496
+ }
4497
+ const inFile = (byName.get(baseName(id.file)) ?? []).filter((c) => fileMatches(c.file, id.file));
4347
4498
  const key = id.title.join(" \u203A ");
4348
4499
  const tail = inFile.filter((c) => c.title.length >= n && c.title.slice(-n).join(" \u203A ") === key);
4349
4500
  const matches = tail.length ? tail : inFile.filter((c) => c.title.length > n && c.title.slice(0, n).join(" \u203A ") === key);
@@ -4565,17 +4716,18 @@ var BOUND_TESTS = "boundTests";
4565
4716
  function withBoundTests(nodes, verifies) {
4566
4717
  if (!verifies?.length) return nodes;
4567
4718
  const bound = /* @__PURE__ */ new Map();
4568
- for (const v of verifies) bound.set(v.element, [...bound.get(v.element) ?? [], ...v.tests]);
4719
+ for (const v of verifies) bound.set(v.element, rebindTests([...bound.get(v.element) ?? [], ...v.tests], [], []));
4569
4720
  return nodes.map((n) => bound.has(n.id) ? { ...n, [BOUND_TESTS]: bound.get(n.id) } : n);
4570
4721
  }
4571
- var conditionsOf = (node) => {
4722
+ var boundConditions = (node) => {
4572
4723
  const bound = node[BOUND_TESTS];
4573
- return [
4574
- ...parseConditions(node.metrics),
4575
- ...Array.isArray(bound) ? bound.map((id) => parseCondition(`test(${id}) passed`)) : []
4576
- ];
4724
+ return Array.isArray(bound) ? bound.map((id) => parseCondition(`test(${id}) passed`)) : [];
4577
4725
  };
4578
- var testIdsOf = (node) => conditionsOf(node).flatMap((c) => c.kind === "test" ? [c.id] : []);
4726
+ var conditionsOf = (node) => [
4727
+ ...parseConditions(node.metrics),
4728
+ ...boundConditions(node)
4729
+ ];
4730
+ var testIdsOf = (node) => (originOf(node) ? boundConditions(node) : conditionsOf(node)).flatMap((c) => c.kind === "test" ? [c.id] : []);
4579
4731
  var testOutcome = (id, model) => {
4580
4732
  const { fileSeen, matches } = findTests(id, model.tests ?? []);
4581
4733
  return matches.length ? outcomeOf(matches) : fileSeen ? "not-found" : "not-run";
@@ -4594,6 +4746,7 @@ function conditionResults(node, model, element) {
4594
4746
  return { condition: c.raw, outcome: e2.outcome, ...e2.measurement ? { measurement: e2.measurement } : {}, ...e2.detail ? { detail: e2.detail } : {} };
4595
4747
  });
4596
4748
  }
4749
+ var boundResults = (node, model) => boundConditions(node).map((c) => c.kind === "test" ? { condition: c.raw, test: c.id.raw, outcome: testOutcome(c.id, model) } : { condition: c.raw, outcome: "invalid", ...c.kind === "invalid" ? { detail: c.problem } : {} });
4597
4750
  var PASSED = (o) => o === "passed";
4598
4751
  var FAILING = (o) => o === "failed" || o === "not-found" || o === "invalid";
4599
4752
  function checkedStatus(outcomes, combine = { kind: "all" }) {
@@ -4629,8 +4782,34 @@ function combineElements(statuses) {
4629
4782
  if (statuses.every((s2) => s2 === "passed")) return "passed";
4630
4783
  return statuses.includes("stale") ? "stale" : "not-run";
4631
4784
  }
4785
+ var RELATION_INDEX = /* @__PURE__ */ new WeakMap();
4786
+ var NO_RELATIONS = { from: /* @__PURE__ */ new Map(), to: /* @__PURE__ */ new Map() };
4787
+ function relationsOf(model, type2) {
4788
+ let byType = RELATION_INDEX.get(model.relations);
4789
+ if (!byType) {
4790
+ const built = /* @__PURE__ */ new Map();
4791
+ for (const r of Object.values(model.relations)) {
4792
+ if (r.relationType === void 0) continue;
4793
+ let index = built.get(r.relationType);
4794
+ if (!index) {
4795
+ index = { from: /* @__PURE__ */ new Map(), to: /* @__PURE__ */ new Map() };
4796
+ built.set(r.relationType, index);
4797
+ }
4798
+ const from = index.from.get(r.sourceId);
4799
+ if (from) from.push(r);
4800
+ else index.from.set(r.sourceId, [r]);
4801
+ const to2 = index.to.get(r.targetId);
4802
+ if (to2) to2.push(r);
4803
+ else index.to.set(r.targetId, [r]);
4804
+ }
4805
+ byType = built;
4806
+ RELATION_INDEX.set(model.relations, byType);
4807
+ }
4808
+ return byType.get(type2) ?? NO_RELATIONS;
4809
+ }
4632
4810
  function linkedNodes(model, id, relationType, end, type2) {
4633
- return Object.values(model.relations).filter((r) => r.relationType === relationType && (end === "source" ? r.targetId : r.sourceId) === id).map((r) => model.nodes[end === "source" ? r.sourceId : r.targetId]).filter((n) => !!n && (!type2 || n.type === type2));
4811
+ const index = relationsOf(model, relationType);
4812
+ return ((end === "source" ? index.to.get(id) : index.from.get(id)) ?? []).map((r) => model.nodes[end === "source" ? r.sourceId : r.targetId]).filter((n) => !!n && (!type2 || n.type === type2));
4634
4813
  }
4635
4814
  function computeEvidence(model) {
4636
4815
  const nodes = {};
@@ -4641,14 +4820,15 @@ function computeEvidence(model) {
4641
4820
  const conditions2 = elementConditions(node, model, element);
4642
4821
  return { id: element.id, label: element.label, status: checkedStatus(conditions2, combineOf(node)), conditions: conditions2 };
4643
4822
  });
4644
- if (origin && !elements.length) continue;
4645
- const conditions = elements.length ? origin ? [] : conditionResults(node, model).filter((r) => r.test) : conditionResults(node, model);
4823
+ const bound = origin ? boundResults(node, model) : [];
4824
+ if (origin && !elements.length && !bound.length) continue;
4825
+ const conditions = origin ? bound : elements.length ? conditionResults(node, model).filter((r) => r.test) : conditionResults(node, model);
4646
4826
  const own = elements.length && conditions.length ? [checkedStatus(conditions)] : [];
4647
4827
  nodes[node.id] = {
4648
4828
  type: node.type,
4649
4829
  label: node.label,
4650
- status: elements.length ? combineElements([...own, ...elements.map((e2) => e2.status)]) : checkedStatus(conditions, combineOf(node)),
4651
- tests: origin ? [] : testOutcomes(node, model).map((o) => ({ id: o.id.raw, outcome: o.outcome })),
4830
+ status: elements.length ? combineElements([...own, ...elements.map((e2) => e2.status)]) : checkedStatus(conditions, origin ? void 0 : combineOf(node)),
4831
+ tests: testOutcomes(node, model).map((o) => ({ id: o.id.raw, outcome: o.outcome })),
4652
4832
  conditions,
4653
4833
  ...elements.length ? { elements } : {},
4654
4834
  ...origin ? { origin } : {}
@@ -5027,39 +5207,33 @@ function searchModel(data, query) {
5027
5207
  }
5028
5208
  const scope = parsed.scope;
5029
5209
  const inScope = (id) => !scope?.nodes || scope.nodes.has(id);
5210
+ const narrow = narrowing(data, parsed);
5211
+ if (!narrow) fullScans++;
5212
+ const foundElements = [];
5213
+ const foundRelations = [];
5030
5214
  if (wants(parsed, "element")) {
5031
- for (const n of Object.values(data.nodes)) {
5215
+ for (const n of narrow?.elements ?? Object.values(data.nodes)) {
5032
5216
  if (!inScope(n.id)) continue;
5033
5217
  if (parsed.types && !parsed.types.includes(n.type)) continue;
5034
5218
  const props = propertyFields(n, mm);
5035
5219
  if (parsed.properties.length && !parsed.properties.every((p) => props.some((f) => f.key === p.key && foldText(f.text).includes(p.value)))) continue;
5036
- const hit = hitFor([
5037
- { text: n.label || typeName(n.type), weight: 3, label: true },
5038
- { text: typeName(n.type), weight: 1.2 },
5039
- { text: n.technology ?? "", weight: 1.5, name: "Technology" },
5040
- { text: n.description ?? "", weight: 1, name: "Description", snippet: true },
5041
- ...props.map((p) => ({ text: p.text, weight: 1, name: p.name, snippet: true }))
5042
- ], parsed, true);
5220
+ const hit = hitFor(elementFields(n, mm, props), parsed, true);
5043
5221
  if (!hit) continue;
5222
+ foundElements.push(n);
5044
5223
  const path = pathOf(data.nodes, n.id);
5045
5224
  push({ kind: "element", id: n.id, label: n.label || typeName(n.type), detail: [typeName(n.type), path].filter(Boolean).join(" \xB7 "), type: n.type, ...hit });
5046
5225
  }
5047
5226
  }
5048
5227
  if (wants(parsed, "relation") && !parsed.types && !parsed.properties.length) {
5049
- for (const r of Object.values(data.relations)) {
5228
+ for (const r of narrow?.relations ?? Object.values(data.relations)) {
5050
5229
  const src = data.nodes[r.sourceId];
5051
5230
  const tgt = data.nodes[r.targetId];
5052
5231
  if (!src || !tgt || !inScope(r.sourceId) || !inScope(r.targetId)) continue;
5053
5232
  const label = r.label || `${src.label} \u2192 ${tgt.label}`;
5054
5233
  const kindName = r.relationType ? mm?.relationTypes[r.relationType]?.label ?? r.relationType : "";
5055
- const hit = hitFor([
5056
- { text: label, weight: 3, label: true },
5057
- { text: src.label, weight: 1.5 },
5058
- { text: tgt.label, weight: 1.5 },
5059
- { text: r.technology ?? "", weight: 1.5, name: "Technology" },
5060
- { text: kindName, weight: 1 }
5061
- ], parsed, false);
5234
+ const hit = hitFor(relationFields(r, src, tgt, mm), parsed, false);
5062
5235
  if (!hit) continue;
5236
+ foundRelations.push(r);
5063
5237
  push({ kind: "relation", id: r.id, label, detail: [kindName, `${src.label} \u2192 ${tgt.label}`].filter(Boolean).join(" \xB7 "), ...hit, score: hit.score - 2 });
5064
5238
  }
5065
5239
  }
@@ -5094,8 +5268,39 @@ function searchModel(data, query) {
5094
5268
  }
5095
5269
  }
5096
5270
  result.hits.sort((a2, b) => b.score - a2.score || a2.label.localeCompare(b.label));
5271
+ lastSearch = Object.isFrozen(data.nodes) && Object.isFrozen(data.relations) ? { nodes: data.nodes, relations: data.relations, metamodel: data.metamodel, filters: filtersOf(parsed), scopeNodes: parsed.scope?.nodes ?? null, words: parsed.words, elements: foundElements, relationsFound: foundRelations } : null;
5097
5272
  return result;
5098
5273
  }
5274
+ function elementFields(n, mm, props = propertyFields(n, mm)) {
5275
+ const typeName = mm?.nodeTypes[n.type]?.label ?? n.type;
5276
+ return [
5277
+ { text: n.label || typeName, weight: 3, label: true },
5278
+ { text: typeName, weight: 1.2 },
5279
+ { text: n.technology ?? "", weight: 1.5, name: "Technology" },
5280
+ { text: n.description ?? "", weight: 1, name: "Description", snippet: true },
5281
+ ...props.map((p) => ({ text: p.text, weight: 1, name: p.name, snippet: true }))
5282
+ ];
5283
+ }
5284
+ function relationFields(r, src, tgt, mm) {
5285
+ return [
5286
+ { text: r.label || `${src.label} \u2192 ${tgt.label}`, weight: 3, label: true },
5287
+ { text: src.label, weight: 1.5 },
5288
+ { text: tgt.label, weight: 1.5 },
5289
+ { text: r.technology ?? "", weight: 1.5, name: "Technology" },
5290
+ { text: r.relationType ? mm?.relationTypes[r.relationType]?.label ?? r.relationType : "", weight: 1 }
5291
+ ];
5292
+ }
5293
+ var fullScans = 0;
5294
+ var lastSearch = null;
5295
+ var filtersOf = (p) => JSON.stringify([p.command, p.kinds, p.scope?.viewId ?? null, p.scope?.name ?? null, p.missingView ?? null, p.types, p.properties]);
5296
+ function narrowing(data, parsed) {
5297
+ const last = lastSearch;
5298
+ if (!last || last.nodes !== data.nodes || last.relations !== data.relations || last.metamodel !== data.metamodel) return null;
5299
+ if (last.scopeNodes !== (parsed.scope?.nodes ?? null) || last.filters !== filtersOf(parsed)) return null;
5300
+ if (!last.words.length || parsed.words.length < last.words.length) return null;
5301
+ if (!last.words.every((w, i) => parsed.words[i].startsWith(w))) return null;
5302
+ return { elements: last.elements, relations: last.relationsFound };
5303
+ }
5099
5304
 
5100
5305
  // ../../packages/common/src/ai/queryLanguage.ts
5101
5306
  var MODEL_QUERY_LANGUAGE_HELP = `Query the CURRENT diagram structure with a small built-in query language \u2014
@@ -5112,7 +5317,7 @@ Syntax:
5112
5317
  - LIST VIEWS WHERE <expr> [LIMIT n]
5113
5318
  - LIST SEQUENCES
5114
5319
  - LIST TECHNOLOGIES
5115
- - GET NODE <id>
5320
+ - GET NODE <id> \u2014 the element whole, with its ancestors, children and relations
5116
5321
  - GET VIEW <id>
5117
5322
  - GET SEQUENCE <id>
5118
5323
  - GET CHILDREN OF <id>
@@ -5135,6 +5340,15 @@ Boolean logic in WHERE:
5135
5340
  - AND, OR, NOT
5136
5341
  - Parentheses are supported: ( ... )
5137
5342
 
5343
+ Answers to search_model are in brief: LIST NODES, LIST RELATIONS, GET
5344
+ CHILDREN OF and the traversals give each element its id, type, label,
5345
+ parent, technology, origin, its short properties (enums, numbers, yes/no:
5346
+ status, kind, order, ears_type, \u2026) and one sentence (a requirement's EARS
5347
+ sentence, an ADR's decision, a scenario's given/when/then, else its
5348
+ description, cut to 160 characters), and each relation once. GET NODE <id>
5349
+ gives one element whole; FULL at the end of a query gives every field of
5350
+ every row ("LIST NODES WHERE type = "adr" FULL").
5351
+
5138
5352
  Supported node fields:
5139
5353
  - id, type, label, description, technology, parentId, external,
5140
5354
  plus any custom/governance property key for that node's type
@@ -5527,8 +5741,91 @@ function summarizeTraversalResults(startNodeId, reached, nodes, relations) {
5527
5741
  relations: relationRows
5528
5742
  };
5529
5743
  }
5744
+ var BRIEF_SENTENCE_CHARS = 160;
5745
+ var BRIEF_NOTE = "In brief: GET NODE <id> gives an element whole, FULL at the end of the query every field of every row.";
5746
+ var cut = (text3) => {
5747
+ const flat = text3.replace(/\s+/g, " ").trim();
5748
+ return flat.length <= BRIEF_SENTENCE_CHARS ? flat : `${flat.slice(0, BRIEF_SENTENCE_CHARS - 1).trimEnd()}\u2026`;
5749
+ };
5750
+ function briefSentence(node, ctx) {
5751
+ const p = node;
5752
+ const str2 = (key) => typeof p[key] === "string" ? p[key].trim() : "";
5753
+ if (node.type === "requirement" && str2("action")) return cut(composeEarsSentence(p, void 0, requirementStatePhrase(node, ctx.nodes, ctx.relations)).sentence);
5754
+ if (node.type === "adr" && str2("decision")) return cut(str2("decision"));
5755
+ if (node.type === "scenario" && (str2("given") || str2("when") || str2("then"))) {
5756
+ return cut([str2("given") && `Given ${str2("given")}`, str2("when") && `when ${str2("when")}`, str2("then") && `then ${str2("then")}`].filter(Boolean).join(", "));
5757
+ }
5758
+ return node.description ? cut(node.description) : "";
5759
+ }
5760
+ function shortProperties(node, ctx) {
5761
+ const p = node;
5762
+ const defs = ctx.metamodel?.nodeTypes[node.type]?.properties ?? [];
5763
+ const keys = defs.filter((d) => d.type === "enum" || d.type === "number" || d.type === "boolean").map((d) => d.key);
5764
+ if (!ctx.metamodel && typeof p.status === "string") keys.push("status");
5765
+ return Object.fromEntries(keys.filter((k) => p[k] !== void 0 && p[k] !== "" && p[k] !== null).map((k) => [k, p[k]]));
5766
+ }
5767
+ function briefNode(node, ctx) {
5768
+ const p = node;
5769
+ const sentence = briefSentence(node, ctx);
5770
+ return {
5771
+ id: node.id,
5772
+ type: node.type,
5773
+ label: node.label,
5774
+ ...node.parentId ? { parentId: node.parentId } : {},
5775
+ ...node.technology ? { technology: node.technology } : {},
5776
+ ...node.external ? { external: true } : {},
5777
+ ...typeof p.origin === "string" && p.origin ? { origin: p.origin } : {},
5778
+ ...shortProperties(node, ctx),
5779
+ ...sentence ? { text: sentence } : {}
5780
+ };
5781
+ }
5782
+ function briefRelation(rel, nodes, labels) {
5783
+ return {
5784
+ id: rel.id,
5785
+ relationType: rel.relationType ?? null,
5786
+ sourceId: rel.sourceId,
5787
+ ...labels ? { sourceLabel: nodes[rel.sourceId]?.label ?? null } : {},
5788
+ targetId: rel.targetId,
5789
+ ...labels ? { targetLabel: nodes[rel.targetId]?.label ?? null } : {},
5790
+ ...rel.label ? { label: rel.label } : {},
5791
+ // A relation's own properties are short (a guard, an event, a note): kept, long text cut.
5792
+ ...Object.fromEntries(Object.entries(rel).filter(([key, value]) => !RELATION_BASE_KEYS.has(key) && value !== void 0 && value !== "" && value !== null).map(([key, value]) => [key, typeof value === "string" ? cut(value) : value]))
5793
+ };
5794
+ }
5795
+ var RELATION_BASE_KEYS = /* @__PURE__ */ new Set(["id", "relationType", "sourceId", "targetId", "label", "technology", "sourceHandle", "targetHandle", "waypoints", "labelPosition"]);
5796
+ function inBrief(result, ctx) {
5797
+ const r = result.result;
5798
+ const node = (row) => briefNode(ctx.nodes[row.id] ?? row, ctx);
5799
+ switch (result.command) {
5800
+ case "LIST NODES":
5801
+ case "GET CHILDREN OF":
5802
+ return { ...result, result: { total: r.total, rows: r.rows.map(node), note: BRIEF_NOTE } };
5803
+ case "LIST RELATIONS":
5804
+ return { ...result, result: { total: r.total, rows: r.rows.map((row) => briefRelation(ctx.relations[row.id] ?? row, ctx.nodes, true)), note: BRIEF_NOTE } };
5805
+ case "GET NEIGHBORS OF":
5806
+ case "GET DEPENDENCIES OF":
5807
+ case "GET DEPENDENTS OF":
5808
+ return {
5809
+ ...result,
5810
+ result: {
5811
+ nodeId: r.nodeId,
5812
+ total: r.total,
5813
+ neighbors: r.rows.map((row) => ({ ...node(row.node), depth: row.depth })),
5814
+ relations: r.relations.map((row) => briefRelation(ctx.relations[row.id] ?? row, ctx.nodes, false)),
5815
+ note: BRIEF_NOTE
5816
+ }
5817
+ };
5818
+ default:
5819
+ return result;
5820
+ }
5821
+ }
5530
5822
  function runModelQuery(query, ctx) {
5531
- const raw = query.trim();
5823
+ const full = /\s+FULL\s*$/i.test(query.trim());
5824
+ const raw = full ? query.trim().replace(/\s+FULL\s*$/i, "") : query.trim();
5825
+ const result = runFullQuery(raw, ctx);
5826
+ return ctx.brief && !full ? inBrief(result, ctx) : result;
5827
+ }
5828
+ function runFullQuery(raw, ctx) {
5532
5829
  const upper = raw.toUpperCase();
5533
5830
  const views = ctx.views ?? {};
5534
5831
  const relations = Object.values(ctx.relations);
@@ -5555,11 +5852,8 @@ function runModelQuery(query, ctx) {
5555
5852
  }
5556
5853
  const listNodes = parseListQuery(raw, "NODES");
5557
5854
  if (listNodes) {
5558
- const rows = applyWhere(
5559
- Object.values(ctx.nodes).sort((a2, b) => a2.label.localeCompare(b.label) || a2.id.localeCompare(b.id)),
5560
- listNodes.expr,
5561
- getNodeField
5562
- );
5855
+ const rows = applyWhere(Object.values(ctx.nodes), listNodes.expr, getNodeField);
5856
+ if (!ctx.unordered || listNodes.limit) rows.sort((a2, b) => a2.label.localeCompare(b.label) || a2.id.localeCompare(b.id));
5563
5857
  const limited = listNodes.limit ? rows.slice(0, listNodes.limit) : rows;
5564
5858
  return {
5565
5859
  query: raw,
@@ -5569,11 +5863,8 @@ function runModelQuery(query, ctx) {
5569
5863
  }
5570
5864
  const listRelations = parseListQuery(raw, "RELATIONS");
5571
5865
  if (listRelations) {
5572
- const rows = applyWhere(
5573
- relations.slice().sort((a2, b) => a2.id.localeCompare(b.id)),
5574
- listRelations.expr,
5575
- (rel, field) => getRelationField(rel, field, ctx.nodes)
5576
- );
5866
+ const rows = applyWhere(relations, listRelations.expr, (rel, field) => getRelationField(rel, field, ctx.nodes));
5867
+ if (!ctx.unordered || listRelations.limit) rows.sort((a2, b) => a2.id.localeCompare(b.id));
5577
5868
  const limited = listRelations.limit ? rows.slice(0, listRelations.limit) : rows;
5578
5869
  return {
5579
5870
  query: raw,
@@ -5760,9 +6051,13 @@ function questionLine(param) {
5760
6051
  const choices = param.options?.length ? ` (${param.options.map((o) => `${o.value}: ${o.label}`).join(" | ")})` : "";
5761
6052
  return `${param.label}${choices}`;
5762
6053
  }
5763
- function concernTargets(pack, nodes, relations) {
5764
- const { result } = runModelQuery(pack.concern.trigger, { nodes, relations });
5765
- const rows = result.rows ?? [];
6054
+ function concernTargets(pack, nodes, relations, asked) {
6055
+ let rows = asked?.get(pack.concern.trigger);
6056
+ if (!rows) {
6057
+ const { result } = runModelQuery(pack.concern.trigger, { nodes, relations, unordered: true });
6058
+ rows = result.rows ?? [];
6059
+ asked?.set(pack.concern.trigger, rows);
6060
+ }
5766
6061
  const key = /^\s*LIST\s+RELATIONS/i.test(pack.concern.trigger) ? pack.concern.applyTo === "source" ? "sourceId" : "targetId" : "id";
5767
6062
  const ids = new Set(rows.map((row) => row[key]).filter((id) => typeof id === "string" && !!nodes[id]));
5768
6063
  return [...ids].sort((a2, b) => nodes[a2].label.localeCompare(nodes[b].label) || a2.localeCompare(b));
@@ -5770,14 +6065,29 @@ function concernTargets(pack, nodes, relations) {
5770
6065
  var holdsConcerns = (metamodel) => !!metamodel?.nodeTypes.adr?.properties?.some((p) => p.key === CONCERN_KEY);
5771
6066
  function concernStatuses(packs, nodes, relations) {
5772
6067
  const out = [];
6068
+ const adrsBy = /* @__PURE__ */ new Map();
6069
+ for (const n of Object.values(nodes)) {
6070
+ if (n.type !== "adr") continue;
6071
+ const concern = prop2(n, CONCERN_KEY);
6072
+ const list = adrsBy.get(concern);
6073
+ if (list) list.push(n);
6074
+ else adrsBy.set(concern, [n]);
6075
+ }
6076
+ const constrained = /* @__PURE__ */ new Map();
6077
+ for (const r of Object.values(relations)) {
6078
+ if (r.relationType !== "constrains") continue;
6079
+ const list = constrained.get(r.sourceId);
6080
+ if (list) list.push(r.targetId);
6081
+ else constrained.set(r.sourceId, [r.targetId]);
6082
+ }
6083
+ const asked = /* @__PURE__ */ new Map();
5773
6084
  for (const pack of packs) {
5774
- const targets = concernTargets(pack, nodes, relations);
6085
+ const targets = concernTargets(pack, nodes, relations, asked);
5775
6086
  if (!targets.length) continue;
5776
- const marked = Object.values(nodes).filter((n) => n.type === "adr" && prop2(n, CONCERN_KEY) === pack.concern.id);
5777
- const accepted = new Set(marked.filter((n) => prop2(n, "status") === "accepted").map((n) => n.id));
6087
+ const marked = adrsBy.get(pack.concern.id) ?? [];
5778
6088
  const settled = /* @__PURE__ */ new Set();
5779
- for (const r of Object.values(relations)) {
5780
- if (r.relationType === "constrains" && accepted.has(r.sourceId)) settled.add(r.targetId);
6089
+ for (const n of marked) {
6090
+ if (prop2(n, "status") === "accepted") for (const id of constrained.get(n.id) ?? []) settled.add(id);
5781
6091
  }
5782
6092
  const covered = (id) => {
5783
6093
  for (let cur = id; cur; cur = nodes[cur]?.parentId) if (settled.has(cur)) return true;
@@ -5812,8 +6122,8 @@ function unboundDecisions(packs, nodes, relations, metamodel) {
5812
6122
  }
5813
6123
  function bindProblem(element, metamodel) {
5814
6124
  if (!element) return "no such element";
5815
- const allows = (type2, from, to2) => !metamodel || !!metamodel.relationTypes[type2]?.allowedPairs.some((p) => p.from === from && p.to === to2);
5816
- if (!allows("constrains", "adr", element.type) || !allows("satisfies", element.type, "requirement")) {
6125
+ const allows2 = (type2, from, to2) => !metamodel || !!metamodel.relationTypes[type2]?.allowedPairs.some((p) => p.from === from && p.to === to2);
6126
+ if (!allows2("constrains", "adr", element.type) || !allows2("satisfies", element.type, "requirement")) {
5817
6127
  return `${/^[aeiou]/.test(element.type) ? "an" : "a"} ${element.type} ("${element.label}") cannot be constrained by an ADR and satisfy requirements`;
5818
6128
  }
5819
6129
  return null;
@@ -5850,21 +6160,405 @@ function suggestedCover(suggestions) {
5850
6160
  return picked;
5851
6161
  }
5852
6162
 
6163
+ // ../../packages/common/src/check/words.ts
6164
+ init_define_RADICAL_BUILD();
6165
+ function kept(read2) {
6166
+ const found = /* @__PURE__ */ new Map();
6167
+ return (text3) => {
6168
+ let r = found.get(text3);
6169
+ if (r === void 0) {
6170
+ if (found.size > 2e4) found.clear();
6171
+ r = read2(text3);
6172
+ found.set(text3, r);
6173
+ }
6174
+ return r;
6175
+ };
6176
+ }
6177
+ var plainWords = kept((text3) => text3.replace(/\r/g, "").replace(/^[ \t]*#{1,6}[ \t]+/gm, "").replace(/^[ \t]*(?:[-*+>]|\d+[.)])[ \t]+/gm, "").replace(/\*\*|__|`/g, "").replace(/(^|[\s([{"'])[*_](?=\S)/g, "$1").replace(/(\S)[*_](?=[\s)\]}"'.,;:!?]|$)/g, "$1").replace(/[‐-―−]/g, "-").replace(/[‘’‚]/g, "'").replace(/[“”„]/g, '"').replace(/[   ]/g, " ").toLowerCase().replace(/\s+/g, " ").trim());
6178
+ var WORD = /[\p{L}\p{N}]/u;
6179
+ var DIGIT = /\d/;
6180
+ function wordsAt(text3, piece, from = 0) {
6181
+ if (!piece) return -1;
6182
+ for (let i = text3.indexOf(piece, from); i >= 0; i = text3.indexOf(piece, i + 1)) {
6183
+ const end = i + piece.length;
6184
+ const first = piece[0];
6185
+ const last = piece[piece.length - 1];
6186
+ const before = text3[i - 1] ?? "";
6187
+ const after = text3[end] ?? "";
6188
+ const startOk = !WORD.test(first) || !before || !WORD.test(before) && !(DIGIT.test(first) && /[.,]/.test(before) && DIGIT.test(text3[i - 2] ?? ""));
6189
+ const endOk = !WORD.test(last) || !after || !WORD.test(after) && !(DIGIT.test(last) && /[.,]/.test(after) && DIGIT.test(text3[end + 1] ?? ""));
6190
+ if (startOk && endOk) return end;
6191
+ }
6192
+ return -1;
6193
+ }
6194
+ var QA_START = /^[ \t]*(?:[-*+>][ \t]*)?(?:\*\*|__)?[ \t]*(Q|A|Question|Answer)[ \t]*\d*[ \t]*(?:\*\*|__)?[ \t]*:(?:[ \t]*(?:\*\*|__)(?=\s|$))?[ \t]*/i;
6195
+ var INLINE_ANSWER = /([?.!)"'*_])[ \t]+(?:\*\*|__)?(?:A|Answer)[ \t]*\d*[ \t]*(?:\*\*|__)?[ \t]*:(?:[ \t]*(?:\*\*|__)(?=\s|$))?[ \t]*/;
6196
+ var unwrap = (text3) => {
6197
+ let t = text3.trim();
6198
+ if ((t.match(/\*\*/g) ?? []).length % 2) t = t.replace(/^\*\*\s*|\s*\*\*$/g, "");
6199
+ if ((t.match(/__/g) ?? []).length % 2) t = t.replace(/^__\s*|\s*__$/g, "");
6200
+ return t.trim();
6201
+ };
6202
+ var needParts = kept(readNeedParts);
6203
+ function readNeedParts(text3) {
6204
+ const parts2 = [{ kind: "intro", lines: [] }];
6205
+ for (const line of text3.split("\n")) {
6206
+ const m = QA_START.exec(line);
6207
+ if (!m) {
6208
+ parts2[parts2.length - 1].lines.push(line);
6209
+ continue;
6210
+ }
6211
+ const rest = line.slice(m[0].length);
6212
+ if (/^a/i.test(m[1])) {
6213
+ parts2.push({ kind: "answer", lines: [rest] });
6214
+ continue;
6215
+ }
6216
+ const inline = INLINE_ANSWER.exec(rest);
6217
+ if (inline) {
6218
+ parts2.push({ kind: "question", lines: [rest.slice(0, inline.index + inline[1].length)] });
6219
+ parts2.push({ kind: "answer", lines: [rest.slice(inline.index + inline[0].length)] });
6220
+ } else parts2.push({ kind: "question", lines: [rest] });
6221
+ }
6222
+ return parts2.map((p) => ({ kind: p.kind, text: unwrap(p.lines.join("\n")) })).filter((p) => p.text);
6223
+ }
6224
+ var needAnswers = (text3) => needParts(text3).filter((p) => p.kind === "answer").map((p) => p.text);
6225
+ var quoteFragments = (quote3) => typeof quote3 === "string" ? fragmentsOf(quote3) : [];
6226
+ var fragmentsOf = kept((quote3) => {
6227
+ return quote3.split("\n").map((line) => line.trim().replace(/^["'“‘„>]+|["'”’]+$/g, "").trim()).filter(Boolean).map((line) => line.split(/…|\.\.\./).map((piece) => plainWords(piece).replace(/^["']+|["']+$/g, "").trim()).filter(Boolean)).filter((pieces) => pieces.length);
6228
+ });
6229
+ function quoteFound(needText, pieces) {
6230
+ if (pieces.length === 1) return wordsAt(plainWords(needText), pieces[0]) >= 0;
6231
+ return needParts(needText).some((part) => {
6232
+ const text3 = plainWords(part.text);
6233
+ let at = 0;
6234
+ for (const piece of pieces) {
6235
+ at = wordsAt(text3, piece, at);
6236
+ if (at < 0) return false;
6237
+ }
6238
+ return true;
6239
+ });
6240
+ }
6241
+ var fragmentWords = (pieces) => pieces.join(" ").split(" ").filter((w) => WORD.test(w)).length;
6242
+ var UNITS = { zero: 0, one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9, ten: 10, eleven: 11, twelve: 12, thirteen: 13, fourteen: 14, fifteen: 15, sixteen: 16, seventeen: 17, eighteen: 18, nineteen: 19 };
6243
+ var TENS = { twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70, eighty: 80, ninety: 90 };
6244
+ var SCALES = { hundred: 100, thousand: 1e3, million: 1e6 };
6245
+ var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
6246
+ var isNumberWord = (w) => has(UNITS, w) || has(TENS, w) || has(SCALES, w);
6247
+ function numerals(text3) {
6248
+ return text3.replace(/\b(?:(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|million)(?:[ -]+(?:and[ -]+)?|\b))+/gi, (run2) => {
6249
+ const words = run2.toLowerCase().split(/[ -]+/).filter((w) => w && w !== "and");
6250
+ if (!words.length || words.some((w) => !isNumberWord(w))) return run2;
6251
+ if (words.length === 1 && words[0] === "one") return run2;
6252
+ if (has(SCALES, words[0])) return run2;
6253
+ let total = 0;
6254
+ let current = 0;
6255
+ for (const w of words) {
6256
+ if (has(UNITS, w)) current += UNITS[w];
6257
+ else if (has(TENS, w)) current += TENS[w];
6258
+ else if (w === "hundred") current = (current || 1) * 100;
6259
+ else {
6260
+ total += (current || 1) * SCALES[w];
6261
+ current = 0;
6262
+ }
6263
+ }
6264
+ return `${total + current}${/\s$/.test(run2) ? " " : ""}`;
6265
+ });
6266
+ }
6267
+ var DURATION = [
6268
+ [/^(?:ms|msecs?|milliseconds?)$/, 1e-3],
6269
+ [/^(?:s|secs?|seconds?)$/, 1],
6270
+ [/^(?:mins?|minutes?)$/, 60],
6271
+ [/^(?:h|hrs?|hours?)$/, 3600],
6272
+ [/^(?:d|days?)$/, 86400],
6273
+ [/^(?:weeks?|wks?)$/, 604800],
6274
+ [/^(?:months?|mos?)$/, 2628e3],
6275
+ [/^(?:years?|yrs?)$/, 31536e3]
6276
+ ];
6277
+ var MONEY_AFTER = /^(?:€|eur|euros?|zł|zl|pln|usd|\$|£|gbp|chf|dollars?|pounds?)$/;
6278
+ var CENTS = /^(?:cents?|ct|grosz[ey]?|pence|p)$/;
6279
+ var MONEY_BEFORE = /(?:€|\$|£|eur|usd|pln|gbp|chf)\s?$/;
6280
+ var CURRENCIES = [
6281
+ [/€|\beur\b|\beuros?\b/, "EUR"],
6282
+ [/zł|\bzl\b|\bpln\b/, "PLN"],
6283
+ [/\$|\busd\b|\bdollars?\b/, "USD"],
6284
+ [/£|\bgbp\b|\bpounds?\b/, "GBP"],
6285
+ [/\bchf\b/, "CHF"]
6286
+ ];
6287
+ var currencyOf = (text3) => CURRENCIES.find(([re2]) => re2.test(text3))?.[1];
6288
+ var SIGN_AFTER = /(?:^|[^\w\s%€$£)\]]|\b(?:is|are|was|were|be|been|becomes?|became|reach(?:es|ed)?|show(?:s|n|ed)?|reads?|equals?|stays?|remains?|falls?|fell|drops?|dropped|sinks?|goes|went|gets?|of|at|to|from|in|on|by|as|than|above|below|under|over|between|and|or|until|till|down|least|most|minimum|maximum|around|about|approximately|only|still|with))\s*$/i;
6289
+ var minusSigns = (text3) => text3.replace(/[‐‑‒–−]/g, "-");
6290
+ var numberValue = (raw) => {
6291
+ const sign = /^(?:[-−]|minus\s+)/i.exec(raw)?.[0] ?? "";
6292
+ const digits = raw.slice(sign.length);
6293
+ let n = /^\d{1,3}(,\d{3})+$/.test(digits) ? digits.replace(/,/g, "") : digits.replace(",", ".");
6294
+ if (/^\d+\.\d+$/.test(n)) n = n.replace(/0+$/, "").replace(/\.$/, "");
6295
+ return sign && Number(n) !== 0 ? `-${n}` : n;
6296
+ };
6297
+ var fmt = (n) => String(Math.round(n * 1e3) / 1e3);
6298
+ var readValues = kept(valuesOf);
6299
+ function valuesOf(text3) {
6300
+ const values = /* @__PURE__ */ new Set();
6301
+ const aliases = /* @__PURE__ */ new Map();
6302
+ const also = /* @__PURE__ */ new Set();
6303
+ const quantities = [];
6304
+ const alias = (value, ...more) => {
6305
+ aliases.set(value, [.../* @__PURE__ */ new Set([...aliases.get(value) ?? [], ...more])]);
6306
+ more.forEach((m) => also.add(m));
6307
+ };
6308
+ let t = text3.replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/[  ]/g, " ");
6309
+ for (const m of t.matchAll(/`([^`\s][^`\n]{0,38}[^`\s]|[^`\s])`|"([^"\s][^"\n]{0,38}[^"\s]|[^"\s])"|(?<![\w])'([a-z0-9][a-z0-9_-]{0,39})'(?![\w])/gi)) {
6310
+ const id = (m[1] ?? m[2] ?? m[3]).trim().toLowerCase();
6311
+ if (/^[a-z0-9][a-z0-9_-]*$/.test(id) && !/^\d+$/.test(id)) values.add(id);
6312
+ }
6313
+ t = t.replace(/\b(\d{4}-\d{2}-\d{2})(?:[t ](\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?z?)?\b/gi, (_, date, time) => {
6314
+ values.add(date);
6315
+ if (time) values.add(time);
6316
+ return " ";
6317
+ });
6318
+ t = t.replace(/(?<![\d:])(\d{1,2}:\d{2})(?![\d:])/g, (_, time) => {
6319
+ values.add(time.padStart(5, "0"));
6320
+ return " ";
6321
+ });
6322
+ t = minusSigns(numerals(t));
6323
+ for (const m of t.matchAll(/((?:(?<![\w.,)\]])-|\bminus\s+)?(?<![\w.,]|[a-z]-)(?:\d{1,3}(?:,\d{3})+|\d+(?:[.,]\d+)?))(?:\s?(%|percent\b|per cent\b)|(st|nd|rd|th)\b|\s?([a-zżł€$£]+\b|€|\$|£))?(?![\w])/gi)) {
6324
+ const raw = /^minus/i.test(m[1]) && !SIGN_AFTER.test(t.slice(Math.max(0, (m.index ?? 0) - 40), m.index ?? 0)) ? m[1].replace(/^minus\s+/i, "") : m[1];
6325
+ const n = numberValue(raw);
6326
+ if (m[2]) {
6327
+ values.add(`${n}%`);
6328
+ alias(`${n}%`, n, ...n.startsWith("-") ? [`${n.slice(1)}%`] : []);
6329
+ continue;
6330
+ }
6331
+ values.add(n);
6332
+ if (/[.,]\d\d$/.test(raw) && !/^\D*\d{1,3}(,\d{3})+$/.test(raw)) alias(n, fmt(Number(n) * 100));
6333
+ if (!/%$/.test(n)) alias(n, `${n}%`);
6334
+ const unit = (m[4] ?? "").toLowerCase();
6335
+ const before = t.slice(Math.max(0, (m.index ?? 0) - 4), m.index ?? 0).toLowerCase();
6336
+ const duration = DURATION.find(([re2]) => re2.test(unit));
6337
+ if (duration) {
6338
+ const base = `${fmt(Number(n) * duration[1])}s`;
6339
+ alias(n, base);
6340
+ quantities.push({ value: n, dimension: "time", base, text: `${raw} ${unit}` });
6341
+ } else if (MONEY_AFTER.test(unit) || MONEY_BEFORE.test(before)) {
6342
+ const cents = fmt(Number(n) * 100);
6343
+ alias(n, `${cents}\xA2`, cents);
6344
+ const sign = MONEY_AFTER.test(unit) ? unit : MONEY_BEFORE.exec(before)[0].trim();
6345
+ quantities.push({ value: n, dimension: "money", base: `${cents}\xA2`, text: sign === unit ? `${raw} ${unit}` : `${sign}${/\w$/.test(sign) ? " " : ""}${raw}`, currency: currencyOf(sign) });
6346
+ } else if (CENTS.test(unit)) {
6347
+ alias(n, `${n}\xA2`);
6348
+ quantities.push({ value: n, dimension: "money", base: `${n}\xA2`, text: `${raw} ${unit}` });
6349
+ }
6350
+ }
6351
+ const lower = t.toLowerCase();
6352
+ for (const m of lower.matchAll(/\b(null|true|false)\b/g)) values.add(m[1]);
6353
+ if (/\bone\b|\bonce\b|\bsingle\b/.test(lower)) also.add("1");
6354
+ if (/\btwice\b/.test(lower)) also.add("2");
6355
+ if (/\bdozen\b/.test(lower)) also.add("12");
6356
+ return { values, aliases, also, quantities };
6357
+ }
6358
+ var says = (reading2, value) => reading2.values.has(value) || reading2.also.has(value);
6359
+ var saysValueOf = (from, value, to2) => says(to2, value) || (from.aliases.get(value) ?? []).some((a2) => says(to2, a2));
6360
+ var COMPLEMENT = { "<=": ">", "<": ">=", ">=": "<", ">": "<=" };
6361
+ var N = String.raw`((?:(?<![\w.,])-|minus )?\d+(?:[.,]\d+)?)`;
6362
+ var LIMIT_BEFORE = [
6363
+ [new RegExp(String.raw`\b(?:at most|no more than|not more than|up to|maximum of|a maximum of|max(?:imum)?\.?|no longer than|not over)\s+${N}`, "g"), "<="],
6364
+ [new RegExp(String.raw`(?:≤|<=)\s*${N}`, "g"), "<="],
6365
+ [new RegExp(String.raw`\b(?:at least|no less than|no fewer than|not less than|not fewer than|minimum of|a minimum of|min(?:imum)?\.?)\s+${N}`, "g"), ">="],
6366
+ [new RegExp(String.raw`(?:≥|>=)\s*${N}`, "g"), ">="],
6367
+ [new RegExp(String.raw`\b(?:more than|greater than|longer than|larger than|higher than|over|above|exceeds?|exceeding|beyond)\s+${N}`, "g"), ">"],
6368
+ [new RegExp(String.raw`(?<![<>=-])>\s*${N}`, "g"), ">"],
6369
+ [new RegExp(String.raw`\b(?:less than|fewer than|shorter than|smaller than|lower than|below|under)\s+${N}`, "g"), "<"],
6370
+ [new RegExp(String.raw`(?<![<>=-])<\s*${N}(?![\d=])`, "g"), "<"]
6371
+ ];
6372
+ var LIMIT_AFTER = [
6373
+ [new RegExp(String.raw`${N}(?:\s*[a-z%€$£]+)?\s+or\s+(?:less|fewer|below|under|lower|smaller|shorter)\b`, "g"), "<="],
6374
+ [new RegExp(String.raw`${N}(?:\s*[a-z%€$£]+)?\s+or\s+(?:more|above|over|higher|greater|larger|longer)\b`, "g"), ">="]
6375
+ ];
6376
+ var CLAUSE = /(?<!\d),|,(?!\d)|;|(?<!\bbetween (?:-|minus )?\d+(?:[.,]\d+)?)\s(?:and|but|so|then|otherwise)\s/;
6377
+ var RANGE = new RegExp(String.raw`\b(?:from|between)\s+${N}\s+(?:to|and)\s+${N}|(?<![\d.,-])${N}\s?(?:-|to)\s?${N}(?![\d.,-])`, "g");
6378
+ var NEGATION = /\b(?:not|never|neither|nor|cannot|\w+n't)\b/g;
6379
+ var negates = (before) => {
6380
+ const text3 = before.replace(/\bnot (?:allowed|accepted|permitted)\b/g, " ");
6381
+ if (/\bno\s*$/.test(text3)) return true;
6382
+ const last = [...text3.matchAll(NEGATION)].pop();
6383
+ return !!last && !ownClause(text3.slice(0, last.index), text3.slice((last.index ?? 0) + last[0].length));
6384
+ };
6385
+ var OPENER = /\b(?:who|which|that|whose|whom|where|when|whenever|if|while|until|unless|because|since|once)\b/;
6386
+ var MODAL = /* @__PURE__ */ new Set(["can", "could", "may", "might", "must", "shall", "should", "will", "would", "to"]);
6387
+ var CARRIER = /* @__PURE__ */ new Set([
6388
+ ...MODAL,
6389
+ "a",
6390
+ "an",
6391
+ "the",
6392
+ "its",
6393
+ "their",
6394
+ "his",
6395
+ "her",
6396
+ "my",
6397
+ "our",
6398
+ "your",
6399
+ "this",
6400
+ "that",
6401
+ "these",
6402
+ "those",
6403
+ "each",
6404
+ "every",
6405
+ "any",
6406
+ "some",
6407
+ "be",
6408
+ "been",
6409
+ "being",
6410
+ "is",
6411
+ "are",
6412
+ "was",
6413
+ "were",
6414
+ "am",
6415
+ "do",
6416
+ "does",
6417
+ "did",
6418
+ "have",
6419
+ "has",
6420
+ "had",
6421
+ "yet",
6422
+ "ever",
6423
+ "always",
6424
+ "still",
6425
+ "also",
6426
+ "even",
6427
+ "just",
6428
+ "only",
6429
+ "already",
6430
+ "again",
6431
+ "now",
6432
+ "later",
6433
+ "really",
6434
+ "in",
6435
+ "on",
6436
+ "at",
6437
+ "of",
6438
+ "with",
6439
+ "for",
6440
+ "by",
6441
+ "from",
6442
+ "into",
6443
+ "out",
6444
+ "up",
6445
+ "off"
6446
+ ]);
6447
+ function ownClause(before, after) {
6448
+ if (!OPENER.test(before)) return false;
6449
+ const words = after.split(/[^\p{L}\p{N}']+/u).filter(Boolean);
6450
+ const verb = words[words.length - 1];
6451
+ if (!verb || CARRIER.has(verb) || words.filter((w) => !CARRIER.has(w)).length < 2) return false;
6452
+ return MODAL.has(words[words.length - 2]) || /[^s']s$/.test(verb);
6453
+ }
6454
+ var REFUSAL = /\b(?:refus\w*|reject\w*|declin\w*|den(?:y|ies|ied)|invalid|not (?:allowed|accepted|permitted)|forbidden|disallow\w*|error|too (?:long|short|many|few|high|low|big|small))\b/;
6455
+ function refusalBefore(clause, at) {
6456
+ const last = [...clause.matchAll(new RegExp(REFUSAL.source, "g"))].pop();
6457
+ if (!last) return false;
6458
+ const end = (last.index ?? 0) + last[0].length;
6459
+ return end <= at && ownClause(clause.slice(0, last.index), clause.slice(end, at));
6460
+ }
6461
+ var readLimits = (text3, refusing = false) => (refusing ? refusedLimits : allowedLimits)(text3);
6462
+ var allowedLimits = kept((text3) => limitsOf(text3, false));
6463
+ var refusedLimits = kept((text3) => limitsOf(text3, true));
6464
+ function limitsOf(text3, refusing) {
6465
+ const limits = [];
6466
+ const plain = numerals(plainWords(text3)).replace(/\b\d{4}-\d{2}-\d{2}\S*|\b\d{1,2}:\d{2}\b/g, " ");
6467
+ for (const sentence of plain.split(/(?<=[.;!?])\s+(?=\D)/)) {
6468
+ const clauses = sentence.split(CLAUSE).filter((c) => c.trim());
6469
+ clauses.forEach((clause, i) => {
6470
+ const refused = refusing || REFUSAL.test(clause) || /^\s*(?:if|when|whenever|where|once|should)\b/.test(clause) && REFUSAL.test(clauses[i + 1] ?? "");
6471
+ const read2 = [];
6472
+ for (const [re2, op] of [...LIMIT_BEFORE, ...LIMIT_AFTER]) {
6473
+ for (const m of clause.matchAll(re2)) {
6474
+ const start = m.index ?? 0;
6475
+ const end = start + m[0].length;
6476
+ if (read2.some(([from, to2]) => from <= start && end <= to2)) continue;
6477
+ read2.push([start, end]);
6478
+ const negated = negates(clause.slice(0, start));
6479
+ const turned = refused && !(!refusing && refusalBefore(clause, start));
6480
+ limits.push({ value: numberValue(m[1]), op: turned !== negated ? COMPLEMENT[op] : op, text: m[0].trim() });
6481
+ }
6482
+ }
6483
+ if (refused) return;
6484
+ for (const m of clause.matchAll(RANGE)) {
6485
+ const [low, high] = m[1] !== void 0 ? [m[1], m[2]] : [m[3], m[4]];
6486
+ if (Number(numberValue(low)) >= Number(numberValue(high))) continue;
6487
+ limits.push({ value: numberValue(low), op: ">=", text: m[0].trim() }, { value: numberValue(high), op: "<=", text: m[0].trim() });
6488
+ }
6489
+ });
6490
+ }
6491
+ return limits;
6492
+ }
6493
+ var ORDERS = [
6494
+ [/\b(?:oldest|earliest)(?: \w+)? first\b|\bin (?:the )?order (?:they|it) (?:came|were|was) \w+/, "oldest-first"],
6495
+ [/\b(?:newest|latest|most recent)(?: \w+)? first\b|\breverse chronological\b/, "newest-first"],
6496
+ [/\bascending\b|\b(?:lowest|smallest|cheapest) first\b|\ba to z\b/, "ascending"],
6497
+ [/\bdescending\b|\b(?:highest|largest|biggest|dearest) first\b|\bz to a\b/, "descending"]
6498
+ ];
6499
+ var OPPOSITE = { "oldest-first": "newest-first", "newest-first": "oldest-first", ascending: "descending", descending: "ascending" };
6500
+ var oppositeOrder = (o) => OPPOSITE[o];
6501
+ var readOrders = kept(ordersOf);
6502
+ function ordersOf(text3) {
6503
+ const t = plainWords(text3);
6504
+ return new Set(ORDERS.filter(([re2]) => re2.test(t)).map(([, o]) => o));
6505
+ }
6506
+ var readRoundings = kept(roundingsOf);
6507
+ function roundingsOf(text3) {
6508
+ let t = plainWords(text3);
6509
+ const found = /* @__PURE__ */ new Set();
6510
+ t = t.replace(/\b(?:round(?:ed|s|ing)? )?half(?:[ -]way)?[ -](up|down|even)\b|\bbanker'?s rounding\b/g, (m, kind) => {
6511
+ found.add(`half ${kind ?? "even"}`);
6512
+ return " ";
6513
+ });
6514
+ for (const m of t.matchAll(/\bround(?:ed|s|ing)?(?: \w+){0,3} (up|down)\b/g)) found.add(m[1]);
6515
+ return found;
6516
+ }
6517
+ var EXAMPLE = /\b(?:for example|for instance|e\.g\.|example:|examples:)/i;
6518
+ function exampleSentences(text3) {
6519
+ const out = [];
6520
+ for (const line of text3.split("\n")) {
6521
+ const sentences = line.split(/(?<=[.!?])\s+(?=[A-Z(*`"“-])/);
6522
+ for (const s2 of sentences) {
6523
+ const clean = s2.replace(/\*\*|__|`/g, "").replace(/^[\s>*+-]+/, "").replace(/(^|[\s,;:(])\d{1,2}[.)](?=\s+[a-z])/g, "$1").trim();
6524
+ if (EXAMPLE.test(clean) && (clean.match(/\d+(?:[.,]\d+)?/g) ?? []).length >= 2) out.push(clean);
6525
+ }
6526
+ }
6527
+ return out;
6528
+ }
6529
+ var SUPERSEDED = /\(superseded\b[^)]*\)/i;
6530
+ function answerBlocks(answer) {
6531
+ return answer.split(/\n\s*\n|\n(?=[ \t]*(?:[-*+]|\d+[.)])[ \t]+)/).map((block) => block.trim()).filter((block) => block && !/:\s*$/.test(plainWords(block)) && plainWords(block).split(" ").filter((w) => WORD.test(w)).length >= 4);
6532
+ }
6533
+ function currentNeedText(text3) {
6534
+ const parts2 = needParts(text3);
6535
+ if (!parts2.some((p) => p.kind === "answer" && SUPERSEDED.test(p.text))) return text3;
6536
+ return parts2.filter((p) => !(p.kind === "answer" && SUPERSEDED.test(p.text))).map((p) => p.kind === "question" ? `Q: ${p.text}` : p.kind === "answer" ? `A: ${p.text}` : p.text).join("\n");
6537
+ }
6538
+ var answerKey = (answer) => plainWords(answer.replace(SUPERSEDED, " "));
6539
+
5853
6540
  // ../../packages/common/src/check/rules.ts
5854
6541
  var prop3 = (node, key) => {
5855
6542
  const value = node[key];
5856
6543
  return typeof value === "string" ? value.trim() : value == null ? "" : String(value);
5857
6544
  };
5858
- function linked(model, type2, end) {
5859
- const map2 = /* @__PURE__ */ new Map();
5860
- for (const r of Object.values(model.relations)) {
5861
- if (r.relationType !== type2) continue;
5862
- const id = end === "in" ? r.targetId : r.sourceId;
5863
- map2.set(id, [...map2.get(id) ?? [], r]);
5864
- }
5865
- return map2;
5866
- }
5867
- var nodesOf = (model, type2) => model.metamodel.nodeTypes[type2] ? Object.values(model.nodes).filter((n) => n.type === type2) : [];
6545
+ var linked = (model, type2, end) => end === "in" ? relationsOf(model, type2).to : relationsOf(model, type2).from;
6546
+ var NODES_BY_TYPE = /* @__PURE__ */ new WeakMap();
6547
+ var NO_NODES = [];
6548
+ var nodesOf = (model, type2) => {
6549
+ if (!model.metamodel.nodeTypes[type2]) return NO_NODES;
6550
+ let byType = NODES_BY_TYPE.get(model.nodes);
6551
+ if (!byType) {
6552
+ byType = /* @__PURE__ */ new Map();
6553
+ for (const n of Object.values(model.nodes)) {
6554
+ const list = byType.get(n.type);
6555
+ if (list) list.push(n);
6556
+ else byType.set(n.type, [n]);
6557
+ }
6558
+ NODES_BY_TYPE.set(model.nodes, byType);
6559
+ }
6560
+ return byType.get(type2) ?? NO_NODES;
6561
+ };
5868
6562
  var hasRelationType = (model, type2) => !!model.metamodel.relationTypes[type2];
5869
6563
  function unlinked(model, type2, relation, end, otherTypes) {
5870
6564
  if (!hasRelationType(model, relation)) return [];
@@ -5875,6 +6569,11 @@ function unlinked(model, type2, relation, end, otherTypes) {
5875
6569
  }));
5876
6570
  }
5877
6571
  var quote = (n) => `"${n.label}"`;
6572
+ function inheritedDecisions(model) {
6573
+ const waived = new Set(Object.values(model.relations).filter((r) => r.relationType === "waives" && !originOf(model.nodes[r.sourceId]) && model.nodes[r.sourceId] && prop3(model.nodes[r.sourceId], "status") === "accepted").map((r) => r.targetId));
6574
+ return nodesOf(model, "adr").filter((n) => originOf(n) && prop3(n, "status") === "accepted" && !waived.has(n.id)).map((adr) => ({ adr, origin: originOf(adr), elements: linkedNodes(model, adr.id, "constrains", "target").filter((e2) => !originOf(e2)) }));
6575
+ }
6576
+ var namesCheck = (ff) => conditionsOf(ff).some((c) => c.kind !== "invalid");
5878
6577
  var TYPE_NAME = { scenario: "Scenario", "fitness-fn": "Fitness function" };
5879
6578
  var TYPE_LABEL = (node) => TYPE_NAME[node.type] ?? node.type.charAt(0).toUpperCase() + node.type.slice(1);
5880
6579
  var affectedBy = (model, node) => node.type === "scenario" ? linkedNodes(model, node.id, "verifies", "target", "requirement") : linkedNodes(model, node.id, "implements", "target", "adr");
@@ -5884,6 +6583,7 @@ function brokenWith(model, node) {
5884
6583
  const what = node.type === "scenario" ? "requirement" : "ADR";
5885
6584
  return ` Not verified now: ${what}${affected.length === 1 ? "" : "s"} ${affected.map(quote).join(", ")}.`;
5886
6585
  }
6586
+ var testedName = (node) => `${TYPE_NAME[node.type]} ${quote(node)}${originOf(node) ? ` of ${originOf(node)}` : ""}`;
5887
6587
  function testRule(outcome, message) {
5888
6588
  const failing = outcome === "failed" || outcome === "not-found";
5889
6589
  return (model) => {
@@ -5965,6 +6665,169 @@ function invalidChecks(model) {
5965
6665
  return found;
5966
6666
  });
5967
6667
  }
6668
+ var READINGS = /* @__PURE__ */ new Map();
6669
+ function reading(text3) {
6670
+ let found = READINGS.get(text3);
6671
+ if (!found) {
6672
+ if (READINGS.size > 2e4) READINGS.clear();
6673
+ found = readValues(text3);
6674
+ READINGS.set(text3, found);
6675
+ }
6676
+ return found;
6677
+ }
6678
+ var relationQuote = (r) => {
6679
+ const q = r.quote;
6680
+ return typeof q === "string" ? q : "";
6681
+ };
6682
+ var requirementToNeed = (model) => Object.values(model.relations).filter((r) => r.relationType === "derives" && model.nodes[r.sourceId]?.type === "requirement" && model.nodes[r.targetId]?.type === "need" && !originOf(model.nodes[r.targetId]));
6683
+ var CONDITION_FIELDS = ["trigger", "precondition", "unwanted_condition"];
6684
+ var RESPONSE_FIELDS = ["feature", "action"];
6685
+ var requirementText = (n) => [...CONDITION_FIELDS, ...RESPONSE_FIELDS].map((k) => prop3(n, k)).join(" \n ");
6686
+ var scenarioText = (n) => ["given", "when", "then", "gherkin"].map((k) => prop3(n, k)).join(" \n ");
6687
+ function quoteOf(model, r) {
6688
+ const q = relationQuote(r);
6689
+ const need = model.nodes[r.targetId];
6690
+ if (!q || need?.type !== "need") return "";
6691
+ const text3 = need.description ?? "";
6692
+ return plainWords(q) === plainWords(text3) && !needAnswers(text3).length ? "" : q;
6693
+ }
6694
+ var GAPS = /* @__PURE__ */ new WeakMap();
6695
+ function quoteValueGaps(model, req) {
6696
+ let byRelations = GAPS.get(model.nodes);
6697
+ if (!byRelations) {
6698
+ byRelations = /* @__PURE__ */ new WeakMap();
6699
+ GAPS.set(model.nodes, byRelations);
6700
+ }
6701
+ let byReq = byRelations.get(model.relations);
6702
+ if (!byReq) {
6703
+ byReq = /* @__PURE__ */ new Map();
6704
+ byRelations.set(model.relations, byReq);
6705
+ }
6706
+ let gaps = byReq.get(req.id);
6707
+ if (!gaps) {
6708
+ gaps = computeGaps(model, req);
6709
+ byReq.set(req.id, gaps);
6710
+ }
6711
+ return gaps;
6712
+ }
6713
+ function computeGaps(model, req) {
6714
+ const derives = relationsOf(model, "derives");
6715
+ const own = reading(requirementText(req));
6716
+ const missing2 = [];
6717
+ const carried = /* @__PURE__ */ new Set();
6718
+ for (const r of derives.from.get(req.id) ?? []) {
6719
+ const q = reading(quoteOf(model, r));
6720
+ for (const value of q.values) {
6721
+ if (saysValueOf(q, value, own)) carried.add(value);
6722
+ else missing2.push({ value, relationId: r.id });
6723
+ }
6724
+ }
6725
+ const allowed = [];
6726
+ const seen = /* @__PURE__ */ new Set([req.id]);
6727
+ const queue = [req.id];
6728
+ while (queue.length) {
6729
+ const id = queue.shift();
6730
+ for (const r of derives.from.get(id) ?? []) {
6731
+ const q = quoteOf(model, r);
6732
+ if (q) allowed.push(reading(q));
6733
+ if (!seen.has(r.targetId) && model.nodes[r.targetId]?.type === "requirement") {
6734
+ seen.add(r.targetId);
6735
+ queue.push(r.targetId);
6736
+ }
6737
+ }
6738
+ }
6739
+ if (!allowed.length) return { missing: missing2, unsupported: [], carried: [...carried] };
6740
+ allowed.push(reading(prop3(req, "rationale")));
6741
+ return { missing: missing2, unsupported: [...own.values].filter((v) => !allowed.some((a2) => saysValueOf(own, v, a2))), carried: [...carried] };
6742
+ }
6743
+ var OP_TEXT = { "<=": "up to and with", "<": "below", ">=": "from and with", ">": "above" };
6744
+ var allows = (l) => `${OP_TEXT[l.op]} ${l.value}`;
6745
+ function requirementLimits(req) {
6746
+ const response = RESPONSE_FIELDS.map((k) => prop3(req, k)).join(" \n ");
6747
+ const refuses = REFUSAL.test(plainWords(response));
6748
+ return [
6749
+ ...CONDITION_FIELDS.flatMap((k) => readLimits(prop3(req, k), refuses)),
6750
+ ...readLimits(response)
6751
+ ];
6752
+ }
6753
+ function quoteSenseGaps(model, req) {
6754
+ const out = [];
6755
+ const text3 = requirementText(req);
6756
+ const limits = requirementLimits(req);
6757
+ const own = reading(text3);
6758
+ const orders = readOrders(text3);
6759
+ const roundings = readRoundings(text3);
6760
+ for (const r of relationsOf(model, "derives").from.get(req.id) ?? []) {
6761
+ const q = quoteOf(model, r);
6762
+ if (!q) continue;
6763
+ const need = quoteLabel(model.nodes[r.targetId]);
6764
+ for (const l of readLimits(q)) {
6765
+ const same = limits.filter((m) => m.value === l.value);
6766
+ if (same.length && !same.some((m) => m.op === l.op)) {
6767
+ out.push({ relationId: r.id, about: [`limit ${l.op}${l.value}`], message: `Requirement ${quoteLabel(req)} allows ${same.map(allows).join(" and ")} ("${same[0].text}") where the words it quotes from ${need} allow ${allows(l)} ("${l.text}"): check on which side of ${l.value} the limit is.` });
6768
+ }
6769
+ }
6770
+ for (const qty of reading(q).quantities) {
6771
+ if (own.quantities.some((m) => m.dimension === qty.dimension && m.base === qty.base && sameCurrency(m, qty))) continue;
6772
+ const other = own.quantities.find((m) => m.dimension === qty.dimension && m.value === qty.value);
6773
+ if (other) out.push({ relationId: r.id, about: [`unit ${qty.text}`], message: `Requirement ${quoteLabel(req)} says "${other.text}" where the words it quotes from ${need} say "${qty.text}".` });
6774
+ }
6775
+ for (const o of readOrders(q)) {
6776
+ if (!orders.has(o) && orders.has(oppositeOrder(o))) out.push({ relationId: r.id, about: [`order ${o}`], message: `Requirement ${quoteLabel(req)} lists ${oppositeOrder(o).replace("-", " ")} where the words it quotes from ${need} say ${o.replace("-", " ")}.` });
6777
+ }
6778
+ const said = readRoundings(q);
6779
+ if (said.size && roundings.size && ![...said].some((x) => roundings.has(x))) {
6780
+ out.push({ relationId: r.id, about: [...said].map((x) => `rounding ${x}`), message: `Requirement ${quoteLabel(req)} rounds ${[...roundings].join(", ")} where the words it quotes from ${need} say ${[...said].join(", ")}.` });
6781
+ }
6782
+ }
6783
+ return out;
6784
+ }
6785
+ var quoteLabel = (n) => `"${n.label}"`;
6786
+ var sameCurrency = (a2, b) => !a2.currency || !b.currency || a2.currency === b.currency;
6787
+ function unquotedBlocks(answer, fragments) {
6788
+ const blocks = answerBlocks(answer);
6789
+ const parts2 = blocks.length ? blocks : [answer];
6790
+ const plain = parts2.map((b) => plainWords(b));
6791
+ const text3 = plain.join(" ");
6792
+ const ranges = [];
6793
+ let at = 0;
6794
+ for (const p of plain) {
6795
+ ranges.push([at, at + p.length]);
6796
+ at += p.length + 1;
6797
+ }
6798
+ const covered = /* @__PURE__ */ new Set();
6799
+ for (const piece of fragments.flat()) {
6800
+ for (let end = wordsAt(text3, piece); end >= 0; end = wordsAt(text3, piece, end - piece.length + 1)) {
6801
+ const start = end - piece.length;
6802
+ ranges.forEach(([from, to2], i) => {
6803
+ if (start < to2 && end > from) covered.add(i);
6804
+ });
6805
+ }
6806
+ }
6807
+ return parts2.filter((_, i) => !covered.has(i));
6808
+ }
6809
+ function requirementsOfNeed(model, needId) {
6810
+ const derives = relationsOf(model, "derives");
6811
+ const found = /* @__PURE__ */ new Map();
6812
+ const parts2 = /* @__PURE__ */ new Set([needId]);
6813
+ const queue = [needId];
6814
+ while (queue.length) {
6815
+ for (const r of derives.to.get(queue.shift()) ?? []) {
6816
+ const n = model.nodes[r.sourceId];
6817
+ if (n?.type === "requirement" && !found.has(n.id)) {
6818
+ found.set(n.id, n);
6819
+ queue.push(n.id);
6820
+ } else if (n?.type === "need" && !parts2.has(n.id) && model.nodes[r.targetId]?.type === "need") {
6821
+ parts2.add(n.id);
6822
+ queue.push(n.id);
6823
+ }
6824
+ }
6825
+ }
6826
+ return [...found.values()];
6827
+ }
6828
+ var scenariosOf = (model, reqId) => (relationsOf(model, "verifies").to.get(reqId) ?? []).map((r) => model.nodes[r.sourceId]).filter((n) => n?.type === "scenario");
6829
+ var telling = (v) => !/^\d$/.test(v) && !(/^[a-z]+$/.test(v) && v.length < 3) && !/^\d{4}-\d{2}-\d{2}$|^\d{2}:\d{2}$/.test(v);
6830
+ var sourceReading = (text3) => reading(text3.replace(/(\d)_(?=\d)/g, "$1").replace(/\b(?:toBe|is|assert)(Null|True|False)\b/g, " $1 ").replace(/(\d)([a-z])/gi, "$1 $2").replace(/([a-z/])(\d)/gi, "$1 $2"));
5968
6831
  var CHECK_RULES = [
5969
6832
  {
5970
6833
  id: "metamodel",
@@ -6009,10 +6872,148 @@ var CHECK_RULES = [
6009
6872
  },
6010
6873
  {
6011
6874
  id: "need-without-requirement",
6012
- description: "Every need has at least one requirement derived from it.",
6875
+ description: "Every need has at least one requirement derived from it, or from a need inside it (a need that derives from it, Part of).",
6876
+ severity: "warning",
6877
+ dimension: "traceability",
6878
+ run: (model) => unlinked(model, "need", "derives", "in", ["requirement"]).filter((n) => !requirementsOfNeed(model, n.id).length).map((n) => ({ nodeId: n.id, message: `No requirement derives from need ${quote(n)}.` }))
6879
+ },
6880
+ {
6881
+ id: "derives-quote-missing",
6882
+ description: "A requirement's derives relation to a need quotes the words of the need it rests on (property quote, one verbatim fragment per line). Off unless check.json turns it on; the goal requirements-quoting-need follows it in percent.",
6883
+ severity: "warning",
6884
+ off: true,
6885
+ dimension: "traceability",
6886
+ run: (model) => requirementToNeed(model).filter((r) => !quoteFragments(relationQuote(r)).length).map((r) => ({ nodeId: r.sourceId, message: `Requirement ${quote(model.nodes[r.sourceId])} derives from need ${quote(model.nodes[r.targetId])} without quoting the words it rests on.` }))
6887
+ },
6888
+ {
6889
+ id: "derives-quote-not-in-need",
6890
+ description: "Every fragment a derives relation quotes is in the need's text outside its superseded answers, as whole words (case, white space, Markdown marks, dashes and quotation marks aside; an ellipsis joins pieces that must be there in that order, within one question, answer or the text before the questions), and holds at least two words; only a relation to a need quotes.",
6891
+ severity: "error",
6892
+ dimension: "traceability",
6893
+ run: (model) => Object.values(model.relations).filter((r) => r.relationType === "derives" && relationQuote(r).trim() && model.nodes[r.sourceId]?.type === "requirement" && !originOf(model.nodes[r.sourceId])).flatMap((r) => {
6894
+ const req = model.nodes[r.sourceId];
6895
+ const target = model.nodes[r.targetId];
6896
+ if (!target) return [];
6897
+ if (target.type !== "need") return [{ relationId: r.id, message: `Requirement ${quote(req)} quotes words on its relation to ${target.type} ${quote(target)}: only a need holds a person's words. Quote them on the requirement's relation to the need.` }];
6898
+ if (originOf(target)) return [];
6899
+ const text3 = target.description ?? "";
6900
+ return quoteFragments(relationQuote(r)).flatMap((pieces) => fragmentWords(pieces) < 2 ? [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}", too short to say which words of need ${quote(target)} it rests on: quote the words around it.` }] : quoteFound(currentNeedText(text3), pieces) ? [] : quoteFound(text3, pieces) ? [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}" from an answer of need ${quote(target)} marked (superseded): quote the answer that replaces it.` }] : [{ relationId: r.id, message: `Requirement ${quote(req)} quotes "${pieces.join(" \u2026 ")}", which need ${quote(target)} does not say${pieces.length > 1 ? " in that order within one answer" : ""}.` }]);
6901
+ })
6902
+ },
6903
+ {
6904
+ id: "quote-value-missing",
6905
+ description: "Every hard value a derives relation quotes (a number, null, true or false, a date or time, an identifier in backticks or quotation marks) is in the requirement's sentence, in that form or another (20 percent as 20%, 15 minutes as 900 seconds, 12.30 \u20AC as 1230 cents).",
6906
+ severity: "warning",
6907
+ dimension: "traceability",
6908
+ run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
6909
+ const byRelation = /* @__PURE__ */ new Map();
6910
+ for (const g of quoteValueGaps(model, req).missing) byRelation.set(g.relationId, [...byRelation.get(g.relationId) ?? [], g.value]);
6911
+ return [...byRelation].map(([relationId, values]) => ({ relationId, about: values, message: `Requirement ${quote(req)} does not say ${values.map((v) => `"${v}"`).join(", ")}, which the words it quotes from ${quote(model.nodes[model.relations[relationId].targetId])} say.` }));
6912
+ })
6913
+ },
6914
+ {
6915
+ id: "quote-value-differs",
6916
+ description: "A requirement keeps the sense the words it quotes give a value: the same side of a limit (at most, more than, from \u2026 to; a refusal speaks of the other side), the same unit, the same order of a list, the same rounding.",
6917
+ severity: "warning",
6918
+ dimension: "traceability",
6919
+ run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => quoteSenseGaps(model, req))
6920
+ },
6921
+ {
6922
+ id: "requirement-value-unquoted",
6923
+ description: "Every hard value a requirement states that quotes its need is in those quotes (or in those of the requirements it derives from), in that form or another, or its rationale names it as a decision of the model.",
6924
+ severity: "warning",
6925
+ dimension: "traceability",
6926
+ run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
6927
+ const { unsupported } = quoteValueGaps(model, req);
6928
+ return unsupported.length ? [{ nodeId: req.id, about: unsupported, message: `Requirement ${quote(req)} says ${unsupported.map((v) => `"${v}"`).join(", ")}, which none of the words it quotes say: correct it to what the person said, or say in its rationale that ${unsupported.length === 1 ? "it is" : "they are"} the model's decision.` }] : [];
6929
+ })
6930
+ },
6931
+ {
6932
+ id: "scenario-value-missing",
6933
+ description: "Every hard value a requirement takes from the words it quotes is in a scenario that verifies it (its given, when, then or Gherkin text): what the person said reaches a check.",
6934
+ severity: "warning",
6935
+ dimension: "traceability",
6936
+ run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
6937
+ const scenarios = scenariosOf(model, req.id);
6938
+ if (!scenarios.length) return [];
6939
+ const gaps = quoteValueGaps(model, req);
6940
+ if (!gaps.carried.length) return [];
6941
+ const quoted2 = relationsOf(model, "derives").from.get(req.id) ?? [];
6942
+ const from = quoted2.map((r) => reading(quoteOf(model, r)));
6943
+ const readings = scenarios.map((sc) => reading(scenarioText(sc)));
6944
+ const missing2 = gaps.carried.filter((v) => !readings.some((sc) => from.some((q) => q.values.has(v) && saysValueOf(q, v, sc))));
6945
+ return missing2.length ? [{ nodeId: req.id, relatedIds: scenarios.map((sc) => sc.id), about: missing2, message: `Requirement ${quote(req)} takes ${missing2.map((v) => `"${v}"`).join(", ")} from the words it quotes, which ${scenarios.length === 1 ? `its scenario ${quote(scenarios[0])} does not say` : `none of its ${scenarios.length} scenarios says`}: a scenario that checks the requirement names the values the person gave.` }] : [];
6946
+ })
6947
+ },
6948
+ {
6949
+ id: "example-not-in-scenario",
6950
+ description: `Every example a need gives with values ("for example", "e.g.", "Example:") is whole in one scenario of the requirements derived from the need: the person's own case checks what they meant.`,
6951
+ severity: "warning",
6952
+ dimension: "traceability",
6953
+ run: (model) => nodesOf(model, "need").filter((n) => !originOf(n)).flatMap((need) => {
6954
+ const scenarios = [...new Map(requirementsOfNeed(model, need.id).flatMap((req) => scenariosOf(model, req.id)).map((sc) => [sc.id, sc])).values()];
6955
+ if (!scenarios.length) return [];
6956
+ const readings = scenarios.map((sc) => ({ sc, reading: reading(scenarioText(sc)) }));
6957
+ return needParts(need.description ?? "").filter((part) => part.kind !== "question" && !/\(no requirement\)/i.test(part.text) && !SUPERSEDED.test(part.text)).flatMap((part) => exampleSentences(part.text)).flatMap((example) => {
6958
+ const ex = reading(example);
6959
+ const closest = readings.map(({ sc, reading: r }) => ({ sc, missing: [...ex.values].filter((v) => !saysValueOf(ex, v, r)) })).sort((x, y2) => x.missing.length - y2.missing.length)[0];
6960
+ if (!closest.missing.length) return [];
6961
+ const shown3 = example.length > 140 ? `${example.slice(0, 139)}\u2026` : example;
6962
+ return [{ nodeId: need.id, relatedIds: [closest.sc.id], about: [example], message: `Need ${quote(need)} gives the example "${shown3}", which no scenario of its requirements holds whole: the closest, ${quote(closest.sc)}, does not say ${closest.missing.map((v) => `"${v}"`).join(", ")}. A scenario with the person's own example checks what they meant.` }];
6963
+ });
6964
+ })
6965
+ },
6966
+ {
6967
+ id: "scenario-value-untested",
6968
+ description: "With the test sources (radical check reads the files of the tests .radical/radical.json binds): every hard value a scenario names that tells a case apart (not a count below 10) is in the file of a test bound to it.",
6013
6969
  severity: "warning",
6014
6970
  dimension: "traceability",
6015
- run: (model) => unlinked(model, "need", "derives", "in", ["requirement"]).map((n) => ({ nodeId: n.id, message: `No requirement derives from need ${quote(n)}.` }))
6971
+ run: (model) => {
6972
+ const sources = model.testSources;
6973
+ if (!sources) return [];
6974
+ return nodesOf(model, "scenario").filter((n) => !originOf(n)).flatMap((sc) => {
6975
+ const bound = sc[BOUND_TESTS];
6976
+ const tests = Array.isArray(bound) ? bound.filter((id) => typeof sources[id] === "string") : [];
6977
+ if (!tests.length) return [];
6978
+ const said = reading(scenarioText(sc));
6979
+ const source = sourceReading(tests.map((id) => sources[id]).join("\n"));
6980
+ const text3 = tests.map((id) => sources[id]).join("\n").toLowerCase();
6981
+ const missing2 = [...said.values].filter((v) => telling(v) && !saysValueOf(said, v, source) && !(/[a-z]/.test(v) && text3.includes(v)));
6982
+ return missing2.length ? [{ nodeId: sc.id, details: tests, message: `Scenario ${quote(sc)} names ${missing2.map((v) => `"${v}"`).join(", ")}, which ${tests.length === 1 ? "the file of the test bound to it does not use" : `the files of the ${tests.length} tests bound to it do not use`}: a test that checks the scenario uses the values it names, or the scenario says what the test checks.` }] : [];
6983
+ });
6984
+ }
6985
+ },
6986
+ {
6987
+ id: "need-answer-unquoted",
6988
+ description: "Every paragraph and list item of an answer of a person in a need (from a line that starts with A:, Answer: or A1:, or an answer on its question's line; lead-ins and lines of fewer than four words aside) is quoted by a requirement that derives from the need, or the answer is marked (no requirement) or (superseded).",
6989
+ severity: "warning",
6990
+ dimension: "traceability",
6991
+ run: (model) => {
6992
+ const quotes = /* @__PURE__ */ new Map();
6993
+ for (const r of requirementToNeed(model)) quotes.set(r.targetId, [...quotes.get(r.targetId) ?? [], ...quoteFragments(relationQuote(r))]);
6994
+ return nodesOf(model, "need").filter((n) => !originOf(n)).flatMap((need) => needAnswers(need.description ?? "").filter((answer) => !/\(no requirement\)/i.test(answer) && !SUPERSEDED.test(answer)).flatMap((answer) => {
6995
+ const open4 = unquotedBlocks(answer, quotes.get(need.id) ?? []);
6996
+ if (!open4.length) return [];
6997
+ const blocks = answerBlocks(answer);
6998
+ const start = (t) => `"${t.replace(/\s+/g, " ").slice(0, 90)}${t.length > 90 ? "\u2026" : ""}"`;
6999
+ if (open4.length === Math.max(1, blocks.length)) return [{ nodeId: need.id, about: open4, message: `No requirement quotes this answer in need ${quote(need)}: ${start(answer)} Quote it on a requirement's derives relation, or mark it (no requirement).` }];
7000
+ return [{ nodeId: need.id, details: open4.map(start), about: open4, message: `No requirement quotes ${open4.length} of the ${blocks.length} parts of this answer in need ${quote(need)}: ${open4.map(start).join(", ")}. Quote each on a requirement's derives relation, or mark the answer (no requirement).` }];
7001
+ }));
7002
+ }
7003
+ },
7004
+ {
7005
+ id: "need-answer-changed",
7006
+ description: "With the model at the base (radical check in git, the Inspector with the branch's base): every answer of a person a need held there it still holds, word for word; a person's words are only added to, and an answer a later one replaces is marked (superseded).",
7007
+ severity: "error",
7008
+ dimension: "traceability",
7009
+ run: (model) => {
7010
+ const base = model.baseNodes;
7011
+ if (!base) return [];
7012
+ return nodesOf(model, "need").filter((n) => !originOf(n) && base[n.id]?.type === "need").flatMap((need) => {
7013
+ const now = new Set(needAnswers(need.description ?? "").map(answerKey));
7014
+ return needAnswers(base[need.id].description ?? "").filter((answer) => !now.has(answerKey(answer))).map((answer) => ({ nodeId: need.id, message: `Need ${quote(need)} no longer holds the answer "${answer.replace(/\s+/g, " ").slice(0, 90)}${answer.length > 90 ? "\u2026" : ""}" it held at the base: a person's words are only added to. Restore it as it was, and mark it (superseded) if a later answer replaces it.` }));
7015
+ });
7016
+ }
6016
7017
  },
6017
7018
  {
6018
7019
  id: "scenario-verifies-nothing",
@@ -6026,7 +7027,31 @@ var CHECK_RULES = [
6026
7027
  description: "Every accepted ADR is implemented by a fitness function that checks it.",
6027
7028
  severity: "warning",
6028
7029
  dimension: "decisions",
6029
- run: (model) => model.metamodel.nodeTypes["fitness-fn"] ? unlinked(model, "adr", "implements", "in", ["fitness-fn"]).filter((n) => prop3(n, "status") === "accepted").map((n) => ({ nodeId: n.id, message: `No fitness function implements accepted ADR ${quote(n)}.` })) : []
7030
+ run: (model) => model.metamodel.nodeTypes["fitness-fn"] ? unlinked(model, "adr", "implements", "in", ["fitness-fn"]).filter((n) => prop3(n, "status") === "accepted").filter((n) => !relationsOf(model, "waives").from.has(n.id)).map((n) => ({ nodeId: n.id, message: `No fitness function implements accepted ADR ${quote(n)}.` })) : []
7031
+ },
7032
+ {
7033
+ id: "inherited-adr-unapplied",
7034
+ description: "Every accepted ADR of a model this one depends on (deps.json) binds it: it constrains at least one of this model's elements, or an accepted ADR of this model waives it and says why.",
7035
+ severity: "error",
7036
+ dimension: "decisions",
7037
+ run: (model) => inheritedDecisions(model).filter((d) => !d.elements.length).map(({ adr, origin }) => ({
7038
+ relatedIds: [adr.id],
7039
+ message: `ADR ${quote(adr)} of ${origin} binds this model and applies to none of its elements: link it with constrains to the elements it governs, or record an accepted ADR of this model that waives it and says why.`
7040
+ }))
7041
+ },
7042
+ {
7043
+ id: "inherited-adr-unchecked",
7044
+ description: "Every element an accepted ADR of a model this one depends on constrains is checked: a fitness function implements the ADR (this model's or the other's) and names its check (metric conditions, or tests .radical/radical.json binds to it).",
7045
+ severity: "error",
7046
+ dimension: "decisions",
7047
+ run: (model) => inheritedDecisions(model).flatMap(({ adr, origin, elements }) => {
7048
+ if (!model.metamodel.nodeTypes["fitness-fn"] || linkedNodes(model, adr.id, "implements", "source", "fitness-fn").some(namesCheck)) return [];
7049
+ return elements.map((e2) => ({
7050
+ nodeId: e2.id,
7051
+ relatedIds: [adr.id],
7052
+ message: `Nothing checks ADR ${quote(adr)} of ${origin} on ${e2.type} ${quote(e2)}: add a fitness function that implements the ADR and names its check (metrics, or tests .radical/radical.json binds to it).`
7053
+ }));
7054
+ })
6030
7055
  },
6031
7056
  {
6032
7057
  id: "adr-incomplete",
@@ -6196,7 +7221,7 @@ var CHECK_RULES = [
6196
7221
  severity: "error",
6197
7222
  dimension: "tests",
6198
7223
  readsReports: true,
6199
- run: testRule("failed", (node, id, model) => `${TYPE_NAME[node.type]} ${quote(node)}: test ${id} failed.${brokenWith(model, node)}`)
7224
+ run: testRule("failed", (node, id, model) => `${testedName(node)}: test ${id} failed.${brokenWith(model, node)}`)
6200
7225
  },
6201
7226
  {
6202
7227
  id: "test-not-found",
@@ -6204,7 +7229,7 @@ var CHECK_RULES = [
6204
7229
  severity: "error",
6205
7230
  dimension: "tests",
6206
7231
  readsReports: true,
6207
- run: (model) => testRule("not-found", (node, id) => model.testsReadAt ? `${TYPE_NAME[node.type]} ${quote(node)}: no test ${id} in the test results read ${model.testsReadAt.slice(0, 10)}, ${formatAge((model.now ?? Date.now()) - Date.parse(model.testsReadAt))} ago; added since, renamed or deleted? radical check --report reads the tests again.` : `${TYPE_NAME[node.type]} ${quote(node)}: no test ${id} in the reports, though its file ran; renamed or deleted?${brokenWith(model, node)}`)(model).map((f) => model.testsReadAt ? { ...f, asOf: model.testsReadAt } : f)
7232
+ run: (model) => testRule("not-found", (node, id) => model.testsReadAt ? `${testedName(node)}: no test ${id} in the test results read ${model.testsReadAt.slice(0, 10)}, ${formatAge((model.now ?? Date.now()) - Date.parse(model.testsReadAt))} ago; added since, renamed or deleted? radical check --report reads the tests again.` : `${testedName(node)}: no test ${id} in the reports, though its file ran; renamed or deleted?${brokenWith(model, node)}`)(model).map((f) => model.testsReadAt ? { ...f, asOf: model.testsReadAt } : f)
6208
7233
  },
6209
7234
  {
6210
7235
  id: "test-skipped",
@@ -6212,7 +7237,7 @@ var CHECK_RULES = [
6212
7237
  severity: "warning",
6213
7238
  dimension: "tests",
6214
7239
  readsReports: true,
6215
- run: testRule("skipped", (node, id) => `${TYPE_NAME[node.type]} ${quote(node)}: test ${id} was skipped.`)
7240
+ run: testRule("skipped", (node, id) => `${testedName(node)}: test ${id} was skipped.`)
6216
7241
  },
6217
7242
  {
6218
7243
  id: "test-not-run",
@@ -6220,7 +7245,7 @@ var CHECK_RULES = [
6220
7245
  severity: "warning",
6221
7246
  dimension: "tests",
6222
7247
  readsReports: true,
6223
- run: testRule("not-run", (node, id) => `${TYPE_NAME[node.type]} ${quote(node)}: no report has the file of test ${id}.`)
7248
+ run: testRule("not-run", (node, id) => `${testedName(node)}: no report has the file of test ${id}.`)
6224
7249
  },
6225
7250
  {
6226
7251
  id: "metric-failed",
@@ -6317,8 +7342,14 @@ var CHECK_METRICS = [
6317
7342
  byRule("elements-valid", "Elements the metamodel allows", "Elements no metamodel issue points at.", "consistency", "metamodel", (m) => Object.values(m.nodes)),
6318
7343
  byRule("requirements-complete", "Complete requirements", "Requirements with an action and every field their EARS type reads.", "completeness", "requirement-incomplete", (m) => nodesOf(m, "requirement")),
6319
7344
  byRule("adrs-complete", "Complete accepted ADRs", "Accepted ADRs with a date, context, decision and consequences.", "completeness", "adr-incomplete", acceptedAdrs),
6320
- byRule("needs-with-requirement", "Needs with a requirement", "Needs at least one requirement derives from.", "traceability", "need-without-requirement", (m) => nodesOf(m, "need")),
7345
+ byRule("needs-with-requirement", "Needs with a requirement", "Needs at least one requirement derives from, directly or through a need inside them.", "traceability", "need-without-requirement", (m) => nodesOf(m, "need")),
6321
7346
  byRule("requirements-with-origin", "Requirements with an origin", "Requirements that derive from a need or another requirement.", "traceability", "requirement-without-origin", (m) => nodesOf(m, "requirement")),
7347
+ byRule("requirements-quoting-need", "Requirements that quote their need", "Requirements derived from a need whose Derives from relation quotes the words they rest on; measured once a relation of the model quotes.", "traceability", "derives-quote-missing", (m) => {
7348
+ const toNeed = Object.values(m.relations).filter((r) => r.relationType === "derives" && m.nodes[r.targetId]?.type === "need");
7349
+ if (!toNeed.some((r) => typeof r.quote === "string" && r.quote.trim())) return null;
7350
+ const derived = new Set(toNeed.map((r) => r.sourceId));
7351
+ return nodesOf(m, "requirement").filter((n) => derived.has(n.id));
7352
+ }),
6322
7353
  byRule("requirements-satisfied", "Requirements satisfied", "Requirements an element of the architecture satisfies.", "traceability", "requirement-unsatisfied", (m) => nodesOf(m, "requirement")),
6323
7354
  byRule("requirements-with-scenario", "Requirements with a scenario", "Requirements at least one scenario verifies.", "traceability", "requirement-without-scenario", (m) => hasType(m, "scenario") ? nodesOf(m, "requirement") : null),
6324
7355
  byRule("scenarios-verifying", "Scenarios that verify something", "Scenarios that verify a requirement or a state machine.", "traceability", "scenario-verifies-nothing", (m) => nodesOf(m, "scenario")),
@@ -6421,6 +7452,170 @@ function measureGoals(ctx, goals) {
6421
7452
  return { metrics, findings, notRun };
6422
7453
  }
6423
7454
 
7455
+ // ../../packages/common/src/check/testSource.ts
7456
+ init_define_RADICAL_BUILD();
7457
+ function splitTestId(id) {
7458
+ const [file, ...titles] = testIdParts(id);
7459
+ return { file, titles: titles.filter(Boolean) };
7460
+ }
7461
+
7462
+ // ../../packages/common/src/check/trace.ts
7463
+ init_define_RADICAL_BUILD();
7464
+ var TRACE_TYPES = ["need", "requirement", "scenario", "adr", "fitness-fn"];
7465
+ var UP = [
7466
+ { relationType: "derives", from: "requirement", to: ["need", "requirement"] },
7467
+ // A need inside a broader one (Part of): the path goes up to the broadest.
7468
+ { relationType: "derives", from: "need", to: ["need"] },
7469
+ { relationType: "verifies", from: "scenario", to: ["requirement"] },
7470
+ { relationType: "implements", from: "fitness-fn", to: ["adr"] }
7471
+ ];
7472
+ var RANK = {
7473
+ failed: 0,
7474
+ broken: 0,
7475
+ "not-found": 0,
7476
+ invalid: 0,
7477
+ stale: 1,
7478
+ "not-run": 2,
7479
+ skipped: 2,
7480
+ unverified: 2,
7481
+ "no-checks": 3,
7482
+ passed: 4,
7483
+ verified: 4
7484
+ };
7485
+ var rankOf = (status) => status ? RANK[status] ?? 3 : 3;
7486
+ function rollUp(children) {
7487
+ const statuses = children.map((c) => c.status).filter((s2) => !!s2);
7488
+ if (!statuses.length) return children.length ? void 0 : "unverified";
7489
+ if (statuses.includes("broken") || statuses.includes("failed")) return "broken";
7490
+ return statuses.length === children.length && statuses.every((s2) => s2 === "verified" || s2 === "passed") ? "verified" : "unverified";
7491
+ }
7492
+ function resultsOf(conditions, cases) {
7493
+ return (conditions ?? []).map((c) => {
7494
+ const id = c.test ? parseTestIds(c.test)[0] : void 0;
7495
+ const found = id && cases ? findTests(id, cases).matches : [];
7496
+ return {
7497
+ condition: c.condition,
7498
+ outcome: c.outcome,
7499
+ ...c.test ? { test: c.test } : {},
7500
+ ...c.measurement ? { measurement: c.measurement } : {},
7501
+ ...c.detail ? { detail: c.detail } : {},
7502
+ ...found.length ? { cases: [...found].sort((a2, b) => rankOf(a2.status) - rankOf(b.status)) } : {}
7503
+ };
7504
+ }).sort((a2, b) => rankOf(a2.outcome) - rankOf(b.outcome));
7505
+ }
7506
+ var unjudged = (node) => (originOf(node) ? boundConditions(node) : conditionsOf(node)).map((c) => ({ condition: c.raw, ...c.kind === "test" ? { test: c.id.raw } : {} }));
7507
+ function verifiedFrom(checkers) {
7508
+ if (!checkers.some((s2) => s2)) return void 0;
7509
+ if (checkers.includes("failed")) return "broken";
7510
+ return checkers.every((s2) => s2 === "passed") ? "verified" : "unverified";
7511
+ }
7512
+ var CHECKER = { requirement: "scenario", adr: "fitness-fn" };
7513
+ function traceOf(input, id) {
7514
+ const { nodes, relations } = input;
7515
+ const target = nodes[id];
7516
+ if (!target || !TRACE_TYPES.includes(target.type)) return { id, roots: [] };
7517
+ const up = /* @__PURE__ */ new Map();
7518
+ const down = /* @__PURE__ */ new Map();
7519
+ for (const r of Object.values(relations)) {
7520
+ const s2 = nodes[r.sourceId];
7521
+ const t = nodes[r.targetId];
7522
+ if (!s2 || !t || s2.id === t.id) continue;
7523
+ if (!UP.some((u) => u.relationType === r.relationType && u.from === s2.type && u.to.includes(t.type))) continue;
7524
+ up.set(s2.id, [...up.get(s2.id) ?? [], t.id]);
7525
+ down.set(t.id, [...down.get(t.id) ?? [], s2.id]);
7526
+ }
7527
+ const above = /* @__PURE__ */ new Set();
7528
+ const roots = [];
7529
+ const climb = (n, seen) => {
7530
+ const parents = (up.get(n) ?? []).filter((p) => !seen.has(p));
7531
+ if (!parents.length) {
7532
+ if (!roots.includes(n)) roots.push(n);
7533
+ return;
7534
+ }
7535
+ for (const p of parents) {
7536
+ above.add(p);
7537
+ climb(p, /* @__PURE__ */ new Set([...seen, p]));
7538
+ }
7539
+ };
7540
+ climb(id, /* @__PURE__ */ new Set([id]));
7541
+ const ev = input.evidence?.nodes;
7542
+ const build2 = (n, path, under) => {
7543
+ const node = nodes[n];
7544
+ const e2 = ev?.[n];
7545
+ const isTarget = n === id;
7546
+ const below = under || isTarget;
7547
+ const base = { id: n, type: node.type, label: node.label, ...isTarget ? { target: true } : {}, children: [], results: [] };
7548
+ if (path.has(n)) return { ...base, status: e2?.status, repeated: true };
7549
+ const next = /* @__PURE__ */ new Set([...path, n]);
7550
+ const kids = (down.get(n) ?? []).filter((k, i, all) => all.indexOf(k) === i && (below || k === id || above.has(k)));
7551
+ const children = kids.map((k) => build2(k, next, below)).sort((a2, b) => rankOf(a2.status) - rankOf(b.status) || Number(a2.type === b.type ? 0 : a2.type === "requirement") - Number(a2.type === b.type ? 0 : b.type === "requirement") || a2.label.localeCompare(b.label));
7552
+ const elements = e2?.elements?.map((el) => ({ id: el.id, label: el.label, status: el.status, results: resultsOf(el.conditions, input.cases) })).sort((a2, b) => rankOf(a2.status) - rankOf(b.status));
7553
+ const checkers = !e2 && ev && CHECKER[node.type] ? (down.get(n) ?? []).filter((k) => nodes[k].type === CHECKER[node.type]).map((k) => ev[k]?.status) : [];
7554
+ return {
7555
+ ...base,
7556
+ status: e2?.status ?? (node.type === "need" && ev ? rollUp(children) : checkers.length ? verifiedFrom(checkers) : void 0),
7557
+ children,
7558
+ results: e2 || !TESTED_TYPES.includes(node.type) ? resultsOf(e2?.conditions, input.cases) : unjudged(node),
7559
+ ...elements?.length ? { elements } : {}
7560
+ };
7561
+ };
7562
+ return {
7563
+ id,
7564
+ roots: roots.map((r) => build2(r, /* @__PURE__ */ new Set(), false)).sort((a2, b) => rankOf(a2.status) - rankOf(b.status) || a2.label.localeCompare(b.label))
7565
+ };
7566
+ }
7567
+ var TYPE_LABEL2 = { need: "Need", requirement: "Requirement", scenario: "Scenario", adr: "ADR", "fitness-fn": "Fitness function" };
7568
+ var traceTypeLabel = (type2) => TYPE_LABEL2[type2] ?? type2;
7569
+ function traceGap(node) {
7570
+ if (node.repeated || node.children.length || node.results.length || node.elements?.length) return null;
7571
+ switch (node.type) {
7572
+ case "need":
7573
+ return "no requirement derives from it";
7574
+ case "requirement":
7575
+ return "no scenario verifies it";
7576
+ case "adr":
7577
+ return "no fitness function implements it";
7578
+ case "scenario":
7579
+ case "fitness-fn":
7580
+ return "names no check";
7581
+ default:
7582
+ return null;
7583
+ }
7584
+ }
7585
+ function resultLine(r, now) {
7586
+ const what = r.test ?? r.condition;
7587
+ const m = r.measurement;
7588
+ const measured = m ? ` \xB7 ${m.value}${m.unit ? ` ${m.unit}` : ""} by ${m.source}, ${Math.max(0, Math.round((now - Date.parse(m.at)) / 36e5))} h ago` : "";
7589
+ return `${what} \u2014 ${r.outcome ?? "no results"}${measured}${r.detail && !m ? ` (${r.detail})` : ""}`;
7590
+ }
7591
+ function formatTrace(trace, nodes, now = Date.now()) {
7592
+ const asked = nodes[trace.id];
7593
+ if (!asked) return `No element ${trace.id} in the model.`;
7594
+ const out = [];
7595
+ if (!trace.roots.length) return `${asked.label} (${asked.type}) is on no verification path: paths are made of ${TRACE_TYPES.join(", ")}.`;
7596
+ out.push(`Verification path of ${asked.label} [${asked.id}]`);
7597
+ const walk = (n, depth) => {
7598
+ const pad = " ".repeat(depth);
7599
+ out.push(`${pad}${n.target ? "\u25B6 " : "- "}${traceTypeLabel(n.type)}: ${n.label} [${n.id}] \u2014 ${n.status ?? "no results"}${n.repeated ? " (again, see above)" : ""}`);
7600
+ const gap = traceGap(n);
7601
+ if (gap) out.push(`${pad} (${gap})`);
7602
+ for (const r of n.results) {
7603
+ out.push(`${pad} \xB7 ${resultLine(r, now)}`);
7604
+ for (const c of r.cases ?? []) {
7605
+ if (c.status !== "failed" || !c.message) continue;
7606
+ for (const line of c.message.split("\n").slice(0, 4)) out.push(`${pad} ${line}`);
7607
+ }
7608
+ }
7609
+ for (const el of n.elements ?? []) {
7610
+ out.push(`${pad} for ${el.label} [${el.id}] \u2014 ${el.status}`);
7611
+ for (const r of el.results) out.push(`${pad} \xB7 ${resultLine(r, now)}`);
7612
+ }
7613
+ for (const c of n.children) walk(c, depth + 1);
7614
+ };
7615
+ for (const r of trace.roots) walk(r, 0);
7616
+ return out.join("\n");
7617
+ }
7618
+
6424
7619
  // ../../packages/common/src/check/files.ts
6425
7620
  init_define_RADICAL_BUILD();
6426
7621
  var CHECK_CONFIG_FILE = "check.json";
@@ -6632,6 +7827,7 @@ function upgradeCheckConfig(config) {
6632
7827
  }
6633
7828
  var RULE_IDS = new Set(ALL_RULES.map((r) => r.id));
6634
7829
  var DEFAULT_SEVERITY = new Map(ALL_RULES.map((r) => [r.id, r.severity]));
7830
+ var DEFAULT_OFF = new Set(ALL_RULES.filter((r) => r.off).map((r) => r.id));
6635
7831
  function runCheck(files, given = {}, options = {}) {
6636
7832
  const config = upgradeCheckConfig(given);
6637
7833
  const found = [];
@@ -6671,8 +7867,8 @@ function runCheck(files, given = {}, options = {}) {
6671
7867
  };
6672
7868
  if (!found.some((f) => FATAL.has(f.rule))) {
6673
7869
  const data = deserializeFromMdFolder(files).data;
6674
- const others = options.others;
6675
- model = checkData(others ? { ...data, nodes: [...data.nodes, ...others.nodes], relations: [...data.relations, ...others.relations] } : data, options, config);
7870
+ const others2 = options.others;
7871
+ model = checkData(others2 ? { ...data, nodes: [...data.nodes, ...others2.nodes], relations: [...data.relations, ...others2.relations] } : data, options, config);
6676
7872
  }
6677
7873
  const result = settle([...found, ...model.found].map((f) => ({
6678
7874
  ...f,
@@ -6681,6 +7877,11 @@ function runCheck(files, given = {}, options = {}) {
6681
7877
  })), config, model);
6682
7878
  return model.evidence ? { ...result, evidence: model.evidence } : result;
6683
7879
  }
7880
+ function withElement(finding, model) {
7881
+ if (finding.nodeId || !finding.relationId) return finding;
7882
+ const source = model.relations[finding.relationId]?.sourceId;
7883
+ return source && model.nodes[source] ? { ...finding, nodeId: source } : finding;
7884
+ }
6684
7885
  function withRepositorySettings(rules, tests) {
6685
7886
  if (!tests?.include && !tests?.exclude) return rules;
6686
7887
  const own = rules["test-unbound"];
@@ -6714,14 +7915,17 @@ function checkData(data, options, config) {
6714
7915
  ...options.now !== void 0 ? { now: options.now } : {},
6715
7916
  ...options.sensors !== void 0 ? { sensors: options.sensors } : {},
6716
7917
  ...options.repository !== void 0 ? { repository: options.repository } : {},
6717
- ...options.missingPaths ? { missingPaths: options.missingPaths } : {}
7918
+ ...options.missingPaths ? { missingPaths: options.missingPaths } : {},
7919
+ ...options.testSources ? { testSources: options.testSources } : {},
7920
+ ...options.baseNodes ? { baseNodes: byId(options.baseNodes) } : {}
6718
7921
  };
6719
7922
  const model = { nodes, relations, ...settings };
6720
7923
  const theirs = new Set([...data.nodes, ...data.relations].filter((item) => originOf(item)).map((item) => item.id));
6721
7924
  const ownModel2 = theirs.size ? { nodes: byId(data.nodes.filter((n) => !theirs.has(n.id))), relations: byId(data.relations.filter((r) => !theirs.has(r.id))), ...settings } : model;
7925
+ const boundHere = (rule, id) => !!rule.readsReports && !!id && BOUND_TESTS in (nodes[id] ?? {});
6722
7926
  for (const rule of CHECK_RULES) {
6723
7927
  rule.run(model).forEach((finding) => {
6724
- if (!(finding.nodeId && theirs.has(finding.nodeId)) && !(finding.relationId && theirs.has(finding.relationId))) found.push({ rule: rule.id, ...finding });
7928
+ if (!(finding.nodeId && theirs.has(finding.nodeId) && !boundHere(rule, finding.nodeId)) && !(finding.relationId && theirs.has(finding.relationId))) found.push({ rule: rule.id, ...withElement(finding, model) });
6725
7929
  });
6726
7930
  }
6727
7931
  const evidence = options.tests || options.measurements ? computeEvidence(model) : void 0;
@@ -6780,7 +7984,8 @@ function settle(found, config, { nodeCount, relationCount, metrics, notRun, goal
6780
7984
  const results = [];
6781
7985
  for (const key of keys) {
6782
7986
  const list = groups.get(key) ?? [];
6783
- const { severity: set2, max: max2 } = settingOf(rules[key]);
7987
+ const { severity: given, max: max2 } = settingOf(rules[key]);
7988
+ const set2 = given ?? (DEFAULT_OFF.has(key.split("/")[0]) ? "off" : void 0);
6784
7989
  const ruleSeverity = DEFAULT_SEVERITY.get(key.split("/")[0]) ?? "error";
6785
7990
  const why = notRun.get(key.split("/")[0]);
6786
7991
  if (why) {
@@ -6927,8 +8132,8 @@ function parseFederationFile(text3) {
6927
8132
  }
6928
8133
  function otherModelView(view, origin) {
6929
8134
  if (view.kind === "explore") return null;
6930
- const { sequenceId: _sequence, explore: _explore, partOf: _partOf, ...kept } = view;
6931
- return { ...kept, origin };
8135
+ const { sequenceId: _sequence, explore: _explore, ...kept2 } = view;
8136
+ return { ...kept2, origin };
6932
8137
  }
6933
8138
  var refShown = (d) => d.resolved ? `${d.ref} \u2192 ${d.resolved}` : d.ref;
6934
8139
 
@@ -7398,7 +8603,7 @@ function a(r) {
7398
8603
 
7399
8604
  // ../../node_modules/markdown-to-jsx/dist/html.js
7400
8605
  var S = 32;
7401
- var N = 9;
8606
+ var N2 = 9;
7402
8607
  var cr = 13;
7403
8608
  var y = 10;
7404
8609
  var Ae = 96;
@@ -7480,7 +8685,7 @@ function la(e2) {
7480
8685
  let o = e2.charCodeAt(i);
7481
8686
  if (o >= Ce && o <= He || o >= J && o <= G || o >= Y && o <= V || o === Ne) {
7482
8687
  for (i++; i < a2 && (o = e2.charCodeAt(i), o >= Ce && o <= He || o >= J && o <= G || o >= Y && o <= V || o === Ne || o === z || o === ir); ) i++;
7483
- i < a2 && e2.charCodeAt(i) === Qe && (i++, i >= a2 ? n = true : (o = e2.charCodeAt(i), (o === S || o === N) && (n = true)));
8688
+ i < a2 && e2.charCodeAt(i) === Qe && (i++, i >= a2 ? n = true : (o = e2.charCodeAt(i), (o === S || o === N2) && (n = true)));
7484
8689
  }
7485
8690
  }
7486
8691
  }
@@ -7560,7 +8765,7 @@ var vr = 32;
7560
8765
  var Br = 64;
7561
8766
  var Ca = (() => {
7562
8767
  var e2 = new Uint8Array(128), r;
7563
- for (e2[N] = Fr, e2[y] = Fr | ta, e2[Zt] = Fr, e2[cr] = Fr | ta, e2[S] = Fr, r = Ze; r <= be; r++) e2[r] = on;
8768
+ for (e2[N2] = Fr, e2[y] = Fr | ta, e2[Zt] = Fr, e2[cr] = Fr | ta, e2[S] = Fr, r = Ze; r <= be; r++) e2[r] = on;
7564
8769
  for (r = Qe; r <= yn; r++) e2[r] = on;
7565
8770
  for (r = he; r <= Ae; r++) e2[r] = on;
7566
8771
  for (r = Mr; r <= De; r++) e2[r] = on;
@@ -7742,19 +8947,19 @@ function ya(e2) {
7742
8947
  return bn.has(e2);
7743
8948
  }
7744
8949
  function Pa(e2, r, n) {
7745
- for (var t = r, a2 = n; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N); ) t++;
8950
+ for (var t = r, a2 = n; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N2); ) t++;
7746
8951
  if (t >= a2) return false;
7747
8952
  e2.charCodeAt(t) === Fe && t++;
7748
8953
  for (var i = 0; t < a2; ) {
7749
- for (; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N); ) t++;
8954
+ for (; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N2); ) t++;
7750
8955
  if (t >= a2) break;
7751
8956
  if (e2.charCodeAt(t) === Fe && i > 0) {
7752
- for (var o = t + 1; o < a2 && (e2.charCodeAt(o) === S || e2.charCodeAt(o) === N); ) o++;
8957
+ for (var o = t + 1; o < a2 && (e2.charCodeAt(o) === S || e2.charCodeAt(o) === N2); ) o++;
7753
8958
  if (o >= a2) return true;
7754
8959
  }
7755
8960
  if (e2.charCodeAt(t) === Qe && t++, t >= a2 || e2.charCodeAt(t) !== z) return false;
7756
8961
  for (; t < a2 && e2.charCodeAt(t) === z; ) t++;
7757
- for (t < a2 && e2.charCodeAt(t) === Qe && t++, i++; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N); ) t++;
8962
+ for (t < a2 && e2.charCodeAt(t) === Qe && t++, i++; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N2); ) t++;
7758
8963
  if (t < a2) if (e2.charCodeAt(t) === Fe) t++;
7759
8964
  else return false;
7760
8965
  }
@@ -7812,7 +9017,7 @@ function yr(e2, r) {
7812
9017
  let A = e2.slice(i, n);
7813
9018
  if (!A) return null;
7814
9019
  let C = A.charCodeAt(0), l = C >= J && C <= G || A.indexOf("-") !== -1, _ = n;
7815
- for (; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N || e2.charCodeAt(n) === y); ) n++;
9020
+ for (; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N2 || e2.charCodeAt(n) === y); ) n++;
7816
9021
  let d = e2.slice(_, n);
7817
9022
  if (n === _ && n < t) {
7818
9023
  var c = e2.charCodeAt(n);
@@ -7825,7 +9030,7 @@ function yr(e2, r) {
7825
9030
  let O = g ? $a(e2, f, n, g) : e2.slice(f, n);
7826
9031
  return { t: u, u: l, g: a2, a: O, q: g != null, o: false, h: d, attrs: h, end: n + 1, tag: A };
7827
9032
  }
7828
- if (b === S || b === N || b === y) {
9033
+ if (b === S || b === N2 || b === y) {
7829
9034
  n++;
7830
9035
  continue;
7831
9036
  }
@@ -7841,10 +9046,10 @@ function yr(e2, r) {
7841
9046
  if (T >= Ce && T <= He || T >= J && T <= G || T >= Y && T <= V || T === Ne || T === ir || T === Qe || T === z) n++;
7842
9047
  else break;
7843
9048
  }
7844
- for (var x = e2.slice(R, n), D = n; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N); ) n++;
9049
+ for (var x = e2.slice(R, n), D = n; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N2); ) n++;
7845
9050
  var v, I;
7846
9051
  if (e2.charCodeAt(n) === _r) {
7847
- for (n++; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N); ) n++;
9052
+ for (n++; n < t && (e2.charCodeAt(n) === S || e2.charCodeAt(n) === N2); ) n++;
7848
9053
  var E = e2.charCodeAt(n);
7849
9054
  if (E === dr || E === Gr) {
7850
9055
  n++;
@@ -7852,7 +9057,7 @@ function yr(e2, r) {
7852
9057
  if (n >= t) return null;
7853
9058
  if (v = e2.slice(p, n), n++, n < t) {
7854
9059
  var k = e2.charCodeAt(n);
7855
- if (k !== S && k !== N && k !== y && k !== U && k !== be) return null;
9060
+ if (k !== S && k !== N2 && k !== y && k !== U && k !== be) return null;
7856
9061
  }
7857
9062
  I = n;
7858
9063
  } else if (E === Mr) {
@@ -7865,7 +9070,7 @@ function yr(e2, r) {
7865
9070
  } else {
7866
9071
  for (var p = n; n < t; ) {
7867
9072
  var M = e2.charCodeAt(n);
7868
- if (M === S || M === N || M === U || M === y || M === dr || M === Gr || M === _r || M === ae || M === Ae) break;
9073
+ if (M === S || M === N2 || M === U || M === y || M === dr || M === Gr || M === _r || M === ae || M === Ae) break;
7869
9074
  n++;
7870
9075
  }
7871
9076
  if (n === p) return null;
@@ -7890,7 +9095,7 @@ function Ii(e2, r, n) {
7890
9095
  for (var t = 0, a2 = e2.length, i = false, o = false; t < a2; ) {
7891
9096
  for (var A = e2.indexOf(`
7892
9097
  `, t), C = A < 0 ? a2 : A, l = t, _ = 0; l < C && _ < 4; ) if (e2.charCodeAt(l) === S) _++, l++;
7893
- else if (e2.charCodeAt(l) === N) _ += 4, l++;
9098
+ else if (e2.charCodeAt(l) === N2) _ += 4, l++;
7894
9099
  else break;
7895
9100
  if (l >= C) {
7896
9101
  i = false, t = A < 0 ? a2 : A + 1;
@@ -7914,13 +9119,13 @@ function Ii(e2, r, n) {
7914
9119
  for (var H = R, T = 0; H < a2 && T < 4; ) {
7915
9120
  var x = e2.charCodeAt(H);
7916
9121
  if (x === S) T++, H++;
7917
- else if (x === N) T += 4, H++;
9122
+ else if (x === N2) T += 4, H++;
7918
9123
  else break;
7919
9124
  }
7920
9125
  if (T < 4 && H < a2 && e2.charCodeAt(H) === c) {
7921
9126
  for (var D = 0; H < a2 && e2.charCodeAt(H) === c; ) D++, H++;
7922
9127
  if (D >= f) {
7923
- for (; H < a2 && (e2.charCodeAt(H) === S || e2.charCodeAt(H) === N); ) H++;
9128
+ for (; H < a2 && (e2.charCodeAt(H) === S || e2.charCodeAt(H) === N2); ) H++;
7924
9129
  if (H >= a2 || e2.charCodeAt(H) === y) {
7925
9130
  t = H >= a2 ? a2 : H + 1;
7926
9131
  break;
@@ -7939,7 +9144,7 @@ function Ii(e2, r, n) {
7939
9144
  for (var v = l; v < C && e2.charCodeAt(v) === U; ) {
7940
9145
  v++, v < C && e2.charCodeAt(v) === S && v++;
7941
9146
  for (var I = 0; v < C && I < 4; ) if (e2.charCodeAt(v) === S) I++, v++;
7942
- else if (e2.charCodeAt(v) === N) I += 4, v++;
9147
+ else if (e2.charCodeAt(v) === N2) I += 4, v++;
7943
9148
  else break;
7944
9149
  if (I >= 4) break;
7945
9150
  i = false;
@@ -7957,7 +9162,7 @@ function Ii(e2, r, n) {
7957
9162
  for (var k = l, L = 0; k < C; ) {
7958
9163
  var M = e2.charCodeAt(k);
7959
9164
  if (M === p) L++;
7960
- else if (M !== S && M !== N) break;
9165
+ else if (M !== S && M !== N2) break;
7961
9166
  k++;
7962
9167
  }
7963
9168
  i = !(L >= 3 && k >= C);
@@ -7988,7 +9193,7 @@ function Da(e2, r, n) {
7988
9193
  let l = false;
7989
9194
  for (; i < t; ) {
7990
9195
  let b = e2.charCodeAt(i);
7991
- if (b === S || b === N) i++;
9196
+ if (b === S || b === N2) i++;
7992
9197
  else if (b === y && !l) l = true, i++;
7993
9198
  else break;
7994
9199
  }
@@ -8004,7 +9209,7 @@ function Da(e2, r, n) {
8004
9209
  if (i >= t || e2.charCodeAt(i) !== U) return null;
8005
9210
  _ = e2.slice(d, i), i++;
8006
9211
  for (var c = e2.indexOf(`
8007
- `, i), f = c < 0 ? t : c, h = i; h < f && (e2.charCodeAt(h) === S || e2.charCodeAt(h) === N); ) h++;
9212
+ `, i), f = c < 0 ? t : c, h = i; h < f && (e2.charCodeAt(h) === S || e2.charCodeAt(h) === N2); ) h++;
8008
9213
  if (h < f) {
8009
9214
  if (h === i) return null;
8010
9215
  var u = e2.charCodeAt(h);
@@ -8018,24 +9223,24 @@ function Da(e2, r, n) {
8018
9223
  if (g === 0) break;
8019
9224
  g--;
8020
9225
  } else {
8021
- if (o === S || o === N || o === y) break;
9226
+ if (o === S || o === N2 || o === y) break;
8022
9227
  o === Me && i + 1 < t && i++;
8023
9228
  }
8024
9229
  i++;
8025
9230
  }
8026
9231
  if (_ = e2.slice(d, i), !_) return null;
8027
9232
  }
8028
- for (; i < t && (e2.charCodeAt(i) === S || e2.charCodeAt(i) === N); ) i++;
9233
+ for (; i < t && (e2.charCodeAt(i) === S || e2.charCodeAt(i) === N2); ) i++;
8029
9234
  var R = e2.indexOf(`
8030
9235
  `, i), H = R < 0 ? t : R, T, x = false, D = i, v = i;
8031
- if (i === H && i < t) for (v = i + 1; v < t && (e2.charCodeAt(v) === S || e2.charCodeAt(v) === N); ) v++;
9236
+ if (i === H && i < t) for (v = i + 1; v < t && (e2.charCodeAt(v) === S || e2.charCodeAt(v) === N2); ) v++;
8032
9237
  if (v < t) {
8033
9238
  var I = e2.charCodeAt(v);
8034
9239
  if (I === dr || I === Gr || I === or) {
8035
9240
  for (var E = I === or ? 41 : I, p = v + 1, k = p; p < t; ) {
8036
9241
  var L = e2.charCodeAt(p);
8037
9242
  if (L === E) {
8038
- for (var M = p + 1; M < t && (e2.charCodeAt(M) === S || e2.charCodeAt(M) === N); ) M++;
9243
+ for (var M = p + 1; M < t && (e2.charCodeAt(M) === S || e2.charCodeAt(M) === N2); ) M++;
8039
9244
  (M >= t || e2.charCodeAt(M) === y) && (T = e2.slice(k, p), x = true, D = M < t ? M + 1 : t);
8040
9245
  break;
8041
9246
  }
@@ -8050,7 +9255,7 @@ function Da(e2, r, n) {
8050
9255
  }
8051
9256
  }
8052
9257
  if (x) return n[C] || (n[C] = { target: Hr(un(_)), title: T === void 0 ? T : Hr(un(T)) }), D;
8053
- for (; i < H && (e2.charCodeAt(i) === S || e2.charCodeAt(i) === N); ) i++;
9258
+ for (; i < H && (e2.charCodeAt(i) === S || e2.charCodeAt(i) === N2); ) i++;
8054
9259
  return i < H ? null : (n[C] || (n[C] = { target: Hr(un(_)), title: T }), R < 0 ? t : R + 1);
8055
9260
  }
8056
9261
  var Ar = new Uint8Array(Ca);
@@ -8107,7 +9312,7 @@ function re(e2, r) {
8107
9312
  function wn(e2, r, n) {
8108
9313
  for (; r < n; ) {
8109
9314
  let t = e2.charCodeAt(r);
8110
- if (t !== S && t !== N) break;
9315
+ if (t !== S && t !== N2) break;
8111
9316
  r++;
8112
9317
  }
8113
9318
  return r;
@@ -8131,7 +9336,7 @@ var le = 0;
8131
9336
  function Xe(e2, r, n) {
8132
9337
  for (_e = 0, le = 0; r + le < n; ) {
8133
9338
  let t = e2.charCodeAt(r + le);
8134
- if (t === N) _e += 4 - _e % 4;
9339
+ if (t === N2) _e += 4 - _e % 4;
8135
9340
  else if (t === S) _e++;
8136
9341
  else break;
8137
9342
  le++;
@@ -8153,7 +9358,7 @@ function mi(e2, r, n, t) {
8153
9358
  let i = r + le;
8154
9359
  if (e2.charCodeAt(i) !== fr) return null;
8155
9360
  let o = Vr(e2, i, a2, 35);
8156
- if (o < 1 || o > 6 || (i += o, i < a2 && e2.charCodeAt(i) !== S && e2.charCodeAt(i) !== N)) return null;
9361
+ if (o < 1 || o > 6 || (i += o, i < a2 && e2.charCodeAt(i) !== S && e2.charCodeAt(i) !== N2)) return null;
8157
9362
  i = wn(e2, i, a2);
8158
9363
  for (var A = a2; A > i && e2.charCodeAt(A - 1) === S; ) A--;
8159
9364
  for (var C = A; A > i && e2.charCodeAt(A - 1) === fr; ) A--;
@@ -8166,7 +9371,7 @@ function ki(e2, r, n) {
8166
9371
  var t = e2.charCodeAt(r);
8167
9372
  if (t !== _r && t !== z) return false;
8168
9373
  for (var a2 = r; a2 < n && e2.charCodeAt(a2) === t; ) a2++;
8169
- for (; a2 < n && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N); ) a2++;
9374
+ for (; a2 < n && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N2); ) a2++;
8170
9375
  return a2 >= n;
8171
9376
  }
8172
9377
  function Qr(e2, r) {
@@ -8178,7 +9383,7 @@ function Qr(e2, r) {
8178
9383
  for (; t < n; ) {
8179
9384
  let o = e2.charCodeAt(t);
8180
9385
  if (o === a2) i++;
8181
- else if (o !== S && o !== N) return null;
9386
+ else if (o !== S && o !== N2) return null;
8182
9387
  t++;
8183
9388
  }
8184
9389
  return i < 3 ? null : { node: { type: s.breakThematic }, end: re(e2, n) };
@@ -8198,7 +9403,7 @@ function Li(e2, r, n) {
8198
9403
  if (A === Ae) {
8199
9404
  for (let B = l; B < t; B++) if (e2.charCodeAt(B) === Ae) return null;
8200
9405
  }
8201
- for (; _ > l && (e2.charCodeAt(_ - 1) === S || e2.charCodeAt(_ - 1) === N); ) _--;
9406
+ for (; _ > l && (e2.charCodeAt(_ - 1) === S || e2.charCodeAt(_ - 1) === N2); ) _--;
8202
9407
  let d = e2.slice(l, _), c = "", f = "", h = d.indexOf(" ");
8203
9408
  h === -1 ? c = d : (c = d.slice(0, h), f = d.slice(h + 1).trim()), c = un(c);
8204
9409
  var u;
@@ -8239,7 +9444,7 @@ function Li(e2, r, n) {
8239
9444
  return { node: { type: s.codeBlock, lang: c || void 0, text: L, infoString: f || void 0, attrs: u }, end: T };
8240
9445
  }
8241
9446
  function Na(e2, r, n) {
8242
- for (var t = 0, a2 = r; a2 < n && t < 4; ) e2.charCodeAt(a2) === N ? t += 4 - t % 4 : t++, a2++;
9447
+ for (var t = 0, a2 = r; a2 < n && t < 4; ) e2.charCodeAt(a2) === N2 ? t += 4 - t % 4 : t++, a2++;
8243
9448
  if (t < 4) return "";
8244
9449
  for (var i = "", o = 4; o < t; o++) i += " ";
8245
9450
  return i + e2.slice(a2, n);
@@ -8269,7 +9474,7 @@ function Mi(e2, r) {
8269
9474
  let f = 0, h = 0;
8270
9475
  var C = 0;
8271
9476
  for (let u = a2; u < c && h < 4; u++) {
8272
- if (e2.charCodeAt(u) === N) {
9477
+ if (e2.charCodeAt(u) === N2) {
8273
9478
  var l = 4 - h % 4;
8274
9479
  h + l > 4 && (C = h + l - 4), h += l;
8275
9480
  } else h++;
@@ -8298,19 +9503,19 @@ function xi(e2, r, n, t) {
8298
9503
  var c = _e + 1, f = false;
8299
9504
  if (Q < m) {
8300
9505
  var h = e2.charCodeAt(Q);
8301
- h === S ? (Q++, c++, f = true) : h === N && (f = true);
9506
+ h === S ? (Q++, c++, f = true) : h === N2 && (f = true);
8302
9507
  }
8303
- for (var u = "", g = false, R = Q; R < m; R++) if (e2.charCodeAt(R) === N) {
9508
+ for (var u = "", g = false, R = Q; R < m; R++) if (e2.charCodeAt(R) === N2) {
8304
9509
  g = true;
8305
9510
  break;
8306
9511
  }
8307
9512
  if (g) {
8308
9513
  var H = c;
8309
- if (f && Q < m && e2.charCodeAt(Q) === N) {
9514
+ if (f && Q < m && e2.charCodeAt(Q) === N2) {
8310
9515
  for (var T = 4 - H % 4, x = 0; x < T - 1; x++) u += " ";
8311
9516
  H += T, Q++;
8312
9517
  }
8313
- for (var D = Q; D < m; D++) if (e2.charCodeAt(D) === N) {
9518
+ for (var D = Q; D < m; D++) if (e2.charCodeAt(D) === N2) {
8314
9519
  for (var v = 4 - H % 4, I = 0; I < v; I++) u += " ";
8315
9520
  H += v;
8316
9521
  } else u += e2[D], H++;
@@ -8329,7 +9534,7 @@ function xi(e2, r, n, t) {
8329
9534
  } else if (o && !tr(e2, A, m) && _) {
8330
9535
  if (_e < 4) {
8331
9536
  var p = A + le, k = p < m ? e2.charCodeAt(p) : 0;
8332
- if (k === fr || k === U || k === Ae || k === De || k === ae || (k === z || k === Oe || k === Ne) && Qr(e2, A) || (k === z || k === Oe || k === Lr) && p + 1 < m && (e2.charCodeAt(p + 1) === S || e2.charCodeAt(p + 1) === N)) break;
9537
+ if (k === fr || k === U || k === Ae || k === De || k === ae || (k === z || k === Oe || k === Ne) && Qr(e2, A) || (k === z || k === Oe || k === Lr) && p + 1 < m && (e2.charCodeAt(p + 1) === S || e2.charCodeAt(p + 1) === N2)) break;
8333
9538
  if (k >= Y && k <= V) {
8334
9539
  for (var L = p; L < m && e2.charCodeAt(L) >= Y && e2.charCodeAt(L) <= V; ) L++;
8335
9540
  if (L < m && (e2.charCodeAt(L) === ir || e2.charCodeAt(L) === Rr)) break;
@@ -8349,7 +9554,7 @@ function xi(e2, r, n, t) {
8349
9554
  return n.i = O, n.inBlockQuote = M, n.l = b, { node: { type: s.blockQuote, children: B, alert: C || void 0 }, end: A };
8350
9555
  }
8351
9556
  function Xa(e2, r, n) {
8352
- for (var t = 0, a2 = r; a2 < n; a2++) e2.charCodeAt(a2) === N ? t += 4 - t % 4 : t++;
9557
+ for (var t = 0, a2 = r; a2 < n; a2++) e2.charCodeAt(a2) === N2 ? t += 4 - t % 4 : t++;
8353
9558
  return t;
8354
9559
  }
8355
9560
  function zr(e2, r, n) {
@@ -8358,7 +9563,7 @@ function zr(e2, r, n) {
8358
9563
  if (t >= n) return null;
8359
9564
  var a2 = e2.charCodeAt(t), i = _e, o = t, A = t;
8360
9565
  if (a2 === z || a2 === Oe || a2 === Lr) {
8361
- if (o = t + 1, o < n && e2.charCodeAt(o) !== S && e2.charCodeAt(o) !== N && e2.charCodeAt(o) !== y) return null;
9566
+ if (o = t + 1, o < n && e2.charCodeAt(o) !== S && e2.charCodeAt(o) !== N2 && e2.charCodeAt(o) !== y) return null;
8362
9567
  } else if (a2 >= Y && a2 <= V) {
8363
9568
  for (; A < n && A - t < 9; ) {
8364
9569
  var C = e2.charCodeAt(A);
@@ -8368,14 +9573,14 @@ function zr(e2, r, n) {
8368
9573
  if (A > t && A < n) {
8369
9574
  var l = e2.charCodeAt(A);
8370
9575
  if (l === ir || l === Rr) {
8371
- if (o = A + 1, o < n && e2.charCodeAt(o) !== S && e2.charCodeAt(o) !== N && e2.charCodeAt(o) !== y) return null;
9576
+ if (o = A + 1, o < n && e2.charCodeAt(o) !== S && e2.charCodeAt(o) !== N2 && e2.charCodeAt(o) !== y) return null;
8372
9577
  } else return null;
8373
9578
  } else return null;
8374
9579
  } else return null;
8375
9580
  var _ = o, d = Xa(e2, r, o), c = 0, f = _, h = d;
8376
9581
  if (_ >= n) return { ordered: a2 >= Y && a2 <= V, marker: a2 >= Y && a2 <= V ? e2[A] : e2[t], start: a2 >= Y && a2 <= V ? Number.parseInt(e2.slice(t, A), 10) : void 0, contentStart: _, contentCol: d + 1, markerCol: i, isEmpty: true };
8377
- for (; f < n && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N); ) {
8378
- if (e2.charCodeAt(f) === N) {
9582
+ for (; f < n && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N2); ) {
9583
+ if (e2.charCodeAt(f) === N2) {
8379
9584
  var u = 4 - h % 4;
8380
9585
  h += u;
8381
9586
  } else h++;
@@ -8389,7 +9594,7 @@ function wa(e2, r, n, t) {
8389
9594
  var a2 = 0, i = r;
8390
9595
  for (Rn = 0; i < n && a2 < t; ) {
8391
9596
  var o = e2.charCodeAt(i);
8392
- if (o === N) {
9597
+ if (o === N2) {
8393
9598
  var A = 4 - a2 % 4;
8394
9599
  if (a2 + A > t) {
8395
9600
  Rn = a2 + A - t, i++, a2 = t;
@@ -8407,14 +9612,14 @@ function ba(e2, r, n, t) {
8407
9612
  if (!i) return null;
8408
9613
  var o = [], A = r, C = i.contentCol, l = "", _ = i.isEmpty, d = false, c = false;
8409
9614
  if (!i.isEmpty) {
8410
- for (var f = false, h = i.contentStart; h < a2; h++) if (e2.charCodeAt(h) === N) {
9615
+ for (var f = false, h = i.contentStart; h < a2; h++) if (e2.charCodeAt(h) === N2) {
8411
9616
  f = true;
8412
9617
  break;
8413
9618
  }
8414
9619
  if (f) {
8415
9620
  var u = "", g = Xa(e2, r, i.contentStart), R = g - i.contentCol;
8416
9621
  if (R > 0) for (var H = 0; H < R; H++) u += " ";
8417
- for (var T = i.contentStart; T < a2; T++) if (e2.charCodeAt(T) === N) {
9622
+ for (var T = i.contentStart; T < a2; T++) if (e2.charCodeAt(T) === N2) {
8418
9623
  for (var x = 4 - g % 4, D = 0; D < x; D++) u += " ";
8419
9624
  g += x;
8420
9625
  } else u += e2[T], g++;
@@ -8445,7 +9650,7 @@ function ba(e2, r, n, t) {
8445
9650
  A = re(e2, v);
8446
9651
  for (var M = false, b = 0; b < l.length; b++) {
8447
9652
  var O = l.charCodeAt(b);
8448
- if (O !== y && O !== cr && O !== S && O !== N) {
9653
+ if (O !== y && O !== cr && O !== S && O !== N2) {
8449
9654
  M = true;
8450
9655
  break;
8451
9656
  }
@@ -8473,7 +9678,7 @@ function ba(e2, r, n, t) {
8473
9678
  var ve = wa(e2, A, v, C);
8474
9679
  if (Rn > 0) {
8475
9680
  for (var W = "", me = C, we = 0; we < Rn; we++) W += " ", me++;
8476
- for (var Re = ve; Re < v; Re++) if (e2.charCodeAt(Re) === N) {
9681
+ for (var Re = ve; Re < v; Re++) if (e2.charCodeAt(Re) === N2) {
8477
9682
  for (var $e = 4 - me % 4, We = 0; We < $e; We++) W += " ";
8478
9683
  me += $e;
8479
9684
  } else W += e2[Re], me++;
@@ -8486,7 +9691,7 @@ function ba(e2, r, n, t) {
8486
9691
  }
8487
9692
  for (var X = false, pe = 0; pe < l.length; pe++) {
8488
9693
  var j = l.charCodeAt(pe);
8489
- if (j !== y && j !== cr && j !== S && j !== N) {
9694
+ if (j !== y && j !== cr && j !== S && j !== N2) {
8490
9695
  X = true;
8491
9696
  break;
8492
9697
  }
@@ -8729,7 +9934,7 @@ function gt(e2, r, n) {
8729
9934
  f ? (f.tag.toLowerCase() === t && !f.g && !f.o && !An(f.tag) && o++, A = f.end) : A = d + 1;
8730
9935
  } else {
8731
9936
  var l = c + i.length, _ = l < C ? e2.charCodeAt(l) : 62;
8732
- if ((_ === U || _ === S || _ === N || _ === y) && (o--, o === 0)) {
9937
+ if ((_ === U || _ === S || _ === N2 || _ === y) && (o--, o === 0)) {
8733
9938
  Qn = c;
8734
9939
  let f = c + i.length;
8735
9940
  for (; f < C && e2.charCodeAt(f) !== U; ) f++;
@@ -8788,7 +9993,7 @@ function Ja(e2, r, n, t) {
8788
9993
  g.charCodeAt(m) === y && m++;
8789
9994
  for (var F = p; F > m; ) {
8790
9995
  var Q = g.charCodeAt(F - 1);
8791
- if (Q !== S && Q !== N && Q !== y && Q !== cr) break;
9996
+ if (Q !== S && Q !== N2 && Q !== y && Q !== cr) break;
8792
9997
  F--;
8793
9998
  }
8794
9999
  var ve = g.slice(m, F);
@@ -8818,14 +10023,14 @@ function Ja(e2, r, n, t) {
8818
10023
  var Z = Be + j.length + 1;
8819
10024
  if (Z < K.length) {
8820
10025
  var Te = K.charCodeAt(Z);
8821
- (Te === S || Te === N || Te === y || Te === U || Te === be) && ce++;
10026
+ (Te === S || Te === N2 || Te === y || Te === U || Te === be) && ce++;
8822
10027
  }
8823
10028
  Ee = Be + 1;
8824
10029
  } else {
8825
10030
  var q = Ke + ue.length;
8826
10031
  if (q < K.length) {
8827
10032
  var Ie = K.charCodeAt(q);
8828
- if ((Ie === U || Ie === S || Ie === N || Ie === y) && (ce--, ce === 0)) {
10033
+ if ((Ie === U || Ie === S || Ie === N2 || Ie === y) && (ce--, ce === 0)) {
8829
10034
  Se = Ke;
8830
10035
  for (var ze = q; ze < K.length && K.charCodeAt(ze) !== U; ) ze++;
8831
10036
  ge = ze + 1;
@@ -8844,7 +10049,7 @@ function Ja(e2, r, n, t) {
8844
10049
  for (var te = Qn, Ve = X.end, ee = false, Ye = false, oe = false, fe = 0, Ge = false, ke = false, Le = Ve; Le < te; ) {
8845
10050
  var ye = e2.charCodeAt(Le);
8846
10051
  if (ye === y) ke && (ee = true), Ge || fe++, ke = true, Le++;
8847
- else if (ye === S || ye === N) Le++;
10052
+ else if (ye === S || ye === N2) Le++;
8848
10053
  else {
8849
10054
  if (!Ge && (Ge = true, fe >= 2 && ye === ae)) {
8850
10055
  oe = true;
@@ -8878,7 +10083,7 @@ function Ja(e2, r, n, t) {
8878
10083
  if (Se !== -1) {
8879
10084
  var Er = i + ge, ar = de(e2, Er - 1);
8880
10085
  if (Er < ar) {
8881
- for (var Nr = Er; Nr < ar && (e2.charCodeAt(Nr) === S || e2.charCodeAt(Nr) === N); ) Nr++;
10086
+ for (var Nr = Er; Nr < ar && (e2.charCodeAt(Nr) === S || e2.charCodeAt(Nr) === N2); ) Nr++;
8882
10087
  if (Nr < ar && e2.charCodeAt(Nr) === ae) {
8883
10088
  var Cn = yr(e2, Nr);
8884
10089
  Cn && !Cn.g && (mr = true, jr = Er, Dr = Er, qr = true);
@@ -8887,7 +10092,7 @@ function Ja(e2, r, n, t) {
8887
10092
  if (!mr) {
8888
10093
  var en = re(e2, ar);
8889
10094
  if (en < Re) {
8890
- for (var Tr = en; Tr < Re && (e2.charCodeAt(Tr) === S || e2.charCodeAt(Tr) === N); ) Tr++;
10095
+ for (var Tr = en; Tr < Re && (e2.charCodeAt(Tr) === S || e2.charCodeAt(Tr) === N2); ) Tr++;
8891
10096
  if (Tr < Re && e2.charCodeAt(Tr) === ae) {
8892
10097
  var Fa = yr(e2, Tr);
8893
10098
  Fa && (mr = true, jr = ar, Dr = en, qr = true);
@@ -8995,18 +10200,18 @@ function yi(e2, r) {
8995
10200
  if (bn.has(l.toLowerCase())) {
8996
10201
  if (i) return 0;
8997
10202
  var _ = e2.charCodeAt(A);
8998
- return _ === S || _ === N || _ === U || _ === y || A >= t ? 1 : 0;
10203
+ return _ === S || _ === N2 || _ === U || _ === y || A >= t ? 1 : 0;
8999
10204
  }
9000
10205
  if (Zn.has(l.toLowerCase())) {
9001
10206
  if (i) {
9002
- for (var d = A; d < t && (e2.charCodeAt(d) === S || e2.charCodeAt(d) === N); ) d++;
10207
+ for (var d = A; d < t && (e2.charCodeAt(d) === S || e2.charCodeAt(d) === N2); ) d++;
9003
10208
  return d < t && e2.charCodeAt(d) === U ? 6 : 0;
9004
10209
  }
9005
10210
  var c = A < t ? e2.charCodeAt(A) : -1;
9006
- return c === S || c === N || c === U || c === y || c === be || c === -1 ? 6 : 0;
10211
+ return c === S || c === N2 || c === U || c === y || c === be || c === -1 ? 6 : 0;
9007
10212
  }
9008
10213
  if (i) {
9009
- for (var f = A; f < t && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N); ) f++;
10214
+ for (var f = A; f < t && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N2); ) f++;
9010
10215
  if (f < t && e2.charCodeAt(f) === U) {
9011
10216
  var h = de(e2, r), u = e2.slice(f + 1, h).trim();
9012
10217
  if (u === "") return 7;
@@ -9021,8 +10226,8 @@ function yi(e2, r) {
9021
10226
  return 0;
9022
10227
  }
9023
10228
  function pa(e2, r, n) {
9024
- for (var t = 0, a2 = e2.length; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N); ) t++;
9025
- for (; a2 > t && (e2.charCodeAt(a2 - 1) === S || e2.charCodeAt(a2 - 1) === N); ) a2--;
10229
+ for (var t = 0, a2 = e2.length; t < a2 && (e2.charCodeAt(t) === S || e2.charCodeAt(t) === N2); ) t++;
10230
+ for (; a2 > t && (e2.charCodeAt(a2 - 1) === S || e2.charCodeAt(a2 - 1) === N2); ) a2--;
9026
10231
  t < a2 && e2.charCodeAt(t) === Fe && t++, a2 > t && e2.charCodeAt(a2 - 1) === Fe && (a2 - 2 < t || e2.charCodeAt(a2 - 2) !== Me) && a2--;
9027
10232
  for (var i = [], o = t, A = false, C = [], l = t; l < a2; ) {
9028
10233
  var _ = e2.charCodeAt(l);
@@ -9060,14 +10265,14 @@ function Ia(e2, r, n, t) {
9060
10265
  let A = de(e2, o);
9061
10266
  if (!Pa(e2, o, A)) return null;
9062
10267
  let C = e2.slice(r, a2), l = e2.slice(o, A);
9063
- for (var _ = [], d = 0, c = l.length; d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N); ) d++;
10268
+ for (var _ = [], d = 0, c = l.length; d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N2); ) d++;
9064
10269
  for (d < c && l.charCodeAt(d) === Fe && d++; d < c; ) {
9065
- for (; d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N); ) d++;
10270
+ for (; d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N2); ) d++;
9066
10271
  if (d >= c || l.charCodeAt(d) === Fe) break;
9067
10272
  var f = l.charCodeAt(d) === Qe;
9068
10273
  for (f && d++; d < c && l.charCodeAt(d) === z; ) d++;
9069
10274
  var h = d < c && l.charCodeAt(d) === Qe;
9070
- for (h && d++, _.push(f && h ? "center" : h ? "right" : f ? "left" : null); d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N); ) d++;
10275
+ for (h && d++, _.push(f && h ? "center" : h ? "right" : f ? "left" : null); d < c && (l.charCodeAt(d) === S || l.charCodeAt(d) === N2); ) d++;
9071
10276
  d < c && l.charCodeAt(d) === Fe && d++;
9072
10277
  }
9073
10278
  let u = pa(C, n, t);
@@ -9114,8 +10319,8 @@ function Di(e2, r, n) {
9114
10319
  if (a2 >= t) return null;
9115
10320
  var o = `^${e2.slice(i, a2)}`.toLowerCase();
9116
10321
  if (a2++, a2 >= t || e2.charCodeAt(a2) !== Qe) return null;
9117
- for (a2++; a2 < t && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N); ) a2++;
9118
- if (a2 < t && e2.charCodeAt(a2) === y) for (a2++; a2 < t && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N); ) a2++;
10322
+ for (a2++; a2 < t && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N2); ) a2++;
10323
+ if (a2 < t && e2.charCodeAt(a2) === y) for (a2++; a2 < t && (e2.charCodeAt(a2) === S || e2.charCodeAt(a2) === N2); ) a2++;
9119
10324
  var A = e2.indexOf(`
9120
10325
  `, a2);
9121
10326
  A < 0 && (A = t);
@@ -9149,7 +10354,7 @@ function Xi(e2, r, n, t) {
9149
10354
  if (B === _r || B === z) {
9150
10355
  let P = a2 + le;
9151
10356
  for (; P < b && e2.charCodeAt(P) === B; ) P++;
9152
- for (; P < b && (e2.charCodeAt(P) === S || e2.charCodeAt(P) === N); ) P++;
10357
+ for (; P < b && (e2.charCodeAt(P) === S || e2.charCodeAt(P) === N2); ) P++;
9153
10358
  if (P >= b) {
9154
10359
  i = B === _r ? 1 : 2, a2 = re(e2, b);
9155
10360
  break;
@@ -9173,7 +10378,7 @@ function Xi(e2, r, n, t) {
9173
10378
  }
9174
10379
  if (P === fr) {
9175
10380
  for (var l = O + le, _ = 0; l < B && e2.charCodeAt(l) === fr && _ <= 6; ) _++, l++;
9176
- if (_ >= 1 && _ <= 6 && (l >= B || e2.charCodeAt(l) === S || e2.charCodeAt(l) === N)) {
10381
+ if (_ >= 1 && _ <= 6 && (l >= B || e2.charCodeAt(l) === S || e2.charCodeAt(l) === N2)) {
9177
10382
  a2 = O;
9178
10383
  break;
9179
10384
  }
@@ -9204,7 +10409,7 @@ function Xi(e2, r, n, t) {
9204
10409
  }
9205
10410
  if (P === z || P === Oe || P === Lr) {
9206
10411
  let m = O + le + 1;
9207
- if (m < B && (e2.charCodeAt(m) === S || e2.charCodeAt(m) === N)) {
10412
+ if (m < B && (e2.charCodeAt(m) === S || e2.charCodeAt(m) === N2)) {
9208
10413
  var x = wn(e2, m, B);
9209
10414
  if (x < B && !Qr(e2, O)) {
9210
10415
  a2 = O;
@@ -9217,7 +10422,7 @@ function Xi(e2, r, n, t) {
9217
10422
  for (; m < B && e2.charCodeAt(m) >= Y && e2.charCodeAt(m) <= V; ) m++;
9218
10423
  if (m < B && (e2.charCodeAt(m) === ir || e2.charCodeAt(m) === Rr) && m - (O + le) === 1 && e2.charCodeAt(O + le) === 49) {
9219
10424
  var D = m + 1;
9220
- if (D < B && (e2.charCodeAt(D) === S || e2.charCodeAt(D) === N)) {
10425
+ if (D < B && (e2.charCodeAt(D) === S || e2.charCodeAt(D) === N2)) {
9221
10426
  var v = wn(e2, D, B);
9222
10427
  if (v < B) {
9223
10428
  a2 = O;
@@ -9243,7 +10448,7 @@ function Xi(e2, r, n, t) {
9243
10448
  }
9244
10449
  let m = 0, F = O + le;
9245
10450
  for (; F < B && e2.charCodeAt(F) === z; ) m++, F++;
9246
- for (; F < B && (e2.charCodeAt(F) === S || e2.charCodeAt(F) === N); ) F++;
10451
+ for (; F < B && (e2.charCodeAt(F) === S || e2.charCodeAt(F) === N2); ) F++;
9247
10452
  if (F < B) {
9248
10453
  a2 = O;
9249
10454
  break;
@@ -9253,8 +10458,8 @@ function Xi(e2, r, n, t) {
9253
10458
  }
9254
10459
  a2 = re(e2, b);
9255
10460
  }
9256
- for (var I = i ? o : a2; I > r && (e2.charCodeAt(I - 1) === y || e2.charCodeAt(I - 1) === cr || e2.charCodeAt(I - 1) === S || e2.charCodeAt(I - 1) === N); ) I--;
9257
- for (var E = r; E < I && (e2.charCodeAt(E) === S || e2.charCodeAt(E) === N); ) E++;
10461
+ for (var I = i ? o : a2; I > r && (e2.charCodeAt(I - 1) === y || e2.charCodeAt(I - 1) === cr || e2.charCodeAt(I - 1) === S || e2.charCodeAt(I - 1) === N2); ) I--;
10462
+ for (var E = r; E < I && (e2.charCodeAt(E) === S || e2.charCodeAt(E) === N2); ) E++;
9258
10463
  if (E >= I) return null;
9259
10464
  for (var p = false, k = E; k < I; k++) if (e2.charCodeAt(k) === Xn) {
9260
10465
  p = true;
@@ -9710,7 +10915,7 @@ function Yi(e2, r, n, t) {
9710
10915
  let A = r + a2.length;
9711
10916
  for (; A < n; ) {
9712
10917
  let v = e2.charCodeAt(A);
9713
- if (v === S || v === y || v === N || v === cr || v === ae || v === U) break;
10918
+ if (v === S || v === y || v === N2 || v === cr || v === ae || v === U) break;
9714
10919
  A++;
9715
10920
  }
9716
10921
  for (var C = 0, l = 0, _ = r; _ < A; _++) {
@@ -9867,7 +11072,7 @@ function ji(e2, r, n, t, a2) {
9867
11072
  if (u >= J && u <= G || u >= Ce && u <= He || u >= Y && u <= V || u === z) f++;
9868
11073
  else break;
9869
11074
  }
9870
- for (; f < n && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N || e2.charCodeAt(f) === y); ) f++;
11075
+ for (; f < n && (e2.charCodeAt(f) === S || e2.charCodeAt(f) === N2 || e2.charCodeAt(f) === y); ) f++;
9871
11076
  if (f < n && e2.charCodeAt(f) === U) {
9872
11077
  var g = e2.slice(i + 1, f).trim();
9873
11078
  return { node: { type: s.htmlSelfClosing, tag: g, attrs: {}, f: e2.slice(r, f + 1), b: true }, end: f + 1 };
@@ -10066,7 +11271,7 @@ function Yr(e2, r, n) {
10066
11271
  if (i > o && e2.charCodeAt(o) === Fe) {
10067
11272
  for (var A = false, C = o + 1; C < i; C++) {
10068
11273
  var l = e2.charCodeAt(C);
10069
- if (l !== S && l !== N && l !== Fe && l !== Qe && l !== z) {
11274
+ if (l !== S && l !== N2 && l !== Fe && l !== Qe && l !== z) {
10070
11275
  A = true;
10071
11276
  break;
10072
11277
  }
@@ -10078,7 +11283,7 @@ function Yr(e2, r, n) {
10078
11283
  for (var g = true, R = false, H = u; H < h; H++) {
10079
11284
  var T = e2.charCodeAt(H);
10080
11285
  if (T === z) R = true;
10081
- else if (T !== S && T !== N && T !== Qe && T !== Fe) {
11286
+ else if (T !== S && T !== N2 && T !== Qe && T !== Fe) {
10082
11287
  g = false;
10083
11288
  break;
10084
11289
  }
@@ -10134,16 +11339,16 @@ function Yr(e2, r, n) {
10134
11339
  var ge = e2.charCodeAt(K), ne = false;
10135
11340
  if (ge === Oe || ge === z || ge === Lr) {
10136
11341
  var ue = K + 1;
10137
- if (ue >= Je || e2.charCodeAt(ue) === S || e2.charCodeAt(ue) === N) {
10138
- for (var xe = ue; xe < Je && (e2.charCodeAt(xe) === S || e2.charCodeAt(xe) === N); ) xe++;
11342
+ if (ue >= Je || e2.charCodeAt(ue) === S || e2.charCodeAt(ue) === N2) {
11343
+ for (var xe = ue; xe < Je && (e2.charCodeAt(xe) === S || e2.charCodeAt(xe) === N2); ) xe++;
10139
11344
  xe >= Je && (ne = true);
10140
11345
  }
10141
11346
  } else if (ge >= Y && ge <= V) {
10142
11347
  for (var ce = K; ce < Je && e2.charCodeAt(ce) >= Y && e2.charCodeAt(ce) <= V; ) ce++;
10143
11348
  if (ce < Je && (e2.charCodeAt(ce) === ir || e2.charCodeAt(ce) === Rr)) {
10144
11349
  var Ee = ce + 1;
10145
- if (Ee >= Je || e2.charCodeAt(Ee) === S || e2.charCodeAt(Ee) === N) {
10146
- for (var Be = Ee; Be < Je && (e2.charCodeAt(Be) === S || e2.charCodeAt(Be) === N); ) Be++;
11350
+ if (Ee >= Je || e2.charCodeAt(Ee) === S || e2.charCodeAt(Ee) === N2) {
11351
+ for (var Be = Ee; Be < Je && (e2.charCodeAt(Be) === S || e2.charCodeAt(Be) === N2); ) Be++;
10147
11352
  Be >= Je && (ne = true);
10148
11353
  }
10149
11354
  }
@@ -10379,7 +11584,7 @@ function Vn(e2, r) {
10379
11584
  if (!f.e) return `<${u}${R}>${n}</${u}>`;
10380
11585
  for (var m = 0; m < n.length; m++) {
10381
11586
  var F = n.charCodeAt(m);
10382
- if (F !== S && F !== N && F !== y && F !== cr) return `<${u}${R}>${n}</${u}>`;
11587
+ if (F !== S && F !== N2 && F !== y && F !== cr) return `<${u}${R}>${n}</${u}>`;
10383
11588
  }
10384
11589
  return `<${u}${R}>${n}`;
10385
11590
  }
@@ -10650,6 +11855,8 @@ function createWikiDocument(view, context) {
10650
11855
  visibleSet.add(id);
10651
11856
  }
10652
11857
  }
11858
+ } else if (view?.originScope) {
11859
+ visibleSet = viewShownNodes(view, nodes, relations) ?? null;
10653
11860
  }
10654
11861
  const chain = view && pipelineOf(view)?.levels?.length ? runPipeline(view, { ...context, metamodel: metamodel ?? NO_METAMODEL2 }) : null;
10655
11862
  if (chain) visibleSet = new Set(chain.nodes.map((n) => n.id));
@@ -10846,9 +12053,9 @@ ${escapeMarkdown(fact.text)}`);
10846
12053
  ${fieldValue(block.field, shift)}`);
10847
12054
  break;
10848
12055
  case "relations":
10849
- for (const group of block.groups) content.push(`**${escapeMarkdown(group.label)}${group.label.endsWith(":") ? "" : ":"}** ${group.entries.map(({ relation, other, details }) => {
12056
+ for (const group of block.groups) content.push(`**${escapeMarkdown(group.label)}${group.label.endsWith(":") ? "" : ":"}** ${group.entries.map(({ relation, other, details: details2 }) => {
10850
12057
  const id = group.direction === "out" ? relation.targetId : relation.sourceId;
10851
- return `${other ? link(id) : "(missing)"}${details.length ? ` (${escapeMarkdown(details.join(", "))})` : ""}`;
12058
+ return `${other ? link(id) : "(missing)"}${details2.length ? ` (${escapeMarkdown(details2.join(", "))})` : ""}`;
10852
12059
  }).join(", ")}.`);
10853
12060
  break;
10854
12061
  case "wireframe":
@@ -12594,10 +13801,10 @@ async function fetchAll(root, deps) {
12594
13801
  notes.push(`${dep.name}: ${via ?? deps.name} names this model so; left out, as a dependency back to it.`);
12595
13802
  continue;
12596
13803
  }
12597
- const kept = chosen.get(dep.name);
12598
- if (kept) {
12599
- if (kept.ref !== dep.ref || kept.where !== where2) {
12600
- notes.push(`${dep.name}: ${via ?? deps.name} pins ${dep.ref}, ${kept.via} pins ${kept.ref}; ${kept.ref} is composed, the nearer pin (pin it in ${DEPS_FILE} to choose).`);
13804
+ const kept2 = chosen.get(dep.name);
13805
+ if (kept2) {
13806
+ if (kept2.ref !== dep.ref || kept2.where !== where2) {
13807
+ notes.push(`${dep.name}: ${via ?? deps.name} pins ${dep.ref}, ${kept2.via} pins ${kept2.ref}; ${kept2.ref} is composed, the nearer pin (pin it in ${DEPS_FILE} to choose).`);
12601
13808
  }
12602
13809
  continue;
12603
13810
  }
@@ -12703,8 +13910,8 @@ async function fetchFederation(root) {
12703
13910
  if (!read2) return null;
12704
13911
  const { fetched, notes, sources } = await fetchAll(root, read2.deps);
12705
13912
  const own = await new MdFolderSession(diskFolderStorage(root)).readAll();
12706
- const others = federationOthers(own, fetched);
12707
- const all = [...notes, ...others.notes];
13913
+ const others2 = federationOthers(own, fetched);
13914
+ const all = [...notes, ...others2.notes];
12708
13915
  const atCommits = {};
12709
13916
  let snapshots = [];
12710
13917
  try {
@@ -12746,12 +13953,12 @@ async function fetchFederation(root) {
12746
13953
  ...deps?.dependencies.length ? { dependsOn: deps.dependencies.map((d) => d.name) } : {}
12747
13954
  })),
12748
13955
  notes: all,
12749
- nodes: others.nodes,
12750
- relations: others.relations,
12751
- ...others.views.length ? { views: others.views } : {},
13956
+ nodes: others2.nodes,
13957
+ relations: others2.relations,
13958
+ ...others2.views.length ? { views: others2.views } : {},
12752
13959
  ...Object.keys(atCommits).length ? { atCommits } : {}
12753
13960
  }));
12754
- return { fetched, notes: all, nodes: others.nodes.length };
13961
+ return { fetched, notes: all, nodes: others2.nodes.length };
12755
13962
  }
12756
13963
  async function federationCommand(args, io2) {
12757
13964
  let parsed;
@@ -12888,8 +14095,9 @@ its own ("model": { "repo": \u2026 }), it judges that repository's part of the m
12888
14095
  without --metrics too, and the metric conditions of
12889
14096
  scenarios and fitness functions are evaluated against
12890
14097
  the latest measurement each matches. The reviews
12891
- radical sense review keeps in the model folder's
12892
- reviews.json are read as measurements too
14098
+ radical sense review keeps in the repository's
14099
+ .radical/reviews.json (and a model folder's
14100
+ reviews.json from before) are read as measurements too
12893
14101
  --baseline <path> earlier radical-metrics/1 files (a file, or a directory of
12894
14102
  them; repeat for more) that a condition stated against a
12895
14103
  baseline (<metric> <= baseline + 20%) compares with: the
@@ -12904,10 +14112,23 @@ its own ("model": { "repo": \u2026 }), it judges that repository's part of the m
12904
14112
  --ratchet lower each baseline (max) in the config to the count found
12905
14113
  now, so a rule that got better cannot get worse again
12906
14114
  (the test rules only with --report: without it they
12907
- do not run and keep their baselines)
14115
+ do not run and keep their baselines). Where only this
14116
+ repository's part of a model is judged, it lowers no
14117
+ baseline of the model's check.json (exit 2): only one
14118
+ --config names. With --alone or --trigger, which leave
14119
+ part of the model out, it lowers none (exit 2)
12908
14120
  --alone check without the models deps.json names; with a
12909
14121
  deps.json the model is checked composed with them, at
12910
14122
  their pinned refs (radical federation --help)
14123
+ --trace <id> print every verification path through one element (a
14124
+ need, requirement, scenario, ADR or fitness function):
14125
+ from its need or ADR to the tests and metric conditions
14126
+ that check it, each with its status and why a test
14127
+ failed, instead of the check's findings. Without
14128
+ --report or --from-ci it reads the test results kept
14129
+ beside the model. With --format json, the paths as JSON.
14130
+ With deps.json, also an element of a model it depends
14131
+ on (a scenario of theirs this repository's tests check)
12911
14132
  --verbose list every warning, not the first five of each rule
12912
14133
  --list-rules list the rules and their default severity, and the
12913
14134
  metrics check.json can set goals for ("goals":
@@ -12931,6 +14152,7 @@ async function checkCommand(args, io2) {
12931
14152
  baseline: { type: "string", multiple: true },
12932
14153
  trigger: { type: "string" },
12933
14154
  evidence: { type: "string" },
14155
+ trace: { type: "string" },
12934
14156
  ratchet: { type: "boolean", default: false },
12935
14157
  alone: { type: "boolean", default: false },
12936
14158
  verbose: { type: "boolean", default: false },
@@ -12950,16 +14172,21 @@ ${CHECK_USAGE}`);
12950
14172
  return 0;
12951
14173
  }
12952
14174
  if (values["list-rules"]) {
12953
- for (const rule of [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE]) io2.out(`${rule.id.padEnd(30)} ${rule.severity.padEnd(8)} ${rule.description}`);
14175
+ for (const rule of [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE]) io2.out(`${rule.id.padEnd(30)} ${(rule.off ? "off" : rule.severity).padEnd(8)} ${rule.description}`);
12954
14176
  io2.out("\nMetrics for goals (in percent):");
12955
14177
  for (const metric of CHECK_METRICS) io2.out(`${metric.id.padEnd(30)} ${(metric.tests ? "evidence" : "").padEnd(8)} ${metric.description}`);
12956
14178
  return 0;
12957
14179
  }
12958
14180
  const fromCi = values["from-ci"];
12959
- if (positionals.length > 1 || !["text", "json", "github"].includes(values.format) || fromCi && values.report?.length || values.evidence && !values.report?.length && !fromCi && !values.metrics?.length) {
14181
+ if (positionals.length > 1 || !["text", "json", "github"].includes(values.format) || fromCi && values.report?.length || values.evidence && !values.report?.length && !fromCi && !values.metrics?.length || values.trace !== void 0 && (!values.trace.trim() || values.format === "github" || values.ratchet)) {
12960
14182
  io2.err(CHECK_USAGE);
12961
14183
  return 2;
12962
14184
  }
14185
+ const partial = values.alone ? "--alone" : values.trigger !== void 0 ? "--trigger" : null;
14186
+ if (values.ratchet && partial) {
14187
+ io2.err(`radical check --ratchet: with ${partial} the check leaves part of the model out (${partial === "--alone" ? "the models deps.json names" : "the metric conditions of other events"}), and a baseline counts the whole model. Ratchet with a check of all of it.`);
14188
+ return 2;
14189
+ }
12963
14190
  if (values.detach) {
12964
14191
  if (!io2.background) {
12965
14192
  io2.err("radical check --detach: nothing here can start a command in the background.");
@@ -12991,8 +14218,10 @@ ${CHECK_USAGE}`);
12991
14218
  }
12992
14219
  }
12993
14220
  let repository;
14221
+ let mappedFrom = root;
12994
14222
  try {
12995
14223
  const mapping = await readRepositoryMapping(root);
14224
+ if (mapping) mappedFrom = mapping.root;
12996
14225
  repository = mapping && {
12997
14226
  file: relative5(io2.cwd, mapping.file),
12998
14227
  ...mapping.model ? { model: mapping.model } : {},
@@ -13005,6 +14234,10 @@ ${CHECK_USAGE}`);
13005
14234
  io2.err(`Cannot read the repository's mapping: ${error.message}`);
13006
14235
  return 2;
13007
14236
  }
14237
+ if (values.ratchet && repository?.model && !relative5(root, await realpath4(dirname8(configPath)).catch(() => dirname8(configPath))).startsWith("..")) {
14238
+ io2.err(`radical check --ratchet: ${configPath} holds the baselines of the whole model of ${repository.model.repo}, and this repository judges only its part of it. Ratchet in the model's repository, or name a config of this repository's own with --config.`);
14239
+ return 2;
14240
+ }
13008
14241
  let tests;
13009
14242
  let testsReadAt;
13010
14243
  let keep;
@@ -13063,8 +14296,17 @@ ${CHECK_USAGE}`);
13063
14296
  }
13064
14297
  }
13065
14298
  }
13066
- const kept = await readEditorStateFile(root, MEASUREMENTS_FILE);
13067
- const stored = kept === null ? null : parseMeasurementStore(kept);
14299
+ let fromKept = false;
14300
+ if (values.trace && !tests) {
14301
+ const keptResults = parseTestResults(await readEditorStateFile(root, TEST_RESULTS_FILE) ?? "");
14302
+ if (keptResults) {
14303
+ tests = keptResults.cases;
14304
+ testsReadAt = testsRanAt(keptResults);
14305
+ fromKept = true;
14306
+ }
14307
+ }
14308
+ const kept2 = await readEditorStateFile(root, MEASUREMENTS_FILE);
14309
+ const stored = kept2 === null ? null : parseMeasurementStore(kept2);
13068
14310
  let measurements = stored ?? void 0;
13069
14311
  if (values.metrics?.length) {
13070
14312
  const read2 = [];
@@ -13104,7 +14346,7 @@ ${CHECK_USAGE}`);
13104
14346
  io2.err(`Cannot compose the federation of ${folder}: ${error.message}`);
13105
14347
  return 2;
13106
14348
  }
13107
- const others = federation ? federationOthers(files, federation.fetched) : void 0;
14349
+ const others2 = federation ? federationOthers(files, federation.fetched) : void 0;
13108
14350
  let sensors;
13109
14351
  try {
13110
14352
  const found = await repositorySensors(root);
@@ -13118,8 +14360,10 @@ ${CHECK_USAGE}`);
13118
14360
  missingPaths = await missingCodePaths(await mappingRoot(root), deserializeFromMdFolder(files).data.nodes);
13119
14361
  } catch {
13120
14362
  }
13121
- const result = runCheck(files, config, { sensors, repository, missingPaths, ...tests ? { tests } : {}, ...testsReadAt ? { testsReadAt } : {}, ...measurements ? { measurements } : {}, ...baseline ? { baseline } : {}, ...values.trigger ? { trigger: values.trigger } : {}, concerns: concernPacks(), ...others ? { others } : {} });
13122
- if (tests && (keep || !fromCi)) {
14363
+ const testSources = repository?.verifies?.length ? await boundTestSources(mappedFrom, repository.verifies) : void 0;
14364
+ const baseNodes = await baseModelNodes(root);
14365
+ const result = runCheck(files, config, { sensors, repository, missingPaths, ...testSources ? { testSources } : {}, ...baseNodes ? { baseNodes } : {}, ...tests ? { tests } : {}, ...testsReadAt ? { testsReadAt } : {}, ...measurements ? { measurements } : {}, ...baseline ? { baseline } : {}, ...values.trigger ? { trigger: values.trigger } : {}, concerns: concernPacks(), ...others2 ? { others: others2 } : {} });
14366
+ if (tests && !fromKept && (keep || !fromCi)) {
13123
14367
  await writeBeside(join13(root, TEST_RESULTS_FILE), serializeTestResults(
13124
14368
  tests,
13125
14369
  keep?.reports ?? values.report ?? [],
@@ -13128,6 +14372,19 @@ ${CHECK_USAGE}`);
13128
14372
  ));
13129
14373
  }
13130
14374
  if (values.evidence && result.evidence) await writeBeside(resolve10(io2.cwd, values.evidence), JSON.stringify(result.evidence, null, 2) + "\n");
14375
+ if (values.trace) {
14376
+ const own = deserializeFromMdFolder(files).data;
14377
+ const nodes = [...own.nodes, ...others2?.nodes ?? []];
14378
+ const relations = [...own.relations, ...others2?.relations ?? []];
14379
+ const byId3 = Object.fromEntries(withBoundTests(nodes, repository?.verifies).map((n) => [n.id, n]));
14380
+ if (!byId3[values.trace]) {
14381
+ io2.err(`radical check --trace: no element ${values.trace} in ${folder}${others2?.nodes.length ? " or the models it depends on" : ""}.`);
14382
+ return 2;
14383
+ }
14384
+ const trace = traceOf({ nodes: byId3, relations: Object.fromEntries(relations.map((r) => [r.id, r])), evidence: result.evidence, cases: tests }, values.trace);
14385
+ if (!values.quiet) io2.out(values.format === "json" ? JSON.stringify(trace, null, 2) : formatTrace(trace, byId3));
14386
+ return 0;
14387
+ }
13131
14388
  const options = { folder, verbose: values.verbose };
13132
14389
  if (repository?.model && values.format !== "json" && !values.quiet) io2.out(`Judged this repository's part of the model of ${repository.model.repo}.`);
13133
14390
  if (federation && values.format !== "json" && !values.quiet) {
@@ -13173,6 +14430,28 @@ function concernPacks() {
13173
14430
  const bundled = join13(dirname8(fileURLToPath2(import.meta.url)), "hub-catalogue");
13174
14431
  return concernPacksOf(readCatalogue(existsSync2(bundled) ? bundled : CATALOGUE_DIR));
13175
14432
  }
14433
+ async function boundTestSources(root, verifies) {
14434
+ const files = /* @__PURE__ */ new Map();
14435
+ const sources = {};
14436
+ for (const id of new Set(verifies.flatMap((v) => v.tests))) {
14437
+ const { file } = splitTestId(id);
14438
+ if (!files.has(file)) {
14439
+ const path = resolve10(root, file);
14440
+ files.set(file, path.startsWith(resolve10(root)) && existsSync2(path) && (await stat7(path)).isFile() ? await readFile10(path, "utf8") : null);
14441
+ }
14442
+ const text3 = files.get(file);
14443
+ if (text3 != null) sources[id] = text3;
14444
+ }
14445
+ return sources;
14446
+ }
14447
+ async function baseModelNodes(folder) {
14448
+ try {
14449
+ const files = await readModelAtCommit(folder, (await resolveGitBase(folder)).commit);
14450
+ return Object.keys(files).length ? deserializeFromMdFolder(files).data.nodes : void 0;
14451
+ } catch {
14452
+ return void 0;
14453
+ }
14454
+ }
13176
14455
 
13177
14456
  // src/diff.ts
13178
14457
  init_define_RADICAL_BUILD();
@@ -13765,7 +15044,8 @@ two elements share needs the id.
13765
15044
  --path <folder> a folder that builds the element, from the working
13766
15045
  directory; more than once for several. Replaces the
13767
15046
  element's paths
13768
- --remove takes the element out of the file
15047
+ --remove takes the element out of the file; an element the model
15048
+ no longer has too, by its id or name
13769
15049
  --folder <dir> the model folder (default: the working directory when it
13770
15050
  is one, else the repository's .radical/model)
13771
15051
 
@@ -13774,7 +15054,7 @@ paths, or those it inherits from its nearest parent with an entry.
13774
15054
 
13775
15055
  Exit status: 0 done, 2 it could not (no such element, or several).`;
13776
15056
  var shown = (node) => `${node.type} "${node.label}" (${node.id})${originOf(node) ? ` of ${originModel(originOf(node))}` : ""}`;
13777
- async function openElement(io2, folderArg, wanted, types2) {
15057
+ async function openElement(io2, folderArg, wanted, types2, orphans) {
13778
15058
  const folder = resolve14(io2.cwd, await modelFolderArg(folderArg, io2.cwd));
13779
15059
  let nodes;
13780
15060
  try {
@@ -13786,8 +15066,19 @@ async function openElement(io2, folderArg, wanted, types2) {
13786
15066
  return 2;
13787
15067
  }
13788
15068
  const byId3 = new Map(nodes.map((n) => [n.id, n]));
15069
+ const { file, root } = await repositoryFileOf(folder);
15070
+ const where2 = relative8(io2.cwd, file) || REPOSITORY_FILE;
15071
+ let repository;
15072
+ try {
15073
+ repository = existsSync5(file) ? parseRepositoryFile(await readFile12(file, "utf8"), where2) : { implements: [], verifies: [] };
15074
+ } catch (error) {
15075
+ io2.err(error.message);
15076
+ return 2;
15077
+ }
13789
15078
  const kinds = types2 ? nodes.filter((n) => types2.includes(n.type)) : nodes;
13790
15079
  const named = byId3.get(wanted) && (!types2 || types2.includes(byId3.get(wanted).type)) ? [byId3.get(wanted)] : kinds.filter((n) => n.label.trim().toLowerCase() === wanted.toLowerCase());
15080
+ const gone = orphans && !named.length ? repository[orphans].filter((e2) => !byId3.has(e2.element) && (e2.element === wanted || e2.name?.trim().toLowerCase() === wanted.toLowerCase())) : [];
15081
+ if (gone.length === 1) return { orphan: gone[0], byId: byId3, root, file, where: where2, repository };
13791
15082
  if (named.length !== 1) {
13792
15083
  const near = named.length ? named : kinds.filter((n) => n.label.toLowerCase().includes(wanted.toLowerCase())).slice(0, 8);
13793
15084
  const what = types2 ? types2.join(" or ") : "element";
@@ -13796,17 +15087,9 @@ ${near.map((n) => ` ${shown(n)}`).join("\n")}` : `No ${what} named "${wanted}"
13796
15087
  ${near.map((n) => ` ${shown(n)}`).join("\n")}` : ""}`);
13797
15088
  return 2;
13798
15089
  }
13799
- const root = await repositoryRoot(folder) ?? await repositoryRoot(io2.cwd) ?? dirname10(dirname10(folder));
13800
- const file = join16(root, REPOSITORY_FILE);
13801
- const where2 = relative8(io2.cwd, file) || REPOSITORY_FILE;
13802
- try {
13803
- const repository = existsSync5(file) ? parseRepositoryFile(await readFile12(file, "utf8"), where2) : { implements: [], verifies: [] };
13804
- return { node: named[0], byId: byId3, root, file, where: where2, repository };
13805
- } catch (error) {
13806
- io2.err(error.message);
13807
- return 2;
13808
- }
15090
+ return { node: named[0], byId: byId3, root, file, where: where2, repository };
13809
15091
  }
15092
+ var shownOrphan = (entry) => `${entry.name !== void 0 ? `"${entry.name}" (${entry.element})` : entry.element}, no element of the model,`;
13810
15093
  async function implementCommand(args, io2) {
13811
15094
  let parsed;
13812
15095
  try {
@@ -13827,10 +15110,17 @@ ${IMPLEMENT_USAGE}`);
13827
15110
  io2.err(IMPLEMENT_USAGE);
13828
15111
  return 2;
13829
15112
  }
13830
- const opened = await openElement(io2, values.folder, wanted);
15113
+ const opened = await openElement(io2, values.folder, wanted, void 0, values.remove ? "implements" : void 0);
13831
15114
  if (typeof opened === "number") return opened;
13832
- const { node, byId: byId3, root, file, where: where2, repository } = opened;
15115
+ const { byId: byId3, root, file, where: where2, repository } = opened;
13833
15116
  const mapped = repository.implements;
15117
+ if (opened.orphan) {
15118
+ mapped.splice(mapped.findIndex((m) => m.element === opened.orphan.element), 1);
15119
+ await writeFile7(file, serializeRepositoryFile(repository));
15120
+ io2.out(`- ${shownOrphan(opened.orphan)} taken out of ${where2}`);
15121
+ return 0;
15122
+ }
15123
+ const node = opened.node;
13834
15124
  const parentOf = (id) => byId3.get(id)?.parentId;
13835
15125
  if (!values.remove && !values.path?.length) {
13836
15126
  const found = builtIn(mapped, node.id, parentOf);
@@ -13858,7 +15148,7 @@ ${IMPLEMENT_USAGE}`);
13858
15148
  for (const p of paths) if (!existsSync5(join16(root, p))) io2.err(`! ${p} is not in the repository yet; radical check warns about it until it is.`);
13859
15149
  const entry = { element: node.id, name: node.label, paths };
13860
15150
  if (at < 0) mapped.push(entry);
13861
- else mapped[at] = entry;
15151
+ else mapped[at] = { ...mapped[at], ...entry };
13862
15152
  await mkdir7(dirname10(file), { recursive: true });
13863
15153
  await writeFile7(file, serializeRepositoryFile(repository));
13864
15154
  io2.out(`+ ${shown(node)} is built in ${paths.join(", ")} (${where2})`);
@@ -13876,9 +15166,13 @@ elements share needs the id.
13876
15166
 
13877
15167
  --test <id> a test to bind, as Vitest and Playwright print it, from
13878
15168
  the repository's root: <file> \u203A <describe> \u203A <title>, or
13879
- <file> for every test in it; more than once for several
15169
+ <file> for every test in it; more than once for several.
15170
+ Vitest's <file> > <describe> > <title> is kept with \u203A,
15171
+ without the [project] or |project| and :line:col
15172
+ printed around the file
13880
15173
  --drop <id> a test to take off
13881
- --remove takes the element's entry out
15174
+ --remove takes the element's entry out; one the model no longer
15175
+ has too, by its id or name
13882
15176
  --folder <dir> the model folder (default: the working directory when it
13883
15177
  is one, else the repository's .radical/model)
13884
15178
 
@@ -13901,15 +15195,22 @@ ${VERIFY_USAGE}`);
13901
15195
  return 0;
13902
15196
  }
13903
15197
  const wanted = positionals.join(" ").trim();
13904
- const adds = (values.test ?? []).map((t) => t.trim()).filter(Boolean);
13905
- const drops = (values.drop ?? []).map((t) => t.trim()).filter(Boolean);
15198
+ const adds = [...new Set((values.test ?? []).map(canonicalTestId).filter(Boolean))];
15199
+ const drops = (values.drop ?? []).map(canonicalTestId).filter(Boolean);
13906
15200
  if (!wanted || values.remove && (adds.length || drops.length)) {
13907
15201
  io2.err(VERIFY_USAGE);
13908
15202
  return 2;
13909
15203
  }
13910
- const opened = await openElement(io2, values.folder, wanted, ["scenario", "fitness-fn"]);
15204
+ const opened = await openElement(io2, values.folder, wanted, ["scenario", "fitness-fn"], values.remove ? "verifies" : void 0);
13911
15205
  if (typeof opened === "number") return opened;
13912
- const { node, file, where: where2, repository } = opened;
15206
+ const { file, where: where2, repository } = opened;
15207
+ if (opened.orphan) {
15208
+ repository.verifies.splice(repository.verifies.findIndex((v) => v.element === opened.orphan.element), 1);
15209
+ await writeFile8(file, serializeRepositoryFile(repository));
15210
+ io2.out(`- ${shownOrphan(opened.orphan)} taken out of ${where2}`);
15211
+ return 0;
15212
+ }
15213
+ const node = opened.node;
13913
15214
  const bound = testsBoundTo(repository.verifies, node.id);
13914
15215
  if (!values.remove && !adds.length && !drops.length) {
13915
15216
  io2.out(bound.length ? `${shown(node)} is checked by:
@@ -13924,11 +15225,12 @@ ${bound.map((t) => ` ${t}`).join("\n")}` : `${where2} binds no test to ${shown(
13924
15225
  }
13925
15226
  repository.verifies.splice(at, 1);
13926
15227
  } else {
13927
- const tests = [...bound.filter((t) => !drops.includes(t)), ...adds.filter((t) => !bound.includes(t))];
15228
+ const tests = rebindTests(bound, adds, drops);
13928
15229
  const entry = { element: node.id, name: node.label, tests };
13929
- if (!tests.length) repository.verifies.splice(at, 1);
13930
- else if (at < 0) repository.verifies.push(entry);
13931
- else repository.verifies[at] = entry;
15230
+ if (!tests.length) {
15231
+ if (at >= 0) repository.verifies.splice(at, 1);
15232
+ } else if (at < 0) repository.verifies.push(entry);
15233
+ else repository.verifies[at] = { ...repository.verifies[at], ...entry };
13932
15234
  }
13933
15235
  await mkdir8(dirname11(file), { recursive: true });
13934
15236
  await writeFile8(file, serializeRepositoryFile(repository));
@@ -14160,10 +15462,9 @@ function findingRun(finding, config, root) {
14160
15462
  return { label: findingTestName(finding), command: "npx", args: ["vitest", "run", relative9(cwd, resolve15(root, entry.file)), "-t", escapeRegExp(findingTestName(finding))], cwd };
14161
15463
  }
14162
15464
  function testRun(spec, config, root) {
14163
- const at = spec.indexOf(" \u203A ");
14164
- if (at < 0) return `--test takes "<file> \u203A <name>", not "${spec}".`;
14165
- const file = spec.slice(0, at).trim();
14166
- const name = spec.slice(at + 3).split(" \u203A ").map((part) => escapeRegExp(part.trim())).join(" ");
15465
+ const [file, ...titles] = testIdParts(spec);
15466
+ if (!titles.length) return `--test takes "<file> \u203A <name>", not "${spec}".`;
15467
+ const name = titles.map((part) => escapeRegExp(part)).join(" ");
14167
15468
  if (!existsSync6(resolve15(root, file))) return `No test file ${file}.`;
14168
15469
  const runner = config.runners.find((r) => file.startsWith(r.files));
14169
15470
  if (runner) {
@@ -14310,11 +15611,16 @@ checks what comes back; the agent session starts the agents
14310
15611
  --areas "<a>;\u2026" an area per run, in order (the rest choose their own)
14311
15612
  --since <ref> what changed is counted from here (default: the last
14312
15613
  round's commit)
14313
- --from <n> the first run's number (default: after the last round's)
15614
+ --from <n> the first run's number (default: after the last round's);
15615
+ a run an earlier round has is refused
14314
15616
  --no-build copy what is built already
14315
15617
  verify <run> \u2026 serves the run's build on its ports, runs each script
14316
- ("<script> [args]", from the run's folder) and stops the
14317
- servers; the results go into round.json
15618
+ ("<script> [args]", from the run's folder; one not
15619
+ there stops it before anything runs) and stops the
15620
+ servers; the results go into round.json. A script
15621
+ shows the bug when it exits 1, or when a line of its
15622
+ output says so (REPRODUCED: yes, BUG: \u2026, FINDING: \u2026;
15623
+ REPRODUCED: no says it does not), which wins
14318
15624
  record <report> writes the findings of a run's report (its JSON block)
14319
15625
  as findings, with a copy of each one's script and
14320
15626
  screenshot; warns about a script that names the
@@ -14448,6 +15754,11 @@ async function prepare(settings, count3, areas, sinceArg, fromArg, build2, io2)
14448
15754
  const commit = head.stdout.trim();
14449
15755
  const dirty = git5(root, ["status", "--porcelain", "--untracked-files=no"]).stdout.trim() !== "";
14450
15756
  const since = sinceArg ?? last?.commit;
15757
+ const taken = earlier.find((r) => r.from <= to2 && from <= r.to);
15758
+ if (taken) {
15759
+ io2.err(`Run ${Math.max(from, taken.from)} is in ${taken.round} already: give --from ${Math.max(...earlier.map((r) => r.to)) + 1} or more.`);
15760
+ return 2;
15761
+ }
14451
15762
  const name = `round-${from}-${to2}`;
14452
15763
  const dir = join18(roundsDir, name);
14453
15764
  if (existsSync7(dir)) {
@@ -14486,7 +15797,7 @@ ${r.stdout ?? ""}${r.stderr ?? ""}
14486
15797
  const commits = since ? git5(root, ["log", "--oneline", "--no-decorate", `${since}..HEAD`]).stdout.trim().split("\n").filter(Boolean) : [];
14487
15798
  const modelAreas = since && explore.model ? await changedAreas(root, explore.model, since) : [];
14488
15799
  const open4 = readFindings(resolve16(root, settings.findings)).filter((f) => f.status === "open" || f.status === "question" || f.status === "hardened");
14489
- const earlierRuns = earlier.flatMap((r) => r.runs.map((x) => x.folder)).slice(-20);
15800
+ const earlierRuns = earlier.flatMap((r) => r.runs.map((x) => runFolder(roundsDir, r, x))).slice(-20);
14490
15801
  const serve = (entry) => serveCommands(settings, dir, entry);
14491
15802
  const brief = [
14492
15803
  `# Exploratory runs ${from}\u2013${to2}: common setup`,
@@ -14513,6 +15824,7 @@ ${r.stdout ?? ""}${r.stderr ?? ""}
14513
15824
  `- The build of ${commit}: \`${dir}/build\`${Object.keys(explore.copy).length ? ` (${Object.keys(explore.copy).join(", ")})` : ""}.`,
14514
15825
  ...explore.serve.length ? [`- Serve it for your run with the command${explore.serve.length === 1 ? "" : "s"} in your prompt.`] : [],
14515
15826
  "- Your folder and your ports are in your prompt: a run NN has the ports of NN. Write scripts, screenshots and notes only in your folder.",
15827
+ "- A script exits 1 while the bug shows and 0 when it does not, and says which in a line of its own, `REPRODUCED: yes` or `REPRODUCED: no`: `radical explore verify` reads both (a script that throws exits 1 too) and says when they disagree.",
14516
15828
  `- Scripts name no absolute path: a finding's script is copied into \`${settings.findings}/F-NNNN/\` with the helpers it imports and must run from there too. Find the repository by walking up from the script's own folder to the one that holds \`.radical/crucible/crucible.json\`, and take your ports and anything of the round's folder as arguments.`,
14517
15829
  `- ${count3} run${count3 === 1 ? "" : "s"} share this machine: keep one browser open at a time and close it when a script ends; do not run the project's whole test suites.`,
14518
15830
  "",
@@ -14574,11 +15886,15 @@ async function changedAreas(root, model, since) {
14574
15886
  return [...byArea].sort((a2, b) => count(b[1]) - count(a2[1])).map(([area, c]) => `${area}: ${[c.added.length && `${c.added.length} added`, c.changed.length && `${c.changed.length} changed`, c.removed.length && `${c.removed.length} removed`].filter(Boolean).join(", ")} \u2014 ${[...c.changed, ...c.added, ...c.removed].slice(0, 6).join(", ")}${count(c) > 6 ? ", \u2026" : ""}`);
14575
15887
  }
14576
15888
  var count = (c) => c.added.length + c.changed.length + c.removed.length;
15889
+ var runFolder = (roundsDir, round2, entry) => join18(roundsDir, round2.round, `run-${entry.run}`);
14577
15890
  function findRun(settings, run2) {
14578
15891
  const roundsDir = resolve16(settings.root, settings.explore.rounds);
14579
15892
  for (const round2 of rounds(roundsDir)) {
14580
15893
  const entry = round2.runs.find((r) => r.run === run2);
14581
- if (entry) return { dir: join18(roundsDir, round2.round), round: round2, entry };
15894
+ if (entry) {
15895
+ entry.folder = runFolder(roundsDir, round2, entry);
15896
+ return { dir: join18(roundsDir, round2.round), round: round2, entry };
15897
+ }
14582
15898
  }
14583
15899
  return void 0;
14584
15900
  }
@@ -14589,6 +15905,11 @@ async function verify(settings, run2, scripts, io2) {
14589
15905
  return 2;
14590
15906
  }
14591
15907
  const { dir, round: round2, entry } = found;
15908
+ const absent = scripts.map((line) => line.trim().split(/\s+/)[0]).find((script) => !existsSync7(resolve16(entry.folder, script)));
15909
+ if (absent !== void 0) {
15910
+ io2.err(`No script ${absent} in ${relative10(io2.cwd, entry.folder)}: nothing was run.`);
15911
+ return 2;
15912
+ }
14592
15913
  const servers = serveCommands(settings, dir, entry);
14593
15914
  const started = [];
14594
15915
  try {
@@ -14608,15 +15929,23 @@ async function verify(settings, run2, scripts, io2) {
14608
15929
  const ports = servers.map((s2) => s2.port);
14609
15930
  io2.out(`Serving run ${run2}'s build on port${ports.length === 1 ? "" : "s"} ${ports.length === 1 ? ports[0] : `${ports.slice(0, -1).join(", ")} and ${ports[ports.length - 1]}`}.`);
14610
15931
  }
15932
+ const shown3 = [];
15933
+ const notShown = [];
14611
15934
  for (const line of scripts) {
14612
15935
  const [script, ...args] = line.trim().split(/\s+/);
14613
15936
  const r = spawnSync3("node", [script, ...args], { cwd: entry.folder, encoding: "utf8", timeout: 10 * 6e4, maxBuffer: 64 * 1024 * 1024 });
14614
- const output = `${r.stdout ?? ""}${r.stderr ?? ""}`.trimEnd().split("\n").slice(-20);
15937
+ const all = `${r.stdout ?? ""}${r.stderr ?? ""}`.trimEnd().split("\n");
14615
15938
  io2.out(`=== ${line}`);
14616
- for (const l of output) if (l) io2.out(` ${l}`);
15939
+ for (const l of all.slice(-20)) if (l) io2.out(` ${l}`);
14617
15940
  io2.out(` (exit ${r.status ?? "killed"})`);
14618
- entry.verified.push({ at: (/* @__PURE__ */ new Date()).toISOString(), script: line, exit: r.status ?? -1 });
14619
- }
15941
+ const says2 = [...new Set(all.filter((l) => SAYS.test(l)).map((l) => l.trim()))];
15942
+ const judged = judgeScript(r.status, says2);
15943
+ for (const l of says2) io2.out(` says: ${l}`);
15944
+ io2.out(` \u2192 ${judged.text}`);
15945
+ if (judged.shown !== void 0) (judged.shown ? shown3 : notShown).push(line);
15946
+ entry.verified.push({ at: (/* @__PURE__ */ new Date()).toISOString(), script: line, exit: r.status ?? -1, ...judged.shown !== void 0 ? { shown: judged.shown } : {}, ...says2.length ? { says: says2 } : {} });
15947
+ }
15948
+ if (shown3.length || notShown.length) io2.out(`Shows the bug: ${shown3.join(", ") || "none"}. Does not: ${notShown.join(", ") || "none"}.`);
14620
15949
  writeFileSync3(join18(dir, "round.json"), JSON.stringify(round2, null, 2) + "\n");
14621
15950
  return 0;
14622
15951
  } finally {
@@ -14630,6 +15959,19 @@ async function verify(settings, run2, scripts, io2) {
14630
15959
  for (const server of started) await waitClosed(server.port);
14631
15960
  }
14632
15961
  }
15962
+ var SAYS = /^\s*(REPRODUCED|BUG|FINDING)\b/;
15963
+ var SAYS_NO = /^\s*REPRODUCED\s*[:=]?\s*(no|false|none|0)\b/i;
15964
+ function judgeScript(exit, says2) {
15965
+ const fromLines = says2.length ? says2.some((l) => !SAYS_NO.test(l)) : void 0;
15966
+ const fromExit = exit === 1 ? true : exit === 0 ? false : void 0;
15967
+ const shown3 = fromLines ?? fromExit;
15968
+ if (shown3 === void 0) return { text: `it did not run to the end (exit ${exit ?? "killed"}): neither its exit nor a line says whether the bug shows` };
15969
+ const text3 = shown3 ? "the bug shows" : "the bug does not show";
15970
+ if (fromLines !== void 0 && fromExit !== void 0 && fromLines !== fromExit) {
15971
+ return { shown: shown3, text: `${text3}, as its output says; its exit ${exit} says otherwise (a script exits 1 while the bug shows, 0 when it does not)` };
15972
+ }
15973
+ return { shown: shown3, text: fromLines === void 0 ? `${text3} (exit ${exit})` : text3 };
15974
+ }
14633
15975
  async function listening(port, ms) {
14634
15976
  const until = Date.now() + ms;
14635
15977
  do {
@@ -15067,13 +16409,13 @@ function splitMetrics(node) {
15067
16409
  const text3 = node.metrics;
15068
16410
  if (typeof text3 !== "string") return { tests: [], rest: "" };
15069
16411
  const tests = [];
15070
- const kept = [];
16412
+ const kept2 = [];
15071
16413
  for (const line of text3.split("\n")) {
15072
16414
  const condition2 = line.trim() ? parseCondition(line.trim()) : null;
15073
16415
  if (condition2?.kind === "test") tests.push(condition2.id.raw);
15074
- else kept.push(line);
16416
+ else kept2.push(line);
15075
16417
  }
15076
- return { tests, rest: kept.join("\n").trim() };
16418
+ return { tests, rest: kept2.join("\n").trim() };
15077
16419
  }
15078
16420
  var naming = (data) => data.nodes.filter((n) => TESTED_TYPES.includes(n.type) && !originOf(n) && splitMetrics(n).tests.length > 0);
15079
16421
  async function testsNamedIn(folder) {
@@ -15650,7 +16992,7 @@ ${SETUP_USAGE}`);
15650
16992
  const what = `${named} scenario${named === 1 ? "" : "s"} and fitness function${named === 1 ? "" : "s"}`;
15651
16993
  if (!await confirm(` ${what} name their tests in the model. Move them into .radical/radical.json?`)) io2.out(" - left in the model: radical setup moves them later");
15652
16994
  else if (dry) io2.out(` would move the tests of ${what} into .radical/radical.json`);
15653
- else for (const line of await moveTestsOut(folder, await mappingRoot(folder))) io2.out(` + ${line}`);
16995
+ else for (const line of await moveTestsOut(folder, (await repositoryFileOf(folder)).root)) io2.out(` + ${line}`);
15654
16996
  }
15655
16997
  const real = existsSync12(folder) ? await realpath9(folder) : folder;
15656
16998
  const git6 = async (...gitArgs) => (await exec8("git", gitArgs, { cwd: existsSync12(real) ? real : io2.cwd, windowsHide: true })).stdout.trim();
@@ -15961,9 +17303,9 @@ ADR, the element with its paths from .radical/radical.json, metricsOut: a
15961
17303
  file it may write radical-metrics/1 measurements to), measured as
15962
17304
  <sensor>.exit_code and <sensor>.duration labelled element=<id>.
15963
17305
 
15964
- review records a person's review of a manual fitness function in the model
15965
- folder's reviews.json, kept in git; its \`review(<name>) passed\` condition
15966
- reads the latest review of <name>.
17306
+ review records a person's review of a manual fitness function in the
17307
+ repository's .radical/reviews.json, kept in git; its \`review(<name>)
17308
+ passed\` condition reads the latest review of <name>.
15967
17309
 
15968
17310
  Adapters:
15969
17311
  ${SENSOR_ADAPTERS.map((a2) => ` ${a2.name.padEnd(18)}${a2.description}`).join("\n")}
@@ -16049,9 +17391,9 @@ ${SENSE_USAGE}`);
16049
17391
  const files = await new MdFolderSession(diskFolderStorage(folder), { writeCache: false }).readAll();
16050
17392
  const own = deserializeFromMdFolder(files).data;
16051
17393
  const federation = await composeFolder(folder);
16052
- const others = federation ? federationOthers(files, federation.fetched) : null;
17394
+ const others2 = federation ? federationOthers(files, federation.fetched) : null;
16053
17395
  const mapping = await readRepositoryMapping(folder);
16054
- const whole = { nodes: [...own.nodes, ...others?.nodes ?? []], relations: [...own.relations, ...others?.relations ?? []] };
17396
+ const whole = { nodes: [...own.nodes, ...others2?.nodes ?? []], relations: [...own.relations, ...others2?.relations ?? []] };
16055
17397
  const part = mapping?.model ? repositoryPart(whole, mapping.implements) : whole;
16056
17398
  nodes = part.nodes;
16057
17399
  model = sensorModel(part, federation?.deps.name || basename5(folder), mapping?.implements ?? []);
@@ -16157,7 +17499,7 @@ ${SENSE_USAGE}`);
16157
17499
  try {
16158
17500
  text3 = addReview(existing, { name, result, by: values.by.trim(), at: now().toISOString(), ...values.note?.trim() ? { note: values.note.trim() } : {} });
16159
17501
  } catch (error) {
16160
- io2.err(`Cannot read ${REVIEWS_FILE2}: ${error.message}`);
17502
+ io2.err(`Cannot read ${REVIEWS_FILE}: ${error.message}`);
16161
17503
  return 2;
16162
17504
  }
16163
17505
  await mkdir12(dirname19(path), { recursive: true });
@@ -16389,8 +17731,8 @@ var RepoFiles = class {
16389
17731
  const builds = new Set(listing.files.filter((f) => /(^|\/)build\/[^/]+\.(cs|fs)proj$/i.test(f)).map((f) => f.slice(0, f.lastIndexOf("/"))));
16390
17732
  const deployment = (f) => /(^|\/)build\//.test(f) && /(^|\/)((docker-)?compose[^/]*\.ya?ml|Dockerfile)$/i.test(f);
16391
17733
  const report = (f) => /\.(html?|css|js|json|xml|info|lcov|png|svg|gif|txt|gz)$/i.test(f);
16392
- const kept = (seg, f, at) => seg === "build" && (listing.git || builds.has(at)) || seg === "coverage" && !!listing.git && !report(f);
16393
- const skipped = (f) => VENDORED.test(f) || !deployment(f) && f.split("/").slice(0, -1).some((seg, i, segs) => SKIPPED.has(seg) && !kept(seg, f, segs.slice(0, i + 1).join("/")));
17734
+ const kept2 = (seg, f, at) => seg === "build" && (listing.git || builds.has(at)) || seg === "coverage" && !!listing.git && !report(f);
17735
+ const skipped = (f) => VENDORED.test(f) || !deployment(f) && f.split("/").slice(0, -1).some((seg, i, segs) => SKIPPED.has(seg) && !kept2(seg, f, segs.slice(0, i + 1).join("/")));
16394
17736
  const frameworks = listing.files.map((f) => /^(.+\/)(?:source\/core\/ut_utils\.pks|pgtap\.control)$/i.exec(f)?.[1]).filter((d) => !!d);
16395
17737
  this.list = listing.files.filter((f) => !skipped(f) && !frameworks.some((d) => f.startsWith(d))).sort();
16396
17738
  this.set = new Set(this.list);
@@ -21967,10 +23309,10 @@ function sqlFolders(files, claimed) {
21967
23309
  return dir === "." ? "." : /^(db|database|databases|sql|schemas?|scripts)$/i.test(segs[0]) && segs.length > 1 ? segs.slice(0, 2).join("/") : segs[0];
21968
23310
  };
21969
23311
  const dirs = [...new Set(scripts.map((f) => top(dirOf(f))))].sort((a2, b) => a2.length - b.length);
21970
- const kept = [];
21971
- for (const d of dirs) if (!kept.some((k) => k === "." || d.startsWith(`${k}/`))) kept.push(d);
23312
+ const kept2 = [];
23313
+ for (const d of dirs) if (!kept2.some((k) => k === "." || d.startsWith(`${k}/`))) kept2.push(d);
21972
23314
  const under = (dir) => scripts.filter((f) => dir === "." || f.startsWith(`${dir}/`));
21973
- return [...projects, ...kept.map((path) => {
23315
+ return [...projects, ...kept2.map((path) => {
21974
23316
  const d = draft("sql", path, under(path)[0], void 0, 1);
21975
23317
  d.aliases.push(basename8(path === "." ? files.root : path));
21976
23318
  return d;
@@ -22776,7 +24118,7 @@ function readCode(files, repo, units) {
22776
24118
  const accessNamed = /* @__PURE__ */ new Map();
22777
24119
  const accessUsers = /* @__PURE__ */ new Set();
22778
24120
  const valuesByUnit = /* @__PURE__ */ new Map();
22779
- const valuesOf = (unit) => {
24121
+ const valuesOf2 = (unit) => {
22780
24122
  const known = valuesByUnit.get(unit.id);
22781
24123
  if (known) return known;
22782
24124
  const mine = files.list.filter((f) => owner(units, f)?.id === unit.id);
@@ -22806,7 +24148,7 @@ function readCode(files, repo, units) {
22806
24148
  let text3 = configures.has(file) ? settingsFor(files, file, unit) : files.read(file);
22807
24149
  if (!text3) continue;
22808
24150
  const vb = VB_CODE.test(file);
22809
- if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)), valuesOf(unit));
24151
+ if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)), valuesOf2(unit));
22810
24152
  if (config && /\.(ya?ml|properties|env|toml|conf|ini)$|(^|\/)\.env(\.[\w-]+)?$/i.test(file)) text3 = text3.replace(/^[ \t]*#.*$/gm, "").replace(/\.ini$/i.test(file) ? /^[ \t]*;.*$/gm : /$^/, "");
22811
24153
  const unresolved = text3;
22812
24154
  text3 = text3.replace(/\$\{([\w.-]+):([^${}\n]*)\}/g, (_, key, value) => value.startsWith("?") ? `\${${key}}` : value.replace(/^-/, ""));
@@ -22871,7 +24213,7 @@ function readCode(files, repo, units) {
22871
24213
  accessNamed.set(unit.id, [...accessNamed.get(unit.id) ?? [], { name: m[2], evidence: at(m.index) }]);
22872
24214
  }
22873
24215
  if (/\.(frm|dob|pag|ctl)$/i.test(file)) formAddress(text3, file, unit, repo, out, once);
22874
- const values = valuesOf(unit);
24216
+ const values = valuesOf2(unit);
22875
24217
  const hostOf = (expr) => (values.resolve(expr) ?? /^"([^"]+)"$/.exec(expr.trim())?.[1] ?? expr.trim()).toLowerCase();
22876
24218
  const remoteHost = /\.RemoteHost\s*=\s*([^\n]+)/i.exec(text3)?.[1];
22877
24219
  const connects = [
@@ -23069,9 +24411,9 @@ function blueprint(body, at, text3, t) {
23069
24411
  for (const m of body.matchAll(/\$\w+->(\w+)\(\s*(?:'([^']+)'|"([^"]+)"|\[([^\]]*)\])?([^;]*);/g)) {
23070
24412
  const [method, name, list, rest] = [m[1], m[2] ?? m[3], m[4], m[5]];
23071
24413
  const line = lineAt(text3, at + m.index);
23072
- const has = (column) => t.columns.some((c) => c.name === column);
24414
+ const has2 = (column) => t.columns.some((c) => c.name === column);
23073
24415
  const add = (column, type2) => {
23074
- if (!has(column)) t.columns.push({ name: column, ...type2 ? { type: type2 } : {}, .../->nullable\(/.test(rest) ? {} : { notNull: true }, line });
24416
+ if (!has2(column)) t.columns.push({ name: column, ...type2 ? { type: type2 } : {}, .../->nullable\(/.test(rest) ? {} : { notNull: true }, line });
23075
24417
  };
23076
24418
  if (method === "dropColumn" || method === "dropColumns") {
23077
24419
  const gone = name ? [name] : [...(list ?? "").matchAll(/'([^']+)'|"([^"]+)"/g)].map((x) => x[1] ?? x[2]);
@@ -25150,17 +26492,17 @@ function linkRepositories(repositories) {
25150
26492
  }
25151
26493
  for (const r of repositories) {
25152
26494
  const deps = r.dependencies.filter((d) => !d.target);
25153
- const has = (u, re2) => deps.some((d) => d.unit === u.id && re2.test(d.package));
26495
+ const has2 = (u, re2) => deps.some((d) => d.unit === u.id && re2.test(d.package));
25154
26496
  for (const c of CONVENTIONS) {
25155
26497
  const servers = [
25156
- ...r.units.filter((u) => c.server && has(u, c.server)).map((u) => u.id),
26498
+ ...r.units.filter((u) => c.server && has2(u, c.server)).map((u) => u.id),
25157
26499
  ...c.image ? services.filter((s2) => repoOf(s2.id) === r.repository && c.image.test(`${s2.image ?? ""} ${s2.name}`) && !s2.unit).map((s2) => s2.id) : [],
25158
26500
  ...c.image ? r.units.filter((u) => u.stack === "docker" && c.image.test(u.name)).map((u) => u.id) : []
25159
26501
  ];
25160
26502
  const named = [...new Set(servers)].filter((id) => /^(kafka|rabbitmq|rabbit|nats|eureka|config)(-?server)?$/i.test(services.find((x) => x.id === id)?.name ?? r.units.find((u) => u.id === id)?.name ?? ""));
25161
26503
  if (new Set(servers).size !== 1 && named.length !== 1) continue;
25162
26504
  if (new Set(servers).size !== 1) servers.splice(0, servers.length, named[0]);
25163
- for (const u of r.units.filter((x) => x.kind === "app" && x.id !== servers[0] && !(c.server && has(x, c.server)))) {
26505
+ for (const u of r.units.filter((x) => x.kind === "app" && x.id !== servers[0] && !(c.server && has2(x, c.server)))) {
25164
26506
  const dep = deps.find((d) => d.unit === u.id && c.client.test(d.package));
25165
26507
  if (!dep || [...links.values()].some((l) => l.from === u.id && l.to === servers[0])) continue;
25166
26508
  add("address", u.id, servers[0], "inferred", [dep.id, servers[0]], `${c.name} client (${dep.package}): the repository's only ${c.name}`);
@@ -26087,9 +27429,9 @@ Commands:
26087
27429
  (radical export confluence --help)
26088
27430
  discussions confluence connect|sync|status [folder]
26089
27431
  preview or sync managed wiki footer discussions
26090
- federation <open|sync|watch> [folder]
26091
- compose the model with the models its deps.json names,
26092
- and carry its own changes back (radical federation --help)
27432
+ federation fetch [folder]
27433
+ fetch the models its deps.json names, to show and check
27434
+ beside it, read-only (radical federation --help)
26093
27435
  fuzz [plan] run the fuzz files .radical/crucible/crucible.json lists (Radical Crucible;
26094
27436
  radical fuzz --help)
26095
27437
  harden <finding> turn a finding into a test, and gate a test: it fails