arkgate 3.9.2 → 4.0.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 (74) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +16 -5
  3. package/bin/ark-check-runtime.mjs +75 -3
  4. package/bin/ark-mcp-runtime.mjs +94 -0
  5. package/bin/lib/adapter-contract.mjs +14 -1
  6. package/bin/lib/analysis-engine.mjs +8 -8
  7. package/bin/lib/architecture-scan.mjs +35 -2
  8. package/bin/lib/arkrule-file-hints.mjs +71 -0
  9. package/bin/lib/arkrules-contract.mjs +382 -0
  10. package/bin/lib/arkrules-sensors.mjs +411 -0
  11. package/bin/lib/config-contract.mjs +85 -6
  12. package/bin/lib/doctor-advisories.mjs +14 -1
  13. package/bin/lib/doctor-plan.mjs +21 -0
  14. package/bin/lib/effective-contract-load.mjs +116 -0
  15. package/bin/lib/field-install.mjs +104 -0
  16. package/bin/lib/graph-blind.mjs +19 -0
  17. package/bin/lib/html-report-advisories.mjs +24 -0
  18. package/bin/lib/install-migrate.mjs +20 -2
  19. package/bin/lib/invariant-coverage-io.mjs +157 -0
  20. package/bin/lib/invariant-coverage.mjs +127 -0
  21. package/bin/lib/policy-delta-io.mjs +33 -0
  22. package/bin/lib/presets.mjs +241 -1
  23. package/bin/lib/remediation.mjs +28 -0
  24. package/bin/lib/resolved-candidate-facts.mjs +14 -1
  25. package/bin/lib/rules-inventory.mjs +144 -0
  26. package/bin/lib/rules-under-contract.mjs +66 -0
  27. package/bin/lib/start-preview.mjs +24 -7
  28. package/bin/lib/upgrade-command.mjs +48 -2
  29. package/dist/{configTypes-DAPvBqK6.d.ts → configTypes-CC0FEXoF.d.ts} +16 -3
  30. package/dist/eslint/index.cjs +2 -2
  31. package/dist/eslint/index.d.ts +1 -1
  32. package/dist/eslint/index.js +2 -2
  33. package/dist/index.cjs +14 -7
  34. package/dist/index.d.ts +615 -20
  35. package/dist/index.js +13 -6
  36. package/docs/README.md +4 -3
  37. package/docs/agent-guide.md +7 -3
  38. package/docs/ai-gates.md +6 -1
  39. package/docs/brownfield-adoption.md +20 -0
  40. package/docs/configuration.md +37 -4
  41. package/docs/develop.md +8 -2
  42. package/docs/enthusiast/README.md +11 -0
  43. package/docs/package-surface.md +13 -11
  44. package/docs/product-voice.md +9 -2
  45. package/docs/use.md +9 -0
  46. package/package.json +4 -17
  47. package/schemas/ark.analysis-result.schema.json +9 -1
  48. package/schemas/ark.arkrules.schema.json +141 -0
  49. package/schemas/ark.config.schema.json +10 -2
  50. package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
  51. package/server.json +2 -2
  52. package/templates/arkrules/ApplicationOrchestration.json +14 -0
  53. package/templates/arkrules/DomainModel.json +32 -0
  54. package/templates/arkrules/PersistenceAdapters.json +14 -0
  55. package/templates/arkrules/PresentationAdapters.json +14 -0
  56. package/templates/skills/ark-adopt.md +28 -1
  57. package/templates/skills/ark-architect.md +23 -0
  58. package/templates/skills/ark-autopilot.md +27 -1
  59. package/templates/skills/ark-contract.md +27 -1
  60. package/templates/skills/ark-coverage.md +23 -0
  61. package/templates/skills/ark-explain.md +23 -0
  62. package/templates/skills/ark-explore.md +26 -1
  63. package/templates/skills/ark-fix.md +23 -0
  64. package/templates/skills/ark-loop.md +23 -0
  65. package/templates/skills/ark-place.md +26 -0
  66. package/templates/skills/ark-runtime.md +4 -0
  67. package/templates/skills/ark-think.md +24 -1
  68. package/templates/skills/ark-upgrade.md +23 -0
  69. package/compat/nestjs.cjs +0 -2
  70. package/compat/nestjs.d.ts +0 -2
  71. package/compat/nestjs.js +0 -1
  72. package/compat/runtime.cjs +0 -2
  73. package/compat/runtime.d.ts +0 -2
  74. package/compat/runtime.js +0 -1
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/pedroknigge/arkgate",
7
7
  "source": "github"
