arkgate 4.0.1 → 4.1.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 (52) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +6 -5
  3. package/bin/ark-check-runtime.mjs +244 -25
  4. package/bin/ark-check.mjs +10 -1
  5. package/bin/ark-layer-match.mjs +80 -5
  6. package/bin/ark-shared.mjs +170 -9
  7. package/bin/ark.mjs +52 -5
  8. package/bin/lib/adapter-contract.mjs +7 -1
  9. package/bin/lib/agent-gates.mjs +2 -0
  10. package/bin/lib/analysis-engine.mjs +6 -6
  11. package/bin/lib/arkrules-sensors.mjs +63 -22
  12. package/bin/lib/ci-and-commands.mjs +148 -8
  13. package/bin/lib/core-ratchet.mjs +9 -4
  14. package/bin/lib/doctor-advisories.mjs +8 -1
  15. package/bin/lib/doctor-plan.mjs +277 -59
  16. package/bin/lib/enforcement-honesty.mjs +351 -26
  17. package/bin/lib/enforcement-state.mjs +1 -1
  18. package/bin/lib/field-install.mjs +35 -2
  19. package/bin/lib/html-report-depth.mjs +167 -3
  20. package/bin/lib/html-report.mjs +12 -5
  21. package/bin/lib/install-migrate.mjs +109 -6
  22. package/bin/lib/managed-upgrade.mjs +99 -0
  23. package/bin/lib/presets.mjs +314 -46
  24. package/bin/lib/project-root.mjs +268 -0
  25. package/bin/lib/remediation.mjs +12 -11
  26. package/bin/lib/rules-inventory.mjs +71 -29
  27. package/bin/lib/rules-under-contract.mjs +134 -4
  28. package/bin/lib/start-preview.mjs +48 -14
  29. package/bin/lib/suggestions.mjs +118 -3
  30. package/bin/lib/unavailable-analysis.mjs +2 -0
  31. package/bin/lib/write-path-capabilities.mjs +38 -9
  32. package/dist/eslint/index.cjs +2 -2
  33. package/dist/eslint/index.d.ts +27 -2
  34. package/dist/eslint/index.js +2 -2
  35. package/dist/index.cjs +16 -14
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.js +16 -14
  38. package/docs/README.md +3 -3
  39. package/docs/ai-gates.md +15 -11
  40. package/docs/brownfield-adoption.md +36 -0
  41. package/docs/configuration.md +36 -0
  42. package/docs/package-surface.md +3 -3
  43. package/docs/product-voice.md +7 -0
  44. package/docs/typescript-support.md +9 -5
  45. package/package.json +3 -1
  46. package/server.json +3 -3
  47. package/templates/architecture-playbook.json +3 -0
  48. package/templates/layers/shared-types.starter.json +29 -0
  49. package/templates/skills/ark-adopt.md +2 -0
  50. package/templates/skills/ark-explain.md +5 -0
  51. package/templates/skills/ark-explore.md +21 -1
  52. package/templates/skills/ark-fix.md +16 -5
package/docs/README.md CHANGED
@@ -57,9 +57,9 @@ These are **not** the day-to-day product path. They stay in the repo for evidenc
57
57
  | Field adoption kit (scaffolding, not closed) | [field/](field/) |
58
58
  | Runtime hardening (experimental) | [production-hardening.md](production-hardening.md) |
59
59
 
60
- Current major on npm `latest`: [releases/4.0.0.md](releases/4.0.0.md) (`arkgate@4.0.0` layers + optional **ArkRules**).
61
- Next prepared: [releases/4.0.1.md](releases/4.0.1.md) (`arkgate@4.0.1` — not yet `latest`).
62
- Previous: [releases/3.9.2.md](releases/3.9.2.md) (`arkgate@3.9.2`).
60
+ Current published: [releases/4.0.1.md](releases/4.0.1.md) (`arkgate@4.0.1` on npm `latest`).
61
+ Next prepared: [releases/4.1.0.md](releases/4.1.0.md) (`arkgate@4.1.0` — field product phases + CI PR slim; not published until registry).
62
+ Previous major: [releases/4.0.0.md](releases/4.0.0.md) (`arkgate@4.0.0`).
63
63
  Config: [configuration.md](configuration.md) · Agent skills dual-plane: [agent-guide.md](agent-guide.md).
64
64
 
65
65
  ---
