arkgate 4.8.5 → 4.8.7

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 (71) hide show
  1. package/CHANGELOG.md +56 -2
  2. package/README.md +16 -9
  3. package/bin/ark-mcp-runtime.mjs +8 -2
  4. package/bin/lib/analysis-engine.mjs +5 -5
  5. package/bin/lib/ark-order-invariants.mjs +163 -14
  6. package/bin/lib/ark-order-types.mjs +3 -0
  7. package/bin/lib/diagnostic-catalog.mjs +5 -4
  8. package/bin/lib/doctor-human.mjs +9 -0
  9. package/bin/lib/doctor-plan.mjs +5 -1
  10. package/bin/lib/html-report.mjs +4 -2
  11. package/bin/lib/layer-description.mjs +27 -0
  12. package/bin/lib/prepare-write.mjs +7 -1
  13. package/bin/lib/remediation.mjs +11 -5
  14. package/dist/{configTypes-dy5PfTqS.d.ts → configTypes-0eHpocR3.d.ts} +4 -0
  15. package/dist/{diagnosticCatalog-DMO30svh.d.ts → diagnosticCatalog-wDAH08gH.d.ts} +3 -3
  16. package/dist/eslint/index.cjs +1 -1
  17. package/dist/eslint/index.d.ts +1 -1
  18. package/dist/eslint/index.js +1 -1
  19. package/dist/index.cjs +19 -19
  20. package/dist/index.d.ts +5 -4
  21. package/dist/index.js +20 -20
  22. package/dist/nestjs/index.cjs +5 -5
  23. package/dist/nestjs/index.d.ts +3 -3
  24. package/dist/nestjs/index.js +5 -5
  25. package/dist/order/index.cjs +1 -1
  26. package/dist/order/index.d.ts +61 -10
  27. package/dist/order/index.js +1 -1
  28. package/dist/runtime/index.cjs +11 -11
  29. package/dist/runtime/index.d.ts +6 -6
  30. package/dist/runtime/index.js +11 -11
  31. package/dist/{types-BuM8WNqe.d.ts → types-BK47clMl.d.ts} +1 -1
  32. package/dist/{types-CzE6LMaW.d.ts → types-CwZ_oz1N.d.ts} +22 -7
  33. package/docs/README.md +5 -4
  34. package/docs/agent-guide.md +2 -0
  35. package/docs/ai-gates.md +5 -2
  36. package/docs/arkorder.md +32 -14
  37. package/docs/configuration.md +28 -5
  38. package/docs/develop.md +7 -2
  39. package/docs/diagnostics.md +15 -5
  40. package/docs/package-surface.md +18 -12
  41. package/docs/product-voice.md +3 -3
  42. package/docs/use.md +1 -1
  43. package/package.json +1 -1
  44. package/server.json +2 -2
  45. package/templates/agent-skills/README.md +1 -1
  46. package/templates/agent-skills/ark-adopt/SKILL.md +22 -5
  47. package/templates/agent-skills/ark-architect/SKILL.md +1 -1
  48. package/templates/agent-skills/ark-autopilot/SKILL.md +4 -4
  49. package/templates/agent-skills/ark-contract/SKILL.md +1 -1
  50. package/templates/agent-skills/ark-coverage/SKILL.md +3 -2
  51. package/templates/agent-skills/ark-explain/SKILL.md +3 -2
  52. package/templates/agent-skills/ark-explore/SKILL.md +3 -2
  53. package/templates/agent-skills/ark-fix/SKILL.md +1 -1
  54. package/templates/agent-skills/ark-loop/SKILL.md +1 -1
  55. package/templates/agent-skills/ark-place/SKILL.md +25 -12
  56. package/templates/agent-skills/ark-runtime/SKILL.md +3 -0
  57. package/templates/agent-skills/ark-think/SKILL.md +2 -2
  58. package/templates/agent-skills/ark-upgrade/SKILL.md +2 -2
  59. package/templates/skills/ark-adopt.md +22 -5
  60. package/templates/skills/ark-architect.md +1 -1
  61. package/templates/skills/ark-autopilot.md +4 -4
  62. package/templates/skills/ark-contract.md +1 -1
  63. package/templates/skills/ark-coverage.md +3 -2
  64. package/templates/skills/ark-explain.md +3 -2
  65. package/templates/skills/ark-explore.md +3 -2
  66. package/templates/skills/ark-fix.md +1 -1
  67. package/templates/skills/ark-loop.md +1 -1
  68. package/templates/skills/ark-place.md +25 -12
  69. package/templates/skills/ark-runtime.md +3 -0
  70. package/templates/skills/ark-think.md +2 -2
  71. package/templates/skills/ark-upgrade.md +2 -2
