From c04612560c6221c337b97fed248568ad6062b060 Mon Sep 17 00:00:00 2001 From: Andrey Rychkov Date: Thu, 26 Nov 2026 21:11:46 +0000 Subject: [PATCH] docs: define saved report and CLI compatibility Give consumers a way to read persisted queries across 0.x upgrades and distinguish a strict partial result from a command failure. --- README.md | 2 ++ docs/reference.html | 77 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e69230f..b3a9146 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ To review what an external caller can reach by invoking a handler, use `--entry- Repeat `--entry` to combine entry points or `--project` to select multiple configs. Output files must be new. Use `--strict` when a partial result should set exit code 2. The CLI still produces the report. +For scripts that save JSON, see the [0.x report compatibility rules](docs/reference.html#compatibility) and [CLI exit codes](docs/reference.html#exit-codes). + Check diagnostics before interpreting counts. Call sites measure source occurrences. Runtime dispatch, callbacks, and external consumers can introduce paths the scanner cannot see. Review declarations with no known path before considering removal. ## Use the library diff --git a/docs/reference.html b/docs/reference.html index c2a8dff..6973ded 100644 --- a/docs/reference.html +++ b/docs/reference.html @@ -28,9 +28,11 @@ On this page @@ -104,13 +106,28 @@

CLI options

--output new-file
Write the result to a new file. An existing path produces an error.
--strict
-
- Write the report and exit with code 2 for a partial scan. A successful scan otherwise exits with 0. Invalid - arguments and filesystem errors exit with 1. -
+
Signal a partial scan after writing its report. See exit codes.
-h, --help
Print usage and exit.
+

Exit codes

+
+
0 · Success
+
+ The CLI printed help or produced the requested report. Without --strict, both complete and + partial scans succeed. Check the JSON completeness field when the distinction matters. +
+
1 · Command failed
+
+ An invalid option, failed query, or read or write error sends an explanation to stderr. Stop before + consuming output. In particular, an existing --output file may be from an earlier run. +
+
2 · Strict scan produced a partial report
+
+ Read the report from stdout or the new file named by --output. Inspect its diagnostics before + using the results. A complete scan with --strict exits with 0. +
+

Project selection

node dist/cli.js . --project tsconfig.build.json --exclude '**/generated/**' --test 'qa/**'

@@ -198,14 +215,52 @@

Consuming the 0.x API

the selected file or invocation root and target, or null for an unreached ID. Select the ID with usages. Each non-root node carries the edge kind and source location. summary, usageText and markdown render display text.

+

Saved reports and 0.x upgrades

+

+ Use --format json for scripts. The packaged JSON Schema lists + the required properties, types, allowed values and nullable fields for each report. Summary, Markdown, + diagnostic messages and limitation text are for display. --changed-since produces a text summary. +

+
+
Full inventory
+
+ Require schemaVersion === 1 for the layout above. Save the full inventory to run new + usages or reachability queries later. Use analyzer.version and + analyzer.compilerVersion to identify the producer. +
+
Symbol query
+
+ Require schemaVersion === 1 and read usage.symbol, + usage.references and usage.counts. The CLI puts snapshot-wide diagnostics + alongside usage. +
+
Entry query
+
+ In 0.3.0 this report has no schemaVersion. Validate it against the schema’s + entryReport definition. File roots appear in entries. The optional + entrySymbols lists explicitly invoked declarations. Use reached to reconstruct + paths and declarations to look up reachability status. +
+
+

+ All three shapes carry snapshotId, completeness and diagnostics. Keep + the matching inventory or its producer metadata with a saved query. Treat IDs as opaque and join records only + within the same snapshot. A fresh scan with an improved resolver can produce different IDs, counts, paths or + diagnostics for the same source. +

+

+ Within schema version 1, readers can rely on required fields and their documented meanings. Producers may add + optional fields and diagnostic codes. Ignore unfamiliar properties, handle unfamiliar codes, and allow + optional fields such as files[].project to be absent. A required field with a nullable type, such + as references[].callerId, is present even when its value is null. +

- The JSON Schema describes all three CLI report shapes. For persisted data - check schemaVersion before reading a full inventory or symbol response. The entry response has the - Reachability shape in the shipped TypeScript declarations. In 0.1.0 it has no schemaVersion. Keep analyzer and - compiler versions from the full snapshot alongside query results. Use snapshot-local IDs for joins. Accept - additional fields and unknown diagnostic codes. Compare counts across upgrades against source examples; - changes in resolution can change a result even when its shape stays compatible. Keep the generating version - for older snapshots. During 0.x the format and API can change. + During 0.x, a change that invalidates existing reports or breaks a reader following these rules belongs in a + new minor release with migration instructions. An incompatible JSON shape also needs a new schema version, + including an explicit version on a replacement for the unversioned entry report. A change to the documented + exit codes is likewise a breaking CLI change. Before moving to another minor release, validate a saved report + with the target schema and replay a representative query. For an unsupported version, retain the original + report and use its generating release until you migrate.

TS-prefixed codes are compiler diagnostics. unresolved-module and dynamic-module identify missing module