package/docs/ai-gates.md CHANGED
@@ -560,21 +560,25 @@ export default [
560
560
 
561
561
  **Exact layer-edge parity envelope:** the linted production source is on disk, inside
562
562
  `include`, outside configured/generated exclusions, parse-clean, and uses a static
563
- `import`/`export` with a relative literal whose target is also on disk. Inside that envelope,
564
- ESLint uses the same layer glob specificity, rule decision, rule id, severity, and evidence as
565
- the resolved CLI. It reloads `ark.config.json` when its content changes and never invents a
566
- not-yet-created target.
563
+ `import`/`export` with a **relative** or **tsconfig `paths` / `baseUrl` alias** (e.g. `@/*`)
564
+ literal whose target is also on disk. Inside that envelope, ESLint uses the same layer glob
565
+ specificity, rule decision, rule id, and evidence as the resolved CLI. It reloads
566
+ `ark.config.json` when its content changes and never invents a not-yet-created target.
567
567
 
568
- Outside that envelope—path aliases, packages/workspaces, symlinks, CommonJS,
569
- `import = require`, dynamic imports, virtual creates/deletes, unresolved targets, or complete
570
- cross-file candidates—ESLint emits no layer-parity verdict. Use `ark preflight`,
571
- `ark_prepare_change`, the complete ApplyPatch hook, or final strict CI; those paths consume the
572
- canonical resolved facts.
568
+ **Path-alias residual (honest):** simple `paths` + `baseUrl` (including one level of relative
569
+ `extends`) are resolved. Not claimed: TypeScript project references, multi-target path arrays
570
+ beyond the first entry, catch-all `*` mappings, package/workspace bare imports, or symlink
571
+ hops. Those stay CI / preflight / write-gate truth.
572
+
573
+ Outside that envelope—packages/workspaces, symlinks, CommonJS, `import = require`, dynamic
574
+ imports, virtual creates/deletes, unresolved targets, or complete cross-file candidates—ESLint
575
+ emits no layer-parity verdict. Use `ark preflight`, `ark_prepare_change`, the complete
576
+ ApplyPatch hook, or final strict CI; those paths consume the canonical resolved facts.
573
577
 
574
578
  Additional rule notes:
575
579
 
576
- - Relative imports are resolved only to existing on-disk TS/JS targets; package bare imports are left to CI/TS.
577
- - Type-only and value forbidden edges both error (same pass/fail as `arkgate-check`).
580
+ - Relative and tsconfig-aliased imports resolve only to existing on-disk TS/JS targets; package bare imports are left to CI/TS.
581
+ - Value forbidden edges error (same pass/fail as `arkgate-check`). Type-only forbidden edges are **placement debt** (reported with `typeOnly`); merge blocking prefers value edges — align with doctor `typeEdgePolicy`.
578
582
  - `no-forbidden-globals` applies from the file layer’s `forbiddenGlobals`; the `globals` option is only a standalone fallback when no project config applies, never an override that weakens the project contract. Layers without either surface are not inventively restricted. `process` also owns exact value imports of `process` / `node:process`; type-only forms, subpaths, and `child_process` stay excluded. If the same layer also denies the `process` capability, this rule is the single `FORBIDDEN_GLOBAL` voice.
579
583
  - Without `ark.config.json`, `no-domain-infra-imports` emits no contract verdict.
580
584
 
@@ -20,6 +20,42 @@ every ungoverned directory** (harvested from the 11-layer profile + presets; unr
20
20
  ones are flagged for you to classify, never guessed). Keep an existing config; don't
21
21
  regenerate it unasked.
22
22
 
23
+ ### Next.js honesty (default overlays / ui-surface / monorepo)
24
+
25
+ **App Router API routes are Application / use-case shell by default**, not Presentation/UI:
26
+
27
+ | Path | Default layer |
28
+ |------|----------------|
29
+ | `app/api/**`, `src/app/api/**` | **ApplicationOrchestration** (orchestration shell) |
30
+ | `pages/api/**`, `src/pages/api/**` | **ApplicationOrchestration** |
31
+ | UI routes (`app/(…)`, `page.tsx`, `components/**`) | **PresentationAdapters** |
32
+
33
+ Without this split, broad `**/app/**` Presentation patterns push every API handler into UI and
34
+ create a Presentation→Persistence tsunami. Specificity still wins: more-specific Application
35
+ globs beat Presentation. ArkRules stay **opt-in** (not forced on by start/adopt).
36
+
37
+ ### Composition-root / factory modules (optional Application-only)
38
+
39
+ Many brownfield trees park DI composition roots and object factories next to domain code
40
+ (`src/factories/**`, `src/composition/**`, `src/app/container.ts`). Those modules are
41
+ **wiring**, not domain rules:
42
+
43
+ | Pattern | Recommended layer | Why |
44
+ |---------|-------------------|-----|
45
+ | `**/factories/**`, `**/composition/**`, `**/container.ts`, `**/bootstrap.ts` | **ApplicationOrchestration** (or a dedicated optional CompositionRoot layer if you need it) | Constructs aggregates / wires ports; may import Domain + Persistence adapters |
46
+ | Aggregate `static create` / private ctor factories **inside** domain entities | **DomainModel** | Always-valid factory is a domain rule (ArkRules `always-valid-factory`), not composition |
47
+ | NestJS modules / providers | FrameworkAdapters / Application | Framework shell, not Domain |
48
+
49
+ Do **not** map composition roots into DomainModel solely because a file constructs entities —
50
+ that turns honest Application→Domain edges into false Domain purity failures. Prefer:
51
+
52
+ 1. Application patterns that match `**/factories/**` / `**/composition/**` (higher specificity than broad Domain globs), or
53
+ 2. An optional **CompositionRoot** layer that may depend on Domain + Persistence and is
54
+ forbidden as a dependency *from* Domain (mirror Application rules).
55
+
56
+ Field note (S3.1.3): factory-bag composition roots belong in Application (or CompositionRoot),
57
+ not Domain — document the choice in `ark.config.json` rather than freezing factory noise.
58
+
23
59
  ## 2. Diagnose before you freeze
24
60
 
25
61
  ```bash
@@ -107,6 +107,42 @@ Rule fields:
107
107
  when both paths classify. Missing paths, empty slice folders, or unclassifiable slices
108
108
  **fail closed** (deny — cannot prove same-slice).
109
109
 
110
+ ### Type-only edges (placement debt)
111
+
112
+ `import type` / `export type` and pure type-only named bindings are **type placement debt**, not
113
+ runtime coupling. They still appear on the **violations** list with `typeOnly: true`,
114
+ `failsStrict: false`, and adapter diagnostic **severity: warning** so doctor/HTML keep
115
+ `violations.typeOnly` / `typeEdgePolicy` honest — but they **do not** fail merge/exit, library
116
+ `valid`, or preflight the way **value** edges do. **Exception:** `peerIsolation` slice
117
+ boundaries stay hard even for type-only. A value import of a pure-type barrel is still a value
118
+ edge (not soft-skipped). Prefer placing shared types in a **SharedTypes** (or owning) layer
119
+ both sides may import. Optional starter: [`templates/layers/shared-types.starter.json`](../templates/layers/shared-types.starter.json)
120
+ (layer globs + allow rules). Doctor always emits `violations.typeEdgePolicy`; plan groups type-only
121
+ steps under `plan.typeOnlyGroup` when volume is high.
122
+
123
+ ### Next.js API shell (framework overlay / presets)
124
+
125
+ When Next is detected (or `ui-surface` / monorepo patterns apply), **`app/api/**` and
126
+ `pages/api/**` classify as Application orchestration**, not Presentation. UI routes stay
127
+ Presentation. More-specific Application globs win over broad `**/app/**` Presentation patterns.
128
+ See [brownfield adoption](brownfield-adoption.md#nextjs-honesty-default-overlays--ui-surface--monorepo).
129
+
130
+ ### ArkRules dual plane (when `arkRules` is present)
131
+
132
+ | Plane | What it is | Merge teeth |
133
+ |-------|------------|-------------|
134
+ | **Layers** | Inter-layer import graph | Always on |
135
+ | **Structure sensors** | Intra-layer heuristics | Only `mode: "enforced"` |
136
+ | **Invariants** | Catalog + coverage evidence (not a business runtime) | Only enforced + proven-uncovered |
137
+
138
+ Absence of `arkRules` adds **no** extra merge teeth. **Advisory** structure sensors and advisory
139
+ invariants also add **no** merge teeth (FG-ARKRULES-ADVISORY-ONLY) — packing every starter
140
+ `arkrules/*` file does not make merge fail structure alone. Enforced structure/invariants arm
141
+ `mergePlanes.extraMergeTeeth` only when the layer plane is honestly classified
142
+ (governed ≥ 50% and ≥ 1 populated layer); empty classification never gets structure teeth
143
+ (P1M-EXTRATEETH-EMPTY-GRAPH). Structure and invariants **never** merge into one architecture
144
+ score. Doctor exposes `rulesUnderContract.mergePlanes` for which plane can fail.
145
+
110
146
  Safety fields:
111
147
 
112
148
  - `maxTsSuppressions`, `maxAnyCasts`
@@ -189,7 +189,7 @@ production deployment would need to satisfy; it is not a readiness certification
189
189
  ## Release notes (maintainers)
190
190
 
191
191
  Ship notes for a version live under [releases/](https://github.com/pedroknigge/arkgate/tree/main/docs/releases)
192
- (current on npm: [4.0.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.0.md); prepared:
193
- [4.0.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.1.md); previous:
194
- [3.9.2.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/3.9.2.md)).
192
+ (current published: [4.0.1.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.1.md);
193
+ next prepared: [4.1.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.1.0.md);
194
+ previous: [4.0.0.md](https://github.com/pedroknigge/arkgate/blob/main/docs/releases/4.0.0.md)).
195
195
  Publish path: signed annotated tag → GitHub Release → `publish-npm.yml` (see [CONTRIBUTING.md](https://github.com/pedroknigge/arkgate/blob/main/CONTRIBUTING.md)).
@@ -51,8 +51,11 @@ Examples:
51
51
  | **contract** | `ark.config.json` layers, rules, include — the machine-readable architecture file |
52
52
  | **Layers plane** | Inter-layer edges: imports, placement, purity, isolation |
53
53
  | **ArkRules** (opt-in) | Intra-layer structure sensors + domain invariant catalogs as data (`arkrules/*`) |
54
+ | **advisory ArkRules** | Default sensor mode — **not** merge teeth; does not fail CI/merge alone (FG-ARKRULES-ADVISORY-ONLY) |
55
+ | **extraMergeTeeth** | Only when enforced structure/invariant rules exist **and** classification is honest (≥50% governed, ≥1 populated layer) |
54
56
  | **dual-plane residual** | Label findings **`[Layer]`** vs **`[ArkRules]`** — never blur them |
55
57
  | **rulesUnderContract** | Doctor/inventory counts for ArkRules — **never a score** |
58
+ | **type-only placement debt** | `import type` edges on the violations list with `failsStrict:false` — prefer SharedTypes / owning layer; not runtime coupling |
56
59
  | **gate** / **write gate** | Host boundary that blocks or advises on invalid writes |
57
60
  | **edges** | Allowed import graph (plan **A** / remediation) |
58
61
  | **baseline** | Frozen known debt; does not make a wrong contract honest |
@@ -83,6 +86,7 @@ Examples:
83
86
  | Keep Suggest on start → doctor | New-here primary is finish `start`, not a competing recommend/architect curriculum |
84
87
  | Qualify edge-clean under design-weak | “None on checked edges … design residual remains. Not healthy finished.” |
85
88
  | Prefer fail-closed over fake hard | Incomplete analysis, unobserved hooks, and soft MCP never paint as hard green |
89
+ | Honesty clear ≠ architecture healthy | `productHonesty.finished` means residual honesty sensors are clear — not a green graph score. Open blocking violations, ADAPT/SUGGEST with debt, dual-truth pin, or design residual keep `unfinished: true`. |
86
90
 
87
91
  ## Avoid
88
92
 
@@ -95,9 +99,12 @@ Examples:
95
99
  | “modes you pick” for Suggest/Adapt/Enforce | Those are **status lights**, not settings |
96
100
  | Skill-shopping lists as the default curriculum | Progressive disclosure: one door first |
97
101
  | “Healthy / done” while design-weak | False done |
102
+ | “Honesty clear” as “architecture finished” | Honesty clear only means residual honesty sensors are quiet; graph/mode debt is separate |
98
103
  | “ArkRules prove business correctness” | They enforce *declared* structure/coverage evidence, not arbitrary logic or full semantic proof |
99
104
  | “Structure enforced = Domain extraction done” | Structure sensors are **heuristics**; extraction is judgment (`/ark-fix` / pilot) |
100
105
  | “Covered invariant = E2E business tests” | Coverage = symbol/test evidence for a named policy, not a runtime test runner |
106
+ | “Max arkRules packs = merge fails structure” | **Advisory ArkRules ≠ merge teeth.** Only `mode: "enforced"` can add teeth, and only after honest classification (FG-ARKRULES-ADVISORY-ONLY) |
107
+ | “Type-only volume means the gate is broken” | High type-only count is placement debt (behavior OK); group under plan A type-only, offer SharedTypes starter |
101
108
  | Blurring import edges with invariants | Always label **`[Layer]`** vs **`[ArkRules]`** |
102
109
 
103
110
  ---
@@ -176,11 +176,15 @@ The release compatibility workflow packs the candidate first, then tests clean c
176
176
  - **npm / pnpm / Yarn**;
177
177
  - project TypeScript **5.9.3 / 6.0.3 / 7.0.2**.
178
178
 
179
- That is 36 installed-artifact cells. Each cell verifies that the project's `tsc` stays on the
180
- requested project compiler and that ArkGate resolves its fallback as exact 6.0.3 when the project
181
- API is unusable. Reports record `installMode` so the Yarn TS7 linker boundary cannot disappear
182
- behind a green job. All 36 cells passed on source `228dd893` in CI run `29655190747`. Locally, the
183
- repository entry point is:
179
+ That is **36** installed-artifact cells on the **full matrix** path (`push` to `main`, PR labels
180
+ `full-matrix` / `release`, or release-prep branch names such as `feat/4.1*`). Ordinary PRs run a
181
+ **slim** packed smoke: **one** cell (Node 20 + npm) that still exercises TS 5/6/7 in-process.
182
+ See [CONTRIBUTING.md CI profiles](../CONTRIBUTING.md#ci-profiles-pr-slim-vs-full-matrix).
183
+
184
+ Each cell verifies that the project's `tsc` stays on the requested project compiler and that
185
+ ArkGate resolves its fallback as exact 6.0.3 when the project API is unusable. Reports record
186
+ `installMode` so the Yarn TS7 linker boundary cannot disappear behind a green job. All 36 cells
187
+ passed on source `228dd893` in CI run `29655190747`. Locally, the repository entry point is:
184
188
 
185
189
  ```bash
186
190
  npm run test:ts-compat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkgate",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "ArkGate — architecture co-pilot for AI TypeScript (write gate, CI gate, plan/loop; optional ArkRules)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -136,6 +136,7 @@
136
136
  "check:package-files": "node scripts/verify-package-files.mjs",
137
137
  "check:release-artifacts": "node scripts/verify-release-artifacts.mjs",
138
138
  "test:release-artifacts": "vitest run tests/unit/scripts/verifyReleaseArtifacts.test.ts",
139
+ "test:field-dogfood-smoke": "node scripts/field-dogfood/smoke.mjs",
139
140
  "audit:beta-exit": "node scripts/beta-exit-audit.mjs",
140
141
  "clean": "rm -rf dist",
141
142
  "release:npm": "node scripts/release-npm.mjs",
@@ -156,6 +157,7 @@
156
157
  "overrides": {
157
158
  "qs": "6.15.3",
158
159
  "vite": "6.4.3",
160
+ "postcss": "8.5.23",
159
161
  "tsup": {
160
162
  "esbuild": "0.28.1"
161
163
  },
package/server.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.pedroknigge/arkgate",
4
- "description": "ArkGate \u2014 architecture co-pilot for AI TypeScript (write gate, CI, plan/loop)",
4
+ "description": "ArkGate architecture co-pilot for AI TypeScript (write gate, CI, plan/loop)",
5
5
  "repository": {
6
6
  "url": "https://github.com/pedroknigge/arkgate",
7
7
  "source": "github"
8
8
  },
9
- "version": "4.0.1",
9
+ "version": "4.1.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "arkgate",
14
- "version": "4.0.1",
14
+ "version": "4.1.0",
15
15
  "runtimeHint": "npx",
16
16
  "transport": {
17
17
  "type": "stdio"
@@ -86,6 +86,9 @@
86
86
  "label": "UI-focused repository; backend lives elsewhere or is thin",
87
87
  "preset": "layered",
88
88
  "presetAlternatives": {
89
+ "vite-vercel-spa": {
90
+ "whenSignal": "viteVercelSpaLayout"
91
+ },
89
92
  "feature-sliced": {
90
93
  "whenSignal": "featureSlicedLayout"
91
94
  }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$comment": "Optional SharedTypes layer starter (NEW-TYPEONLY-VOLUME). Copy the layer + allow rules into ark.config.json when type-only placement debt volume is high. Both application and presentation may import SharedTypes; SharedTypes must not import adapters or orchestration.",
3
+ "layer": {
4
+ "name": "SharedTypes",
5
+ "patterns": [
6
+ "src/types/**",
7
+ "src/shared/types/**",
8
+ "packages/shared/src/types/**",
9
+ "lib/types/**"
10
+ ],
11
+ "intentPrefixes": ["Shared.Types."]
12
+ },
13
+ "suggestedRules": [
14
+ { "from": "DomainModel", "to": "SharedTypes", "allowed": true },
15
+ { "from": "ApplicationOrchestration", "to": "SharedTypes", "allowed": true },
16
+ { "from": "PresentationAdapters", "to": "SharedTypes", "allowed": true },
17
+ { "from": "PersistenceAdapters", "to": "SharedTypes", "allowed": true },
18
+ { "from": "SharedTypes", "to": "DomainModel", "allowed": false },
19
+ { "from": "SharedTypes", "to": "ApplicationOrchestration", "allowed": false },
20
+ { "from": "SharedTypes", "to": "PresentationAdapters", "allowed": false },
21
+ { "from": "SharedTypes", "to": "PersistenceAdapters", "allowed": false }
22
+ ],
23
+ "guidance": [
24
+ "Type-only edges (`import type`) are placement debt — failsStrict:false; value edges still block merge.",
25
+ "Move pure type modules both sides need into SharedTypes (or an owning Domain surface).",
26
+ "Do not put runtime logic or I/O in SharedTypes.",
27
+ "Doctor violations.typeEdgePolicy and plan.typeOnlyGroup describe the same policy."
28
+ ]
29
+ }
@@ -99,6 +99,8 @@ Ark protects the **boundary around** a framework, not its internals. Nest/DI pub
99
99
  If the tree is `src/features` + `shared`/`lib` **without** FSD `entities`/`widgets`, prefer
100
100
  `vertical-slice` (or pack `enthusiast-vertical-slice`) — do **not** force hexagonal.
101
101
  If `src/contexts` or `src/bounded-contexts` exists, prefer `ddd-bounded-contexts`.
102
+ **Next.js:** `app/api/**` / `pages/api/**` (and route-group `app/(…)/api/**`) default to
103
+ **ApplicationOrchestration**, not Presentation — do not reclassify API shells as UI.
102
104
  2. **Check + diagnose** — `summary.concentrated` / dominant edge → fix contract first, don’t freeze.
103
105
  Cross-slice / cross-context `peerIsolation` hits are judgment: extract shared or events.
104
106
  If one edge dominates residual debt: **STOP — do not continue this skill as complete.** **STOP — concentrated edge: invoke /ark-contract with source evidence** (do not freeze a wrong contract or grind N freezes).
@@ -139,6 +139,11 @@ When explaining the **plan**, name the four `mechanical-safe` remediation kinds
139
139
  `import-type-of-type-exports` for named type exports from mixed modules; W6 port-proof inject is judgment when proof holds) — everything
140
140
  else is judgment/deferred and must not be auto-applied.
141
141
 
142
+ **Type-edge honesty:** type-only denied edges are **placement debt** (`typeOnly` +
143
+ `failsStrict: false`) — prefer SharedTypes / owning layer; they do not fail merge like value
144
+ edges. Doctor `productHonesty` and `violations.typeEdgePolicy` must not be sold as “all done”
145
+ when residual signals remain.
146
+
142
147
  ## Spoken / written explanation
143
148
 
144
149
  1. **Load the real contract**: `ark.config.json`, `ark://manifest` if available, `AGENTS.md`.
@@ -276,6 +276,25 @@ in parallel. When `pilotLoop.queuedBets > 0`, those bets stay **queued**, not co
276
276
  lines — never silent codemod of plan B. After the pilot lands, re-run doctor; success =
277
277
  reduced evidence on pilot paths.
278
278
 
279
+ ### Plan B one-pilot checklist (mandatory before any B apply)
280
+
281
+ Empty plan A + design-weak is **not** architecture finished. Plan B is judgment only.
282
+
283
+ | Step | Gate | Fail closed if… |
284
+ |------|------|-----------------|
285
+ | 1. Confirm residual | `designFitness.designWeak` **or** non-empty `patternBets` / `designSmells` | You would claim healthy finished because plan A is empty |
286
+ | 2. Pick **one** pilot | `pilotLoop.nextPilot` (preferred) **or** one ranked B bet with a path scope | Multi-pilot batch / “fix all smells this PR” |
287
+ | 3. Write extraction card | Pilot · Smell · Move · Do not · Success · **Kill-switch** · Next | Missing kill-switch or success signal |
288
+ | 4. User OK | Explicit approval before edit (or stay map-only) | Silent auto-apply of plan B |
289
+ | 5. Apply **only** that pilot | Via `/ark-autopilot` (apply B) or `/ark-fix` (one cluster) | Opening a second pilot before re-doctor |
290
+ | 6. Re-doctor | Success = reduced evidence on pilot paths; residual outside pilot may remain | Declaring whole-tree done from one pilot |
291
+
292
+ **Hard lines (never break):**
293
+ - `killSwitch` / kill-switch is **required** on every B card (stop condition if pilot does not reduce confusion).
294
+ - `multiPilotBatchForbidden` — never multi-batch Shape extractions.
295
+ - `autoApplyPlanBForbidden` / `neverMechanicalSafe: true` — never invent mechanical-safe for B.
296
+ - `healthyFinishedForbidden` while design-weak — empty plan A is baseline, not done.
297
+
279
298
  ```text
280
299
  ### Extraction card
281
300
  Pilot: <one dir or feature — or pilotLoop.nextPilot.pilotTarget>
@@ -286,8 +305,9 @@ Do not:
286
305
  - weaken ark.config.json
287
306
  - auto-apply as mechanical-safe or invent new mechanical-safe kinds
288
307
  - big-bang the monorepo
308
+ - open a second pilot before re-doctor
289
309
  Success: <observable / falsifiable — re-doctor>
290
- Kill-switch: <stop condition>
310
+ Kill-switch: <stop condition — e.g. if pilot does not clear smell evidence in 1 PR → stop / re-map>
291
311
  Next: /ark-autopilot (apply with user ok) | /ark-fix (one cluster) | re-doctor
292
312
  ```
293
313
 
@@ -19,16 +19,27 @@ the two files on the violation edge.
19
19
 
20
20
  When the fix is really a **Shape** extraction (I/O out of routes, god module split), write an
21
21
  **extraction card** before editing — same template as `docs/brownfield-adoption.md`
22
- §6 and explore §G. Fixed fields (never mechanical-safe, never silent B apply):
22
+ §6 and explore §G. Fixed fields (never mechanical-safe, never silent B apply).
23
+
24
+ ### Plan B one-pilot checklist (when Shape residual, not a single edge fix)
25
+
26
+ Empty plan A + `designWeak` is **not** architecture finished. One pilot only:
27
+
28
+ 1. **Confirm** doctor `designFitness.designWeak` / non-empty `patternBets` (or agent-detected smell).
29
+ 2. **One pilot** — prefer `pilotLoop.nextPilot`; never multi-batch concurrent Shape extractions.
30
+ 3. **Extraction card** with **Kill-switch** + falsifiable Success (required).
31
+ 4. **User OK** before apply — `autoApplyPlanBForbidden` / never mechanical-safe.
32
+ 5. **Edit only that pilot scope** — then `ark-check` / re-doctor; residual outside pilot may remain.
33
+ 6. **Stop** if kill-switch fires; do not open pilot #2 in the same batch.
23
34
 
24
35
  ```text
25
36
  ### Extraction card
26
- Pilot: <one directory or feature path>
37
+ Pilot: <one directory or feature path — or pilotLoop.nextPilot.pilotTarget>
27
38
  Smell: <doctor designSmells id if present>
28
39
  Move: <verbatim relocate / split>
29
- Do not: rewrite queries; weaken ark.config; invent mechanical-safe kinds; big-bang
30
- Success: <falsifiable>
31
- Kill-switch: <stop condition>
40
+ Do not: rewrite queries; weaken ark.config; invent mechanical-safe kinds; big-bang; multi-pilot batch
41
+ Success: <falsifiable — re-doctor on pilot paths>
42
+ Kill-switch: <stop condition — required>
32
43
  Next: re-run ark-check; shrink baseline if applicable
33
44
  ```
34
45