arkgate 2.10.0 → 2.12.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 (55) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/README.md +21 -12
  3. package/SECURITY.md +3 -4
  4. package/bin/ark-check.mjs +41 -16
  5. package/bin/ark-mcp.mjs +54 -10
  6. package/bin/ark.mjs +87 -24
  7. package/bin/lib/agent-gates.mjs +68 -2090
  8. package/bin/lib/architecture-scan.mjs +4 -1
  9. package/bin/lib/baseline-key.mjs +17 -0
  10. package/bin/lib/ci-and-commands.mjs +386 -0
  11. package/bin/lib/config-warnings.mjs +22 -0
  12. package/bin/lib/core-layers.mjs +7 -0
  13. package/bin/lib/core-ratchet.mjs +3 -7
  14. package/bin/lib/deploy-path.mjs +205 -0
  15. package/bin/lib/doctor-plan.mjs +29 -5
  16. package/bin/lib/gate-files.mjs +223 -0
  17. package/bin/lib/hook-templates.mjs +99 -0
  18. package/bin/lib/install-migrate.mjs +442 -0
  19. package/bin/lib/mcp-adoption.mjs +423 -0
  20. package/bin/lib/presets.mjs +3 -0
  21. package/bin/lib/safety-diagnostics.mjs +263 -0
  22. package/bin/lib/scan-files.mjs +51 -6
  23. package/bin/lib/skill-install.mjs +259 -0
  24. package/bin/lib/typescript-host.mjs +88 -0
  25. package/bin/lib/violations.mjs +3 -3
  26. package/bin/lib/write-path-detect.mjs +138 -0
  27. package/dist/index.cjs +103 -8
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +5 -3
  30. package/dist/index.d.ts +5 -3
  31. package/dist/index.js +103 -8
  32. package/dist/index.js.map +1 -1
  33. package/dist/nestjs/index.cjs +18 -5
  34. package/dist/nestjs/index.cjs.map +1 -1
  35. package/dist/nestjs/index.d.cts +1 -1
  36. package/dist/nestjs/index.d.ts +1 -1
  37. package/dist/nestjs/index.js +18 -5
  38. package/dist/nestjs/index.js.map +1 -1
  39. package/dist/runtime/index.cjs +103 -8
  40. package/dist/runtime/index.cjs.map +1 -1
  41. package/dist/runtime/index.d.cts +1 -1
  42. package/dist/runtime/index.d.ts +1 -1
  43. package/dist/runtime/index.js +103 -8
  44. package/dist/runtime/index.js.map +1 -1
  45. package/dist/{types-D6Q8WHes.d.cts → types-BZ17b9i5.d.cts} +5 -1
  46. package/dist/{types-D6Q8WHes.d.ts → types-BZ17b9i5.d.ts} +5 -1
  47. package/docs/agent-guide.md +12 -2
  48. package/docs/ai-gates.md +20 -2
  49. package/docs/package-surface.md +10 -3
  50. package/docs/production-hardening.md +5 -0
  51. package/package.json +5 -2
  52. package/server.json +2 -2
  53. package/templates/skills/ark-autopilot.md +77 -45
  54. package/templates/skills/ark-explain.md +2 -1
  55. package/templates/skills/ark-explore.md +135 -34
@@ -941,7 +941,11 @@ interface WorkflowStep<P extends SagaContext = SagaContext> {
941
941
  onEvent?: IntentName;
942
942
  retry?: RetryPolicy;
943
943
  timeoutMs?: number;
944
- execute: (payload: P, bus: EventBus) => MaybePromise<Partial<P> | void>;
944
+ /**
945
+ * Execute one step. The signal is aborted when `timeoutMs` elapses; implementations
946
+ * performing I/O must pass it to the underlying client for cooperative cancellation.
947
+ */
948
+ execute: (payload: P, bus: EventBus, signal: AbortSignal) => MaybePromise<Partial<P> | void>;
945
949
  compensate?: (payload: P, bus: EventBus, error?: unknown) => MaybePromise<void>;
946
950
  }
