arkgate 2.12.0 → 2.13.0

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 (70) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +55 -31
  3. package/bin/ark-check.mjs +95 -36
  4. package/bin/ark-mcp.mjs +11 -5
  5. package/bin/ark-shared.mjs +88 -56
  6. package/bin/ark.mjs +45 -10
  7. package/bin/lib/agent-gates.mjs +12 -0
  8. package/bin/lib/architecture-scan.mjs +8 -0
  9. package/bin/lib/ci-and-commands.mjs +9 -3
  10. package/bin/lib/codex-home.mjs +7 -0
  11. package/bin/lib/config-contract.mjs +331 -0
  12. package/bin/lib/doctor-plan.mjs +43 -16
  13. package/bin/lib/enforcement-profiles.mjs +97 -0
  14. package/bin/lib/host-support-matrix.mjs +77 -0
  15. package/bin/lib/install-migrate.mjs +45 -14
  16. package/bin/lib/mcp-adoption.mjs +35 -3
  17. package/bin/lib/open-html.mjs +75 -0
  18. package/bin/lib/presets.mjs +3 -2
  19. package/bin/lib/safety-diagnostics.mjs +31 -11
  20. package/bin/lib/skill-install.mjs +64 -0
  21. package/bin/lib/ts-resolve.mjs +2 -1
  22. package/bin/lib/weakest-link.mjs +417 -0
  23. package/bin/lib/write-path-capabilities.mjs +182 -0
  24. package/bin/lib/write-path-detect.mjs +62 -99
  25. package/dist/configContract-iBLxx5Tz.d.cts +53 -0
  26. package/dist/configContract-iBLxx5Tz.d.ts +53 -0
  27. package/dist/eslint/index.cjs +375 -13
  28. package/dist/eslint/index.cjs.map +1 -1
  29. package/dist/eslint/index.d.cts +30 -20
  30. package/dist/eslint/index.d.ts +30 -20
  31. package/dist/eslint/index.js +375 -13
  32. package/dist/eslint/index.js.map +1 -1
  33. package/dist/index.cjs +723 -61
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +95 -5
  36. package/dist/index.d.ts +95 -5
  37. package/dist/index.js +716 -61
  38. package/dist/index.js.map +1 -1
  39. package/dist/nestjs/index.cjs +150 -42
  40. package/dist/nestjs/index.cjs.map +1 -1
  41. package/dist/nestjs/index.d.cts +2 -1
  42. package/dist/nestjs/index.d.ts +2 -1
  43. package/dist/nestjs/index.js +150 -42
  44. package/dist/nestjs/index.js.map +1 -1
  45. package/dist/runtime/index.cjs +723 -61
  46. package/dist/runtime/index.cjs.map +1 -1
  47. package/dist/runtime/index.d.cts +3 -2
  48. package/dist/runtime/index.d.ts +3 -2
  49. package/dist/runtime/index.js +716 -61
  50. package/dist/runtime/index.js.map +1 -1
  51. package/dist/{types-BZ17b9i5.d.cts → types-BxBwnBpC.d.cts} +9 -36
  52. package/dist/{types-BZ17b9i5.d.ts → types-Wcs_l1_J.d.ts} +9 -36
  53. package/docs/agent-guide.md +32 -20
  54. package/docs/ai-gates.md +53 -18
  55. package/docs/configuration.md +97 -0
  56. package/docs/enthusiast/README.md +3 -3
  57. package/docs/enthusiast/how-to-agent-gates.md +7 -3
  58. package/docs/migrate-from-ark-runtime-kernel.md +3 -0
  59. package/docs/package-surface.md +14 -9
  60. package/docs/production-hardening.md +15 -2
  61. package/docs/threat-model.md +65 -0
  62. package/docs/typescript-support.md +3 -3
  63. package/package.json +15 -2
  64. package/schemas/ark.config.schema.json +750 -0
  65. package/server.json +2 -2
  66. package/templates/hooks/pre-commit-ark +37 -0
  67. package/templates/skills/ark-coverage.md +2 -2
  68. package/templates/skills/ark-runtime.md +8 -5
  69. package/templates/skills/ark-upgrade.md +36 -16
  70. package/tests/fixtures/ts-consumer/ark.config.json +2 -0