8
8
  },
9
- "version": "3.9.2",
9
+ "version": "4.0.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "arkgate",
14
- "version": "3.9.2",
14
+ "version": "4.0.0",
15
15
  "runtimeHint": "npx",
16
16
  "transport": {
17
17
  "type": "stdio"
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",
3
+ "schemaVersion": "1.0",
4
+ "layer": "ApplicationOrchestration",
5
+ "structure": [
6
+ {
7
+ "id": "orchestration-only",
8
+ "sensor": "orchestration-only",
9
+ "mode": "advisory",
10
+ "description": "Application use cases orchestrate; keep domain branching in Domain."
11
+ }
12
+ ],
13
+ "invariants": []
14
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",
3
+ "schemaVersion": "1.0",
4
+ "layer": "DomainModel",
5
+ "structure": [
6
+ {
7
+ "id": "always-valid-aggregates",
8
+ "sensor": "aggregate-private-state",
9
+ "mode": "advisory",
10
+ "description": "Aggregates keep state private; mutate through methods."
11
+ },
12
+ {
13
+ "id": "always-valid-factory",
14
+ "sensor": "always-valid-factory",
15
+ "mode": "advisory",
16
+ "description": "Prefer private constructors with static factories for aggregates."
17
+ },
18
+ {
19
+ "id": "events-on-mutation",
20
+ "sensor": "domain-event-on-mutation",
21
+ "mode": "advisory",
22
+ "description": "Domain mutations should guard invariants or publish events."
23
+ },
24
+ {
25
+ "id": "no-anemic-model",
26
+ "sensor": "no-anemic-model",
27
+ "mode": "advisory",
28
+ "description": "Prefer rich domain types over data-only bags (advisory only)."
29
+ }
30
+ ],
31
+ "invariants": []
32
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",
3
+ "schemaVersion": "1.0",
4
+ "layer": "PersistenceAdapters",
5
+ "structure": [
6
+ {
7
+ "id": "thin-adapter",
8
+ "sensor": "thin-adapter",
9
+ "mode": "advisory",
10
+ "description": "Persistence adapters implement ports without domain branching."
11
+ }
12
+ ],
13
+ "invariants": []
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",
3
+ "schemaVersion": "1.0",
4
+ "layer": "PresentationAdapters",
5
+ "structure": [
6
+ {
7
+ "id": "thin-adapter",
8
+ "sensor": "thin-adapter",
9
+ "mode": "advisory",
10
+ "description": "Adapters stay thin: map I/O and delegate; avoid domain branching + persistence here."
11
+ }
12
+ ],
13
+ "invariants": []
14
+ }
@@ -29,6 +29,29 @@ when design smells remain after the contract is honest.
29
29
  | **Exploratory** | walk the real monorepo/app layout; reclassify; mine rules; suggest shape |
30
30
 
31
31
 
32
+
33
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
34
+
35
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
36
+
37
+ | Plane | What it protects | Where it lives | Sensors / tools |
38
+ |-------|------------------|----------------|-----------------|
39
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
40
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
41
+
42
+ **Rules for every report / answer:**
43
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
44
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
45
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
46
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
47
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
48
+
49
+
50
+ ### Adopt + ArkRules
51
+ - After classify: emit or refresh `arkRules` for matched layers (exact names; generic mold for unknowns).
52
+ - Mine rules → inventory + propose invariants/structure; land via `/ark-contract`.
53
+ - Freeze baseline is **[Layer]** debt; inventory residual is **[ArkRules]** — report both.
54
+
32
55
  ## Subagent fan-out (optional, host-dependent)
33
56
 
34
57
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -85,7 +108,10 @@ Ark protects the **boundary around** a framework, not its internals. Nest/DI pub
85
108
  add layers/patterns via `/ark-contract`.