@@ -43,7 +43,7 @@ Atomic multi-file work uses **`ark_prepare_change`** with the same matched `proj
43
43
 
44
44
  ## Dual plane — layers + extras (mandatory, except /ark-runtime)
45
45
 
46
- Label findings **`[Layer]`** vs **`[ArkRules]`** vs **`[ArkRun]`** vs **`[ArkOrder]`**. Absence of extras is valid and silent. Extra skip clusters (`ARKRUN_*` / `ARKORDER_*`) are **`/ark-autopilot`**. Never invent `mechanical-safe` kinds. Do not invent `/ark-run` or `/ark-order`. Skills never enforce.
46
+ Label findings **`[Layer]`** vs **`[ArkRules]`** vs **`[ArkRun]`** vs **`[ArkOrder]`**. Absence of extras is valid and silent. Extra skip clusters (`ARKRUN_*` / `ARKORDER_*`) are **`/ark-autopilot`**. When ArkOrder is on: later ξ is `proposeRelease` then `apply`; `refreshSigma`; ingest residual `absorb | escalate_up | hold`; capacity pack as data; in-memory `ReleaseStore`; ArkRun `decisionTape`. Never invent `mechanical-safe` kinds. Do not invent `/ark-run` or `/ark-order`. Skills never enforce.
47
47
 
48
48
  ## Subagent fan-out (optional, host-dependent)
49
49
 
@@ -19,13 +19,15 @@ description: "Where does new code go? Names the folder from the rules file and w
19
19
  - `filePath` is known before the call. Description alone is not a path.
20
20
  - Golden pattern is load-bearing when present. Adopt generates it.
21
21
  - Do not default a repository to Presentation.
22
+ - When the matched layer has `layers[].description`, print that caption next to the
23
+ layer name and globs. Omit when absent — do not invent a caption or `/ark-describe`.
22
24
  - When `arkRun` is on: scaffold through the kernel (no `new` of managed types; declare
23
25
  `uses` / `reactsTo` / `raises` / `sends`; factory only in `arkRun.kernelRoots`,
24
26
  `compositionRoots` alias). Extra off → do not introduce the kernel. Enable it
25
27
  via `/ark-adopt`. Skills never enforce.
26
28
  - When `arkOrder` is on: factory only in `arkOrder.planeRoots`; Domain stays plane-free;
27
- freeze ξ with `release()`. Extra off do not introduce the plane. Enable it via
28
- `/ark-adopt`. Skills never enforce.
29
+ first freeze ξ with `release()`; later ξ is `proposeRelease` then `apply`. Extra off
30
+ → do not introduce the plane. Enable it via `/ark-adopt`. Skills never enforce.
29
31
 
30
32
  ## Autonomy contract
31
33
 
@@ -57,6 +59,12 @@ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement f
57
59
 
58
60
  **Where so the AI doesn’t mess up next time** — golden pattern + layer home before the write.
59
61
 
62
+ ## Layer captions (process)
63
+
64
+ When `ark_place` / the contract includes `layers[].description`, print that caption
65
+ next to the layer name and globs. Omit it when the field is absent. Do **not** invent
66
+ a caption or `/ark-describe`.
67
+
60
68
  ## Deep modules (process)
61
69
 
62
70
  - Place so new code stays **deep**: one small public surface per concern; hide implementation details.
@@ -80,7 +88,8 @@ and — if they asked to build it — scaffold it there correctly.
80
88
  **No artifact given?** If the skill is invoked with nothing to place, don't error
81
89
  and don't guess — the artifact is the one thing only the user knows. Read the
82
90
  contract (step 1) and print the placement map from it: one row per declared layer
83
- with what belongs there, its directory, and which layers it may/may not import,
91
+ with layer name, globs, and `layers[].description` when present (omit when absent),
92
+ what belongs there, its directory, and which layers it may/may not import,
84
93
  plus the not-yet-adopted `suggestedLayers` as a footnote. Then ask what they want
85
94
  to place. That map is derived entirely from the repo, so producing it is real work,
86
95
  not a stalling question.
@@ -113,8 +122,8 @@ ArkGate has **always-on Layers** plus opt-in extras. The user chooses extras; yo
113
122
  |-------|------------------|----------------|-----------------|
114
123
  | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
115
124
  | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
116
- | **ArkRun** (extra) | Kernel usage + complete declarations | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
117
- | **ArkOrder** (extra) | Operational pattern (ξ vs s) | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
125
+ | **ArkRun** (extra) | Kernel usage + complete declarations; information package `decisionTape` `{ xiHash, event, residual }` | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
126
+ | **ArkOrder** (extra) | Operational pattern (ξ vs s). Valve: first `release()`, later ξ is `proposeRelease` then `apply`; `refreshSigma`; ingest residual `absorb \| escalate_up \| hold` + `reasonCode`; capacity pack as data; in-memory `ReleaseStore` | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
118
127
 
119
128
  **Rules for every report / answer:**
120
129
  1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** or **`[ArkRun]`** or **`[ArkOrder]`** (or a table with those headers).
@@ -123,7 +132,7 @@ ArkGate has **always-on Layers** plus opt-in extras. The user chooses extras; yo
123
132
  4. Missing layer home: add it via **`/ark-adopt`** in this session if needed, then write the file; never invent `mechanical-safe`.
124
133
  5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
125
134
  6. Absence of `arkRun` is **valid**. Do not introduce the kernel speculatively. Skills never enforce this extra.
126
- 7. Absence of `arkOrder` is **valid**. When on: Domain stays plane-free; freeze ξ with `release()`; never `update`/`patch`/`set` the pattern. Import `createOrderPlane` from `arkgate/order` (same npm package). No `/ark-order` skill.
135
+ 7. Absence of `arkOrder` is **valid**. When on: Domain stays plane-free; first freeze ξ with `release()`; later ξ is `proposeRelease` then `apply`; never `update`/`patch`/`set` the pattern. Import `createOrderPlane` from `arkgate/order` (same npm package). No `/ark-order` skill.
127
136
 
128
137
 
129
138
  ### Place + ArkRules
@@ -138,16 +147,16 @@ When `arkRun` is present on the architecture config:
138
147
  - Domain-role files stay kernel-free (`ARKRUN_KERNEL_IN_DOMAIN`). Import from `arkgate/runtime` (or `arkgate/nestjs`). `@arkgate/runtime` is deprecated.
139
148
  - List `uses` / `reactsTo` / `raises` / `sends` when `requireDeclarations` is on. Adding an existing call-site literal to the declaration list is the only mechanical-safe ArkRun edit; inventing a new emit / handle / depend is judgment.
140
149
  - Do not import a homemade bus (`EventEmitter`, queue clients) in `managedLayers` — send on the kernel transport (`local` / `localBlocking` / `broker`; `ephemeral` defaults true). No shipped cloud SDKs.
141
- - In-memory stores are **not** production durability. Doctor `arkRun` is `notAScore`.
150
+ - In-memory stores are **not** production durability. Doctor `arkRun` is `notAScore`. Information package may carry `decisionTape` `{ xiHash, event, residual }` (`appendDecisionTape`). Not a bus. Not durable.
142
151
  - Absence of the extra: place with **[Layer]** + **[ArkRules]** only. Enable advisory extra via `/ark-adopt`; evaluate a hand-rolled bus via `/ark-runtime`. Do not invent `/ark-run`.
143
152
  - Skills never enforce.
144
153
 
145
154
  ### Place + ArkOrder
146
155
  When `arkOrder` is present on the architecture config:
147
156
  - Import `createOrderPlane` from `arkgate/order` (same npm package). Domain-role files stay plane-free.
148
- - Freeze ξ with `release()`; derive s with `project()`; field `ingest()` never mints a pattern; `proposeRelease()` needs a non-empty blast. There is no `update`/`patch`/`set`.
157
+ - First freeze ξ with `release()`; later ξ change is `proposeRelease` then `apply` (`ARKORDER_UNVALVED_RELEASE`). `refreshSigma` for saldo. Field `ingest()` returns `absorb | escalate_up | hold` bound to `xiHash` + `reasonCode`; never a Release. Capacity pack as data; `createMemoryReleaseStore`; `ingestTravelAction`; ArkRun `decisionTape`. No `update`/`patch`/`set`.
149
158
  - Call the factory only inside `arkOrder.planeRoots`. Empty roots in `enforced` mode is `ARKORDER_MISSING_PLANE`.
150
- - Named slow keys live in `arkOrder.xiKeys`. A managed-layer Prisma/pg write of those keys is `ARKORDER_XI_FIELD_WRITE` — absorb with `ingest` or change the pattern with `proposeRelease`.
159
+ - Named slow keys live in `arkOrder.xiKeys`. A managed-layer Prisma/pg write of those keys is `ARKORDER_XI_FIELD_WRITE` — absorb with `ingest` or change the pattern with `proposeRelease` then `apply`.
151
160
  - Skip clusters (`ARKORDER_MISSING_PLANE` / `ARKORDER_KERNEL_IN_DOMAIN` / `ARKORDER_GENERIC_UPDATE` / `ARKORDER_TOO_MANY_PARAMS` / `ARKORDER_INGEST_WRITES_XI` / `ARKORDER_XI_FIELD_WRITE`): place this artifact, then grind via `/ark-autopilot`. Extra not on → `/ark-adopt`. Do not invent `/ark-order`.
152
161
  - Absence of the extra is valid. Do not invent `/ark-order`. Skills never enforce.
153
162
 
@@ -164,7 +173,9 @@ the same files or weaken the gate.
164
173
  the mandatory `ark_identity` preflight first, then call **`ark_place`** with the target file
165
174
  path and bound `project` envelope — it returns the layer,
166
175
  its forbidden globals, and exactly which layers the file may / must not import,
167
- straight from the contract (no guessing). When present, also honor optional
176
+ straight from the contract (no guessing). When the matched layer has
177
+ `layers[].description`, print that caption next to the layer name and globs;
178
+ omit it when absent. When present, also honor optional
168
179
  **`goldenPattern`** (from `.ark/golden-pattern.json`) for **NEW code only** —
169
180
  advisory layout norm; never overrides the gate and never clears design-weak.
170
181
  Absent golden is normal. Otherwise load `ark.config.json`; after the matched preflight,
@@ -197,7 +208,8 @@ the same files or weaken the gate.
197
208
  same technical layer are peerIsolation violations.
198
209
  3. **Answer concretely**: layer name, target directory (from the layer's
199
210
  `patterns`), intent-name prefix if the layer declares `intentPrefixes`, and
200
- which layers it may/may not import (from `rules`).
211
+ which layers it may/may not import (from `rules`). When present, print
212
+ `layers[].description` next to the layer name and globs; omit when absent.
201
213
  4. **If the layer isn't adopted yet** (suggested but no directory): write the
202
214
  layer into `ark.config.json` (session-0 honesty — same as `/ark-adopt` for
203
215
  that glob) **then** write the file. Don't silently drop the code into a
@@ -242,7 +254,8 @@ the same files or weaken the gate.
242
254
  ## Verify and report
243
255
 
244
256
  If you created files, run `ark-check --root . --config ark.config.json