@@ -0,0 +1,65 @@
1
+ # Threat model — ArkGate (Q9)
2
+
3
+ **Scope:** architecture write/CI gates, agent hooks/MCP, and the experimental optional runtime.
4
+ **Not in scope:** full org identity platforms, browser XSS in consumer apps, or npm registry
5
+ infrastructure beyond how this package is published.
6
+
7
+ ## Assets
8
+
9
+ | Asset | Why it matters |
10
+ |-------|----------------|
11
+ | `ark.config.json` contract | Defines what agents may import; weaken it → silent architectural debt |
12
+ | Write hook (`arkgate-mcp --hook`) | Hard local boundary only for installed/trusted Claude/Grok hook operations |
13
+ | CI `ark-check --strict-merge` | Repository check for every host; merge blocking requires a required status |
14
+ | Baselines (`.ark-baseline.json`) | Freezes debt; abuse silences real violations |
15
+ | Published npm tarball + Action SHA | Supply-chain integrity of the gate itself |
16
+ | Experimental runtime kernel | Event/saga state; InMemory is not durable |
17
+
18
+ ## Actors
19
+
20
+ - **AI agent** (Claude / Cursor / Codex / Grok) with tool write access; see the
21
+ [canonical host support matrix](../README.md#host-enforcement-support)
22
+ - **Human developer** editing files outside hooks (IDE, git apply)
23
+ - **CI runner** on PRs / main
24
+ - **Maintainer / attacker** with publish or PR privileges
25
+
26
+ ## Threats (STRIDE-light)
27
+
28
+ | ID | Threat | Impact | Mitigations (shipped) |
29
+ |----|--------|--------|------------------------|
30
+ | T1 | Agent bypasses hook (direct `fs` / alternate tool) | Ungoverned code lands | CI gate; optional pre-commit (Q3); doctor writePath honesty |
31
+ | T2 | Human commits without agent path | Same as T1 | `templates/hooks/pre-commit-ark`; branch protection + required check (Q3 external) |
32
+ | T3 | CI job missing / not required | Merge green without architecture | doctor `enforcement-ci-*` gaps; `--strict-merge` profile |
33
+ | T4 | Config weakened (`peerIsolation: false`, empty rules) | False green | safety diagnostics; false-green adoption detector |
34
+ | T5 | Baseline ratcheted open | Debt reintroduced | baseline unused/stale signals; occurrence keys |
35
+ | T6 | Dual MCP bin / wrong root | Gate points at wrong tree | migrate-commands; Codex fail-closed temp roots |
36
+ | T7 | Malicious dependency in publish | Compromised gate | signed tags, npm provenance, dependency-review, CodeQL, Semgrep, `verify-package-files` |
37
+ | T8 | Path traversal in hooks/check | Read/write outside project | root resolution + under-root import resolve |
38
+ | T9 | Runtime InMemory mistaken for durable | Data loss | durability stance docs + safety InMemory production detector |
39
+ | T10 | Repair payload silently applied | Unexpected rewrites | repair never writes; host must re-inject; exit 2 on deny |
40
+
41
+ ## Trust boundaries
42
+
43
+ ```
44
+ Claude/Grok host --PreToolUse--> arkgate-mcp (hard matched-write boundary)
45
+ Any MCP host --tool call----> arkgate-mcp (advisory validation)
46
+ Human IDE --disk/git-----> working tree
47
+ working tree --PR-----------> CI ark-check --strict-merge
48
+ npm publish <-- signed tag --- GitHub Release + provenance
49
+ ```
50
+
51
+ ## Residual risk (accepted)
52
+
53
+ - Branch protection is **external GitHub state** — doctor reports honestly when unavailable.
54
+ - Full external adoption matrix (Q4) and independent ≥95 audit (Q10) are separate exit gates.
55
+ - Live multi-agent loop-cost remains optional (`ARK_EVAL_LOOP_LIVE`).
56
+
57
+ ## Verification hooks
58
+
59
+ | Check | Command |
60
+ |-------|---------|
61
+ | Package allowlist | `node scripts/verify-package-files.mjs` |
62
+ | Module budgets | `node scripts/check-module-budgets.mjs` |
63
+ | Security CI | `.github/workflows/security.yml` |
64
+ | Audit (prod deps) | `npm run security:audit` |
65
+ | Architecture | `npm run check:architecture` |
@@ -32,7 +32,7 @@ itself; the CLI resolves it from the **project** first, then from the environmen
32
32
  ## How loading works
33
33
 
34
34
  1. Prefer `require('typescript')` from the **project** root (when it has `sys` + AST + resolve).
35
- 2. If missing or **not API-compatible** (TS 7.0 version-only export, or incomplete host), fall back to **ArkGate’s own** `typescript` dependency (JS-API 5.x nested under the package), then bare `import('typescript')`.
35
+ 2. If missing or **not API-compatible** (TS 7.0 version-only export, or incomplete host), fall back to **ArkGate’s own** `typescript` dependency (JS-API 5.x nested under the package), then bare `import('typescript')`.
36
36
  3. If nothing usable is found:
37
37
  - `--plan` still prints **coverage honesty** (no import graph)
38
38
  - full check exits non-zero with an install hint
@@ -49,9 +49,9 @@ ARK_DEBUG_TS=1 npx arkgate-check --plan
49
49
  TypeScript 7 is the **native (Go) compiler** generation. Important for tools like ArkGate:
50
50
 
51
51
  - **`require('typescript')` on 7.0.x** exports only `{ version, versionMajorMinor }` — not `sys`, `createSourceFile`, or `resolveModuleName`.
52
- - Unstable programmatic surfaces live under `typescript/unstable/*` (sync/async API, AST). They are **not** the classic TS 5/6 host ArkGate uses today.
52
+ - Unstable programmatic surfaces live under `typescript/unstable/*` (sync/async API, AST). They are **not** the classic TS 5/6 host ArkGate uses today.
53
53
  - Stable **programmatic JS API** maturity continues over the 7.x line (Microsoft: full story into **7.1+**).
54
- - When the project’s TypeScript is not API-compatible, ArkGate loads its **bundled JS-API dependency** (`typescript@^5.9`, nested under the package) so the write/CI gate keeps working while you try TS 7 as the project compiler.
54
+ - When the project’s TypeScript is not API-compatible, ArkGate loads its **bundled JS-API dependency** (`typescript@^5.9`, nested under the package) so the host write path and CI check keep working while you try TS 7 as the project compiler.
55
55
  - Your **tsconfig** must follow TS 6/7 defaults (see below) or `tsc` / resolve can fail independently of ArkGate.
56
56
 
57
57
  ### tsconfig defaults that surprise teams (TS 6 → 7)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkgate",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "ArkGate — architecture co-pilot for AI TypeScript (write gate, CI gate, plan/loop)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -22,6 +22,8 @@
22
22
  "import": "./dist/eslint/index.js",
23
23
  "require": "./dist/eslint/index.cjs"
24
24
  },
