@archrad/deterministic 0.1.4 → 0.1.6
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/CHANGELOG.md +39 -4
- package/README.md +81 -48
- package/biome.json +32 -25
- package/dist/cli.js +1 -1
- package/dist/mcp-server-tools-patch.d.ts +29 -0
- package/dist/mcp-server-tools-patch.d.ts.map +1 -0
- package/dist/mcp-server-tools-patch.js +71 -0
- package/dist/mcp-server.d.ts +7 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +256 -0
- package/dist/nodeExpress.d.ts.map +1 -1
- package/dist/nodeExpress.js +5 -1
- package/dist/openapi-to-ir.d.ts.map +1 -1
- package/dist/openapi-to-ir.js +6 -4
- package/dist/pythonFastAPI.d.ts.map +1 -1
- package/dist/pythonFastAPI.js +3 -1
- package/dist/static-rule-guidance.d.ts +19 -0
- package/dist/static-rule-guidance.d.ts.map +1 -0
- package/dist/static-rule-guidance.js +165 -0
- package/dist/stringEdgeStrip.d.ts +8 -0
- package/dist/stringEdgeStrip.d.ts.map +1 -0
- package/dist/stringEdgeStrip.js +25 -0
- package/docs/CI.md +122 -0
- package/docs/DRIFT.md +52 -0
- package/docs/MCP.md +153 -0
- package/docs/RULE_CODES.md +208 -0
- package/package.json +17 -10
- package/scripts/generate-corpus.mjs +667 -0
- package/scripts/npm-postinstall.mjs +22 -0
- package/scripts/smoke-mcp.mjs +44 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.6] - 2026-04-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`docs/CI.md`** — exit code semantics (`--fail-on-warning`, `--max-warnings`) and copy-paste snippets for GitHub Actions, GitLab CI, Bitbucket Pipelines, Jenkins, and Azure DevOps.
|
|
15
|
+
- **`scripts/generate-corpus.mjs`** — validates hand-written `corpus/*.json` pairs; `--count` mode generates weighted synthetic JSONL training pairs via the deterministic engine. Run `npm run build` first.
|
|
16
|
+
- **Integration tests** — `archrad validate` exit code assertions (`src/cli-exit.integration.test.ts`).
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **MCP** — Rewrote all six `registerTool` title/description blocks for agent discoverability (`src/mcp-server-tools-patch.ts`).
|
|
21
|
+
- **npm package** — `corpus/` excluded from published tarball (`.npmignore` + removed from `package.json` `files`).
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **`archrad_validate_drift`** MCP schema: `target` enum is `python` | `nodejs` only, aligned with `docs/MCP.md`.
|
|
26
|
+
|
|
27
|
+
### Security
|
|
28
|
+
|
|
29
|
+
- `npm audit fix` applied to dev/test transitive dependencies.
|
|
30
|
+
|
|
31
|
+
## [0.1.5] - 2026-04-07
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **`archrad-mcp`** — [Model Context Protocol](https://modelcontextprotocol.io/) server over **stdio** (same deterministic engine as the CLI). Tools: **`archrad_validate_ir`**, **`archrad_lint_summary`**, **`archrad_validate_drift`**, **`archrad_policy_packs_load`**, **`archrad_suggest_fix`** (static remediation per built-in code — **not** generated patches), **`archrad_list_rule_codes`**. IR input: inline **`ir`** or **`irPath`** (JSON file; max **25 MiB**). **`archrad_suggest_fix`** **`docsUrl`** → GitHub **`docs/RULE_CODES.md`**. Scope: **`docs/MCP.md`** (OSS: IR + local paths; no tracking params in tool responses).
|
|
36
|
+
- **Docs:** **`docs/DRIFT.md`** (deterministic drift semantics), **`docs/RULE_CODES.md`** (built-in codes + anchors for MCP **`docsUrl`**), **`docs/MCP.md`** (local testing).
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **CodeQL** `js/polynomial-redos` — linear-time hyphen/underscore edge stripping for **`safeId`** / OpenAPI-derived ids (replaces ambiguous alternation regexes).
|
|
41
|
+
|
|
10
42
|
## [0.1.4] - 2026-04-06
|
|
11
43
|
|
|
12
44
|
### Added
|
|
@@ -103,8 +135,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
103
135
|
- Documented **codegen vs validation** for retry/timeout IR fields and **InkByte vs OSS** scope in README and structural/semantic doc.
|
|
104
136
|
- README positioning: **deterministic compiler and linter for system architecture**; validation layers table (OSS vs Cloud); **`validate-drift`**, drift GIF / trust-loop recording docs, library **`runValidateDrift`** example.
|
|
105
137
|
|
|
106
|
-
[Unreleased]: https://github.com/archradhq/arch-deterministic/compare/v0.1.
|
|
107
|
-
[0.1.
|
|
108
|
-
[0.1.
|
|
109
|
-
[0.1.
|
|
138
|
+
[Unreleased]: https://github.com/archradhq/arch-deterministic/compare/v0.1.6...HEAD
|
|
139
|
+
[0.1.6]: https://github.com/archradhq/arch-deterministic/compare/v0.1.5...v0.1.6
|
|
140
|
+
[0.1.5]: https://github.com/archradhq/arch-deterministic/compare/v0.1.4...v0.1.5
|
|
141
|
+
[0.1.4]: https://github.com/archradhq/arch-deterministic/compare/v0.1.3...v0.1.4
|
|
142
|
+
[0.1.3]: https://github.com/archradhq/arch-deterministic/compare/v0.1.2...v0.1.3
|
|
143
|
+
[0.1.2]: https://github.com/archradhq/arch-deterministic/compare/v0.1.1...v0.1.2
|
|
144
|
+
[0.1.1]: https://github.com/archradhq/arch-deterministic/compare/v0.1.0...v0.1.1
|
|
110
145
|
[0.1.0]: https://github.com/archradhq/arch-deterministic/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -2,28 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
  
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Your architecture drifts before you write a single line of code. `archrad validate` catches it — deterministically, in CI, before the PR merges.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Define your system as a graph. ArchRAD compiles it, lints it against architecture rules, and tells you exactly what's wrong — with rule codes, not opinions.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick start (60 seconds)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @archrad/deterministic
|
|
17
|
+
archrad validate --ir fixtures/demo-direct-db-violation.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
You should see something like (exact wording may vary slightly by version):
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
⚠️ IR-LINT-DIRECT-DB-ACCESS-002: API node "orders-api" connects directly to datastore node "orders-db"
|
|
24
|
+
Fix: Introduce a service or domain layer between HTTP handlers and persistence.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For a smaller graph (single endpoint, no DB edge), try **`fixtures/minimal-graph.json`** — you will get different warnings (e.g. health/auth heuristics), not **`IR-LINT-DIRECT-DB-ACCESS-002`**.
|
|
28
|
+
|
|
29
|
+
No IR file yet? Cold-start from an existing OpenAPI spec:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
archrad ingest openapi --spec ./openapi.yaml --out ./graph.json
|
|
33
|
+
archrad validate --ir ./graph.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## What it does
|
|
39
|
+
|
|
40
|
+
ArchRAD is a blueprint compiler and governance layer. You define your architecture as an IR — nodes, edges, allowed connections — and ArchRAD validates it against a deterministic rule engine. The same IR, the same rules, the same inputs always produce the same findings.
|
|
12
41
|
|
|
13
|
-
|
|
42
|
+
| Command | What it checks | Codes |
|
|
43
|
+
|---------|---------------|-------|
|
|
44
|
+
| `archrad validate` | Graph structure + architecture lint | `IR-STRUCT-*` `IR-LINT-*` |
|
|
45
|
+
| `archrad validate-drift` | IR vs generated code on disk | `DRIFT-*` |
|
|
46
|
+
| `archrad ingest openapi` | Derive IR from existing OpenAPI spec | — |
|
|
47
|
+
| `archrad export` | Compile IR → FastAPI or Express + Docker | — |
|
|
48
|
+
|
|
49
|
+
## CI integration
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Fail on any structural error (default):
|
|
53
|
+
archrad validate --ir ./graph.json
|
|
54
|
+
|
|
55
|
+
# Also fail on lint warnings:
|
|
56
|
+
archrad validate --ir ./graph.json --fail-on-warning
|
|
14
57
|
|
|
15
|
-
|
|
58
|
+
# Machine-readable output for GitHub Actions:
|
|
59
|
+
archrad validate --ir ./graph.json --json
|
|
60
|
+
```
|
|
16
61
|
|
|
17
|
-
|
|
62
|
+
## MCP server (Cursor / Claude Desktop)
|
|
18
63
|
|
|
19
|
-
|
|
64
|
+
After install, `archrad-mcp` is on your PATH. Add it to your IDE:
|
|
20
65
|
|
|
21
|
-
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"archrad": { "command": "archrad-mcp" }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
22
73
|
|
|
23
|
-
|
|
74
|
+
Your agent can call the same engine as the CLI via **six** MCP tools (e.g. `archrad_validate_ir`, `archrad_lint_summary`, `archrad_validate_drift`, `archrad_policy_packs_load`, `archrad_list_rule_codes`, `archrad_suggest_fix`). See [docs/MCP.md](docs/MCP.md) for parameters and local testing.
|
|
24
75
|
|
|
25
76
|
---
|
|
26
77
|
|
|
78
|
+
|
|
27
79
|
## How it works (architecture)
|
|
28
80
|
|
|
29
81
|
```
|
|
@@ -67,7 +119,7 @@ IR (nodes/edges) → validateIrStructural (IR-STRUCT-*) → errors block exp
|
|
|
67
119
|
| **AI remediation** | Repair loops, suggested edits |
|
|
68
120
|
|
|
69
121
|
1. **IR structural validation:** duplicate/missing node ids, bad HTTP `config.url` / `config.method`, unknown edge endpoints, directed cycles.
|
|
70
|
-
2. **Architecture lint:** Implemented as a **registry of visitor functions** on a parsed graph (`buildParsedLintGraph` → **`LINT_RULE_REGISTRY`** in **`src/lint-rules.ts`**). If the IR cannot be parsed, **`buildParsedLintGraph`** returns **`{ findings }`** (IR-STRUCT-*) instead of **`null`**; use **`isParsedLintGraph()`** or call **`validateIrLint`**, which forwards those findings. Each rule returns **`IrStructuralFinding[]`**; **`runArchitectureLinting`** / **`validateIrLint`** flatten them. **Custom org rules:** compose **`runArchitectureLinting`** with your own **`(g) => findings`** in CI (worked example: **`docs/CUSTOM_RULES.md`**), or **fork** and append to **`LINT_RULE_REGISTRY`** if the stock **`archrad validate`** CLI must emit your codes. CLI **`archrad validate`** / **`archrad export`** print lint under **Architecture lint (IR-LINT-*)** (grouped separately from structural). Codes include **IR-LINT-DIRECT-DB-ACCESS-002**, **IR-LINT-SYNC-CHAIN-001**, **IR-LINT-NO-HEALTHCHECK-003**, **IR-LINT-HIGH-FANOUT-004**, **IR-LINT-ISOLATED-NODE-005**, **IR-LINT-DUPLICATE-EDGE-006**, **IR-LINT-HTTP-MISSING-NAME-007**, **IR-LINT-DATASTORE-NO-INCOMING-008**, **IR-LINT-MULTIPLE-HTTP-ENTRIES-009**. **Sync-chain** depth counts **synchronous** edges only; mark message/queue/async hops via **`edge.metadata.protocol`** / **`config.async`** (see **`edgeRepresentsAsyncBoundary`** in **`lint-graph.ts`** and **`docs/ENGINEERING_NOTES.md`**).
|
|
122
|
+
2. **Architecture lint:** Implemented as a **registry of visitor functions** on a parsed graph (`buildParsedLintGraph` → **`LINT_RULE_REGISTRY`** in **`src/lint-rules.ts`**). If the IR cannot be parsed, **`buildParsedLintGraph`** returns **`{ findings }`** (IR-STRUCT-*) instead of **`null`**; use **`isParsedLintGraph()`** or call **`validateIrLint`**, which forwards those findings. Each rule returns **`IrStructuralFinding[]`**; **`runArchitectureLinting`** / **`validateIrLint`** flatten them. **Custom org rules:** compose **`runArchitectureLinting`** with your own **`(g) => findings`** in CI (worked example: **`docs/CUSTOM_RULES.md`**), or **fork** and append to **`LINT_RULE_REGISTRY`** if the stock **`archrad validate`** CLI must emit your codes. CLI **`archrad validate`** / **`archrad export`** print lint under **Architecture lint (IR-LINT-*)** (grouped separately from structural). Codes include **IR-LINT-DIRECT-DB-ACCESS-002**, **IR-LINT-SYNC-CHAIN-001**, **IR-LINT-NO-HEALTHCHECK-003**, **IR-LINT-HIGH-FANOUT-004**, **IR-LINT-ISOLATED-NODE-005**, **IR-LINT-DUPLICATE-EDGE-006**, **IR-LINT-HTTP-MISSING-NAME-007**, **IR-LINT-DATASTORE-NO-INCOMING-008**, **IR-LINT-MULTIPLE-HTTP-ENTRIES-009**, **IR-LINT-MISSING-AUTH-010**, **IR-LINT-DEAD-NODE-011**. **Sync-chain** depth counts **synchronous** edges only; mark message/queue/async hops via **`edge.metadata.protocol`** / **`config.async`** (see **`edgeRepresentsAsyncBoundary`** in **`lint-graph.ts`** and **`docs/ENGINEERING_NOTES.md`**).
|
|
71
123
|
3. **Generators** → `openapi.yaml`, handlers, deps.
|
|
72
124
|
4. **Golden path** → `make run` / `docker compose up --build`.
|
|
73
125
|
5. **OpenAPI document shape** on the bundle — **not** [Spectral](https://github.com/stoplightio/spectral)-level lint. Issues → **`openApiStructuralWarnings`**.
|
|
@@ -76,6 +128,8 @@ IR (nodes/edges) → validateIrStructural (IR-STRUCT-*) → errors block exp
|
|
|
76
128
|
|
|
77
129
|
**Trust builder:** **IR-STRUCT-*** errors block export; **IR-LINT-*** warnings are visible and can **gate CI** via **`--fail-on-warning`** / **`--max-warnings`**; OpenAPI shape issues surface as export warnings.
|
|
78
130
|
|
|
131
|
+
**Reference (OSS):** **[`docs/DRIFT.md`](docs/DRIFT.md)** (deterministic **`validate-drift`**), **[`docs/RULE_CODES.md`](docs/RULE_CODES.md)** (finding codes; MCP **`docsUrl`** targets GitHub anchors), **[`docs/MCP.md`](docs/MCP.md)** (MCP tools + local testing).
|
|
132
|
+
|
|
79
133
|
### Codegen vs validation (retry, timeouts, policy)
|
|
80
134
|
|
|
81
135
|
Generators **may emit** retry/timeout/circuit-breaker **code** when the IR carries matching edge or node config (e.g. `retryPolicy`). That is **code generation**, not a guarantee. OSS does **not** currently **require** or **lint** “every external call must have timeout/retry” — that class of rule is **semantic / policy** and fits **ArchRad Cloud** or custom linters on top of the IR.
|
|
@@ -92,10 +146,17 @@ Generators **may emit** retry/timeout/circuit-breaker **code** when the IR carri
|
|
|
92
146
|
| **CLI validate** | CI / pre-commit: IR structural + architecture lint, no codegen | `archrad validate --ir graph.json` |
|
|
93
147
|
| **CLI validate-drift** | After export or merges: on-disk tree vs fresh deterministic export from same IR | `archrad validate-drift -i graph.json -t python -o ./out` |
|
|
94
148
|
| **Library** (`@archrad/deterministic`) | IDPs / pipelines | `runDeterministicExport` → files + findings; **`runValidateDrift`** / **`runDriftCheckAgainstFiles`** for drift |
|
|
149
|
+
| **MCP** (`archrad-mcp`) | Cursor / Claude Desktop / other MCP hosts | stdio server: validate IR, lint summary, drift, policy packs, static **`archrad_suggest_fix`** — see **`docs/MCP.md`** |
|
|
150
|
+
|
|
151
|
+
**MCP (Cursor example):** after `npm i -g @archrad/deterministic` (or `npx`), add a server with command **`archrad-mcp`** and no args (stdio). Pass **`ir`** inline or **`irPath`** to a JSON file for large graphs. **`archrad_suggest_fix`** returns curated text for a finding code (e.g. `IR-LINT-MISSING-AUTH-010`) — not machine-generated IR patches. **Step-by-step testing** (smoke script, MCP Inspector, Cursor chat prompts): **`docs/MCP.md`**, section **Local testing**.
|
|
95
152
|
|
|
96
153
|
### CLI
|
|
97
154
|
|
|
98
|
-
**Input is structured IR (JSON), not natural language.** There is no `archrad export --prompt "..."`.
|
|
155
|
+
**Input is structured IR (JSON), not natural language.** There is no `archrad export --prompt "..."`. Pass a **graph file** (nodes/edges).
|
|
156
|
+
|
|
157
|
+
**Fixtures** (in this repo): **`fixtures/minimal-graph.json`** (small); **`fixtures/demo-direct-db-violation.json`** / **`fixtures/demo-direct-db-layered.json`** (before/after **`IR-LINT-DIRECT-DB-ACCESS-002`**); **`fixtures/ecommerce-with-warnings.json`** (many lint rules); **`fixtures/payment-retry-demo.json`** (retry-related codegen in export). **`--target python`** is the FastAPI bundle; there is no separate `fastapi` target. To go from **plain English → IR**, use **ArchRad Cloud** or your own LLM step; this package only does **IR → files**.
|
|
158
|
+
|
|
159
|
+
**Recording demos and GIFs** (VHS, storyboards, drift replay): **`scripts/README_DEMO_RECORDING.md`** only — not required to use the CLI.
|
|
99
160
|
|
|
100
161
|
**OpenAPI → JSON (spec as source of truth):** each operation under `paths` becomes an `http` node (`config.url` + `config.method`). Then validate and export like any other IR:
|
|
101
162
|
|
|
@@ -117,16 +178,13 @@ archrad validate --ir ./graph.json
|
|
|
117
178
|
|
|
118
179
|
YAML must have either top-level **`graph:`** (object) or top-level **`nodes:`** (array); bare graphs are wrapped as `{ "graph": { ... } }` automatically.
|
|
119
180
|
|
|
120
|
-
After `npm
|
|
181
|
+
**After `npm install -g` or `npx`** (typical):
|
|
121
182
|
|
|
122
183
|
```bash
|
|
123
|
-
node dist/cli.js export --ir fixtures/minimal-graph.json --target python --out ./my-api
|
|
124
|
-
node dist/cli.js yaml-to-ir --yaml fixtures/minimal-graph.yaml --out /tmp/ir.json
|
|
125
|
-
# After global install / npx:
|
|
126
184
|
archrad export --ir ./graph.json --target node --out ./my-express-api
|
|
127
185
|
|
|
128
186
|
# Validate IR (structural + architecture lint). Pretty output; exit 1 on structural errors by default:
|
|
129
|
-
|
|
187
|
+
archrad validate --ir ./graph.json
|
|
130
188
|
# Machine-readable + CI gates:
|
|
131
189
|
archrad validate --ir ./graph.json --json
|
|
132
190
|
archrad validate --ir ./graph.json --fail-on-warning
|
|
@@ -137,6 +195,8 @@ archrad validate --ir ./graph.json --skip-lint
|
|
|
137
195
|
archrad validate --ir ./graph.json --policies ./policy-packs
|
|
138
196
|
```
|
|
139
197
|
|
|
198
|
+
**From a git clone** (contributors): run **`npm ci && npm run build`** in the package root (there is no `prepare` hook — see **`docs/ENGINEERING_NOTES.md`**), then use **`node dist/cli.js`** the same way you would use **`archrad`** (e.g. **`node dist/cli.js validate --ir fixtures/minimal-graph.json`**).
|
|
199
|
+
|
|
140
200
|
**Deterministic drift (thin, OSS):** compare an existing export tree on disk to a **fresh** export from the same IR. Detects **missing** / **changed** generated files (line endings normalized). Optional **`--strict-extra`** flags files present on disk but not in the reference export. Not semantic “does code match intent” — **ArchRad Cloud** adds builder/UI drift checks and broader governance.
|
|
141
201
|
|
|
142
202
|
```bash
|
|
@@ -149,8 +209,6 @@ archrad validate-drift -i ./graph.json -t python -o ./out --skip-host-port-check
|
|
|
149
209
|
archrad validate-drift -i ./graph.json -t python -o ./out --strict-extra
|
|
150
210
|
```
|
|
151
211
|
|
|
152
|
-
Regenerate the matching clip: **`npm run record:demo:drift`** (VHS) → **`demo-drift.gif`**, or **`scripts/run-demo-drift-sequence.ps1`** / **`.sh`** + ShareX/OBS if VHS is unavailable (see **`scripts/DEMO_GIF_STORYBOARD.md`**).
|
|
153
|
-
|
|
154
212
|
#### Example: validate architecture
|
|
155
213
|
|
|
156
214
|
```bash
|
|
@@ -183,13 +241,6 @@ By default, if **8080** (or your `--host-port`) looks **busy** on localhost, the
|
|
|
183
241
|
|
|
184
242
|
**Export** runs **IR structural validation**, then **architecture lint**, then codegen. **Structural errors** abort with **no files written**. **`irLintFindings`** contains only **`IR-LINT-*`**; **`IR-STRUCT-*`** from a failed parse always appear under **`irStructuralFindings`** (including when structural validation was skipped). **Lint warnings** print by default; use **`--fail-on-warning`** / **`--max-warnings`** to block writes for CI.
|
|
185
243
|
|
|
186
|
-
### Validate the package as a developer
|
|
187
|
-
|
|
188
|
-
1. `cd packages/deterministic && npm ci && npm run build && npm test`
|
|
189
|
-
2. `node dist/cli.js export --ir fixtures/minimal-graph.json --target python --out ./tmp-out`
|
|
190
|
-
3. `cd tmp-out && make run` then `curl` the URL shown in the generated **README** (port matches `--host-port` if you set it).
|
|
191
|
-
4. Optional: `node dist/cli.js export ... --host-port 18080` if **8080** is already taken.
|
|
192
|
-
|
|
193
244
|
### Library
|
|
194
245
|
|
|
195
246
|
```typescript
|
|
@@ -224,9 +275,9 @@ Optional: `isLocalHostPortFree` / `normalizeGoldenHostPort` from the same packag
|
|
|
224
275
|
|
|
225
276
|
---
|
|
226
277
|
|
|
227
|
-
## Golden path (
|
|
278
|
+
## Golden path (contributors — local clone)
|
|
228
279
|
|
|
229
|
-
|
|
280
|
+
This path assumes you **cloned the repo** and ran **`npm ci && npm run build`** in the package root. If you only installed with **`npm install -g @archrad/deterministic`**, use **`archrad`** instead of **`node dist/cli.js`** (same flags).
|
|
230
281
|
|
|
231
282
|
```bash
|
|
232
283
|
node dist/cli.js export --ir fixtures/minimal-graph.json --target python --out ./out
|
|
@@ -238,13 +289,9 @@ curl -sS -X POST http://localhost:8080/signup -H "Content-Type: application/json
|
|
|
238
289
|
|
|
239
290
|
You should see **422 Unprocessable Entity** (FastAPI/Pydantic) or **400** with a clear body — proof the stack is live and validation matches the spec, not a silent 500.
|
|
240
291
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
bash scripts/golden-path-demo.sh
|
|
245
|
-
```
|
|
292
|
+
Quick check from a clone: **`cd packages/deterministic && npm ci && npm run build && npm test`**, then export to **`./tmp-out`**, **`cd tmp-out && make run`**, **`curl`** as above. Use **`--host-port 18080`** (or **`node dist/cli.js export ... --host-port 18080`**) if **8080** is busy.
|
|
246
293
|
|
|
247
|
-
|
|
294
|
+
Optional: **`bash scripts/golden-path-demo.sh`** runs the same flow. **Demo recording** (GIFs, tapes, drift replays): **`scripts/README_DEMO_RECORDING.md`**.
|
|
248
295
|
|
|
249
296
|
---
|
|
250
297
|
|
|
@@ -261,20 +308,6 @@ See **`scripts/README_DEMO_RECORDING.md`** for **VHS / asciinema / ttyrec** tips
|
|
|
261
308
|
|
|
262
309
|
You can depend on this CLI and library **without** ArchRad Cloud. The cloud product stacks collaboration and AI on top of the same deterministic contract.
|
|
263
310
|
|
|
264
|
-
**InkByte vs this package:** Deeper workflow analysis, enterprise validation routes, and LLM-assisted flows may exist in the **private InkByte monorepo** (`server/`, etc.); they are **not** part of the **`@archrad/deterministic`** npm surface unless shipped here. This README describes **only** what the OSS package proves.
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
## Monorepo vs public OSS repo
|
|
269
|
-
|
|
270
|
-
The **canonical source** for this engine may live in a **private monorepo** next to the full product; `server` can depend on `file:../packages/deterministic`. The **public** GitHub repo should contain **only** this package — canonical clone: **`https://github.com/archradhq/arch-deterministic`**. Subtree publish: **`docs/OSS_VS_PRODUCT_REPOS.md`** and **`docs/PUBLISH_DETERMINISTIC_OSS.md`** (in the product monorepo).
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## Publishing the public OSS repo
|
|
275
|
-
|
|
276
|
-
From the private monorepo root: **`docs/PUBLISH_DETERMINISTIC_OSS.md`**. This tree includes **`.github/workflows/ci.yml`** and **Dependabot**; they run when this folder is the **git root** of the public repo.
|
|
277
|
-
|
|
278
311
|
---
|
|
279
312
|
|
|
280
313
|
## Contributing
|
package/biome.json
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
|
|
3
|
+
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
|
|
4
|
+
"files": {
|
|
5
|
+
"includes": [
|
|
6
|
+
"**",
|
|
7
|
+
"!**/dist",
|
|
8
|
+
"!**/node_modules",
|
|
9
|
+
"!**/*.json",
|
|
10
|
+
"!**/fixtures",
|
|
11
|
+
"!**/schemas"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"formatter": {
|
|
15
|
+
"enabled": false
|
|
16
|
+
},
|
|
17
|
+
"assist": { "actions": { "source": { "organizeImports": "off" } } },
|
|
18
|
+
"linter": {
|
|
19
|
+
"enabled": true,
|
|
20
|
+
"rules": {
|
|
21
|
+
"recommended": false,
|
|
22
|
+
"suspicious": {
|
|
23
|
+
"noDebugger": "error"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"javascript": {
|
|
28
|
+
"formatter": {
|
|
29
|
+
"quoteStyle": "single"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -76,7 +76,7 @@ const program = new Command();
|
|
|
76
76
|
program
|
|
77
77
|
.name('archrad')
|
|
78
78
|
.description('Validate your architecture before you write code. Deterministic compiler + linter — FastAPI / Express (no LLM, no server).')
|
|
79
|
-
.version('0.1.
|
|
79
|
+
.version('0.1.6');
|
|
80
80
|
program
|
|
81
81
|
.command('validate')
|
|
82
82
|
.description('Validate your architecture before you write code — IR structural (IR-STRUCT-*) + architecture lint (IR-LINT-*)')
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool catalog metadata (title + description) for archrad-mcp discoverability.
|
|
3
|
+
* Keep in sync with registerTool handlers in mcp-server.ts.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MCP_TOOL_ARCHRAD_VALIDATE_IR: {
|
|
6
|
+
readonly title: "Validate IR — structural (IR-STRUCT-*) + architecture lint (IR-LINT-*) + PolicyPack";
|
|
7
|
+
readonly description: "Architecture-as-code validation: run this when you need to check whether an IR graph is valid or to list violations before export or drift checks.\n\nKeywords: validate IR, architecture lint, IR-STRUCT, IR-LINT, policy pack, blueprint graph, nodes and edges.\n\nRuns in one call:\n1) Structural validation — graph shape, references, IR-STRUCT-* errors.\n2) Architecture lint — design rules (auth, dead nodes, DB access, sync chains, etc.).\n3) Optional PolicyPack rules — pass policiesDirectory to load YAML/JSON packs from disk.\n\nReturns irStructuralFindings, irLintFindings, and combined (sorted by severity). ok is false when any finding has severity \"error\".\n\nAfter results: call archrad_suggest_fix with a finding code for remediation text; use archrad_lint_summary for a short human-readable digest.\n\nInput: provide exactly one of ir (inline JSON object) or irPath (path to .json). Large graphs: prefer irPath.";
|
|
8
|
+
};
|
|
9
|
+
export declare const MCP_TOOL_ARCHRAD_LINT_SUMMARY: {
|
|
10
|
+
readonly title: "Lint summary — plain-text counts and top findings";
|
|
11
|
+
readonly description: "Human-readable summary of validation results: error/warning counts and up to 20 top findings (plain text).\n\nKeywords: summary, PR comment, explain violations, readable lint output.\n\nUse when you need a short narrative or comment, not structured JSON. For machine-actionable findings, use archrad_validate_ir instead.\n\nSame inputs as archrad_validate_ir: ir or irPath, optional policiesDirectory. Provide only one of ir or irPath.";
|
|
12
|
+
};
|
|
13
|
+
export declare const MCP_TOOL_ARCHRAD_SUGGEST_FIX: {
|
|
14
|
+
readonly title: "Suggest fix — static remediation for a built-in finding code";
|
|
15
|
+
readonly description: "Look up curated remediation steps and documentation URL for one built-in rule code (e.g. IR-LINT-MISSING-AUTH-010, IR-STRUCT-*, DRIFT-*).\n\nKeywords: remediation, how to fix, rule code, docs link, IR-LINT, IR-STRUCT.\n\nDoes not return generated code patches or IR edits — only static guidance. PolicyPack and org-specific rule ids are not covered; see your YAML packs.\n\nCall archrad_list_rule_codes to list codes that have static guidance.";
|
|
16
|
+
};
|
|
17
|
+
export declare const MCP_TOOL_ARCHRAD_LIST_RULE_CODES: {
|
|
18
|
+
readonly title: "List rule codes — built-in codes with static guidance";
|
|
19
|
+
readonly description: "Returns the sorted list of built-in IR-STRUCT-*, IR-LINT-*, and DRIFT-* codes that archrad_suggest_fix can explain.\n\nKeywords: catalog, all rules, rule list, documentation index.\n\nUse before suggest_fix to confirm a code exists. Excludes PolicyPack custom ids. No arguments.";
|
|
20
|
+
};
|
|
21
|
+
export declare const MCP_TOOL_ARCHRAD_VALIDATE_DRIFT: {
|
|
22
|
+
readonly title: "Validate drift — IR blueprint vs on-disk export (python | nodejs)";
|
|
23
|
+
readonly description: "Compare the architecture IR to generated code under exportDir and report drift (files that no longer match deterministic export).\n\nKeywords: drift, CI, codegen diff, FastAPI, Express, Node, Python, validate export, architecture vs implementation.\n\nRequires: ir or irPath, exportDir (absolute path to the export tree), and target. target must be \"python\" or \"nodejs\" (use \"nodejs\" for Node/TypeScript; do not use \"node\").\n\nOptional: policiesDirectory, skipIrLint (true to skip IR-LINT and only check drift).\n\nReturns driftFindings plus IR structural and lint findings from the same engine as CLI validate-drift.";
|
|
24
|
+
};
|
|
25
|
+
export declare const MCP_TOOL_ARCHRAD_POLICY_PACKS_LOAD: {
|
|
26
|
+
readonly title: "Load PolicyPack — compile and validate packs (dry run, no IR)";
|
|
27
|
+
readonly description: "Validate PolicyPack YAML/JSON without running against a graph: syntax, rule ids, and compilation.\n\nKeywords: policy pack, YAML rules, validate policies, org rules, offline check.\n\nYou usually do not need this before archrad_validate_ir or archrad_validate_drift — those accept policiesDirectory and load packs internally. Use this tool to debug pack files in isolation.\n\nProvide either directory (folder path) or files (array of { name, content }), not both.";
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=mcp-server-tools-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server-tools-patch.d.ts","sourceRoot":"","sources":["../src/mcp-server-tools-patch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,4BAA4B;;;CAgB/B,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;CAShC,CAAC;AAEX,eAAO,MAAM,4BAA4B;;;CAS/B,CAAC;AAEX,eAAO,MAAM,gCAAgC;;;CAOnC,CAAC;AAEX,eAAO,MAAM,+BAA+B;;;CAWlC,CAAC;AAEX,eAAO,MAAM,kCAAkC;;;CASrC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool catalog metadata (title + description) for archrad-mcp discoverability.
|
|
3
|
+
* Keep in sync with registerTool handlers in mcp-server.ts.
|
|
4
|
+
*/
|
|
5
|
+
export const MCP_TOOL_ARCHRAD_VALIDATE_IR = {
|
|
6
|
+
title: 'Validate IR — structural (IR-STRUCT-*) + architecture lint (IR-LINT-*) + PolicyPack',
|
|
7
|
+
description: `Architecture-as-code validation: run this when you need to check whether an IR graph is valid or to list violations before export or drift checks.
|
|
8
|
+
|
|
9
|
+
Keywords: validate IR, architecture lint, IR-STRUCT, IR-LINT, policy pack, blueprint graph, nodes and edges.
|
|
10
|
+
|
|
11
|
+
Runs in one call:
|
|
12
|
+
1) Structural validation — graph shape, references, IR-STRUCT-* errors.
|
|
13
|
+
2) Architecture lint — design rules (auth, dead nodes, DB access, sync chains, etc.).
|
|
14
|
+
3) Optional PolicyPack rules — pass policiesDirectory to load YAML/JSON packs from disk.
|
|
15
|
+
|
|
16
|
+
Returns irStructuralFindings, irLintFindings, and combined (sorted by severity). ok is false when any finding has severity "error".
|
|
17
|
+
|
|
18
|
+
After results: call archrad_suggest_fix with a finding code for remediation text; use archrad_lint_summary for a short human-readable digest.
|
|
19
|
+
|
|
20
|
+
Input: provide exactly one of ir (inline JSON object) or irPath (path to .json). Large graphs: prefer irPath.`,
|
|
21
|
+
};
|
|
22
|
+
export const MCP_TOOL_ARCHRAD_LINT_SUMMARY = {
|
|
23
|
+
title: 'Lint summary — plain-text counts and top findings',
|
|
24
|
+
description: `Human-readable summary of validation results: error/warning counts and up to 20 top findings (plain text).
|
|
25
|
+
|
|
26
|
+
Keywords: summary, PR comment, explain violations, readable lint output.
|
|
27
|
+
|
|
28
|
+
Use when you need a short narrative or comment, not structured JSON. For machine-actionable findings, use archrad_validate_ir instead.
|
|
29
|
+
|
|
30
|
+
Same inputs as archrad_validate_ir: ir or irPath, optional policiesDirectory. Provide only one of ir or irPath.`,
|
|
31
|
+
};
|
|
32
|
+
export const MCP_TOOL_ARCHRAD_SUGGEST_FIX = {
|
|
33
|
+
title: 'Suggest fix — static remediation for a built-in finding code',
|
|
34
|
+
description: `Look up curated remediation steps and documentation URL for one built-in rule code (e.g. IR-LINT-MISSING-AUTH-010, IR-STRUCT-*, DRIFT-*).
|
|
35
|
+
|
|
36
|
+
Keywords: remediation, how to fix, rule code, docs link, IR-LINT, IR-STRUCT.
|
|
37
|
+
|
|
38
|
+
Does not return generated code patches or IR edits — only static guidance. PolicyPack and org-specific rule ids are not covered; see your YAML packs.
|
|
39
|
+
|
|
40
|
+
Call archrad_list_rule_codes to list codes that have static guidance.`,
|
|
41
|
+
};
|
|
42
|
+
export const MCP_TOOL_ARCHRAD_LIST_RULE_CODES = {
|
|
43
|
+
title: 'List rule codes — built-in codes with static guidance',
|
|
44
|
+
description: `Returns the sorted list of built-in IR-STRUCT-*, IR-LINT-*, and DRIFT-* codes that archrad_suggest_fix can explain.
|
|
45
|
+
|
|
46
|
+
Keywords: catalog, all rules, rule list, documentation index.
|
|
47
|
+
|
|
48
|
+
Use before suggest_fix to confirm a code exists. Excludes PolicyPack custom ids. No arguments.`,
|
|
49
|
+
};
|
|
50
|
+
export const MCP_TOOL_ARCHRAD_VALIDATE_DRIFT = {
|
|
51
|
+
title: 'Validate drift — IR blueprint vs on-disk export (python | nodejs)',
|
|
52
|
+
description: `Compare the architecture IR to generated code under exportDir and report drift (files that no longer match deterministic export).
|
|
53
|
+
|
|
54
|
+
Keywords: drift, CI, codegen diff, FastAPI, Express, Node, Python, validate export, architecture vs implementation.
|
|
55
|
+
|
|
56
|
+
Requires: ir or irPath, exportDir (absolute path to the export tree), and target. target must be "python" or "nodejs" (use "nodejs" for Node/TypeScript; do not use "node").
|
|
57
|
+
|
|
58
|
+
Optional: policiesDirectory, skipIrLint (true to skip IR-LINT and only check drift).
|
|
59
|
+
|
|
60
|
+
Returns driftFindings plus IR structural and lint findings from the same engine as CLI validate-drift.`,
|
|
61
|
+
};
|
|
62
|
+
export const MCP_TOOL_ARCHRAD_POLICY_PACKS_LOAD = {
|
|
63
|
+
title: 'Load PolicyPack — compile and validate packs (dry run, no IR)',
|
|
64
|
+
description: `Validate PolicyPack YAML/JSON without running against a graph: syntax, rule ids, and compilation.
|
|
65
|
+
|
|
66
|
+
Keywords: policy pack, YAML rules, validate policies, org rules, offline check.
|
|
67
|
+
|
|
68
|
+
You usually do not need this before archrad_validate_ir or archrad_validate_drift — those accept policiesDirectory and load packs internally. Use this tool to debug pack files in isolation.
|
|
69
|
+
|
|
70
|
+
Provide either directory (folder path) or files (array of { name, content }), not both.`,
|
|
71
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* archrad-mcp — Model Context Protocol server (stdio) for deterministic IR validation,
|
|
4
|
+
* architecture lint, policy packs, and drift checks. Uses the same engine as `archrad` CLI.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|