@radicaltools/cli 0.3.0 → 0.3.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.
Files changed (57) hide show
  1. package/README.md +121 -16
  2. package/dist/hub-catalogue/concern/concern-api-collections.radical +1136 -0
  3. package/dist/hub-catalogue/concern/concern-api-errors.radical +1180 -0
  4. package/dist/hub-catalogue/concern/concern-api-evolution.radical +449 -210
  5. package/dist/hub-catalogue/concern/concern-api-idempotency.radical +1218 -0
  6. package/dist/hub-catalogue/concern/concern-api-resource-design.radical +1102 -0
  7. package/dist/hub-catalogue/concern/concern-api-style-guide.radical +1210 -0
  8. package/dist/hub-catalogue/concern/concern-architecture-style.radical +287 -131
  9. package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
  10. package/dist/hub-catalogue/concern/concern-authentication.radical +247 -37
  11. package/dist/hub-catalogue/concern/concern-authorization.radical +311 -89
  12. package/dist/hub-catalogue/concern/concern-availability.radical +287 -63
  13. package/dist/hub-catalogue/concern/concern-backend-stack.radical +300 -381
  14. package/dist/hub-catalogue/concern/concern-backup-recovery.radical +385 -129
  15. package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
  16. package/dist/hub-catalogue/concern/concern-capacity.radical +194 -81
  17. package/dist/hub-catalogue/concern/concern-code-documentation.radical +1397 -0
  18. package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +1409 -0
  19. package/dist/hub-catalogue/concern/concern-code-review-branching.radical +1416 -0
  20. package/dist/hub-catalogue/concern/concern-code-style.radical +1058 -0
  21. package/dist/hub-catalogue/concern/concern-communication-style.radical +473 -167
  22. package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
  23. package/dist/hub-catalogue/concern/concern-data-consistency.radical +339 -308
  24. package/dist/hub-catalogue/concern/concern-data-store.radical +480 -158
  25. package/dist/hub-catalogue/concern/concern-decomposition.radical +260 -85
  26. package/dist/hub-catalogue/concern/concern-definition-of-done.radical +1214 -0
  27. package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +966 -0
  28. package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +1345 -0
  29. package/dist/hub-catalogue/concern/concern-deployment.radical +343 -92
  30. package/dist/hub-catalogue/concern/concern-encryption.radical +339 -76
  31. package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +1197 -0
  32. package/dist/hub-catalogue/concern/concern-eu-dora.radical +1321 -0
  33. package/dist/hub-catalogue/concern/concern-frontend-stack.radical +467 -160
  34. package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
  35. package/dist/hub-catalogue/concern/concern-infrastructure.radical +1300 -268
  36. package/dist/hub-catalogue/concern/concern-integration-resilience.radical +88 -51
  37. package/dist/hub-catalogue/concern/concern-messaging.radical +173 -140
  38. package/dist/hub-catalogue/concern/concern-module-boundaries.radical +162 -159
  39. package/dist/hub-catalogue/concern/concern-observability.radical +224 -275
  40. package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
  41. package/dist/hub-catalogue/concern/concern-personal-data.radical +637 -122
  42. package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
  43. package/dist/hub-catalogue/concern/concern-rate-limiting.radical +433 -141
  44. package/dist/hub-catalogue/concern/concern-release-versioning.radical +1358 -0
  45. package/dist/hub-catalogue/concern/concern-retention.radical +1399 -0
  46. package/dist/hub-catalogue/concern/concern-secrets.radical +332 -74
  47. package/dist/hub-catalogue/concern/concern-secure-coding.radical +1379 -0
  48. package/dist/hub-catalogue/concern/concern-secure-development.radical +1245 -0
  49. package/dist/hub-catalogue/concern/concern-security-detection.radical +1153 -0
  50. package/dist/hub-catalogue/concern/concern-supply-chain.radical +257 -183
  51. package/dist/hub-catalogue/concern/concern-technical-debt.radical +1450 -0
  52. package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +1145 -0
  53. package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +271 -137
  54. package/dist/hub-catalogue/concern/concern-test-strategy.radical +243 -224
  55. package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
  56. package/dist/index.js +3680 -2074
  57. package/package.json +1 -1