86
109
  4. **Mine business rules → manifiesto** (model job — this is why the skill exists):
87
110
  - Scan for loose domain: validators, pricing/policy functions, `can*`/`calculate*`, magic business constants, publish/intent strings, logic in UI/hooks that belongs in Domain.
88
- - Propose: Domain files, `intentPrefixes`, intent names (`Domain.*` / `Application.*`), kernel `defineIntent` stubs if runtime is used.
111
+ - **ArkRules inventory (AR13):** run `ark-check --rules-inventory --json` for deterministic candidates
112
+ (validation-in-controller, magic constants, anemic entities). Counts are **not a score**.
113
+ - Propose: Domain files, `intentPrefixes`, intent names (`Domain.*` / `Application.*`), kernel `defineIntent` stubs if runtime is used;
114
+ land structure/invariant entries under `arkrules/<Layer>.json` via `/ark-contract` (ADR 0015 routing).
89
115
  - Apply config through `/ark-contract` discipline; move pure rules into Domain when safe; validate with ark-check.
90
116
  - Deliver section **“Así te lo re-soluciono en el manifiesto”** with before/after contract snippets.
91
117
  5. **Freeze only real debt** — `--update-baseline` (zero debt → **no empty baseline file** left behind).
@@ -126,6 +152,7 @@ End with **exactly** these headings (markdown `###`):
126
152
  - **Sensor:** commands/tools run
127
153
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
128
154
  - **Result:** one-line outcome
155
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
129
156
  - **Handoff:** `/ark-…` / CLI / `none`
130
157
  - **Incomplete?** `no` | `yes — <what is missing>`
131
158
 
@@ -30,6 +30,28 @@ package manager (`pnpm exec`, `yarn`, `npx`) — match the lockfile.
30
30
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
31
31
 
32
32
 
33
+
34
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
35
+
36
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
37
+
38
+ | Plane | What it protects | Where it lives | Sensors / tools |
39
+ |-------|------------------|----------------|-----------------|
40
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
41
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
42
+
43
+ **Rules for every report / answer:**
44
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
45
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
46
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
47
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
48
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
49
+
50
+
51
+ ### Architect + ArkRules
52
+ - Preset/init should emit lean `arkRules` + templates for phase-1 layers (exact names).
53
+ - Explain to the user: layers = boundaries; arkrules = habits inside Domain/App/adapters (opt-in, start advisory).
54
+
33
55
  ## Subagent fan-out (optional, host-dependent)
34
56
 
35
57
  If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
@@ -135,6 +157,7 @@ End with **exactly** these headings (markdown `###`):
135
157
  - **Sensor:** commands/tools run
136
158
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
137
159
  - **Result:** one-line outcome
160
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
138
161
  - **Handoff:** `/ark-…` / CLI / `none`
139
162
  - **Incomplete?** `no` | `yes — <what is missing>`
140
163
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-autopilot
3
- description: Guided end-to-end path — doctor next action when unsure. Explore first; dual plan A (edges) + B (shape); mechanical-safe only by default; B with user OK, one pilot at a time. Empty plan A is not healthy if design-weak. CLI is a sensor; you read and remediate files.
3
+ description: Guided end-to-end path for layers and opt-in ArkRules — doctor next action when unsure. Explore first; dual plan A (edges) + B (shape); mechanical-safe only by default; B with user OK, one pilot at a time. Empty plan A is not healthy if design-weak. CLI is a sensor; you read and remediate files.
4
4
  ---
5
5
 
6
6
  # /ark-autopilot — Guided end-to-end architecture path
@@ -64,6 +64,31 @@ decision-grade explore pass **and** without opening violating files.
64
64
  optional `reviewBy` in `.ark/reshape-decisions.json`; never infer a verdict from golden prose.
65
65
 
66
66
 
