@radicaltools/cli 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -275,7 +275,10 @@ the base Studio compares with follows the branch checked out, and then
275
275
  `radical check <folder> --from-ci --quiet --detach`, which fetches the test
276
276
  results of CI for the commit checked out in the background (a command of its
277
277
  own, its output closed: a CLI built before `--from-ci` still saves the
278
- base, and without the GitHub CLI nothing is fetched). The line goes
278
+ base, and without the GitHub CLI nothing is fetched). What it found, or why
279
+ it found nothing, is kept in the model folder's `.state/ci-fetch.json`, which
280
+ the Inspector and `radical setup --status` show; CI has to keep its test
281
+ reports as artifacts (see *Test results from CI*). The line goes
279
282
  right after the hook's `#!` line, where an `exit` or `exec` further down
280
283
  cannot skip it; what the hooks already do stays. Each model folder of the
281
284
  repository has a line of its own, a second install adds nothing (or brings
@@ -512,14 +515,50 @@ test reports in it. Which artifacts hold reports is set in the repository's
512
515
  { "ci": { "artifacts": ["test-reports", "e2e-report"] } }
513
516
  ```
514
517
 
515
- (every artifact of the run without it). The results are kept in
518
+ (every artifact of the run without it). **CI has to keep the reports as
519
+ artifacts of the run**: reports kept elsewhere (S3, say) are not found. A
520
+ GitHub Actions step after the tests:
521
+
522
+ ```yaml
523
+ - uses: actions/upload-artifact@v4
524
+ if: always() # failed tests are results too
525
+ with:
526
+ name: test-reports # as "ci": { "artifacts": [...] } names it
527
+ path: reports/ # the Vitest/Jest/Playwright JSON or JUnit XML,
528
+ # and the radical sense --out files
529
+ ```
530
+
531
+ The results are kept in
516
532
  `.state/test-results.json` with the commit they stand for, the runs, when
517
533
  each ran and how many commits HEAD is past it, which the Inspector's *Tests*
518
- chip shows; the same runs a second time download nothing. Results read with
519
- `--report` at that commit or a later one are kept, and checked. `--quiet`
520
- prints nothing; `--detach` starts the check in the background and returns,
521
- as the git hooks of `radical hooks install` do after every checkout, commit,
522
- pull and rebase.
534
+ chip shows (*· CI*, or *· local* for results read with `--report`); the same
535
+ runs a second time download nothing. Results read with `--report` at that
536
+ commit or a later one are kept, and checked. The `radical-metrics/1` files
537
+ in the artifacts (what `radical sense --out` wrote in CI) are added to
538
+ `.state/measurements.json` as `--metrics` adds them, each with the run and
539
+ commit in its context (`ci.run`, `ci.commit`), so metrics measured in CI
540
+ reach Studio too. `--quiet` prints nothing; `--detach` starts the check in
541
+ the background and returns, as the git hooks of `radical hooks install` do
542
+ after every checkout, commit, pull and rebase.
543
+
544
+ What each fetch found is kept in `.state/ci-fetch.json`, with `--quiet` too:
545
+ the runs and what was read, or why nothing was (no `gh`, no run with
546
+ artifacts, no test report in them). The Inspector marks its *Tests* chip
547
+ when the last fetch found no test results and says what it said, and
548
+ `radical setup --status` prints the last fetch.
549
+
550
+ ### A check that keeps nothing
551
+
552
+ ```sh
553
+ radical check path/to/model --report broken.json --no-keep
554
+ ```
555
+
556
+ `--no-keep` reads the reports and measurements given and judges with them,
557
+ but writes nothing beside the model: neither `.state/test-results.json` nor
558
+ `.state/measurements.json` (nor, with `--from-ci`, `.state/ci-fetch.json`).
559
+ For a check used as a gate whose verdict Studio should not show, such as a
560
+ test of the gate on a deliberately broken report. `--evidence`, `--ratchet`
561
+ and `--adopt` still write the file they name.
523
562
 
524
563
  ### Measured values
525
564
 
@@ -16,7 +16,7 @@ var __commonJS = (cb, mod) => function __require2() {
16
16
  var define_RADICAL_BUILD_default;
17
17
  var init_define_RADICAL_BUILD = __esm({
18
18
  "<define:__RADICAL_BUILD__>"() {
19
- define_RADICAL_BUILD_default = { version: "0.6.0", commit: "6b160c8", date: "2026-11-24", release: true };
19
+ define_RADICAL_BUILD_default = { version: "0.6.1", commit: "ce06b9e", date: "2026-11-27", release: true };
20
20
  }
21
21
  });
22
22
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_define_RADICAL_BUILD
3
- } from "./chunk-CWKX2ULF.js";
3
+ } from "./chunk-SBQRTX3Y.js";
4
4
 
5
5
  // ../../packages/assay/node_modules/unpdf/dist/index.mjs
6
6
  init_define_RADICAL_BUILD();
@@ -41,7 +41,7 @@ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
41
41
  }
42
42
  }
43
43
  try {
44
- const { resolvePDFJS } = await import("./pdfjs-ABY3IR7F.js");
44
+ const { resolvePDFJS } = await import("./pdfjs-WWNLOMK2.js");
45
45
  resolvedModule = await resolvePDFJS();
46
46
  } catch (error) {
47
47
  console.error(error);
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-CWKX2ULF.js";
5
+ } from "./chunk-SBQRTX3Y.js";
6
6
 
7
7
  // src/index.ts
8
8
  init_define_RADICAL_BUILD();
@@ -6623,7 +6623,8 @@ function testRule(outcome, message) {
6623
6623
  if (!model.tests) return [];
6624
6624
  return Object.values(model.nodes).filter((n) => TESTED_TYPES.includes(n.type)).flatMap((node) => testOutcomes(node, model).filter((o) => o.outcome === outcome).map((o) => {
6625
6625
  const related = failing ? affectedBy(model, node).map((n) => n.id) : [];
6626
- return { nodeId: node.id, message: message(node, o.id.raw, model), ...related.length ? { relatedIds: related } : {} };
6626
+ const reason = outcome === "failed" ? findTests(o.id, model.tests ?? []).matches.find((c) => c.status === "failed" && c.message)?.message : void 0;
6627
+ return { nodeId: node.id, test: o.id.raw, message: message(node, o.id.raw, model), ...reason ? { reason } : {}, ...related.length ? { relatedIds: related } : {} };
6627
6628
  }));
6628
6629
  };
6629
6630
  }
@@ -6646,6 +6647,9 @@ function metricRule(outcome, message) {
6646
6647
  const origin = originOf(node);
6647
6648
  return elements.flatMap((element) => elementConditions(node, model, element).filter((r) => r.outcome === outcome).map((r) => ({
6648
6649
  nodeId: origin ? element.id : node.id,
6650
+ condition: r.condition,
6651
+ ...r.measurement ? { measured: r.measurement } : {},
6652
+ ...r.detail ? { why: r.detail } : {},
6649
6653
  message: `${message(node, r.condition, seen(r), r.detail).replace(/\.$/, "")} for ${TYPE_NAME[element.type] ?? element.type} ${quote(element)}${origin ? ` (a fitness function of ${origin})` : ""}.`,
6650
6654
  ...origin ? { relatedIds: [node.id] } : outcome === "failed" ? { relatedIds: [element.id] } : {}
6651
6655
  })));
@@ -6653,7 +6657,14 @@ function metricRule(outcome, message) {
6653
6657
  const metricLines = new Set(conditionsOf(node).filter((c) => c.kind === "metric").map((c) => c.raw));
6654
6658
  return conditionResults(node, model).filter((r) => r.outcome === outcome && metricLines.has(r.condition)).map((r) => {
6655
6659
  const related = outcome === "failed" ? affectedBy(model, node).map((n) => n.id) : [];
6656
- return { nodeId: node.id, message: message(node, r.condition, seen(r), r.detail), ...related.length ? { relatedIds: related } : {} };
6660
+ return {
6661
+ nodeId: node.id,
6662
+ condition: r.condition,
6663
+ ...r.measurement ? { measured: r.measurement } : {},
6664
+ ...r.detail ? { why: r.detail } : {},
6665
+ message: message(node, r.condition, seen(r), r.detail),
6666
+ ...related.length ? { relatedIds: related } : {}
6667
+ };
6657
6668
  });
6658
6669
  });
6659
6670
  };
@@ -6864,7 +6875,7 @@ var sourceReading = (text3) => reading(text3.replace(/(\d)_(?=\d)/g, "$1").repla
6864
6875
  var CHECK_RULES = [
6865
6876
  {
6866
6877
  id: "metamodel",
6867
- description: 'The model follows its metamodel: types, parents, relation pairs, required properties, references and the state machine rules. The Validation list in Studio and get_issues over MCP, with their severities: an unknown type or a relation to no element is an error, a relation pair the metamodel does not allow a warning (`"metamodel": "error"` makes every issue one).',
6878
+ description: '**The model follows its metamodel**: types, parents, relation pairs, required properties, references and the state machine rules. The Validation list in Studio and get_issues over MCP, with their severities: an unknown type or a relation to no element is an error, a relation pair the metamodel does not allow a warning (`"metamodel": "error"` makes every issue one).',
6868
6879
  severity: "error",
6869
6880
  dimension: "consistency",
6870
6881
  run: (model) => validateModel(model.nodes, model.relations, model.metamodel).map((issue) => ({
@@ -6877,42 +6888,42 @@ var CHECK_RULES = [
6877
6888
  },
6878
6889
  {
6879
6890
  id: "requirement-incomplete",
6880
- description: "A requirement has an action and every field its EARS type reads (an event-driven one a trigger, a state-driven one a precondition, \u2026).",
6891
+ description: "**A requirement has an action and every field its EARS type reads** (an event-driven one a trigger, a state-driven one a precondition, \u2026).",
6881
6892
  severity: "warning",
6882
6893
  dimension: "completeness",
6883
6894
  run: (model) => nodesOf(model, "requirement").filter((n) => !composeEarsSentence(n, void 0, requirementStatePhrase(n, model.nodes, model.relations)).complete).map((n) => ({ nodeId: n.id, message: `Requirement ${quote(n)} (${prop3(n, "ears_type") || "ubiquitous"}) misses the action or a field its EARS type needs.` }))
6884
6895
  },
6885
6896
  {
6886
6897
  id: "requirement-without-scenario",
6887
- description: "Every requirement is verified by at least one scenario.",
6898
+ description: "**Every requirement is verified by at least one scenario**.",
6888
6899
  severity: "warning",
6889
6900
  dimension: "traceability",
6890
6901
  run: (model) => model.metamodel.nodeTypes.scenario ? unlinked(model, "requirement", "verifies", "in", ["scenario"]).map((n) => ({ nodeId: n.id, message: `No scenario verifies requirement ${quote(n)}.` })) : []
6891
6902
  },
6892
6903
  {
6893
6904
  id: "requirement-unsatisfied",
6894
- description: "Every requirement is satisfied by an element of the architecture.",
6905
+ description: "**Every requirement is satisfied by an element of the architecture**.",
6895
6906
  severity: "warning",
6896
6907
  dimension: "traceability",
6897
6908
  run: (model) => unlinked(model, "requirement", "satisfies", "in").map((n) => ({ nodeId: n.id, message: `Nothing satisfies requirement ${quote(n)}.` }))
6898
6909
  },
6899
6910
  {
6900
6911
  id: "requirement-without-origin",
6901
- description: "Every requirement derives from a need or from another requirement.",
6912
+ description: "**Every requirement derives from a need or from another requirement**.",
6902
6913
  severity: "warning",
6903
6914
  dimension: "traceability",
6904
6915
  run: (model) => unlinked(model, "requirement", "derives", "out", ["need", "requirement"]).map((n) => ({ nodeId: n.id, message: `Requirement ${quote(n)} derives from no need and no other requirement.` }))
6905
6916
  },
6906
6917
  {
6907
6918
  id: "need-without-requirement",
6908
- 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).",
6919
+ 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).",
6909
6920
  severity: "warning",
6910
6921
  dimension: "traceability",
6911
6922
  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)}.` }))