package/README.md CHANGED
@@ -76,6 +76,21 @@ terminal, or with `--yes`, it asks nothing: the folder `architecture`, the agent
76
76
  finds installed, the hooks in a repository. `--dry-run` prints every change and writes
77
77
  nothing. Exit status: 0 set up and checked, 1 a step or a check failed, 2 it could not run.
78
78
 
79
+ **Several models.** One server serves one folder. To connect more models to the same
80
+ agents, run setup once per folder with a name of its own:
81
+
82
+ ```sh
83
+ radical setup payments/architecture --name radical-payments
84
+ radical setup billing/architecture --name radical-billing
85
+ ```
86
+
87
+ The agent sees each server's tools under its name (in Claude Code
88
+ `mcp__radical-payments__get_model_summary`), so they never collide; a name that says
89
+ which model it is helps the agent pick the right one. Without `--name` the second setup
90
+ finds `radical` taken and replaces it, asking first in a terminal (with `--yes`, it does not ask). Keep one server per folder: two
91
+ servers writing the same folder get in each other's way (Studio on the same folder is
92
+ fine).
93
+
79
94
  ### radical setup --status
80
95
 
81
96
  Checks what an agent needs to work on a model folder, and changes nothing:
@@ -231,7 +246,11 @@ radical hooks install path/to/model
231
246
 
232
247
  Adds one marked line to the repository's `post-checkout`, `post-commit`,
233
248
  `post-merge` and `post-rewrite` hooks that runs `radical diff <folder> --save-base --quiet`, so
234
- the base Studio compares with follows the branch checked out. The line goes
249
+ the base Studio compares with follows the branch checked out, and then
250
+ `radical check <folder> --from-ci --quiet --detach`, which fetches the test
251
+ results of CI for the commit checked out in the background (a command of its
252
+ own, its output closed: a CLI built before `--from-ci` still saves the
253
+ base, and without the GitHub CLI nothing is fetched). The line goes
235
254
  right after the hook's `#!` line, where an `exit` or `exec` further down
236
255
  cannot skip it; what the hooks already do stays. Each model folder of the
