Deterministic architecture graph, revision-diff, policy, and bounded runtime-reconciliation tooling for TypeScript.
CARTOGRAPH scans a supported repository with compiler-backed TypeScript resolution, produces a deterministic architecture graph, compares two Git revisions, and shows which nodes and relationships changed. Every emitted relationship carries repository-relative source evidence or an explicit unresolved reason.
CARTOGRAPH owns the complete local architecture-change loop: compiler-backed TypeScript extraction, canonical graph snapshots, semantic revision diffs, evidence-linked reports, policy evaluation, and bounded runtime reconciliation. The graph and report contracts remain source-free after analysis, while the analyzer itself reads only the declared local repository inputs and fails closed on unsupported or unresolved constructs.
The project is pre-alpha. The local TypeScript/Express slice, bounded Fastify adapter, and a read-only, informational-by-default GitHub Action work and are tested; stable identity across refactors, broader framework coverage, runtime redaction/retention, and hosted export remain roadmap work. The versioned local adapter, inert OTLP import, and explicit local reconciliation boundaries are published, but none executes repository code or contacts a network. Any hosted or account-based scope remains behind later traction, privacy, security, capacity, and funding decisions.
Install from npm (Node.js 22.13 or newer):
npm install --global --ignore-scripts cartograph-cli
cartograph init # config, starter policy, and pull-request workflow
mkdir -p .cartograph && cartograph scan . --output .cartograph/graph.jsonEach GitHub release also carries the tarball, SHA256SUMS, an SBOM, and a
signed build-provenance attestation, if you'd rather check the artifact before
installing it:
gh release download v0.1.1 -R AlisinaDevelo/CARTOGRAPH -p 'cartograph-cli-*.tgz' -p SHA256SUMS
shasum -a 256 -c SHA256SUMS --ignore-missing
gh attestation verify cartograph-cli-0.1.1.tgz -R AlisinaDevelo/CARTOGRAPH
npm install --global --ignore-scripts ./cartograph-cli-0.1.1.tgzTo run from source instead:
git clone https://github.com/AlisinaDevelo/CARTOGRAPH.git
cd CARTOGRAPH
npm ci --ignore-scripts
npm run build
node dist/cli.js --help
node dist/cli.js --version
npm pack --dry-run --ignore-scriptsThe full quickstart and limitations guide uses the sample repository to demonstrate a first scan, revision diff, configuration, privacy boundary, unsupported constructs, troubleshooting, and the read-only Action.
The safe policy and ADR workflow connects scan, diff, decision references, policy observation, migration, and human remediation review. Its isolated fixture runs the documented path locally and in CI.
Tagged releases are produced by the read-only package gate in
docs/RELEASE.md. Each GitHub release includes an installable
tarball, release notes, a SHA-256 checksum, and package-install smoke-test metadata.
Scan a working tree into canonical JSON:
mkdir -p .cartograph
node dist/cli.js scan /path/to/typescript-project \
--output .cartograph/current.graph.jsonCompare two local Git revisions without checking either one out:
node dist/cli.js diff /path/to/repository \
--base origin/main \
--head HEAD \
--comparison merge-base \
--format html \
--output .cartograph/architecture-diff.htmlRun the read-only GitHub Action on a pull request with a full-history checkout. It uses the event's exact base and head SHAs, emits a bounded summary with confidence/unresolved counts and evidence-backed line annotations, and uploads a self-contained HTML/JSON artifact:
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: AlisinaDevelo/CARTOGRAPH@addf08d96eb5be3f76e441fb879fe13352d8a871 # self-Action metadata verified
with:
comparison: merge-baseNew output files are created with private permissions and are not overwritten unless you pass --force. Before opening an output path, CARTOGRAPH rejects a final symlink and any existing user-controlled symlinked parent component (apart from macOS's standard /tmp and /var root aliases); the final component is opened with no-follow semantics. These are preflight checks, not a race-free guarantee against concurrent filesystem changes. Omit --output to write to stdout.
| Construct | Current behavior |
|---|---|
TypeScript .ts, .tsx, .mts, and .cts files; JavaScript .js, .jsx, .mjs, and .cjs files when allowJs is set, under a jsconfig.json, or in a repository with no TypeScript |
Scanned; declaration files and bounded build/dependency directories are excluded, with generated provenance retained; JavaScript nodes carry language: "javascript" |
Local and external imports, re-exports, literal dynamic imports, and literal require |
Module edges with source evidence |
| Named functions, class methods, and variable-bound arrow functions | Function nodes; semantically resolvable calls become edges |
Direct Express app/router routes and bounded use middleware with literal paths |
Endpoint and handler relationships |
| GraphQL SDL root fields and OpenAPI path operations with local resolver/handler links | Evidence-backed endpoint boundaries and routes_to relationships |
| Prisma datasources, models, relations, and bounded generated-client references | Typed database, service, and module nodes with schema evidence |
| npm, pnpm, Yarn, and Bun lockfile dependency records | Deterministic offline depends_on edges with lockfile evidence |
Generated directories, filename markers, configured exclusions, and generated-from markers |
Generated modules are classified; excluded generated paths receive exact-path diagnostics and selected sources receive provenance edges |
| Literal EventEmitter events, bounded Bull/BullMQ queues, timers, and local callbacks | Queue publication/registration and handler relationships with source evidence |
Literal fetch and Axios destinations |
Outbound request relationships |
| Conventional Prisma model operations | Read/write relationships to data nodes |
| Dynamic routes, API schema generation/aliases, imports, HTTP destinations, event/queue names, reflective handlers, unresolved calls, or ambiguous/mismatched lockfiles | Stable diagnostics with source evidence and remediation; no guessed edge |
Generated routes, framework metaprogramming, and complete runtime behavior are not supported. JavaScript follows TypeScript's own rules: with a tsconfig.json, .js files are analyzed only when allowJs is set; a jsconfig.json is used when there is no tsconfig.json; and a repository with neither config and no TypeScript implementation files is analyzed as JavaScript. Declaration files (.d.ts, .d.mts, and .d.cts) are excluded from the source graph and do not suppress JavaScript discovery. Generated TypeScript is not silently treated as ordinary source: selected artifacts are marked typescript-generated, and excluded generated files remain visible through EXCLUDED_GENERATED_FILE diagnostics. A plausible-looking result outside the table is not a support claim.
cartograph init [root] [--no-workflow] [--force]
cartograph scan [root]
cartograph diff [root] --base <ref> [--head <ref>] [--comparison direct|merge-base] [--adr <path>]
cartograph diff-snapshots <before.json> <after.json>
cartograph query --snapshot <graph.json> (--cycles | --from <module> --to <module> | --expr <query> | --query <file>)
cartograph export --snapshot <graph.json> --format graph-json|json-ld|edge-list|scip
cartograph policy [root] --policy <policy.json> (--snapshot <graph.json> | --diff <diff.json>) [--format json|sarif]
cartograph review <input.json> [--format json|markdown|html]
cartograph migrate-snapshot <input.json> --report <report.json>
scan emits canonical graph JSON. diff and diff-snapshots support json, markdown, and self-contained html reports. Add --adr <path> to diff to compare a repository-local ADR reference index at both revisions; Markdown and HTML reports then include deterministic ADR title/status, graph evidence, added/removed/changed references, stale-link diagnostics, and bidirectional ADR coverage indexes with counts by node and edge kind. Use --tsconfig <path> to select a configuration inside the analyzed repository. Use --config <path> to apply the versioned, repository-relative configuration contract; command-line flags override matching invocation settings.
init writes a starter cartograph.config.json, an informational
cartograph.policy.json that reports import cycles, and a pull-request
workflow pinned to the reviewed Action commit. Existing files are skipped
unless you pass --force.
query answers questions about a snapshot without rescanning. --cycles
lists module import cycles, --from src/a.ts --to src/b.ts prints the shortest
dependency path with the import evidence for each hop, --expr runs a
graph query language expression
(against a --diff it can select changes), and --query runs an
architecture query JSON request. Add
--fail-on-match to make a CI step exit 2 when the query returns anything, for
example to keep a codebase free of import cycles:
node dist/cli.js scan . --output .cartograph/graph.json
node dist/cli.js query --snapshot .cartograph/graph.json --cycles --fail-on-matchmigrate-snapshot rewrites the historical GraphSnapshot v0 fixture to v1 and
records every changed node or edge identity. Migration output is deterministic
and requires the documented manual review gate in
the migration matrix.
review joins one local GraphDiff with optional lifecycle, ownership, waiver,
policy, ADR, and waiver-drift artifacts into a bounded, evidence-linked review
summary. JSON is canonical; Markdown and HTML are deterministic projections.
Missing context remains visible, and all suggested next steps are read-only.
The input and output contracts are defined in
schema/review-summary.v0.1.schema.json.
patch-filter creates a bounded, patch-scoped view of a GraphDiff for large
changes. It retains changed-file evidence, optional one-hop context, explicit
omitted regions, and the full-diff policy result; a filtered view can never
turn a policy violation into a pass. The versioned contract is defined in
schema/patch-filter.v0.1.schema.json
and validated locally with npm run patch-filter:validate.
export writes a canonical snapshot as strict graph-interchange JSON
(graph-json), inline-context JSON-LD, streaming edge-list NDJSON, or a SCIP
index, for consumers that do not use CARTOGRAPH's renderer. All formats preserve typed edge identities, complete
evidence, confidence, unresolved reasons, and diagnostics; unknown fields fail
closed. See the portable graph interchange guide
and run npm run graph-interchange:validate for the offline round-trip gate.
The bounded SARIF policy-result bridge projects
only line-local policy violations into SARIF 2.1.0. Canonical graph IDs and
evidence references remain in the property bag; source-less or aggregate
findings are reported as omitted rather than misrepresented as code-scanning
results. policy --format sarif emits it directly, ready for
github/codeql-action/upload-sarif; the policy exit codes are unchanged. Run
npm run sarif:validate to replay the offline import/export and security
fixture.
HTML diff reports include a semantic summary and evidence table, native
keyboard disclosures, ordered internal navigation, visible live status text,
focus-visible styling, and reduced-motion behavior. The offline fixture and
automated checks are documented in the accessible HTML reports guide
and run with npm run accessibility:validate.
The Git revision flow validates refs, archives each commit into an isolated temporary directory, rejects archived symbolic links, analyzes without executing repository code, and cleans the temporary tree. It never checks out, resets, cleans, fetches, or stashes the caller's worktree. direct compares the resolved base tree to the resolved head tree. merge-base implements pull-request semantics by comparing the resolved merge base to the head; it fails closed for shallow repositories, unrelated histories, or multiple merge bases instead of fetching or guessing. Direct mode remains available for explicitly comparing unrelated trees.
JSON is the canonical interchange format. A source evidence record includes:
- a repository-relative path and source position;
- a versioned detector identity;
- a SHA-256 content hash;
- no source body or absolute path.
Each edge also records explicit confidence and must carry evidence or an actionable unresolved reason. Unknown evidence fields are rejected by the runtime contract.
The surrounding snapshot records the exact analyzed commit for revision-backed scans. Revision diffs also record the requested refs, resolved base/head commits, comparison mode, and merge base when applicable. Graphs and diffs are runtime-validated, referentially checked, deduplicated, and canonically sorted. Identical input produces byte-identical normalized JSON.
The canonical GraphSnapshot v0.1 JSON Schema
defines the portable interchange shape. The runtime validator additionally checks
cross-record node references, duplicate identities, and canonical normalization.
Identifiers and repository paths use / separators, date-time metadata is emitted
as UTC ISO 8601, and invalid snapshots fail with structured field paths through
GraphValidationError.
Schema compatibility and migration rules are documented in
docs/COMPATIBILITY.md and checked by
npm run schema:compatibility.
Every analyzer snapshot and diff carries the version of the published capability
and unknown-semantics registry; unsupported registry versions fail closed.
Local analysis performs no network request, hidden telemetry, build, package lifecycle script, or module import. Static HTML reports contain no remote asset or script. Repository input is untrusted; review the threat model before processing sensitive code and report vulnerabilities through SECURITY.md.
The analyzer enforces configurable file-count, byte, archive, memory, wall-clock,
and report-cardinality ceilings. Library callers can pass an AbortSignal to
cancel an analysis; revision materialization always removes its temporary tree,
and no partial snapshot or report is returned as a successful result.
npm ci --ignore-scripts
npm run check
npm run test:coverage
npm pack --dry-run --ignore-scriptsThe fixture corpus under test/fixtures/ defines supported relationships and negative cases. Extraction quality is evaluated with expected edge sets and diagnostics rather than graph appearance.
Read CONTRIBUTING.md before proposing a broad change. Material graph, evidence, privacy, adapter, or language changes require a public RFC issue under GOVERNANCE.md.
- Product charter
- Quickstart and limitations
- Safe policy and ADR workflow
- CLI runtime and exit policy
- Read-only GitHub Action
- Support matrix and review process
- Adapter selection RFC
- Adapter support matrix
- Maintenance and ownership
- Maintainer resilience and onboarding
- Compatibility and versioning
- Language-neutral graph semantics
- Portable graph interchange
- Accessible HTML reports
- Snapshot and identity migration
- Configuration contract
- Local ADR references
- Policy ADR bindings
- Local adapter contract
- Adapter review playbook
- Local runtime trace import
- Runtime trace sampling and cost budgets
- Local static/runtime reconciliation
- Explicit local runtime reconciliation CLI
- Runtime trace safety policy
- Fixture provenance
- Architecture
- Evaluation strategy
- Review workflow evaluation
- Benchmark corpus and measurement protocol
- Digest-bound policy bundles
- Policy-bundle migration and revocation
- Assurance signing metadata
- Governed remediation suggestions
- Deterministic remediation rules
- Deprecation and change-control register
- Landscape research
- Five-year roadmap
- Design-partner outreach
- Public community feedback and RFC process
- Adopter feedback template
- OSS health and traction scorecard
- Repository adoption evaluation
- Telemetry-free adoption measurement
- Workspace federation evaluation
- SCIP import and export
- SARIF policy-result bridge
- Explicit ownership resolution
- Auditable finding lifecycle
- Architecture waivers
- Ownership and waiver drift
- Sustainability and cost model
- Year 1–3 claims audit
- Strategy-branch privacy and security review
- Local-first investment ADR
- Conditional Year 4 investment charter
- Architecture query contract
- Graph and diff query language
- Filtered graph views
- Patch-scoped graph and policy filtering
- Release gate
- Release acceptance and rollback rehearsal
- Changelog