6912
6923
  },
6913
6924
  {
6914
6925
  id: "derives-quote-missing",
6915
- 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.",
6926
+ 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.",
6916
6927
  severity: "warning",
6917
6928
  off: true,
6918
6929
  dimension: "traceability",
@@ -6920,7 +6931,7 @@ var CHECK_RULES = [
6920
6931
  },
6921
6932
  {
6922
6933
  id: "derives-quote-not-in-need",
6923
- 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.",
6934
+ 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.",
6924
6935
  severity: "error",
6925
6936
  dimension: "traceability",
6926
6937
  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) => {
@@ -6935,7 +6946,7 @@ var CHECK_RULES = [
6935
6946
  },
6936
6947
  {
6937
6948
  id: "quote-value-missing",
6938
- 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).",
6949
+ 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).",
6939
6950
  severity: "warning",
6940
6951
  dimension: "traceability",
6941
6952
  run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
@@ -6946,14 +6957,14 @@ var CHECK_RULES = [
6946
6957
  },
6947
6958
  {
6948
6959
  id: "quote-value-differs",
6949
- 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.",
6960
+ 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.",
6950
6961
  severity: "warning",
6951
6962
  dimension: "traceability",
6952
6963
  run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => quoteSenseGaps(model, req))
6953
6964
  },