67
+
68
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
69
+
70
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
71
+
72
+ | Plane | What it protects | Where it lives | Sensors / tools |
73
+ |-------|------------------|----------------|-----------------|
74
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
75
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
76
+
77
+ **Rules for every report / answer:**
78
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
79
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
80
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
81
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
82
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
83
+
84
+
85
+ ### Autopilot + ArkRules
86
+ - After explore/doctor: if inventory has high-confidence candidates **or** user wants domain rules, include **[ArkRules] plan A/B**:
87
+ - A: mechanical-safe remains inter-layer only; structure/invariant fixes are **judgment**.
88
+ - B: one pilot = one rule (declare in `arkrules/<Layer>.json` → implement → test title/symbol → re-doctor).
89
+ - Never promote advisory→enforced without coverage evidence (`canPromoteInvariant` / policy-delta).
90
+ - End report must list what was **layer-edge** work vs **intra-layer rule** work.
91
+
67
92
  ## Subagent fan-out (optional, host-dependent)
68
93
 
69
94
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -200,6 +225,7 @@ End with **exactly** these headings (markdown `###`):
200
225
  - **Sensor:** commands/tools run
201
226
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
202
227
  - **Result:** one-line outcome
228
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
203
229
  - **Handoff:** `/ark-…` / CLI / `none`
204
230
  - **Incomplete?** `no` | `yes — <what is missing>`