245
- --strict-config` and make it pass. Report: placement + why, files created (if
257
+ --strict-config` and make it pass. Report: placement + why (include the caption
258
+ next to layer name and globs when present; omit when absent), files created (if
246
259
  any), and the import rules the new code must respect going forward.
247
260
 
248
261
  ## Completion contract (skill incomplete if missing)
@@ -106,6 +106,9 @@ the same files or weaken the gate.
106
106
  public bind. Snapshots / `requestGraph` (process or technical + Mermaid) are tooling, not a
107
107
  score. `getDependencyInformationPackage()` never includes factories, live instances, or
108
108
  input DTOs.
109
+ - Information package may carry `decisionTape` `{ xiHash, event, residual }` via
110
+ `appendDecisionTape`. Shadow / compare / replay that snapshot in-memory (not a bus, not
111
+ durable). This is still **[ArkRun]** — do not turn the tape into an ArkOrder skill.
109
112
  - In-memory stores lose state on restart — **not** production durability. Note bounded history
110
113
  (`maxHistorySize` 1000) if the hand-rolled version retained everything.
111
114
  6. **Delete the hand-rolled version** once call sites are moved — the point is
@@ -77,8 +77,8 @@ ArkGate has **always-on Layers** plus opt-in extras. The user chooses extras; yo
77
77
  |-------|------------------|----------------|-----------------|