237
256
  repository has a line of its own, a second install adds nothing (or brings
@@ -258,10 +277,11 @@ Checks one model folder and prints what it finds:
258
277
  - **completeness**: requirements verified by a scenario, satisfied by an
259
278
  element, derived from a need; needs with requirements; accepted ADRs with
260
279
  a fitness function and their date, context, decision and consequences;
261
- fitness functions linked and with a threshold.
280
+ fitness functions linked; scenarios and fitness functions that state their
281
+ checks, in conditions that read.
262
282
 
263
- With test reports it also checks that the tests the model names passed (see
264
- below). `radical check --list-rules` lists every rule and every metric a goal can
283
+ With test reports it also checks that the tests the model names passed, and
284
+ with measurements that the values it holds to were met (see below). `radical check --list-rules` lists every rule and every metric a goal can
265
285
  be set for. It reads the files only and never writes the model.
266
286
 
267
287
  Exit status: 0 no errors (warnings allowed), 1 errors, 2 the check could not
@@ -328,14 +348,15 @@ describe block, since a fitness function that names a whole file or directory
328
348
 
329
349
  ### Tests and evidence
330
350
 
331
- A scenario or a fitness function names the tests that run it in its `tests`
332
- property, one per line, as Vitest and Playwright print them:
351
+ A scenario or a fitness function says what checks it in its `metrics`
352
+ property, one condition per line. A test that has to pass is named as Vitest
353
+ and Playwright print it:
333
354
 
334
355
  ```
335
- apps/cli/src/cli.test.ts › radical check › prints the result as JSON
336
- apps/e2e/tests/studio/forge.spec.ts › Forge files each stage into its view
337
- packages/layout/tests/geometry.test.ts › createBatchPlacer
338
- apps/e2e/tests
356
+ test(apps/cli/src/cli.test.ts › radical check › prints the result as JSON) passed
357
+ test(apps/e2e/tests/studio/forge.spec.ts › Forge files each stage into its view) passed
358
+ test(packages/layout/tests/geometry.test.ts › createBatchPlacer) passed
359
+ test(apps/e2e/tests) passed
339
360
  ```
340
361
 
341
362
  An id names the test whose title it ends, otherwise every test in the
@@ -362,8 +383,9 @@ is an error; one that was skipped, or whose file no report has, a warning.
362
383
  The text output sums up how many requirements, scenarios, ADRs and fitness
363
384
  functions the reports verify. `--evidence` writes that status per element
364
385
  as JSON (`verified`, `broken`, `unverified` for requirements and ADRs;
365
- `passed`, `failed`, `not-run`, `no-tests` for scenarios and fitness
366
- functions); it never writes into the model.
386
+ `passed`, `failed`, `stale`, `not-run`, `no-checks` for scenarios and
387
+ fitness functions, with each condition's outcome); it never writes into the
388
+ model.
367
389
 
368
390
  With `--report` the command also keeps the test cases it read in the model
369
391
  folder's `.radical/test-results.json` (out of git, like the rest of
@@ -373,6 +395,89 @@ quality and Implementation show the result by dimension, and Settings edit
373
395
  `check.json` (goals, severities, baselines), marking a change that loosens
374
396
  the gate.
375
397
 
398
+ ### Test results from CI
399
+
400
+ ```sh
401
+ radical check path/to/model --from-ci
402
+ ```
403
+
404
+ reads the test reports of CI instead of `--report`. Test results never go
405
+ into git, since a commit cannot hold the results of its own tests; CI runs
406
+ every suite on every pull request and keeps the reports as artifacts. The
407
+ command finds, with the GitHub CLI (`gh`, signed in), the nearest commit in
408
+ HEAD's first-parent history that a completed GitHub Actions run tested; a
409
+ commit merged from a pull request (a squash merge has no run of its own)
410
+ stands for the pull request's head. For each artifact it takes the latest
411
+ completed run that kept it, downloads it, and reads the `.json` and `.xml`
412
+ test reports in it. Which artifacts hold reports is set in `check.json`:
413
+
414
+ ```json
415
+ { "ci": { "artifacts": ["test-reports", "e2e-report"] } }
416
+ ```
417
+
418
+ (every artifact of the run without it). The results are kept in
419
+ `.radical/test-results.json` with the commit they stand for, the runs, when
420
+ each ran and how many commits HEAD is past it, which the Inspector's *Tests*
421
+ chip shows; the same runs a second time download nothing. Results read with
422
+ `--report` at that commit or a later one are kept, and checked. `--quiet`
423
+ prints nothing; `--detach` starts the check in the background and returns,
424
+ as the git hooks of `radical hooks install` do after every checkout, commit,
425
+ pull and rebase.
426
+
427
+ ### Measured values
428
+
429
+ A condition can also hold a value to a threshold, which a sensor measures:
430
+
431
+ ```
432
+ api.latency.p95{env=staging} <= 300 ms
433
+ workspaces.exit_code == 0
434
+ ```
435
+
436
+ `<metric>{<labels>} <op> <number> [unit]`, with `< <= > >= == !=`. It is
437
+ judged by the latest measurement of the metric whose labels include the
438
+ condition's; units of one kind convert (ms and s, KB and MB). The element's
439
+ `combine` says how its conditions make its status (`all`, the default;
440
+ `any`; `at least N`), and `max_age` (`7d`, `12h`) how old a measurement may
441
+ be: an older one is stale, and never passes.
442
+
443
+ `radical check` reads the measurements kept in the model folder's
444
+ `.radical/measurements.json`, and with `--metrics <file|dir>` the
445
+ radical-metrics/1 files another job wrote, which it adds there. A condition
446
+ that does not hold is an error (`metric-failed`); a stale one
447
+ (`metric-stale`) or one nothing measured (`metric-not-measured`) a warning;
448
+ a line that reads as no condition, or a unit that does not convert, an error
449
+ (`metric-invalid`).
450
+
451
+ ## radical sense
452
+
453
+ Measures with a sensor adapter and keeps the values beside the model, for
454
+ the conditions above. A sensor only measures: it takes no threshold and
455
+ exits 0 whatever it measured, 2 when it could not measure.
456
+
457
+ ```sh
458
+ radical sense command --name workspaces -- node tools/check-workspaces.mjs
459
+ radical sense json k6-summary.json --metric 'api.latency.p95=/metrics/http_req_duration/p(95)@ms' --label env=staging
460
+ radical sense json coverage-summary.json --metric 'coverage.lines=total.lines.pct@%' --out reports/metrics/coverage.json
461
+ ```
462
+
463
+ - `command [--name <metric>] -- <command…>`: the command's exit code
464
+ (`<metric>.exit_code`) and duration in seconds (`<metric>.duration`).
465
+ - `json <file> --metric <metric>=<path>[@<unit>]`: a number from a JSON file,
466
+ by dotted keys with `[index]` or a JSON pointer starting with `/`.
467
+ - `--folder <dir>`: the model folder (default: the working directory); the
468
+ values go into its `.radical/measurements.json`, the latest of each metric
469
+ and labels.
470
+ - `--out <file>`: a radical-metrics/1 file instead, for `radical check
471
+ --metrics` in another job.
472
+ - `--label k=v` labels every measurement (conditions match labels);
473
+ `--context k=v` says where it was measured (a commit, a run).
474
+
475
+ An adapter for another tool is one module in `src/sensors/` with the
476
+ `SensorAdapter` interface, one line in `src/sensors/registry.ts` and a fixture
477
+ of its tool's real output; `src/sensors/contract.test.ts` runs every adapter on
478
+ its fixture and checks that it writes valid radical-metrics/1 and takes no
479
+ threshold. Pull requests welcome.
480
+
376
481
  ## radical fuzz
377
482
 
378
483
  Runs a project's fuzz files (Radical Crucible): tests that do random sequences
@@ -409,7 +514,7 @@ A fuzz file is written with the engine, `@radical/crucible`, which is not
409
514
  published yet: so far the fuzz files are this repository's own
410
515
  (`packages/ui/tests/invariants.test.ts`). It reports a test case per world and
411
516
  one per world and rule (`on the bookstore model: undoRestores holds`), which a
412
- scenario or a fitness function can name in its Tests.
517
+ scenario or a fitness function can name in its Metrics.
413
518
 
414
519
  Exit status: 0 every file passed, 1 one failed, 2 radical fuzz could not run.
415
520
 
@@ -426,9 +531,9 @@ radical harden --gate --test "apps/e2e/tests/studio/views.spec.ts › a view kee
426
531
  A fuzz finding is hardened by its own steps: the finding is marked `hardened`,
427
532
  and its fuzz file replays the shrunk sequence as the test
428
533
  `<fuzz file> › F-0003 stays fixed: <title>`, once and without the known
429
- failures, so it fails until the bug is fixed. The command prints that test id
430
- for the scenario's Tests and keeps the scenario's name in the finding; it does
431
- not change the model's files.
534
+ failures, so it fails until the bug is fixed. The command prints that test as a
535
+ `test(…) passed` line for the scenario's Metrics and keeps the scenario's name
536
+ in the finding; it does not change the model's files.
432
537
 
433
538
  `--gate` checks a test before it is bound: with the source files changed since
434
539
  the base (default: the merge base with `origin/main`) set back to it, the test