947
951
  interface WorkflowStartTrigger<P extends SagaContext = SagaContext> {
@@ -941,7 +941,11 @@ interface WorkflowStep<P extends SagaContext = SagaContext> {
941
941
  onEvent?: IntentName;
942
942
  retry?: RetryPolicy;
943
943
  timeoutMs?: number;
944
- execute: (payload: P, bus: EventBus) => MaybePromise<Partial<P> | void>;
944
+ /**
945
+ * Execute one step. The signal is aborted when `timeoutMs` elapses; implementations
946
+ * performing I/O must pass it to the underlying client for cooperative cancellation.
947
+ */
948
+ execute: (payload: P, bus: EventBus, signal: AbortSignal) => MaybePromise<Partial<P> | void>;
945
949
  compensate?: (payload: P, bus: EventBus, error?: unknown) => MaybePromise<void>;
946
950
  }
947
951
  interface WorkflowStartTrigger<P extends SagaContext = SagaContext> {
@@ -49,13 +49,23 @@ MCP `ark_recommend` and the `/ark-architect` skill.
49
49
  ### Terminal onboarding (Phase B)
50
50
 
51
51
  ```bash
52
- npx ark init --archetype crud-product --yes # non-interactive: shape → preset → gates → strict check
52
+ npx ark start --yes # preferred: shape → contract**day-zero origin** → gates → plan
53
+ npx ark init --archetype crud-product --yes # non-interactive: shape → preset → origin → gates
53
54
  npx ark init # TTY wizard: pick application shape (1–8), not a framework
54
55
  npx ark-check --doctor # includes "New here?" when coverage is low or config is fresh
55
56
  npx ark-check --report beginner.html --beginner # simplified HTML for enthusiasts
56
57
  npx ark-check --watch # debounced re-check when governed files change
57
58
  ```
58
59
 
60
+ **Day-zero origin (2.12+):** as soon as `ark.config.json` exists, `ark start` / `ark init`
61
+ freeze `.ark/reports/origin.*` **before** writing agent docs, skills, or CI templates.
62
+ Later `--report` shows evolution vs that snapshot. Do not `--reset-origin` unless the user
63
+ explicitly wants a new baseline.
64
+
65
+ **Default agent co-pilot:** `/ark-autopilot` (explore-first, dual plan A remediation + B
66
+ pattern bets). Recon without applying: `/ark-explore`. Never treat empty `--plan` as
67
+ “architecture healthy” without the explore pass.
68
+
59
69
  `ark init --archetype <id>` maps playbook ids to named presets (`hexagonal`, `layered`,
60
70
  `feature-sliced`, `monorepo`). With `--yes` and no archetype, Ark auto-selects from
61
71
  `--recommend` scoring.
@@ -176,7 +186,7 @@ reference, and explanation for the full path (recommend → init → gallery →
176
186
  3. Run `ark init --archetype <id> --yes`, `--apply-policy-pack enthusiast-<preset>`, or `ark init --preset <preset> --yes` when no `ark.config.json` exists.
177
187
  4. Optional: `--write-plan` for `ark-adoption-plan.json`; copy a gallery starter from `examples/README.md`.
178
188
  5. Use `/ark-place` or `ark_place` for individual files after the contract exists.
179
- 6. Verify with `ark-check --root . --config ark.config.json --strict-config`.
189
+ 6. Verify with `ark-check --root . --config ark.config.json --strict`.
180
190
 
181
191
  ### Write protocol (2.10+ / Track W)
182
192
 
package/docs/ai-gates.md CHANGED
@@ -153,7 +153,7 @@ Layers:
153
153
  - PersistenceAdapters: src/adapters/persistence/**
154
154
  Rules: 10 denied layer edge(s). Full contract: ark://manifest MCP resource.
155
155
  Baseline: 3 frozen violation(s) — only NEW violations fail; do not add to them.
156
- After edits run: npx ark-check --root . --config ark.config.json --strict-config
156
+ After edits run: npx ark-check --root . --config ark.config.json --strict
157
157
  ```
158
158
 
159
159
  The hook belongs in the **project's** `.claude/settings.json` (that's what
@@ -390,9 +390,27 @@ Prefer keeping editor + CI on the same `ark.config.json` — do not maintain a p
390
390
  Whatever the agent side does, gate the merge:
391
391
 
392
392
  ```yaml
393
- - run: npx ark-check --root . --config ark.config.json --strict-config
393
+ - run: npx ark-check --root . --config ark.config.json --strict
394
394
  ```
395
395
 
396
+ The `--strict` profile also requires the generated CI/write gates and fails on safety
397
+ diagnostics. Configure reviewed exceptions explicitly:
398
+
399
+ ```json
400
+ {
401
+ "dynamicImportAllowlist": ["src/plugins/loader.ts"],
402
+ "safety": {
403
+ "maxTsSuppressions": 0,
404
+ "maxAnyCasts": 0,
405
+ "allowInMemory": false,
406
+ "allowDisabledPeerIsolation": false
407
+ }
408
+ }
409
+ ```
410
+
411
+ `ark-check --doctor --json` reports counts under `doctor.safety`. An `any` cast is
412
+ reported as lost static assurance; it does not imply that a runtime schema was bypassed.
413
+
396
414
  Adopting Ark on an existing codebase with violations? Freeze them once and ratchet down:
397
415
 
398
416
  ```bash
@@ -16,10 +16,10 @@ This document is the consumer contract for **what is stable** vs **what is opt-i
16
16
  |---------|----------------|-----------------|
17
17
  | **CLI** | `arkgate` / `arkgate-check` (aliases `ark` / `ark-check`) | Flags and human text may improve; **JSON output shapes** for `--json` (check, doctor, plan, coverage, recommend) are stable within a major. Additive fields OK; removals/renames are major. |
18
18
  | **MCP tools** | `arkgate-mcp` / `ark://…` resources | Tool names and primary argument shapes are stable within a major. |
19
- | **`ark.config.json`** | Layer globs, rules, include/exclude, forbiddenGlobals, intent prefixes | Schema fields documented in playbooks/examples are stable; new optional fields may appear. |
20
- | **Agent skills** | `/ark-*` templates installed by `--install-agent-gates` | Skill *names* and “default flow” are stable; internal skill prose may evolve. |
19
+ | **`ark.config.json`** | Layer globs, rules, include/exclude, forbiddenGlobals, intent prefixes, `peerIsolation`, `dynamicImportAllowlist`, `safety` thresholds | Schema fields documented in playbooks/examples are stable; new optional fields may appear. |
20
+ | **Agent skills** | `/ark-*` templates installed by `--install-agent-gates` | Skill *names* and “default flow” are stable; internal skill prose may evolve (e.g. explore dual-plan seed, day-zero origin order). |
21
21
  | **ESLint subpath** | `arkgate/eslint` | Config-driven layer/import rules; loads consumer `ark.config.json`. |
22
- | **GitHub Action** | `pedroknigge/arkgate` (see `action.yml`) | Inputs for running the check stay stable within a major. |
22
+ | **GitHub Action** | `pedroknigge/arkgate` (see `action.yml`) | The `uses:` tag/SHA selects the checker source; `version` remains an optional exact npm compatibility override. |
23
23
 
24
24
  Gates need **no application code imports**. Most projects only use the CLI + MCP + config.
25
25
 
@@ -73,3 +73,10 @@ See [production-hardening.md](./production-hardening.md) for runtime operational
73
73
  | Bugfix with no contract change | **patch** |
74
74
  | Prefer `arkgate/runtime` over root (docs only; root still exports) | **patch/minor** |
75
75
  | Remove root kernel re-exports | **major** (with migration notes) |
76
+
77
+ ---
78
+
79
+ ## Release notes (maintainers)
80
+
81
+ Ship notes for a version live under [releases/](./releases/) (e.g. [2.12.0.md](./releases/2.12.0.md)).
82
+ Publish path: signed annotated tag → GitHub Release → `publish-npm.yml` (see [CONTRIBUTING.md](../CONTRIBUTING.md)).
@@ -37,6 +37,11 @@ When implementing Ark store interfaces in production, cover these guarantees exp
37
37
  - Observability: failed writes and dispatches are visible to operators.
38
38
  - Migration: schema changes for stored records are versioned.
39
39
 
40
+ Workflow `timeoutMs` uses cooperative cancellation: ArkGate aborts the `AbortSignal`
41
+ passed as the third `execute` argument, but JavaScript cannot stop an operation that
42
+ ignores that signal. Production steps must pass it to network/database clients and keep
43
+ external effects idempotent; otherwise work may finish after the workflow was marked failed.
44
+
40
45
  ## Interface Targets
41
46
 
42
47
  | Concern | Interface |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkgate",
3
- "version": "2.10.0",
3
+ "version": "2.12.0",
4
4
  "description": "ArkGate — architecture co-pilot for AI TypeScript (write gate, CI gate, plan/loop)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -66,9 +66,11 @@
66
66
  "dev": "tsup --watch",
67
67
  "test": "vitest",
68
68
  "test:run": "vitest run",
69
+ "test:coverage": "vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary",
69
70
  "typecheck": "tsc --noEmit",
70
71
  "security:audit": "npm audit --omit=dev --audit-level=high",
71
- "check:architecture": "node bin/ark-check.mjs --root . --config ark.config.json --strict-config",
72
+ "check:architecture": "node bin/ark-check.mjs --root . --config ark.config.json --strict",
73
+ "check:js": "node scripts/check-js-syntax.mjs",
72
74
  "generate:layer-match": "node scripts/generate-layer-match.mjs",
73
75
  "check:layer-match": "node scripts/generate-layer-match.mjs --check",
74
76
  "generate:cli-pure": "node scripts/generate-cli-pure.mjs",
@@ -111,6 +113,7 @@
111
113
  "devDependencies": {
112
114
  "@nestjs/common": "^11.1.27",
113
115
  "@types/node": "^20.14.0",
116
+ "@vitest/coverage-v8": "^3.2.6",
114
117
  "reflect-metadata": "^0.2.2",
115
118
  "rxjs": "^7.8.2",
116
119
  "tsup": "^8.1.0",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/pedroknigge/arkgate",
7
7
  "source": "github"
8
8
  },
9
- "version": "2.10.0",
9
+ "version": "2.12.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "arkgate",
14
- "version": "2.10.0",
14
+ "version": "2.12.0",
15
15
  "runtimeHint": "npx",
16
16
  "transport": {
17
17
  "type": "stdio"
@@ -1,38 +1,44 @@
1
1
  ---
2
2
  name: ark-autopilot
3
- description: End-to-end architecture co-pilot — exploratory map of the real project, then setup, deep plan from source, mechanical-safe fixes, and judgment design. CLI is a sensor; you read and remediate files.
3
+ description: End-to-end architecture co-pilot — decision-grade explore first, dual plan (remediation + pattern improvements), mechanical-safe fixes, judgment design. CLI is a sensor; you read and remediate files.
4
4
  ---
5
5
 
6
6
  # /ark-autopilot — Get to a sound architecture, end to end
7
7
 
8
- Composes **explore + setup + plan + loop**. Safe default: auto-apply only `mechanical-safe`;
9
- when the user says full apply / “al mango” / apply everything, also execute
10
- **judgment** fixes you design from reading source (still validate with ark-check,
8
+ Composes **explore sensors dual plan loop**. Safe default: auto-apply only
9
+ `mechanical-safe`; when the user says full apply / “al mango” / apply everything, also
10
+ execute **judgment** fixes you design from reading source (still validate with ark-check,
11
11
  never weaken the gate).
12
12
 
13
+ **Not a plan grinder.** Empty `--plan` does **not** mean “architecture is healthy” without
14
+ the explore pass and dual-plan section B (pattern bets).
15
+
13
16
 
14
17
  ## Related onboarding
15
18
 
16
19
  - **Greenfield:** `/ark-architect` or `ark-check --recommend` / `ark start`.
17
20
  - **Brownfield:** `/ark-adopt` — match contract to reality; do not force a starter preset.
18
- - **Deep map only:** `/ark-explore` — reconnaissance without applying fixes.
21
+ - **Deep map only:** `/ark-explore` — full recon report without applying fixes.
22
+ - **Adoption metrics only:** `/ark-coverage` — governed% + capability gaps (feeds dual plan B).
19
23
  - **Default path:** `ark start` → `/ark-autopilot` → `ark-check --doctor`.
20
24
 
21
25
  ## Dual engine (mandatory)
22
26
 
23
27
  | Engine | Role |
24
28
  |--------|------|
25
- | **Deterministic** | `ark-check` plan/coverage/doctor, mechanical-safe kinds, write/CI gates, exit codes |
26
- | **Exploratory** | You map **this** product’s real tree: entry points, packages, coupling, false greens, opportunities |
29
+ | **Deterministic** | `ark-check` plan/coverage/doctor, mechanical-safe kinds, write/CI gates, exit codes, origin snapshot |
30
+ | **Exploratory** | You map **this** product’s real tree: entry points, coupling, false greens, field path, pattern debt |
27
31
 
28
- **Forbidden:** only printing `--plan` JSON or “4 safe / 4 judgment — approve?” without reading the violating files **and** without a short product map.
32
+ **Forbidden:** only printing `--plan` JSON or “4 safe / 4 judgment — approve?” without a
33
+ decision-grade explore pass **and** without opening violating files.
29
34
 
30
35
  **Required:**
31
- 1. **Explore pass** (below) before claiming a loop strategy.
32
- 2. CLI sensor: `ark-check --plan --json`, coverage/doctor as needed.
33
- 3. **Open every file** in the plan’s `steps[]` (and its `target` if present) before classifying a fix.
34
- 4. **“Así te lo re-soluciono”** for each cluster: exact moves (extract type, relocate file, invert dependency).
35
- 5. Apply re-run ark-check rollback on regression.
36
+ 1. **Explore pass** (below) **before** claiming a loop strategy — same bar as `/ark-explore`, budgeted.
37
+ 2. CLI sensors: `--plan --json`, `--coverage --json` / `--doctor` as needed.
38
+ 3. **Dual plan** always emitted (sections A and B).
39
+ 4. **Open every file** in plan A `steps[]` (and `target` if present) before classifying a fix.
40
+ 5. **“Así te lo re-soluciono”** for each A cluster and each B pattern bet.
41
+ 6. Apply A → re-run ark-check → rollback on regression. **Never auto-apply B** as mechanical-safe.
36
42
 
37
43
 
38
44
  ## Subagent fan-out (optional, host-dependent)
@@ -52,64 +58,90 @@ feature dirs, plan clusters), you **may** dispatch **subagents**:
52
58
  4. Parent owns the **### Completion** block (union of **Opened**, single **Handoff**).
53
59
  5. Do **not** use subagents to weaken the gate or invent `mechanical-safe` kinds.
54
60
 
55
- ## Explore pass (before grinding the plan)
61
+ Useful first wave: **core product tree** | **field path** (examples/starters) | **agent install surfaces** (hooks vs templates).
62
+
63
+ ## Explore pass (phase 0 — mandatory, first)
56
64
 
57
- Do this even if the plan is non-empty — plan lists *violations*, not *product reality*.
65
+ Do this **before** grinding plan A — plan lists *violations*, not *product reality*.
66
+ Use the **`/ark-explore` decision-grade bar** (compressed into the autopilot report, not optional fluff).
58
67
 
59
- 1. **Product one-liner** — README + main package(s) + what the user gets.
60
- 2. **Entry points** — apps, APIs, CLIs, workers (min paths named).
61
- 3. **Lived layout** — which dirs are really Domain / Application / I/O / UI vs what globs claim.
62
- 4. **False-green soft block** — doctor / coverage: empty Domain/Persistence while Application
63
- globs still cover I/O (`airtable`, `supabase`, `prisma`, `drizzle`, `repositories`, …).
64
- Doctor gap id: `contract-false-green-io-under-application`. If so:
68
+ 1. **Headline** — product one-liner + honesty (mode, governed%, false-green / false-promise risk).
69
+ 2. **Map** — entry points, lived layout vs globs (one screen).
70
+ 3. **Field path** — if `examples/` / gallery / starter docs exist: open ≥2, **run** their check when cheap; flag soft-green or broken demos. Else `Field path: n/a`.
71
+ 4. **Agent/gate reality** — installed hooks vs install templates (e.g. `--hook` vs `--hook-repair`); MCP; CI gate present.
72
+ 5. **Coupling** fan-in / exports / importers for hotspots (LOC alone is a hint).
73
+ 6. **False-green soft block** — doctor/coverage: empty Domain/Persistence while Application owns I/O (`airtable`, `supabase`, `prisma`, `drizzle`, `repositories`, …). Doctor gap id: `contract-false-green-io-under-application`. If so:
65
74
  **STOP — do not continue this skill as complete.** **STOP — false-green: invoke /ark-adopt or /ark-contract before claiming ENFORCE.** Do not claim goal.met / ENFORCE from type-only cleanup while doctor reports `contract-false-green-io-under-application`.
66
- 5. **Suggestive top bets** — 2–5 opportunities ranked (shape, extract, manifiesto, gates/DX),
67
- separate from mechanical-safe steps. User may defer; still list them.
75
+ 7. **Seed dual plan B** — 2–5 pattern / evolution bets ranked (impact × effort × enforceability).
76
+
77
+ Min bar: **≥12 source files** across **≥4 meaningful directories** (not only files in `steps[]`).
78
+ Standalone long report: `/ark-explore`. Adoption numbers deep-dive: `/ark-coverage`.
79
+
80
+ ## Dual plan (always emit)
81
+
82
+ | Section | Source | Question | Auto-apply? |
83
+ |---------|--------|----------|-------------|
84
+ | **A. Remediation** | `--plan --json` + opened step files | What must change so the gate is honest? | Only `mechanical-safe` by default |
85
+ | **B. Pattern / evolution** | Explore + coverage/doctor | What existing patterns should improve even if A is empty? | **Never** as mechanical-safe |
86
+
87
+ **Section A** — group by edge; treat `peerIsolation` / cross-slice as **judgment**.
88
+ **Section B** examples: peerIsolation, move rules out of UI, strengthen starter/preset rules, write-path repair, split god orchestration modules, Domain placement / intents, import surface (`/runtime` vs root). Cap **3–5** B rows. Each row: evidence path + **así te lo re-soluciono** + next skill/command + success signal.
89
+
90
+ B does **not** count as “architecture healthy finished.” Report B as `proposed | deferred | applied-with-user-ok`.
68
91
 
69
- Min bar: **≥8 source files** across **≥3 meaningful directories** (not only files in `steps[]`).
92
+ ## Origin snapshot (day-zero picture)
70
93
 
71
- For a full reconnaissance report, run or fold in `/ark-explore`.
94
+ - **When:** as soon as `ark.config.json` exists and `.ark/reports/origin.json` is missing — **before** applying fixes and **before** treating “done”. Prefer that `ark start` / `ark init` already froze origin **before** agent docs; if missing, freeze now.
95
+ - **How:** `ark-check --report ark-report.html` (writes origin once under `.ark/reports/`).
96
+ - **Never** `--reset-origin` unless the user explicitly wants a new baseline.
97
+ - **Do not** wait until the end of the loop to create origin the first time — later reports need a frozen “before” picture.
98
+ - End of run: re-`--report` for **latest** + evolution vs origin (origin stays frozen).
72
99
 
73
100
  ## Operating modes (detected, not picked)
74
101
 
75
- - **Setup (Suggest):** no config → `ark start` / recommend shape.
102
+ - **Setup (Suggest):** no config → `ark start` / recommend shape (start freezes origin after config, before gates).
76
103
  - **Align (Adapt):** open debt, low honesty, or false-green → explore + adopt/loop; do not claim “guarded”.
77
- - **Guard (Enforce):** `goal.met`, solid governed%, no false-green → install/confirm gates and stop.
104
+ - **Guard (Enforce):** `goal.met`, solid governed%, no false-green → confirm gates; still emit dual plan B if explore found residual.
78
105
 
79
106
  ## Flow
80
107
 
81
- 0. **Explore pass** — product map + false-green check + suggestive bets (see above).
108
+ 0. **Explore pass** — decision-grade recon (see above); seed plan B.
82
109
  1. **Setup if needed** — `ark start` if no `ark.config.json`. Trust `--recommend` / playbook:
83
110
  `vertical-slice-product` and `ddd-bounded-contexts` are first-class shapes (not hexagonal by default).
84
- 2. **Origin report** — `ark-check --report ark-report.html` (do not `--reset-origin` unless asked).
85
- 3. **Plan + code read** — `--plan --json`; read each step’s source/target; group by edge.
86
- Treat `peerIsolation` / cross-slice steps as **judgment** (never mechanical-safe).
87
- 4. **Concentrated edge?** — if one edge dominates:
111
+ 2. **Origin if missing** — freeze day-zero (`--report`) immediately after contract exists.
112
+ 3. **Sensors** — `--plan --json`, doctor/coverage as needed.
113
+ 4. **Emit dual plan** — A from plan steps (files opened); B from explore (3–5 bets).
114
+ 5. **Concentrated edge?** — if one edge dominates A:
88
115
  **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).
89
- 5. **Worktree preferred** — discardable git worktree when possible.
90
- 6. **Mechanical-safe** — only kinds from `/ark-loop` table; one step, validate, rollback.
91
- 7. **Judgment** — default: propose with full “así te lo re-soluciono”. If user authorized full apply: implement the designed fix, validate, rollback on fail.
92
- 8. **Manifiesto** if loose business rules surface (domain logic in UI/core), propose Domain placement + `intentPrefixes` / intents; apply config only via `/ark-contract` discipline (strict check after).
93
- 9. **Final report** — re-`--report`; evolution vs origin; **explore bets** still open vs auto vs judgment applied vs deferred.
94
- 10. **Strict check** — `ark-check --strict-config` (dead preset globs are advisory; real violations still fail).
95
- 11. **Core ratchet (when green)** — if plan `goal.met` and doctor still **ADAPT** only because
116
+ 6. **Worktree preferred** — discardable git worktree when possible.
117
+ 7. **Mechanical-safe (A only)** — kinds from `/ark-loop` table; one step, validate, rollback.
118
+ 8. **Judgment (A)** — default: propose with full “así te lo re-soluciono”. If user authorized full apply: implement, validate, rollback on fail.
119
+ 9. **Pattern bets (B)** propose; apply only with explicit user go + correct skill (`/ark-contract`, refactor, install gates, etc.). Never weaken the gate to clear B.
120
+ 10. **Manifiesto** — loose business rules Domain placement + `intentPrefixes` / intents via `/ark-contract` discipline.
121
+ 11. **Final report** — re-`--report`; evolution vs origin; A applied vs open; B proposed/deferred; gates on.
122
+ 12. **Strict check** — `ark-check --strict-config` (dead preset globs are advisory; real violations still fail).
123
+ 13. **Core ratchet (when green)** — if plan `goal.met` and doctor still **ADAPT** only because
96
124
  populated cores are `optional: true`, run `ark-check --ratchet-cores` then `--doctor`.
97
125
  Never ratchet while active violations remain or false-green gap is open.
98
126
 
99
127
  ## Never
100
128
 
101
129
  - Disable rules, broaden allows, or baseline **new** debt to “finish”.
102
- - Claim clean while judgment steps were skipped without user decision.
130
+ - Claim clean while judgment A steps were skipped without user decision.
103
131
  - Claim ENFORCE / “done” when doctor reports `contract-false-green-io-under-application` (adopt first).
132
+ - Claim “done” solely because plan A is empty while explore/B residual remains unlisted.
104
133
  - Replace host Nest/DI with the runtime kernel unasked.
105
- - Treat “plan empty” as “architecture is healthy” without the explore pass.
134
+ - Auto-apply pattern (B) bets as if they were mechanical-safe.
135
+ - Create origin only after a long cleanup (freezes a polished “before” that never was).
106
136
 
107
137
  ## Done criteria
108
138
 
109
- - Explore pass completed (product map + paths read + bets listed).
110
- - Every applied step validated by real `ark-check`.
111
- - Final plan `goal.met` true **or** remaining steps listed with file-level proposals and why blocked.
112
- - Report cites paths you changed, open **opportunities**, and report HTML paths.
139
+ - Explore pass completed (decision-grade map + paths + field path or n/a + B seeds).
140
+ - Dual plan emitted (A and/or B; if both empty, one-line justification).
141
+ - Origin present under `.ark/reports/origin.*` (frozen this run or earlier).
142
+ - Every applied A step validated by real `ark-check`.
143
+ - Final plan `goal.met` true **or** remaining A steps listed with file-level proposals.
144
+ - Open **B opportunities** listed; report HTML paths cited.
113
145
 
114
146
  ## Completion contract (skill incomplete if missing)
115
147
 
@@ -37,7 +37,8 @@ the same files or weaken the gate.
37
37
  (`pnpm … exec ark-check` / `yarn` / `npx`).
38
38
 
39
39
  This also maintains snapshots under **`.ark/reports/`**:
40
- - `origin.json` / `origin.html` — frozen **first** report (start of the journey)
40
+ - `origin.json` / `origin.html` — frozen **day-zero** report (`ark start`/`ark init`
41
+ freezes this **right after** `ark.config.json`, before agent docs/CI templates)
41
42
  - `latest.json` / `latest.html` — every run
42
43
  - `history/*.json` — last ~20 machine-readable points for later tooling
43
44