78
78
  | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
79
79
  | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
80
- | **ArkRun** (extra) | Kernel usage + complete declarations | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
81
- | **ArkOrder** (extra) | Operational pattern (ξ vs s) | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
80
+ | **ArkRun** (extra) | Kernel usage + complete declarations; information package `decisionTape` `{ xiHash, event, residual }` | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
81
+ | **ArkOrder** (extra) | Operational pattern (ξ vs s). Valve: first `release()`, later ξ is `proposeRelease` then `apply`; `refreshSigma`; ingest residual `absorb \| escalate_up \| hold` + `reasonCode`; capacity pack as data; in-memory `ReleaseStore` | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
82
82
 
83
83
  **Rules for every report / answer:**
84
84
  1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** or **`[ArkRun]`** or **`[ArkOrder]`** (or a table with those headers).
@@ -124,8 +124,8 @@ ArkGate has **always-on Layers** plus opt-in extras. The user chooses extras; yo
124
124
  |-------|------------------|----------------|-----------------|
125
125
  | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
126
126
  | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
127
- | **ArkRun** (extra) | Kernel usage + complete declarations | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
128
- | **ArkOrder** (extra) | Operational pattern (ξ vs s) | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
127
+ | **ArkRun** (extra) | Kernel usage + complete declarations; information package `decisionTape` `{ xiHash, event, residual }` | `arkRun` on `ark.config.json` (schema `1.2+`); factory `arkgate/runtime`; **`kernelRoots` preferred**, `compositionRoots` alias | `ARKRUN_*`, doctor `arkRun` (`notAScore`) |
128
+ | **ArkOrder** (extra) | Operational pattern (ξ vs s). Valve: first `release()`, later ξ is `proposeRelease` then `apply`; `refreshSigma`; ingest residual `absorb \| escalate_up \| hold` + `reasonCode`; capacity pack as data; in-memory `ReleaseStore` | `arkOrder` on `ark.config.json` (schema `1.3+`); factory `arkgate/order` | `ARKORDER_*` |
129
129
 
130
130
  **Rules for every report / answer:**
131
131
  1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** or **`[ArkRun]`** or **`[ArkOrder]`** (or a table with those headers).