205
231
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-contract
3
- description: Safely edit ark.config.json (layers, rules, forbiddenGlobals, intent prefixes) and land business rules into the Ark manifest. Validated with strict ark-check. Deep source evidence required.
3
+ description: Safely edit ark.config.json layers/rules and arkrules/* (structure + invariants); land business rules under the dual plane. Validated with strict ark-check. Deep source evidence required.
4
4
  ---
5
5
 
6
6
  # /ark-contract — Change the architecture contract (safely)
@@ -26,6 +26,29 @@ Also used to **land mined business rules** into the executable manifest (`ark.co
26
26
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
27
27
 
28
28
 
29
+
30
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
31
+
32
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
33
+
34
+ | Plane | What it protects | Where it lives | Sensors / tools |
35
+ |-------|------------------|----------------|-----------------|
36
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
37
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
38
+
39
+ **Rules for every report / answer:**
40
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
41
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
42
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
43
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
44
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
45
+
46
+
47
+ ### Contract + ArkRules
48
+ - You own **both** `layers/rules` and `arkRules`/`arkrules/*.json`.
49
+ - Report diffs in two blocks: **[Layer] config** and **[ArkRules] files**.
50
+ - Promotion ladder: advisory→enforced only with coverage; demote = hash-ack weakening.
51
+
29
52
  ## Subagent fan-out (optional, host-dependent)
30
53
 
31
54
  If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
@@ -54,6 +77,8 @@ the same files or weaken the gate.
54
77
  - `include` / `exclude`
55
78
  - `layers[]` (`name`, `patterns`, `optional`, `forbiddenGlobals`, `intentPrefixes`, layer `exclude`)
56
79
  - `rules[]` (from/to/allowed)
80
+ - **`arkRules` map + `arkrules/<Layer>.json`** (ADR 0012/0014) — structure sensors + invariant catalog;
81
+ promote advisory→enforced only with coverage evidence; demote/delete requires hash-bound policy ack
57
82
  - Never: disable the check, delete CI gates, or add blanket `allowed: true` for a bad edge without a facade design
58
83
 
59
84
  ## Steps
@@ -93,6 +118,7 @@ End with **exactly** these headings (markdown `###`):
93
118
  - **Sensor:** commands/tools run
94
119
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
95
120
  - **Result:** one-line outcome
121
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
96
122
  - **Handoff:** `/ark-…` / CLI / `none`
97
123
  - **Incomplete?** `no` | `yes — <what is missing>`
98
124
 
@@ -42,6 +42,28 @@ Shape ladder by default. If the tree is design-weak under ENFORCE, **handoff** t
42
42
  If you did not open source files, the skill is **not complete**.
43
43
  Full recon + pattern planning: `/ark-explore`.
44
44
 
45
+
46
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
47
+
48
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
49
+
50
+ | Plane | What it protects | Where it lives | Sensors / tools |
51
+ |-------|------------------|----------------|-----------------|
52
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
53
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
54
+
55
+ **Rules for every report / answer:**
56
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
57
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
58
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
59
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
60
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
61
+
62
+
63
+ ### Coverage + ArkRules
64
+ - Fitness report: governed% / gates / baseline = **[Layer]**; `rulesUnderContract` inventoried/under-contract/frozen = **[ArkRules]** (counts, never a score).
65
+ - Capability gap: “no arkRules map” is optional adoption opportunity, not a failed gate.
66
+
45
67
  ## Subagent fan-out (optional, host-dependent)
46
68
 
47
69
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -128,6 +150,7 @@ End with **exactly** these headings (markdown `###`):
128
150
  - **Sensor:** commands/tools run
129
151
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
130
152
  - **Result:** one-line outcome
153
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
131
154
  - **Handoff:** `/ark-…` / CLI / `none`
132
155
  - **Incomplete?** `no` | `yes — <what is missing>`
133
156
 
@@ -26,6 +26,28 @@ Your job is to **teach with this repo's real data** and leave a shareable visual
26
26
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
27
27
 
28
28
 
29
+
30
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
31
+
32
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
33
+
34
+ | Plane | What it protects | Where it lives | Sensors / tools |
35
+ |-------|------------------|----------------|-----------------|
36
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
37
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
38
+
39
+ **Rules for every report / answer:**
40
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
41
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
42
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
43
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
44
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
45
+
46
+
47
+ ### Explain + ArkRules
48
+ - HTML/plain tour: section **Layers** and section **ArkRules** (structure + invariants + residual).
49
+ - Never merge them into one “architecture score.”
50
+
29
51
  ## Subagent fan-out (optional, host-dependent)
30
52
 
31
53
  If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
@@ -147,6 +169,7 @@ End with **exactly** these headings (markdown `###`):
147
169
  - **Sensor:** commands/tools run (include report + browser-open command when used)
148
170
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
149
171
  - **Result:** one-line outcome (include `ark-report.html` path; note if browser open was attempted)
172
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
150
173
  - **Handoff:** `/ark-…` / CLI / `none`
151
174
  - **Incomplete?** `no` | `yes — <what is missing>`
152
175
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-explore
3
- description: Specialized map skill — decision-grade recon + dual-plan seed (no apply). Primary post-green door when design-weak. Not the default day-to-day path (use doctor + place/gate; guided apply is /ark-autopilot). CLI is a sensor; you read the tree. No gate bypass.
3
+ description: Specialized map skill — decision-grade recon of layers + ArkRules opportunities + dual-plan seed (no apply). Primary post-green door when design-weak. Not the default day-to-day path (use doctor + place/gate; guided apply is /ark-autopilot). CLI is a sensor; you read the tree. No gate bypass.
4
4
  ---
5
5
 
6
6
  # /ark-explore — Recon the real project (map only)
@@ -67,6 +67,30 @@ that still matters (dogfood gaps, soft starters, identity drift, **semantic fals
67
67
  **design-weak under ENFORCE**, coupling that blocks evolution). If residual is truly none,
68
68
  say so in one line and hand off `stop`.
69
69
 
70
+
71
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
72
+
73
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
74
+
75
+ | Plane | What it protects | Where it lives | Sensors / tools |
76
+ |-------|------------------|----------------|-----------------|
77
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
78
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
79
+
80
+ **Rules for every report / answer:**
81
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
82
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
83
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
84
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
85
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
86
+
87
+
88
+ ### Explore + ArkRules
89
+ - Always run sensors for **both** planes when present: coverage/doctor **and** `--rules-inventory` if `arkRules` exists or brownfield may hide spaghetti rules.
90
+ - Ranked table kinds may include `arkrules-opportunity` and `invariant-gap`.
91
+ - Dual-plan **B** may include: place advisory structure rules, extract one inventory candidate to Domain + `arkrules` entry, promote one covered invariant.
92
+ - Field path: note whether starters emit `arkrules/*`.
93
+
70
94
  ## Output mode (pick one — do not invent a fourth)
71
95
 
72
96
  | Mode | When | Deliverable |
@@ -316,6 +340,7 @@ End with **exactly** these headings (markdown `###`):
316
340
  - **Sensor:** commands/tools run
317
341
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
318
342
  - **Result:** one-line outcome
343
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
319
344
  - **Handoff:** `/ark-…` / CLI / `none`
320
345
  - **Incomplete?** `no` | `yes — <what is missing>`
321
346
 
@@ -40,6 +40,28 @@ Next: re-run ark-check; shrink baseline if applicable
40
40
  | **Exploratory** | Why this edge exists in *this* product; better home; manifiesto if the rule is business |
41
41
 
42
42
 
43
+
44
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
45
+
46
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
47
+
48
+ | Plane | What it protects | Where it lives | Sensors / tools |
49
+ |-------|------------------|----------------|-----------------|
50
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
51
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
52
+
53
+ **Rules for every report / answer:**
54
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
55
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
56
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
57
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
58
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
59
+
60
+
61
+ ### Fix + ArkRules
62
+ - Classify each violation: `LAYER_*` / capability → **[Layer]**; `ARKRULE_*` / `INVARIANT_*` → **[ArkRules]**.
63
+ - Structure sensor fixes are judgment (ports, factories, private state) — not mechanical-safe.
64
+
43
65
  ## Subagent fan-out (optional, host-dependent)
44
66
 
45
67
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -135,6 +157,7 @@ End with **exactly** these headings (markdown `###`):
135
157
  - **Sensor:** commands/tools run
136
158
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
137
159
  - **Result:** one-line outcome
160
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
138
161
  - **Handoff:** `/ark-…` / CLI / `none`
139
162
  - **Incomplete?** `no` | `yes — <what is missing>`
140
163
 
@@ -41,6 +41,28 @@ Pattern bets always have `neverMechanicalSafe: true` — extraction cards only
41
41
  | **Exploratory** | Read sources; detect concentrated edges / false-green / wrong layer home before grinding |
42
42
 
43
43
 
44
+
45
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
46
+
47
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
48
+
49
+ | Plane | What it protects | Where it lives | Sensors / tools |
50
+ |-------|------------------|----------------|-----------------|
51
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
52
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
53
+
54
+ **Rules for every report / answer:**
55
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
56
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
57
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
58
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
59
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
60
+
61
+
62
+ ### Loop + ArkRules
63
+ - Drive plan to zero **active** debt on the plane the user cares about; keep **[Layer]** and **[ArkRules]** queues separate.
64
+ - One pilot at a time for ArkRules extraction cards (`pilotLoop` / inventory).
65
+
44
66
  ## Subagent fan-out (optional, host-dependent)
45
67
 
46
68
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -141,6 +163,7 @@ End with **exactly** these headings (markdown `###`):
141
163
  - **Sensor:** commands/tools run
142
164
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
143
165
  - **Result:** one-line outcome
166
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
144
167
  - **Handoff:** `/ark-…` / CLI / `none`
145
168
  - **Incomplete?** `no` | `yes — <what is missing>`
146
169
 
@@ -35,6 +35,28 @@ not a stalling question.
35
35
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
36
36
 
37
37
 
38
+
39
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
40
+
41
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
42
+
43
+ | Plane | What it protects | Where it lives | Sensors / tools |
44
+ |-------|------------------|----------------|-----------------|
45
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
46
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
47
+
48
+ **Rules for every report / answer:**
49
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
50
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
51
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
52
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
53
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
54
+
55
+
56
+ ### Place + ArkRules
57
+ - Choose layer from contract **and** check structure sensors for that layer (private state, factory, thin adapter).
58
+ - Scaffold to satisfy **[ArkRules]** when present; state which sensors apply.
59
+
38
60
  ## Subagent fan-out (optional, host-dependent)
39
61
 
40
62
  If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
@@ -56,6 +78,9 @@ the same files or weaken the gate.
56
78
  if present, is authoritative too.
57
79
  2. **Classify the artifact** by what it does, not what it's called:
58
80
  - Pure business rules/entities/value objects → domain-model layer.
81
+ - When Domain ArkRules require private state / factories (`aggregate-private-state`,
82
+ `always-valid-factory`), scaffold private fields + static factory — do not emit public
83
+ mutable aggregates.
59
84
  - Orchestrates a use case, no I/O of its own → application layer.
60
85
  - Talks to a database, queue, API, filesystem → an adapter layer on the side
61
86
  that matches the direction (driven/persistence vs driving/http).
@@ -118,6 +143,7 @@ End with **exactly** these headings (markdown `###`):
118
143
  - **Sensor:** commands/tools run
119
144
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
120
145
  - **Result:** one-line outcome
146
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
121
147
  - **Handoff:** `/ark-…` / CLI / `none`
122
148
  - **Incomplete?** `no` | `yes — <what is missing>`
123
149
 
@@ -25,6 +25,10 @@ one feature at a time.
25
25
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
26
26
 
27
27
 
28
+ ## Out of scope for ArkRules
29
+
30
+ This skill is **runtime-kernel only**. Do not mix ArkRules structure/invariants here; hand off to `/ark-contract` / `/ark-adopt` / `/ark-explore` for static contract planes.
31
+
28
32
  ## Subagent fan-out (optional, host-dependent)
29
33
 
30
34
  If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-think
3
- description: Host-side architectural reasoning — 2–3 enforceable options from real code + contract for ONE decision. Not full recon (use /ark-explore). No gate bypass. No package LLM call.
3
+ description: Host-side architectural reasoning — 2–3 enforceable options on layer and/or ArkRules planes for ONE decision. Not full recon (use /ark-explore). No gate bypass. No package LLM call.
4
4
  ---
5
5
 
6
6
  # /ark-think — Architectural reasoning (host LLM only)
@@ -30,6 +30,28 @@ If you lack a product map and the tree is messy: run a **compressed** explore pa
30
30
 
31
31
  Never reason only from abstract hexagons. Open real modules before recommending a shape.
32
32
 
33
+
34
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
35
+
36
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
37
+
38
+ | Plane | What it protects | Where it lives | Sensors / tools |
39
+ |-------|------------------|----------------|-----------------|
40
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
41
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
42
+
43
+ **Rules for every report / answer:**
44
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
45
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
46
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
47
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
48
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
49
+
50
+
51
+ ### Think + ArkRules
52
+ - For ONE decision, consider options on **both** planes when relevant: e.g. new layer wall **vs** structure sensor **vs** invariant catalog entry.
53
+ - Every option must state enforceability: which plane holds it after the change.
54
+
33
55
  ## Subagent fan-out (optional, host-dependent)
34
56
 
35
57
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -91,6 +113,7 @@ End with **exactly** these headings (markdown `###`):
91
113
  - **Sensor:** commands/tools run
92
114
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
93
115
  - **Result:** one-line outcome
116
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
94
117
  - **Handoff:** `/ark-…` / CLI / `none`
95
118
  - **Incomplete?** `no` | `yes — <what is missing>`
96
119
 
@@ -19,6 +19,28 @@ Use the semantic sensor (`ark-check --doctor --json` plus the strict contract
19
19
  check) and direct inspection of every managed file the preview will change.
20
20
  Neither signal replaces the other.
21
21
 
22
+
23
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
24
+
25
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
26
+
27
+ | Plane | What it protects | Where it lives | Sensors / tools |
28
+ |-------|------------------|----------------|-----------------|
29
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
30
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
31
+
32
+ **Rules for every report / answer:**
33
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
34
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
35
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
36
+ 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
37
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
38
+
39
+
40
+ ### Upgrade + ArkRules
41
+ - Refresh skills + note if templates gained ArkRules deepen; do not force consumers to adopt `arkRules`.
42
+ - After upgrade: doctor `rulesUnderContract` if map exists; dual-truth note if `--no-install` left package pin old.
43
+
22
44
  ## Safety contract
23
45
 
24
46
  - `ark upgrade` is read-only. It reports the selected profile and hosts, every
@@ -133,6 +155,7 @@ End with exactly this structure:
133
155
  - **Active host:** host and verified status
134
156
  - **Deferred hosts:** `none` or host plus future action
135
157
  - **Result:** old → new version and managed-upgrade outcome
158
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
136
159
  - **Handoff:** `/ark-…`, CLI action, or `none`
137
160
  - **Incomplete?** `no` or `yes — <missing work>`
138
161
 
package/compat/nestjs.cjs DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- module.exports = require('@arkgate/runtime/nestjs');
@@ -1,2 +0,0 @@
1
- /** @deprecated Install `@arkgate/runtime` and import from `@arkgate/runtime/nestjs`. */
2
- export * from '@arkgate/runtime/nestjs';