25
+ "./schema": "./schemas/ark.config.schema.json",
26
+ "./schema/ark.config.schema.json": "./schemas/ark.config.schema.json",
25
27
  "./nestjs": {
26
28
  "types": "./dist/nestjs/index.d.ts",
27
29
  "import": "./dist/nestjs/index.js",
@@ -42,6 +44,7 @@
42
44
  "bin",
43
45
  "bin/lib",
44
46
  "dist",
47
+ "schemas",
45
48
  "docs/agent-guide.md",
46
49
  "docs/enthusiast",
47
50
  "docs/demos",
@@ -51,8 +54,10 @@
51
54
  "docs/ark-check-example.json",
52
55
  "docs/assets",
53
56
  "docs/brownfield-adoption.md",
57
+ "docs/configuration.md",
54
58
  "docs/package-surface.md",
55
59
  "docs/production-hardening.md",
60
+ "docs/threat-model.md",
56
61
  "tests/fixtures/ts-consumer",
57
62
  "templates",
58
63
  "server.json",
@@ -66,7 +71,9 @@
66
71
  "dev": "tsup --watch",
67
72
  "test": "vitest",
68
73
  "test:run": "vitest run",
69
- "test:coverage": "vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary",
74
+ "test:coverage": "npm run build && vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary",
75
+ "test:mutation": "npm run build && stryker run",
76
+ "test:confidence": "npm run test:coverage && npm run test:mutation",
70
77
  "typecheck": "tsc --noEmit",
71
78
  "security:audit": "npm audit --omit=dev --audit-level=high",
72
79
  "check:architecture": "node bin/ark-check.mjs --root . --config ark.config.json --strict",
@@ -82,6 +89,9 @@
82
89
  "eval:corpus": "node eval/validate-corpus.mjs",
83
90
  "eval:comparative": "node eval/comparative-run.mjs",
84
91
  "eval:loop-cost": "node eval/loop-cost-run.mjs",
92
+ "bench:scale": "node scripts/ark-scale-bench.mjs",
93
+ "check:module-budgets": "node scripts/check-module-budgets.mjs",
94
+ "check:package-files": "node scripts/verify-package-files.mjs",
85
95
  "clean": "rm -rf dist",
86
96
  "release:npm": "node scripts/release-npm.mjs",
87
97
  "prepack": "npm run build"
@@ -102,6 +112,7 @@
102
112
  }
103
113
  },
104
114
  "overrides": {
115
+ "qs": "6.15.3",
105
116
  "vite": "6.4.3",
106
117
  "tsup": {
107
118
  "esbuild": "0.28.1"
@@ -112,6 +123,8 @@
112
123
  },
113
124
  "devDependencies": {
114
125
  "@nestjs/common": "^11.1.27",
126
+ "@stryker-mutator/core": "^9.6.1",
127
+ "@stryker-mutator/vitest-runner": "^9.6.1",
115
128
  "@types/node": "^20.14.0",
116
129
  "@vitest/coverage-v8": "^3.2.6",
117
130
  "reflect-metadata": "^0.2.2",