6954
6965
  {
6955
6966
  id: "requirement-value-unquoted",
6956
- 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.",
6967
+ 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.",
6957
6968
  severity: "warning",
6958
6969
  dimension: "traceability",
6959
6970
  run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
@@ -6963,7 +6974,7 @@ var CHECK_RULES = [
6963
6974
  },
6964
6975
  {
6965
6976
  id: "scenario-value-missing",
6966
- 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.",
6977
+ 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.",
6967
6978
  severity: "warning",
6968
6979
  dimension: "traceability",
6969
6980
  run: (model) => nodesOf(model, "requirement").filter((n) => !originOf(n)).flatMap((req) => {
@@ -6980,7 +6991,7 @@ var CHECK_RULES = [
6980
6991
  },
6981
6992
  {
6982
6993
  id: "example-not-in-scenario",
6983
- 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.`,
6994
+ 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.`,
6984
6995
  severity: "warning",
6985
6996
  dimension: "traceability",
6986
6997
  run: (model) => nodesOf(model, "need").filter((n) => !originOf(n)).flatMap((need) => {
@@ -6998,7 +7009,7 @@ var CHECK_RULES = [
6998
7009
  },
6999
7010
  {
7000
7011
  id: "scenario-value-untested",
7001
- 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.",
7012
+ 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**.",
7002
7013
  severity: "warning",
7003
7014
  dimension: "traceability",
7004
7015
  run: (model) => {
@@ -7018,7 +7029,7 @@ var CHECK_RULES = [
7018
7029
  },
7019
7030
  {
7020
7031
  id: "need-answer-unquoted",
7021
- 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).",
7032
+ 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).",
7022
7033
  severity: "warning",
7023
7034
  dimension: "traceability",
7024
7035
  run: (model) => {
@@ -7036,7 +7047,7 @@ var CHECK_RULES = [
7036
7047
  },
7037
7048
  {
7038
7049
  id: "need-answer-changed",
7039
- 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).",
7050
+ 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).",
7040
7051
  severity: "error",
7041
7052
  dimension: "traceability",
7042
7053
  run: (model) => {
@@ -7050,21 +7061,21 @@ var CHECK_RULES = [
7050
7061
  },
7051
7062
  {
7052
7063
  id: "scenario-verifies-nothing",
7053
- description: "Every scenario verifies a requirement or a state machine.",
7064
+ description: "**Every scenario verifies a requirement or a state machine**.",
7054
7065
  severity: "warning",
7055
7066
  dimension: "traceability",
7056
7067
  run: (model) => unlinked(model, "scenario", "verifies", "out").map((n) => ({ nodeId: n.id, message: `Scenario ${quote(n)} verifies no requirement and no state machine.` }))
7057
7068
  },
7058
7069
  {
7059
7070
  id: "adr-without-fitness-fn",
7060
- description: "Every accepted ADR is implemented by a fitness function that checks it.",
7071
+ description: "**Every accepted ADR is implemented by a fitness function** that checks it.",
7061
7072
  severity: "warning",
7062
7073
  dimension: "decisions",
7063
7074
  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)}.` })) : []
7064
7075
  },
7065
7076
  {
7066
7077
  id: "inherited-adr-unapplied",
7067
- 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.",
7078
+ 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.",
7068
7079
  severity: "error",
7069
7080
  dimension: "decisions",
7070
7081
  run: (model) => inheritedDecisions(model).filter((d) => !d.elements.length).map(({ adr, origin }) => ({
@@ -7074,7 +7085,7 @@ var CHECK_RULES = [
7074
7085
  },
7075
7086
  {
7076
7087
  id: "inherited-adr-unchecked",
7077
- 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).",
7088
+ 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).",
7078
7089
  severity: "error",
7079
7090
  dimension: "decisions",
7080
7091
  run: (model) => inheritedDecisions(model).flatMap(({ adr, origin, elements }) => {
@@ -7088,7 +7099,7 @@ var CHECK_RULES = [
7088
7099
  },
7089
7100
  {
7090
7101
  id: "adr-incomplete",
7091
- description: "An accepted ADR records its date, context, decision and consequences.",
7102
+ description: "**An accepted ADR records its date, context, decision and consequences**.",
7092
7103
  severity: "warning",
7093
7104
  dimension: "completeness",
7094
7105
  run: (model) => nodesOf(model, "adr").filter((n) => prop3(n, "status") === "accepted").flatMap((n) => {
@@ -7098,7 +7109,7 @@ var CHECK_RULES = [
7098
7109
  },
7099
7110
  {
7100
7111
  id: "adr-superseded-unlinked",
7101
- description: "An ADR is superseded exactly when a newer ADR supersedes it.",
7112
+ description: "**An ADR is superseded exactly when a newer ADR supersedes it**.",
7102
7113
  severity: "warning",
7103
7114
  dimension: "consistency",
7104
7115
  run: (model) => {
@@ -7115,7 +7126,7 @@ var CHECK_RULES = [
7115
7126
  },
7116
7127
  {
7117
7128
  id: "fitness-fn-unlinked",
7118
- description: "Every fitness function implements an ADR or constrains an element.",
7129
+ description: "**Every fitness function implements an ADR or constrains an element**.",
7119
7130
  severity: "warning",
7120
7131
  dimension: "decisions",
7121
7132
  run: (model) => {
@@ -7126,7 +7137,7 @@ var CHECK_RULES = [
7126
7137
  },
7127
7138
  {
7128
7139
  id: "concern-unaddressed",
7129
- description: "Every concern a Hub concern pack finds in the model is settled by an accepted ADR marked with it (property `concern`) that constrains the elements it applies to, or what contains them.",
7140
+ description: "**Every concern a Hub concern pack finds in the model is settled by an accepted ADR marked with it** (property `concern`) that constrains the elements it applies to, or what contains them.",
7130
7141
  severity: "warning",
7131
7142
  dimension: "decisions",
7132
7143
  run: (model) => openConcerns(model.concerns ?? [], model.nodes, model.relations, model.metamodel).map(({ pack, open: open4, pending }) => {
@@ -7143,7 +7154,7 @@ var CHECK_RULES = [
7143
7154
  },
7144
7155
  {
7145
7156
  id: "concern-unbound",
7146
- description: "Every accepted ADR marked with a concern (property `concern`, set by a Hub concern pack) constrains the elements it settles the concern for.",
7157
+ description: "**Every accepted ADR marked with a concern** (property `concern`, set by a Hub concern pack) **constrains the elements it settles the concern for**.",
7147
7158
  severity: "warning",
7148
7159
  dimension: "decisions",
7149
7160
  run: (model) => unboundDecisions(model.concerns ?? [], model.nodes, model.relations, model.metamodel).map(({ adr, concern, checks, bindTo }) => ({
@@ -7155,21 +7166,21 @@ var CHECK_RULES = [
7155
7166
  },
7156
7167
  {
7157
7168
  id: "scenario-without-metrics",
7158
- description: "Every scenario has what checks it: tests the repository's .radical/radical.json binds to it, or metric conditions (property `metrics`, one per line: `<metric>{<labels>} <op> <number> [unit]`). One the repository must verify is scenario-not-verified-here's.",
7169
+ description: "**Every scenario has what checks it**: tests the repository's .radical/radical.json binds to it, or metric conditions (property `metrics`, one per line: `<metric>{<labels>} <op> <number> [unit]`). One the repository must verify is scenario-not-verified-here's.",
7159
7170
  severity: "warning",
7160
7171
  dimension: "traceability",
7161
7172
  run: (model) => nodesOf(model, "scenario").filter((n) => !conditionsOf(n).length && !verifiedHere(model, n)).map((n) => ({ nodeId: n.id, message: `Scenario ${quote(n)} names no check.` }))
7162
7173
  },
7163
7174
  {
7164
7175
  id: "scenario-not-verified-here",
7165
- description: "With the repository's .radical/radical.json (the CLI): every scenario of a requirement an element the repository builds satisfies has tests the file binds to it, or metric conditions.",
7176
+ description: "With the repository's .radical/radical.json (the CLI): **every scenario of a requirement an element the repository builds satisfies has tests the file binds to it, or metric conditions**.",
7166
7177
  severity: "warning",
7167
7178
  dimension: "traceability",
7168
7179
  run: (model) => nodesOf(model, "scenario").filter((n) => !conditionsOf(n).length && verifiedHere(model, n)).map((n) => ({ nodeId: n.id, message: `Scenario ${quote(n)} is this repository's to verify (an element it builds satisfies its requirement), and ${model.repository.file} binds no test to it: radical verify ${n.id} --test "<file> \u203A <title>".` }))
7169
7180
  },
7170
7181
  {
7171
7182
  id: "model-names-tests",
7172
- description: "A scenario or fitness function names no test in its Metrics: the repository binds its tests in .radical/radical.json (radical setup moves them there). A test named in Metrics still counts.",
7183
+ description: "**A scenario or fitness function names no test in its Metrics**: the repository binds its tests in .radical/radical.json (radical setup moves them there). A test named in Metrics still counts.",
7173
7184
  severity: "warning",
7174
7185
  dimension: "traceability",
7175
7186
  run: (model) => Object.values(model.nodes).filter((n) => TESTED_TYPES.includes(n.type) && !originOf(n)).flatMap((n) => {
@@ -7179,14 +7190,14 @@ var CHECK_RULES = [
7179
7190
  },
7180
7191
  {
7181
7192
  id: "fitness-fn-without-metrics",
7182
- description: "Every fitness function states what checks it and when it passes (property `metrics`, one condition per line).",
7193
+ description: "**Every fitness function states what checks it and when it passes** (property `metrics`, one condition per line).",
7183
7194
  severity: "warning",
7184
7195
  dimension: "decisions",
7185
7196
  run: (model) => nodesOf(model, "fitness-fn").filter((n) => !conditionsOf(n).length).map((n) => ({ nodeId: n.id, message: `Fitness function ${quote(n)} names no check.` }))
7186
7197
  },
7187
7198
  {
7188
7199
  id: "fitness-fn-unclassified",
7189
- description: "Every fitness function states its characteristic (ISO/IEC 25010), scope, cadence (with the event it is triggered on, or how often a temporal one falls due) and invocation.",
7200
+ description: "**Every fitness function states its characteristic** (ISO/IEC 25010), scope, cadence (with the event it is triggered on, or how often a temporal one falls due) and invocation.",
7190
7201
  severity: "warning",
7191
7202
  dimension: "decisions",
7192
7203
  run: (model) => nodesOf(model, "fitness-fn").flatMap((n) => {
@@ -7199,7 +7210,7 @@ var CHECK_RULES = [
7199
7210
  },
7200
7211
  {
7201
7212
  id: "fitness-fn-measure-invalid",
7202
- description: `Every line of a fitness function's \`measure\` names a sensor of radical sense (${SENSOR_NAMES.join(", ")}) or, run by the CLI, one of the repository's .radical/sensors/sensors.json.`,
7213
+ description: `**Every line of a fitness function's \`measure\` names a sensor** of radical sense (${SENSOR_NAMES.join(", ")}) or, run by the CLI, one of the repository's .radical/sensors/sensors.json.`,
7203
7214
  severity: "error",
7204
7215
  dimension: "completeness",
7205
7216
  run: (model) => model.sensors === void 0 ? [] : nodesOf(model, "fitness-fn").flatMap((n) => parseMeasure(n.measure).filter((line) => !isSensorName(line.sensor) && !model.sensors?.names.includes(line.sensor)).map((line) => ({
@@ -7209,14 +7220,14 @@ var CHECK_RULES = [
7209
7220
  },
7210
7221
  {
7211
7222
  id: "repository-mapping",
7212
- description: "With the repository's .radical/radical.json (the CLI): each entry names an element of the model, its own or another model's of the federation, under the element's name, with paths the repository has; tests are bound to scenarios and fitness functions.",
7223
+ description: "With the repository's .radical/radical.json (the CLI): **each entry names an element of the model**, its own or another model's of the federation, under the element's name, with paths the repository has; tests are bound to scenarios and fitness functions.",
7213
7224
  severity: "warning",
7214
7225
  dimension: "traceability",
7215
7226
  run: repositoryMapping
7216
7227
  },
7217
7228
  {
7218
7229
  id: "repository-settings-in-model",
7219
- description: `The model's check.json holds the model's rules and goals; the repository's test files (test-unbound's include and exclude) and CI's artifacts belong in .radical/radical.json ("tests", "ci"). Those in check.json are still read.`,
7230
+ description: `The model's check.json holds the model's rules and goals; **the repository's test files** (test-unbound's include and exclude) and CI's artifacts **belong in .radical/radical.json** ("tests", "ci"). Those in check.json are still read.`,
7220
7231
  severity: "warning",
7221
7232
  dimension: "completeness",
7222
7233
  run: (model) => (model.settingsInModel ?? []).map((what) => ({
@@ -7226,7 +7237,7 @@ var CHECK_RULES = [
7226
7237
  },
7227
7238
  {
7228
7239
  id: "description-path-missing",
7229
- description: "With the repository (the CLI): a path from the repository's root an element's description names (apps/cli/src/sense.ts) is in the repository; one that is gone tells of code that moved.",
7240
+ description: "With the repository (the CLI): **a path from the repository's root an element's description names** (apps/cli/src/sense.ts) **is in the repository**; one that is gone tells of code that moved.",
7230
7241
  severity: "warning",
7231
7242
  dimension: "consistency",
7232
7243
  run: (model) => Object.entries(model.missingPaths ?? {}).flatMap(([id, paths]) => {
@@ -7236,21 +7247,21 @@ var CHECK_RULES = [
7236
7247
  },
7237
7248
  {
7238
7249
  id: "measure-with-arguments",
7239
- description: `A fitness function's measure lines name sensors only: an adapter's arguments (files, options of the repository) belong to a sensor of .radical/sensors/sensors.json ({ "adapter": "playwright", "args": [...] }). A line with arguments still runs.`,
7250
+ description: `**A fitness function's measure lines name sensors only**: an adapter's arguments (files, options of the repository) belong to a sensor of .radical/sensors/sensors.json ({ "adapter": "playwright", "args": [...] }). A line with arguments still runs.`,
7240
7251
  severity: "warning",
7241
7252
  dimension: "completeness",
7242
7253
  run: (model) => nodesOf(model, "fitness-fn").flatMap((n) => parseMeasure(n.measure).filter((line) => line.args.length > 0).map((line) => ({ nodeId: n.id, message: `Fitness function ${quote(n)}: measure "${line.raw}" has the repository's arguments; name a sensor of .radical/sensors/sensors.json that holds them ({ "adapter": "${line.sensor}", "args": [...] }).` })))
7243
7254
  },
7244
7255
  {
7245
7256
  id: "metric-invalid",
7246
- description: "Every line of a scenario's or fitness function's `metrics` reads as a condition, its unit converts to the unit of the measurement it matches, and `combine` and `max_age` read.",
7257
+ description: "**Every line of a scenario's or fitness function's `metrics` reads as a condition**, its unit converts to the unit of the measurement it matches, and `combine` and `max_age` read.",
7247
7258
  severity: "error",
7248
7259
  dimension: "completeness",
7249
7260
  run: invalidChecks
7250
7261
  },
7251
7262
  {
7252
7263
  id: "test-failed",
7253
- description: "With --report: every test a scenario or fitness function names passed.",
7264
+ description: "With --report: **every test a scenario or fitness function names passed**.",
7254
7265
  severity: "error",
7255
7266
  dimension: "tests",
7256
7267
  readsReports: true,
@@ -7258,7 +7269,7 @@ var CHECK_RULES = [
7258
7269
  },
7259
7270
  {
7260
7271
  id: "test-not-found",
7261
- description: "With --report: every test a scenario or fitness function names is in the report of its file (a renamed or deleted test is not).",
7272
+ description: "With --report: **every test a scenario or fitness function names is in the report of its file** (a renamed or deleted test is not).",
7262
7273
  severity: "error",
7263
7274
  dimension: "tests",
7264
7275
  readsReports: true,
@@ -7266,7 +7277,7 @@ var CHECK_RULES = [
7266
7277
  },
7267
7278
  {
7268
7279
  id: "test-skipped",
7269
- description: "With --report: no test a scenario or fitness function names was skipped.",
7280
+ description: "With --report: **no test a scenario or fitness function names was skipped**.",
7270
7281
  severity: "warning",
7271
7282
  dimension: "tests",
7272
7283
  readsReports: true,
@@ -7274,15 +7285,15 @@ var CHECK_RULES = [
7274
7285
  },
7275
7286
  {
7276
7287
  id: "test-not-run",
7277
- description: "With --report: every file a scenario or fitness function names a test in is in the reports.",
7288
+ description: "With --report: **every file a scenario or fitness function names a test in is in the reports**.",
7278
7289
  severity: "warning",
7279
7290
  dimension: "tests",
7280
7291
  readsReports: true,
7281
- run: testRule("not-run", (node, id) => `${testedName(node)}: no report has the file of test ${id}.`)
7292
+ run: testRule("not-run", (node, id) => `${testedName(node)}: test ${id} did not run: no report has its file.`)
7282
7293
  },
7283
7294
  {
7284
7295
  id: "metric-failed",
7285
- description: "With measurements: every metric condition a scenario or fitness function states holds for the latest measurement it matches.",
7296
+ description: "With measurements: **every metric condition a scenario or fitness function states holds** for the latest measurement it matches.",
7286
7297
  severity: "error",
7287
7298
  dimension: "tests",
7288
7299
  readsMeasurements: true,
@@ -7290,7 +7301,7 @@ var CHECK_RULES = [
7290
7301
  },
7291
7302
  {
7292
7303
  id: "metric-stale",
7293
- description: "With measurements: the latest measurement each metric condition matches is no older than the element's max_age (a stale one never passes).",
7304
+ description: "With measurements: **the latest measurement each metric condition matches is no older than the element's max_age** (a stale one never passes).",
7294
7305
  severity: "warning",
7295
7306
  dimension: "tests",
7296
7307
  readsMeasurements: true,
@@ -7298,7 +7309,7 @@ var CHECK_RULES = [
7298
7309
  },
7299
7310
  {
7300
7311
  id: "metric-not-measured",
7301
- description: "With measurements: a measurement matches every metric condition a scenario or fitness function states.",
7312
+ description: "With measurements: **a measurement matches every metric condition a scenario or fitness function states**.",
7302
7313
  severity: "warning",
7303
7314
  dimension: "tests",
7304
7315
  readsMeasurements: true,
@@ -7306,7 +7317,7 @@ var CHECK_RULES = [
7306
7317
  },
7307
7318
  {
7308
7319
  id: "test-unbound",
7309
- description: "With --report and an include in check.json: every test in the files it includes is named by a scenario or a fitness function, by its title or its describe block (a whole file or directory does not count). One finding per test file.",
7320
+ description: "With --report and an include in check.json: **every test in the files it includes is named by a scenario or a fitness function**, by its title or its describe block (a whole file or directory does not count). One finding per test file.",
7310
7321
  severity: "warning",
7311
7322
  dimension: "tests",
7312
7323
  readsReports: true,
@@ -7346,7 +7357,7 @@ function testBinding(model) {
7346
7357
  init_define_RADICAL_BUILD();
7347
7358
  var ADOPT_RULE = {
7348
7359
  id: "baselines-pending",
7349
- description: 'check.json does not wait for the baselines of its first run ("adopt": true); radical check --adopt takes them once.',
7360
+ description: '**check.json does not wait for the baselines of its first run** ("adopt": true); radical check --adopt takes them once.',
7350
7361
  severity: "error",
7351
7362
  dimension: "consistency"
7352
7363
  };
@@ -7399,7 +7410,7 @@ function adoptBaselines(config, result) {
7399
7410
  init_define_RADICAL_BUILD();
7400
7411
  var GOAL_RULE = {
7401
7412
  id: "goal-unmet",
7402
- description: 'Every metric check.json sets a goal for ("goals": { "<metric>": { "min": <percent> } }) reaches it. One finding per goal, with the metric as its code.',
7413
+ description: '**Every metric check.json sets a goal for** ("goals": { "<metric>": { "min": <percent> } }) **reaches it**. One finding per goal, with the metric as its code.',
7403
7414
  severity: "error"
7404
7415
  };
7405
7416
  var without = (rule) => (population) => (ctx) => {
@@ -7543,10 +7554,41 @@ init_define_RADICAL_BUILD();
7543
7554
  var CHECK_CONFIG_FILE = "check.json";
7544
7555
  var TEST_RESULTS_FILE = `${STATE_DIR}/test-results.json`;
7545
7556
  var MEASUREMENTS_FILE = `${STATE_DIR}/measurements.json`;
7557
+ var CI_FETCH_FILE = `${STATE_DIR}/ci-fetch.json`;
7546
7558
  function serializeTestResults(cases, reports, readAt = /* @__PURE__ */ new Date(), from = {}) {
7547
- const results = { version: 1, readAt: readAt.toISOString(), reports, cases, ...from.commit ? { commit: from.commit } : {}, ...from.ci ? { ci: from.ci } : {} };
7559
+ const results = {
7560
+ version: 1,
7561
+ readAt: readAt.toISOString(),
7562
+ reports,
7563
+ cases,
7564
+ ...from.commit ? { commit: from.commit } : {},
7565
+ ...from.ci ? { ci: from.ci } : {},
7566
+ ...from.kept ? { kept: from.kept } : {}
7567
+ };
7548
7568
  return JSON.stringify(results);
7549
7569
  }
7570
+ var sameTestFile = (a2, b) => a2 === b || a2.endsWith("/" + b) || b.endsWith("/" + a2);
7571
+ function withEarlierResults(cases, earlier) {
7572
+ if (!earlier?.cases.length) return { cases };
7573
+ const slash = (file) => file.replace(/\\/g, "/");
7574
+ const ran = [...new Set(cases.map((c) => slash(c.file)))];
7575
+ const ranSet = new Set(ran);
7576
+ const replaced = /* @__PURE__ */ new Map();
7577
+ const isReplaced = (file) => {
7578
+ let r = replaced.get(file);
7579
+ if (r === void 0) {
7580
+ r = ranSet.has(file) || ran.some((f) => sameTestFile(f, file));
7581
+ replaced.set(file, r);
7582
+ }
7583
+ return r;
7584
+ };
7585
+ const left = earlier.cases.filter((c) => !isReplaced(slash(c.file)));
7586
+ if (!left.length) return { cases };
7587
+ return {
7588
+ cases: [...cases, ...left],
7589
+ kept: { since: earlier.kept?.since ?? testsRanAt(earlier), cases: left.length, files: new Set(left.map((c) => slash(c.file))).size }
7590
+ };
7591
+ }
7550
7592
  function testsRanAt(results) {
7551
7593
  const runs = results.ci?.runs.map((r) => r.ranAt).filter((at) => !Number.isNaN(Date.parse(at))).sort() ?? [];
7552
7594
  return runs.length ? runs[runs.length - 1] : results.readAt;
@@ -7555,7 +7597,7 @@ function ciSourceOf(value) {
7555
7597
  const ci = value;
7556
7598
  if (!ci || ci.provider !== "github" || typeof ci.commit !== "string" || typeof ci.behind !== "number" || !Array.isArray(ci.runs)) return void 0;
7557
7599
  const runs = ci.runs.filter((r) => !!r && typeof r.id === "number" && typeof r.url === "string" && typeof r.sha === "string" && typeof r.ranAt === "string" && typeof r.workflow === "string" && Array.isArray(r.artifacts));
7558
- return { provider: "github", commit: ci.commit, behind: ci.behind, runs };
7600
+ return { provider: "github", commit: ci.commit, behind: ci.behind, runs, ...typeof ci.measurements === "number" ? { measurements: ci.measurements } : {} };
7559
7601
  }
7560
7602
  var STATUSES = /* @__PURE__ */ new Set(["passed", "failed", "skipped"]);
7561
7603
  function parseTestResults(text3) {
@@ -7569,13 +7611,16 @@ function parseTestResults(text3) {
7569
7611
  if (r?.version !== 1 || typeof r.readAt !== "string" || !Array.isArray(r.cases)) return null;
7570
7612
  const cases = r.cases.filter((c) => !!c && typeof c.file === "string" && Array.isArray(c.title) && c.title.every((t) => typeof t === "string") && STATUSES.has(c.status));
7571
7613
  const ci = ciSourceOf(r.ci);
7614
+ const k = r.kept;
7615
+ const kept2 = k && typeof k.since === "string" && typeof k.cases === "number" && typeof k.files === "number" ? { since: k.since, cases: k.cases, files: k.files } : void 0;
7572
7616
  return {
7573
7617
  version: 1,
7574
7618
  readAt: r.readAt,
7575
7619
  reports: Array.isArray(r.reports) ? r.reports.filter((x) => typeof x === "string") : [],
7576
7620
  cases,
7577
7621
  ...typeof r.commit === "string" ? { commit: r.commit } : {},
7578
- ...ci ? { ci } : {}
7622
+ ...ci ? { ci } : {},
7623
+ ...kept2 ? { kept: kept2 } : {}
7579
7624
  };
7580
7625
  }
7581
7626
  function parseCheckConfig(text3) {
@@ -7601,6 +7646,37 @@ function parseCheckConfig(text3) {
7601
7646
  }
7602
7647
  return data;
7603
7648
  }
7649
+ var CI_ARTIFACTS_HINT = `CI has to keep its test reports (and its radical sense --out files) as artifacts of the run, named in .radical/radical.json's "ci": { "artifacts": [...] }`;
7650
+ var serializeCiFetch = (fetch2) => JSON.stringify({ version: 1, ...fetch2 }, null, 2) + "\n";
7651
+ var OUTCOMES = /* @__PURE__ */ new Set(["read", "same", "kept", "failed"]);
7652
+ function parseCiFetch(text3) {
7653
+ let data;
7654
+ try {
7655
+ data = JSON.parse(text3);
7656
+ } catch {
7657
+ return null;
7658
+ }
7659
+ const f = data;
7660
+ if (f?.version !== 1 || typeof f.at !== "string" || Number.isNaN(Date.parse(f.at)) || !OUTCOMES.has(f.outcome) || typeof f.message !== "string") return null;
7661
+ const runs = Array.isArray(f.runs) ? f.runs.filter((r) => !!r && typeof r.id === "number" && typeof r.url === "string").map((r) => ({ id: r.id, url: r.url })) : void 0;
7662
+ return {
7663
+ version: 1,
7664
+ at: f.at,
7665
+ outcome: f.outcome,
7666
+ message: f.message,
7667
+ ...typeof f.head === "string" ? { head: f.head } : {},
7668
+ ...typeof f.commit === "string" ? { commit: f.commit } : {},
7669
+ ...runs?.length ? { runs } : {},
7670
+ ...typeof f.tests === "number" ? { tests: f.tests } : {},
7671
+ ...typeof f.measurements === "number" ? { measurements: f.measurements } : {}
7672
+ };
7673
+ }
7674
+ function ciFetchProblem(fetch2) {
7675
+ if (!fetch2) return null;
7676
+ if (fetch2.outcome === "failed") return fetch2.message;
7677
+ if (fetch2.outcome === "read" && fetch2.tests === 0) return fetch2.message;
7678
+ return null;
7679
+ }
7604
7680
 
7605
7681
  // ../../packages/common/src/check/testSource.ts
7606
7682
  init_define_RADICAL_BUILD();
@@ -7867,17 +7943,21 @@ function evidenceSummary(result) {
7867
7943
  return lines;
7868
7944
  }
7869
7945
 
7946
+ // ../../packages/common/src/check/findingWords.ts
7947
+ init_define_RADICAL_BUILD();
7948
+ var plainRuleText = (description) => description.replace(/\*\*/g, "");
7949
+
7870
7950
  // ../../packages/common/src/check/configChanges.ts
7871
7951
  init_define_RADICAL_BUILD();
7872
7952
 
7873
7953
  // ../../packages/common/src/check/index.ts
7874
7954
  var FOLDER_RULES = [
7875
- { id: "folder-manifest", description: "The folder has a radical.md manifest of the Markdown-folder format, version 1.", severity: "error", dimension: "consistency" },
7876
- { id: "folder-json", description: "Every JSON sidecar (relations.json, views.json, \u2026) parses.", severity: "error", dimension: "consistency" },
7877
- { id: "folder-conflict", description: "No node file holds git conflict markers.", severity: "error", dimension: "consistency" },
7878
- { id: "folder-not-a-node", description: "A node file with frontmatter has an id and a type (one without them is skipped on loading, and its element is gone).", severity: "error", dimension: "consistency" },
7879
- { id: "folder-duplicate-id", description: "No two node files hold the same id.", severity: "error", dimension: "consistency" },
7880
- { id: "stale-reference", description: "Views, sequences and slides point only at elements, relations and views the model has.", severity: "warning", dimension: "consistency" }
7955
+ { id: "folder-manifest", description: "**The folder has a radical.md manifest** of the Markdown-folder format, version 1.", severity: "error", dimension: "consistency" },
7956
+ { id: "folder-json", description: "**Every JSON sidecar** (relations.json, views.json, \u2026) **parses**.", severity: "error", dimension: "consistency" },
7957
+ { id: "folder-conflict", description: "**No node file holds git conflict markers**.", severity: "error", dimension: "consistency" },
7958
+ { id: "folder-not-a-node", description: "**A node file with frontmatter has an id and a type** (one without them is skipped on loading, and its element is gone).", severity: "error", dimension: "consistency" },
7959
+ { id: "folder-duplicate-id", description: "**No two node files hold the same id**.", severity: "error", dimension: "consistency" },
7960
+ { id: "stale-reference", description: "**Views, sequences and slides point only at elements, relations and views the model has**.", severity: "warning", dimension: "consistency" }
7881
7961
  ];
7882
7962
  var FATAL = /* @__PURE__ */ new Set(["folder-manifest", "folder-json", "folder-conflict"]);
7883
7963
  var STALE_REFERENCE = "stale-reference";
@@ -13271,7 +13351,7 @@ After review, repeat this command with --apply --expect ${preview.token}`);
13271
13351
  // src/check.ts
13272
13352
  init_define_RADICAL_BUILD();
13273
13353
  import { existsSync as existsSync2 } from "fs";
13274
- import { mkdir as mkdir5, readFile as readFile10, readdir as readdir4, realpath as realpath4, stat as stat7, writeFile as writeFile5 } from "fs/promises";
13354
+ import { mkdir as mkdir5, readFile as readFile10, readdir as readdir4, realpath as realpath4, rename as rename4, stat as stat7, writeFile as writeFile5 } from "fs/promises";
13275
13355
  import { basename as basename3, dirname as dirname8, join as join13, relative as relative5, resolve as resolve10 } from "path";
13276
13356
  import { fileURLToPath as fileURLToPath2 } from "url";
13277
13357
  import { parseArgs as parseArgs4 } from "util";
@@ -13405,14 +13485,21 @@ async function downloadCiReports(root, gh, source) {
13405
13485
  try {
13406
13486
  const cases = [];
13407
13487
  const reports = [];
13488
+ const measurements = [];
13408
13489
  for (const run3 of source.runs) {
13409
13490
  for (const artifact of run3.artifacts) {
13410
13491
  const into = join9(dir, String(run3.id), artifact);
13411
13492
  await gh(["run", "download", String(run3.id), "--name", artifact, "--dir", into], root);
13412
13493
  for (const file of await filesUnder(into)) {
13494
+ const text3 = await readFile6(file, "utf8");
13495
+ const measured = metricsIn(text3, file);
13496
+ if (measured) {
13497
+ measurements.push(...measured.map((m) => ({ ...m, context: { ...m.context, "ci.run": String(run3.id), "ci.commit": source.commit } })));
13498
+ continue;
13499
+ }
13413
13500
  let read2;
13414
13501
  try {
13415
- read2 = parseTestReport(await readFile6(file, "utf8"), file);
13502
+ read2 = parseTestReport(text3, file);
13416
13503
  } catch {
13417
13504
  continue;
13418
13505
  }
@@ -13422,15 +13509,24 @@ async function downloadCiReports(root, gh, source) {
13422
13509
  }
13423
13510
  }
13424
13511
  }
13425
- if (!reports.length) throw new CiError(`the artifacts of run${source.runs.length > 1 ? "s" : ""} ${source.runs.map((r) => r.id).join(", ")} hold no test report`);
13426
- return { cases, reports };
13512
+ if (!reports.length && !measurements.length) throw new CiError(`the artifacts of run${source.runs.length > 1 ? "s" : ""} ${source.runs.map((r) => r.id).join(", ")} hold no test report and no radical-metrics/1 file`);
13513
+ return { cases, reports, measurements };
13427
13514
  } finally {
13428
13515
  await rm4(dir, { recursive: true, force: true });
13429
13516
  }
13430
13517
  }
13518
+ function metricsIn(text3, file) {
13519
+ if (!text3.includes(METRICS_FORMAT)) return null;
13520
+ try {
13521
+ const data = JSON.parse(text3);
13522
+ return data?.format === METRICS_FORMAT ? parseMetricsFile(text3, file) : null;
13523
+ } catch {
13524
+ return null;
13525
+ }
13526
+ }
13431
13527
  function sameRuns(results, source) {
13432
13528
  const key = (s2) => s2.runs.map((r) => `${r.id}:${r.artifacts.join(",")}`).join(" ");
13433
- return !!results?.ci && key(results.ci) === key(source);
13529
+ return !!results?.ci && results.ci.measurements !== void 0 && key(results.ci) === key(source);
13434
13530
  }
13435
13531
  async function readLater(root, results, commit) {
13436
13532
  return !!results && !results.ci && !!results.commit && isAncestor(root, commit, results.commit);
@@ -14175,8 +14271,19 @@ its own ("model": { "repo": \u2026 }), it judges that repository's part of the m
14175
14271
  the run. They are kept for Studio as --report keeps
14176
14272
  them, with the commit and runs they come from, unless
14177
14273
  the results there were read with --report at that
14178
- commit or a later one. radical hooks install fetches
14274
+ commit or a later one. The radical-metrics/1 files in
14275
+ the artifacts (radical sense --out) are added to the
14276
+ measurements, as --metrics adds them. What it found,
14277
+ or why it found nothing, is kept in the folder's
14278
+ .state/ci-fetch.json, with --quiet too, for Studio and
14279
+ radical setup --status. CI has to keep the reports as
14280
+ artifacts of the run. radical hooks install fetches
14179
14281
  them after a checkout, a commit, a pull and a rebase
14282
+ --no-keep read the reports and measurements given and judge with
14283
+ them, but keep nothing beside the model: what Studio
14284
+ shows stays as it was (a check used as a gate, a test
14285
+ of the gate). --evidence, --ratchet and --adopt still
14286
+ write the file they name
14180
14287
  --quiet print nothing (the git hooks fetch with --from-ci --quiet)
14181
14288
  --detach start this check in the background and return at once
14182
14289
  (the git hooks, which git waits for)
@@ -14247,6 +14354,7 @@ async function checkCommand(args, io2) {
14247
14354
  format: { type: "string", default: "text" },
14248
14355
  report: { type: "string", multiple: true },
14249
14356
  "from-ci": { type: "boolean", default: false },
14357
+ "no-keep": { type: "boolean", default: false },
14250
14358
  quiet: { type: "boolean", default: false },
14251
14359
  detach: { type: "boolean", default: false },
14252
14360
  metrics: { type: "string", multiple: true },
@@ -14274,12 +14382,13 @@ ${CHECK_USAGE}`);
14274
14382
  return 0;
14275
14383
  }
14276
14384
  if (values["list-rules"]) {
14277
- 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}`);
14385
+ for (const rule of [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE]) io2.out(`${rule.id.padEnd(30)} ${(rule.off ? "off" : rule.severity).padEnd(8)} ${plainRuleText(rule.description)}`);
14278
14386
  io2.out("\nMetrics for goals (in percent):");
14279
14387
  for (const metric of CHECK_METRICS) io2.out(`${metric.id.padEnd(30)} ${(metric.tests ? "evidence" : "").padEnd(8)} ${metric.description}`);
14280
14388
  return 0;
14281
14389
  }
14282
14390
  const fromCi = values["from-ci"];
14391
+ const keepBeside = !values["no-keep"];
14283
14392
  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 || values.adopt)) {
14284
14393
  io2.err(CHECK_USAGE);
14285
14394
  return 2;
@@ -14348,23 +14457,32 @@ ${CHECK_USAGE}`);
14348
14457
  let tests;
14349
14458
  let testsReadAt;
14350
14459
  let keep;
14460
+ let keptCases;
14461
+ let ciMeasurements = [];
14351
14462
  if (fromCi) {
14352
14463
  const say = (text3) => {
14353
14464
  if (!values.quiet) io2.err(text3);
14354
14465
  };
14355
- const resultsPath = join13(root, TEST_RESULTS_FILE);
14356
14466
  const existing = parseTestResults(await readEditorStateFile(root, TEST_RESULTS_FILE) ?? "");
14357
14467
  const gh = io2.gh ?? ghCli(io2.env ?? process.env);
14468
+ const head = await headOf(root) ?? void 0;
14469
+ const record3 = async (fetch2) => {
14470
+ if (keepBeside) await writeBeside(join13(root, CI_FETCH_FILE), serializeCiFetch({ at: (/* @__PURE__ */ new Date()).toISOString(), ...head ? { head } : {}, ...fetch2 }));
14471
+ };
14358
14472
  let got;
14359
14473
  try {
14360
14474
  got = await withFetchLock(root, async () => {
14361
14475
  const source2 = await findCiRuns(root, gh, repository?.ci?.artifacts ?? config.ci?.artifacts);
14362
14476
  if (await readLater(root, existing, source2.commit)) return { source: source2, kept: existing };
14363
- if (sameRuns(existing, source2)) return { source: source2, cases: existing.cases, reports: existing.reports };
14364
- return { source: source2, ...await downloadCiReports(root, gh, source2) };
14477
+ if (sameRuns(existing, source2)) return { source: { ...source2, measurements: existing.ci.measurements }, same: true, cases: existing.cases, reports: existing.reports, measurements: [] };
14478
+ const read3 = await downloadCiReports(root, gh, source2);
14479
+ return { source: { ...source2, measurements: read3.measurements.length }, ...read3 };
14365
14480
  });
14366
14481
  } catch (error) {
14367
- say(`radical check --from-ci: ${error instanceof CiError ? error.message : error.message}`);
14482
+ const message = error instanceof CiError ? error.message : error.message;
14483
+ await record3({ outcome: "failed", message: `radical check --from-ci: ${message}` }).catch(() => {
14484
+ });
14485
+ say(`radical check --from-ci: ${message}`);
14368
14486
  return 2;
14369
14487
  }
14370
14488
  if (!got) {
@@ -14373,15 +14491,29 @@ ${CHECK_USAGE}`);
14373
14491
  }
14374
14492
  const { source } = got;
14375
14493
  const runs = `run${source.runs.length > 1 ? "s" : ""} ${source.runs.map((r) => r.id).join(", ")}${source.runs[0]?.pr ? ` (pull request #${source.runs[0].pr})` : ""}`;
14494
+ const from = { commit: source.commit, runs: source.runs.map((r) => ({ id: r.id, url: r.url })) };
14495
+ const behind = source.behind ? `, ${source.behind} commit${source.behind > 1 ? "s" : ""} before HEAD` : "";
14376
14496
  if (got.kept) {
14377
14497
  tests = got.kept.cases;
14378
14498
  testsReadAt = got.kept.readAt;
14379
- say(`Kept the test results read with --report at ${got.kept.commit.slice(0, 7)}: CI's (${runs}) are of ${source.commit.slice(0, 7)}, before it.`);
14499
+ const message = `Kept the test results read with --report at ${got.kept.commit.slice(0, 7)}: CI's (${runs}) are of ${source.commit.slice(0, 7)}, before it.`;
14500
+ await record3({ outcome: "kept", message, ...from });
14501
+ say(message);
14380
14502
  } else {
14381
- tests = got.cases;
14382
- testsReadAt = testsRanAt({ version: 1, readAt: (/* @__PURE__ */ new Date()).toISOString(), reports: [], cases: [], ci: source });
14383
- keep = { reports: got.reports, ci: source, commit: await headOf(root) ?? void 0 };
14384
- say(`Test results of CI ${runs} for ${source.commit.slice(0, 7)}${source.behind ? `, ${source.behind} commit${source.behind > 1 ? "s" : ""} before HEAD` : ""}.`);
14503
+ ciMeasurements = got.measurements;
14504
+ const measured = ciMeasurements.length ? `; ${ciMeasurements.length} measurement${ciMeasurements.length === 1 ? "" : "s"}` : "";
14505
+ if (got.cases.length) {
14506
+ tests = got.cases;
14507
+ testsReadAt = testsRanAt({ version: 1, readAt: (/* @__PURE__ */ new Date()).toISOString(), reports: [], cases: [], ci: source });
14508
+ keep = { reports: got.reports, ci: source, commit: head };
14509
+ const message = `${got.same ? "The same test results of CI" : "Test results of CI"} ${runs} for ${source.commit.slice(0, 7)}${behind}${measured}.`;
14510
+ await record3({ outcome: got.same ? "same" : "read", message, ...from, tests: tests.length, ...got.same ? {} : { measurements: ciMeasurements.length } });
14511
+ say(message);
14512
+ } else {
14513
+ const message = `The artifacts of CI ${runs} for ${source.commit.slice(0, 7)}${behind} hold no test report${measured}.`;
14514
+ await record3({ outcome: "read", message, ...from, tests: 0, measurements: ciMeasurements.length });
14515
+ say(message);
14516
+ }
14385
14517
  }
14386
14518
  } else if (values.report?.length) {
14387
14519
  tests = [];
@@ -14402,6 +14534,12 @@ ${CHECK_USAGE}`);
14402
14534
  return 2;
14403
14535
  }
14404
14536
  }
14537
+ const merged = withEarlierResults(tests, parseTestResults(await readEditorStateFile(root, TEST_RESULTS_FILE) ?? ""));
14538
+ if (merged.kept) {
14539
+ tests = merged.cases;
14540
+ keptCases = merged.kept;
14541
+ if (!values.quiet) io2.err(`Kept the results of ${merged.kept.cases} test${merged.kept.cases === 1 ? "" : "s"} in ${merged.kept.files} file${merged.kept.files === 1 ? "" : "s"} the reports here do not have, read since ${merged.kept.since.slice(0, 10)}.`);
14542
+ }
14405
14543
  }
14406
14544
  let fromKept = false;
14407
14545
  if (values.trace && !tests) {
@@ -14415,16 +14553,18 @@ ${CHECK_USAGE}`);
14415
14553
  const kept2 = await readEditorStateFile(root, MEASUREMENTS_FILE);
14416
14554
  const stored = kept2 === null ? null : parseMeasurementStore(kept2);
14417
14555
  let measurements = stored ?? void 0;
14556
+ const read2 = [...ciMeasurements];
14418
14557
  if (values.metrics?.length) {
14419
- const read2 = [];
14420
14558
  try {
14421
14559
  for (const file of await reportFiles(values.metrics, io2.cwd, /\.json$/i, "measurement")) read2.push(...parseMetricsFile(await readFile10(resolve10(io2.cwd, file), "utf8"), file));
14422
14560
  } catch (error) {
14423
14561
  io2.err(error.code === "ENOENT" ? `Cannot read the measurements ${error.path}: no such file.` : error.message);
14424
14562
  return 2;
14425
14563
  }
14564
+ }
14565
+ if (read2.length) {
14426
14566
  measurements = mergeMeasurements(stored ?? [], read2);
14427
- await writeBeside(join13(root, MEASUREMENTS_FILE), serializeMeasurementStore(measurements));
14567
+ if (keepBeside) await writeBeside(join13(root, MEASUREMENTS_FILE), serializeMeasurementStore(measurements));
14428
14568
  }
14429
14569
  for (const [where2, path] of [[REVIEWS_FILE, join13(await mappingRoot(root), REVIEWS_FILE)], [REVIEWS_FILE2, join13(root, REVIEWS_FILE2)]]) {
14430
14570
  const reviewsText = await readFile10(path, "utf8").catch(() => null);
@@ -14486,12 +14626,12 @@ ${CHECK_USAGE}`);
14486
14626
  if (adopted.notRun.length) io2.err(`Not run, so no baseline taken (give the test reports with --report, the measurements with --metrics): ${adopted.notRun.join(", ")}.`);
14487
14627
  }
14488
14628
  }
14489
- if (tests && !fromKept && (keep || !fromCi)) {
14629
+ if (tests && keepBeside && !fromKept && (keep || !fromCi)) {
14490
14630
  await writeBeside(join13(root, TEST_RESULTS_FILE), serializeTestResults(
14491
14631
  tests,
14492
14632
  keep?.reports ?? values.report ?? [],
14493
14633
  /* @__PURE__ */ new Date(),
14494
- keep ?? { commit: await headOf(root) ?? void 0 }
14634
+ keep ?? { commit: await headOf(root) ?? void 0, ...keptCases ? { kept: keptCases } : {} }
14495
14635
  ));
14496
14636
  }
14497
14637
  if (values.evidence && result.evidence) await writeBeside(resolve10(io2.cwd, values.evidence), JSON.stringify(result.evidence, null, 2) + "\n");
@@ -14547,7 +14687,9 @@ async function writeBeside(path, content) {
14547
14687
  if (error.code !== "EEXIST") throw error;
14548
14688
  });
14549
14689
  }
14550
- await writeFile5(path, content);
14690
+ const partial = join13(dir, `.${basename3(path)}.${process.pid}.tmp`);
14691
+ await writeFile5(partial, content);
14692
+ await rename4(partial, path);
14551
14693
  }
14552
14694
  function concernPacks() {
14553
14695
  const bundled = join13(dirname8(fileURLToPath2(import.meta.url)), "hub-catalogue");
@@ -16711,6 +16853,13 @@ async function statusCommand(options, io2) {
16711
16853
  const fromTop = relative12(top, folder).replace(/\\/g, "/");
16712
16854
  if (await hooksSaveBase(hooksDir, fromTop)) ok("the git hooks save its base for Studio's Changes on branch");
16713
16855
  else warn(`the git hooks do not save its base for Studio's Changes on branch: radical hooks install ${shown2(folder, place)}`);
16856
+ const fetch2 = parseCiFetch(await readEditorStateFile(folder, CI_FETCH_FILE).catch(() => null) ?? "");
16857
+ if (fetch2) {
16858
+ const when = `the last fetch from CI (${formatAge(Date.now() - Date.parse(fetch2.at))} ago)`;
16859
+ const problem = ciFetchProblem(fetch2);
16860
+ if (problem) warn(`${when} found no test results: ${problem.replace(/^radical check --from-ci: /, "").replace(/\.$/, "")}. ${CI_ARTIFACTS_HINT}`);
16861
+ else ok(`${when}: ${fetch2.message}`);
16862
+ }
16714
16863
  }
16715
16864
  }
16716
16865
  }
@@ -16785,7 +16934,7 @@ ${problems} problem${problems > 1 ? "s" : ""} found.` : "\nNothing is broken.");
16785
16934
  init_define_RADICAL_BUILD();
16786
16935
  import { execFile as execFile7 } from "child_process";
16787
16936
  import { existsSync as existsSync11 } from "fs";
16788
- import { mkdir as mkdir10, readFile as readFile15, rename as rename4, writeFile as writeFile10 } from "fs/promises";
16937
+ import { mkdir as mkdir10, readFile as readFile15, rename as rename5, writeFile as writeFile10 } from "fs/promises";
16789
16938
  import { dirname as dirname17, join as join21, relative as relative13, resolve as resolve19 } from "path";
16790
16939
  import { promisify as promisify7 } from "util";
16791
16940
  var exec7 = promisify7(execFile7);
@@ -16806,7 +16955,7 @@ async function moveToRadical(root, parts2) {
16806
16955
  for (const part of parts2) {
16807
16956
  const to2 = MOVES[part];
16808
16957
  await mkdir10(dirname17(join21(root, to2)), { recursive: true });
16809
- await git6("mv", part, to2).catch(() => rename4(join21(root, part), join21(root, to2)));
16958
+ await git6("mv", part, to2).catch(() => rename5(join21(root, part), join21(root, to2)));
16810
16959
  said.push(`moved ${part} to ${to2}`);
16811
16960
  }
16812
16961
  if (!existsSync11(join21(root, RADICAL_DIR, ".gitignore"))) {
@@ -16815,7 +16964,7 @@ async function moveToRadical(root, parts2) {
16815
16964
  }
16816
16965
  const model = join21(root, MODEL_FOLDER);
16817
16966
  if (parts2.includes(OLD_MODEL_FOLDER) && existsSync11(join21(model, OLD_STATE_DIR)) && !existsSync11(join21(model, STATE_DIR))) {
16818
- await rename4(join21(model, OLD_STATE_DIR), join21(model, STATE_DIR));
16967
+ await rename5(join21(model, OLD_STATE_DIR), join21(model, STATE_DIR));
16819
16968
  said.push(`renamed the model's ${OLD_STATE_DIR}/ to ${STATE_DIR}/`);
16820
16969
  }
16821
16970
  const plan = join21(root, CRUCIBLE_FILE);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_define_RADICAL_BUILD
3
- } from "./chunk-CWKX2ULF.js";
3
+ } from "./chunk-SBQRTX3Y.js";
4
4
 
5
5
  // ../../packages/assay/node_modules/unpdf/dist/pdfjs.mjs
6
6
  init_define_RADICAL_BUILD();
@@ -2,7 +2,7 @@ import {
2
2
  __commonJS,
3
3
  __require,
4
4
  init_define_RADICAL_BUILD
5
- } from "./chunk-CWKX2ULF.js";
5
+ } from "./chunk-SBQRTX3Y.js";
6
6
 
7
7
  // ../../node_modules/undici/lib/core/symbols.js
8
8
  var require_symbols = __commonJS({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radicaltools/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Connect coding agents to Radical Markdown architecture models, check, diff and export them, and fuzz a project against them, from the command line.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://radical.tools",