arkgate 4.8.2 → 4.8.4

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 (73) hide show
  1. package/CHANGELOG.md +257 -3
  2. package/README.md +47 -9
  3. package/bin/ark-check-runtime.mjs +340 -5
  4. package/bin/ark-layer-match.mjs +170 -13
  5. package/bin/ark-mcp-runtime.mjs +9 -2
  6. package/bin/lib/analysis-completeness.mjs +86 -0
  7. package/bin/lib/analysis-engine.mjs +6 -6
  8. package/bin/lib/architecture-scan.mjs +2 -0
  9. package/bin/lib/ark-order-facts.mjs +59 -0
  10. package/bin/lib/ark-order-sensors.mjs +31 -2
  11. package/bin/lib/arkrule-file-hints.mjs +6 -2
  12. package/bin/lib/arkrules-contract.mjs +9 -1
  13. package/bin/lib/arkrules-sensors.mjs +22 -2
  14. package/bin/lib/check-args.mjs +66 -0
  15. package/bin/lib/config-contract.mjs +26 -0
  16. package/bin/lib/config-extras.mjs +2 -0
  17. package/bin/lib/design-smells.mjs +85 -0
  18. package/bin/lib/diagnostic-catalog.mjs +8 -2
  19. package/bin/lib/first-run-help.mjs +12 -0
  20. package/bin/lib/invariant-coverage-io.mjs +175 -19
  21. package/bin/lib/invariant-coverage.mjs +110 -7
  22. package/bin/lib/literal-path-drift-io.mjs +569 -0
  23. package/bin/lib/literal-path-drift.mjs +761 -0
  24. package/bin/lib/policy-delta-io.mjs +5 -0
  25. package/bin/lib/remediation.mjs +24 -1
  26. package/bin/lib/resolved-candidate-facts.mjs +31 -0
  27. package/bin/lib/rules-under-contract.mjs +5 -0
  28. package/bin/lib/scan-files.mjs +54 -0
  29. package/bin/lib/sensor-promote-cli.mjs +372 -0
  30. package/bin/lib/sensor-promote-io.mjs +246 -0
  31. package/bin/lib/sensor-promotion.mjs +363 -0
  32. package/dist/{configTypes-BdCe_gvv.d.ts → configTypes-dy5PfTqS.d.ts} +36 -0
  33. package/dist/{diagnosticCatalog-CPzH-MLN.d.ts → diagnosticCatalog-DgTs0abp.d.ts} +169 -11
  34. package/dist/eslint/index.cjs +5 -5
  35. package/dist/eslint/index.d.ts +34 -1
  36. package/dist/eslint/index.js +5 -5
  37. package/dist/index.cjs +31 -31
  38. package/dist/index.d.ts +85 -7
  39. package/dist/index.js +31 -31
  40. package/dist/nestjs/index.cjs +5 -5
  41. package/dist/nestjs/index.d.ts +3 -3
  42. package/dist/nestjs/index.js +5 -5
  43. package/dist/runtime/index.cjs +13 -13
  44. package/dist/runtime/index.d.ts +6 -6
  45. package/dist/runtime/index.js +13 -13
  46. package/dist/{types-DCSlrRnV.d.ts → types-BuM8WNqe.d.ts} +1 -1
  47. package/dist/{types-C9KApBzX.d.ts → types-D95drJ3_.d.ts} +1 -1
  48. package/docs/README.md +4 -4
  49. package/docs/agent-guide.md +182 -0
  50. package/docs/configuration.md +89 -9
  51. package/docs/develop.md +24 -2
  52. package/docs/diagnostics.md +79 -1
  53. package/docs/enthusiast/README.md +6 -4
  54. package/docs/package-surface.md +36 -4
  55. package/docs/product-voice.md +15 -5
  56. package/docs/use.md +8 -5
  57. package/package.json +2 -2
  58. package/schemas/ark.arkrules.schema.json +1 -0
  59. package/schemas/ark.config.schema.json +72 -0
  60. package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
  61. package/server.json +3 -3
  62. package/templates/agent-skills/README.md +1 -1
  63. package/templates/agent-skills/ark-adopt/SKILL.md +13 -3
  64. package/templates/agent-skills/ark-autopilot/SKILL.md +1 -1
  65. package/templates/agent-skills/ark-contract/SKILL.md +4 -0
  66. package/templates/agent-skills/ark-coverage/SKILL.md +1 -0
  67. package/templates/agent-skills/ark-place/SKILL.md +6 -2
  68. package/templates/arkrules/ApplicationOrchestration.json +6 -0
  69. package/templates/skills/ark-adopt.md +13 -3
  70. package/templates/skills/ark-autopilot.md +1 -1
  71. package/templates/skills/ark-contract.md +4 -0
  72. package/templates/skills/ark-coverage.md +1 -0
  73. package/templates/skills/ark-place.md +6 -2
@@ -12,6 +12,7 @@ import { effectiveAnalysisConfig } from './analysis-policy.mjs';
12
12
  import { resolveCandidateFacts } from './resolved-candidate-facts.mjs';
13
13
  import { loadEffectiveArkRulesFromDisk } from './effective-contract-load.mjs';
14
14
  import {
15
+ coverageOptionsFromConfig,
15
16
  invariantIdsFromCatalog,
16
17
  loadInvariantCoverageInputs,
17
18
  } from './invariant-coverage-io.mjs';
@@ -72,6 +73,7 @@ export function resolveArchitectureSnapshot({
72
73
  const coverageInputs = hasInvariants
73
74
  ? loadInvariantCoverageInputs(root, facts, {
74
75
  invariantIds: invariantIdsFromCatalog(arkRulesLoad.arkRules),
76
+ ...coverageOptionsFromConfig(effectiveConfig),
75
77
  })
76
78
  : undefined;
77
79
  // AR07: Tooling fileHints for orchestration-only / thin-adapter (reuse coverage contents when present).
@@ -10,6 +10,11 @@
10
10
 
11
11
  export const ARKORDER_PLANE_FACTORY = 'createOrderPlane';
12
12
  export const ARKORDER_FORBIDDEN_METHODS = ['update', 'patch', 'set', 'mutate'];
13
+ const IO_IMPORT_HINT_RE = /\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm|mongoose)/;
14
+ const PERSISTENCE_WRITE_HINT_RE = /\.(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))\s*\(|\bINSERT\s+INTO\b|\bUPDATE\s+[A-Za-z_][\w.]*\s+SET\b|\bDELETE\s+FROM\b/i;
15
+ function escapeRegExp(value) {
16
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
17
+ }
13
18
  export function isArkOrderModuleSpecifier(specifier) {
14
19
  return specifier === 'arkgate/order' || specifier.startsWith('arkgate/order/');
15
20
  }
@@ -51,3 +56,57 @@ export function extractArkOrderGenericUpdatesFromSource(file, content) {
51
56
  }
52
57
  return facts;
53
58
  }
59
+ /**
60
+ * Direct evidence: persistence driver import + write token + a declared slow key
61
+ * written as a property. Absence of xiKeys is the caller's problem (sensor stays silent).
62
+ */
63
+ export function extractArkOrderXiFieldWritesFromSource(file, content, xiKeys) {
64
+ if (xiKeys.length === 0)
65
+ return [];
66
+ const source = stripCommentsPreservingLines(content);
67
+ if (!IO_IMPORT_HINT_RE.test(source) || !PERSISTENCE_WRITE_HINT_RE.test(source))
68
+ return [];
69
+ const facts = [];
70
+ const seen = new Set();
71
+ for (const key of xiKeys) {
72
+ if (!key)
73
+ continue;
74
+ const re = new RegExp(`(?:\\b${escapeRegExp(key)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${escapeRegExp(key)}['"]\\s*:|[{\\,]\\s*${escapeRegExp(key)}\\s*[\\,}]|\\.${escapeRegExp(key)}\\s*=)`, 'g');
75
+ let match;
76
+ while ((match = re.exec(source)) !== null) {
77
+ const stamp = `${key}:${match.index}`;
78
+ if (seen.has(stamp))
79
+ continue;
80
+ seen.add(stamp);
81
+ facts.push({ file, line: lineAt(content, match.index), key });
82
+ break;
83
+ }
84
+ }
85
+ return facts;
86
+ }
87
+ /** ingest() assigned into a release / ξ / current / pattern store. */
88
+ export function extractArkOrderIngestWritesXiFromSource(file, content) {
89
+ const source = stripCommentsPreservingLines(content);
90
+ const facts = [];
91
+ const re = /(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi;
92
+ let match;
93
+ while ((match = re.exec(source)) !== null) {
94
+ facts.push({ file, line: lineAt(content, match.index) });
95
+ }
96
+ return facts;
97
+ }
98
+ /** Count primitive keys in `.release({ ... })` object literals (no nested ξ). */
99
+ export function extractArkOrderReleaseKeyCountsFromSource(file, content) {
100
+ const source = stripCommentsPreservingLines(content);
101
+ const facts = [];
102
+ const re = /\.release\s*\(\s*\{([^}]*)\}/g;
103
+ let match;
104
+ while ((match = re.exec(source)) !== null) {
105
+ const body = match[1] ?? '';
106
+ const keys = body.match(/\b[A-Za-z_][\w]*\s*:/g) ?? [];
107
+ if (keys.length === 0)
108
+ continue;
109
+ facts.push({ file, line: lineAt(content, match.index), keyCount: keys.length });
110
+ }
111
+ return facts;
112
+ }
@@ -8,7 +8,7 @@
8
8
  * Pure CLI helper (bin/lib/ark-order-sensors.mjs). Zero Node I/O.
9
9
  */
10
10
 
11
- import { extractArkOrderGenericUpdatesFromSource, extractArkOrderPlaneCallsFromSource, isArkOrderModuleSpecifier, } from './ark-order-facts.mjs';
11
+ import { extractArkOrderGenericUpdatesFromSource, extractArkOrderIngestWritesXiFromSource, extractArkOrderPlaneCallsFromSource, extractArkOrderReleaseKeyCountsFromSource, extractArkOrderXiFieldWritesFromSource, isArkOrderModuleSpecifier, } from './ark-order-facts.mjs';
12
12
  import { extraMergeTeethAllowed, } from './extra-merge-teeth.mjs';
13
13
  import { deterministicNextAction } from './remediation.mjs';
14
14
  export const ARKORDER_TIER1_SENSOR_IDS = [
@@ -17,6 +17,7 @@ export const ARKORDER_TIER1_SENSOR_IDS = [
17
17
  'arkorder-generic-update',
18
18
  'arkorder-too-many-params',
19
19
  'arkorder-ingest-writes-xi',
20
+ 'arkorder-xi-field-write',
20
21
  ];
21
22
  export const ARKORDER_RULE_IDS = {
22
23
  'arkorder-missing-plane': 'ARKORDER_MISSING_PLANE',
@@ -24,6 +25,7 @@ export const ARKORDER_RULE_IDS = {
24
25
  'arkorder-generic-update': 'ARKORDER_GENERIC_UPDATE',
25
26
  'arkorder-too-many-params': 'ARKORDER_TOO_MANY_PARAMS',
26
27
  'arkorder-ingest-writes-xi': 'ARKORDER_INGEST_WRITES_XI',
28
+ 'arkorder-xi-field-write': 'ARKORDER_XI_FIELD_WRITE',
27
29
  };
28
30
  function isDomainRoleLayer(layer, intentPrefixes = []) {
29
31
  const name = layer.trim();
@@ -96,6 +98,25 @@ export function evaluateArkOrderSensors(input) {
96
98
  for (const update of input.genericUpdates) {
97
99
  findings.push(finding(extra, 'arkorder-generic-update', update.file, update.line, `Generic ${update.method}() on the order plane rewrites ξ; Haken forbids it.`, { target: update.method }, teethAllowed));
98
100
  }
101
+ const xiKeys = extra.xiKeys ?? [];
102
+ if (xiKeys.length > extra.maxXiKeys) {
103
+ findings.push(finding(extra, 'arkorder-too-many-params', 'ark.config.json', 1, `arkOrder.xiKeys has ${xiKeys.length} keys; maxXiKeys is ${extra.maxXiKeys} (few slow modes).`, { target: String(xiKeys.length) }, teethAllowed));
104
+ }
105
+ for (const release of input.releaseKeyCounts ?? []) {
106
+ if (release.keyCount <= extra.maxXiKeys)
107
+ continue;
108
+ findings.push(finding(extra, 'arkorder-too-many-params', release.file, release.line, `release() freezes ${release.keyCount} keys; maxXiKeys is ${extra.maxXiKeys} (few slow modes).`, { target: String(release.keyCount) }, teethAllowed));
109
+ }
110
+ for (const ingest of input.ingestWritesXi ?? []) {
111
+ findings.push(finding(extra, 'arkorder-ingest-writes-xi', ingest.file, ingest.line, 'ingest() result is assigned into a Release or ξ store; ingest may absorb or escalate, never mint a pattern.', undefined, teethAllowed));
112
+ }
113
+ const managed = new Set(extra.managedLayers);
114
+ for (const write of xiKeys.length === 0 ? [] : input.xiFieldWrites ?? []) {
115
+ const fromLayer = input.layerForFile(write.file);
116
+ if (!fromLayer || !managed.has(fromLayer))
117
+ continue;
118
+ findings.push(finding(extra, 'arkorder-xi-field-write', write.file, write.line, `File writes slow key ${JSON.stringify(write.key)} through a persistence driver; route the field through ingest or a pattern change through proposeRelease.`, { fromLayer, target: write.key }, teethAllowed));
119
+ }
99
120
  findings.sort((left, right) => left.file.localeCompare(right.file) ||
100
121
  left.ruleId.localeCompare(right.ruleId) ||
101
122
  left.line - right.line);
@@ -106,13 +127,21 @@ export function evaluateArkOrderEditorSensors(input) {
106
127
  return [];
107
128
  const planeCalls = extractArkOrderPlaneCallsFromSource(input.file, input.source);
108
129
  const genericUpdates = extractArkOrderGenericUpdatesFromSource(input.file, input.source);
130
+ const xiKeys = input.arkOrder.xiKeys ?? [];
109
131
  return evaluateArkOrderSensors({
110
132
  arkOrder: input.arkOrder,
111
133
  layers: [],
112
134
  planeCalls,
113
135
  genericUpdates,
114
136
  planeRootHits: [],
137
+ xiFieldWrites: extractArkOrderXiFieldWritesFromSource(input.file, input.source, xiKeys),
138
+ ingestWritesXi: extractArkOrderIngestWritesXiFromSource(input.file, input.source),
139
+ releaseKeyCounts: extractArkOrderReleaseKeyCountsFromSource(input.file, input.source),
115
140
  dependencies: [],
116
141
  layerForFile: () => input.fromLayer,
117
- }).findings.filter((item) => item.sensor === 'arkorder-generic-update' || item.sensor === 'arkorder-kernel-in-domain');
142
+ }).findings.filter((item) => item.sensor === 'arkorder-generic-update' ||
143
+ item.sensor === 'arkorder-kernel-in-domain' ||
144
+ item.sensor === 'arkorder-xi-field-write' ||
145
+ item.sensor === 'arkorder-ingest-writes-xi' ||
146
+ item.sensor === 'arkorder-too-many-params');
118
147
  }
@@ -10,7 +10,11 @@ import { buildArkRuleFileHints } from './arkrules-sensors.mjs';
10
10
  const MAX_HINT_FILES = 400;
11
11
  const MAX_FILE_BYTES = 256 * 1024;
12
12
 
13
- const HINT_SENSORS = new Set(['orchestration-only', 'thin-adapter']);
13
+ const HINT_SENSORS = new Set([
14
+ 'orchestration-only',
15
+ 'thin-adapter',
16
+ 'writes-via-aggregate',
17
+ ]);
14
18
 
15
19
  /**
16
20
  * @param {{ structure?: Array<{ sensor?: string }> } | null | undefined} arkRules
@@ -26,7 +30,7 @@ export function needsArkRuleFileHints(arkRules) {
26
30
  * @param {{ files?: Array<{ path: string }> }} facts
27
31
  * @param {{ structure?: Array<{ sensor?: string }> } | null | undefined} arkRules
28
32
  * @param {Readonly<Record<string, string>>} [preloadedContents] optional reuse from coverage I/O
29
- * @returns {Record<string, { orchestrationHeavy?: boolean, adapterThick?: boolean }> | undefined}
33
+ * @returns {Record<string, { orchestrationHeavy?: boolean, adapterThick?: boolean, persistenceWrite?: boolean }> | undefined}
30
34
  */
31
35
  export function loadArkRuleFileHints(root, facts, arkRules, preloadedContents) {
32
36
  if (!needsArkRuleFileHints(arkRules)) return undefined;
@@ -17,6 +17,7 @@ export const ARK_RULE_SENSORS = [
17
17
  'domain-event-on-mutation',
18
18
  'orchestration-only',
19
19
  'thin-adapter',
20
+ 'writes-via-aggregate',
20
21
  'no-anemic-model',
21
22
  'invariant-coverage',
22
23
  ];
@@ -250,9 +251,16 @@ function validateSemantics(candidate, issues) {
250
251
  if (typeof entry.sensor === 'string' &&
251
252
  isTier2Sensor(entry.sensor) &&
252
253
  entry.mode === 'enforced') {
254
+ // Name the rule the AUTHOR wrote, not only the sensor it delegates to.
255
+ // A rule called "types-only" on `no-anemic-model` used to be refused with
256
+ // an error naming an id that appears nowhere in the author's file, and
257
+ // finding the connection cost a full run each time. `--sensors` reports
258
+ // the same fact before the attempt.
253
259
  issues.push({
254
260
  path: `$.structure[${index}].mode`,
255
- message: `sensor ${JSON.stringify(entry.sensor)} is Tier-2 advisory-only and cannot be enforced`,
261
+ message: `${id ? `rule ${JSON.stringify(id)} uses sensor ` : 'sensor '}` +
262
+ `${JSON.stringify(entry.sensor)}, which is Tier-2 advisory-only and cannot be enforced` +
263
+ `${id ? ' (arkgate-check --sensors lists which sensors can)' : ''}`,
256
264
  });
257
265
  }
258
266
  if (Array.isArray(entry.appliesTo) && entry.appliesTo.length === 0) {
@@ -187,6 +187,19 @@ function evaluateThinAdapter(rule, input) {
187
187
  }
188
188
  return out;
189
189
  }
190
+ function evaluateWritesViaAggregate(rule, input) {
191
+ const out = [];
192
+ for (const file of input.files) {
193
+ if (!matchesAppliesTo(file, rule.appliesTo))
194
+ continue;
195
+ if (!isInRuleLayer(file, rule, input.layerForFile))
196
+ continue;
197
+ if (input.fileHints?.[file]?.persistenceWrite) {
198
+ out.push(baseViolation(rule, file, `File imports a persistence driver and issues a write; route the write through a Domain aggregate and a persistence adapter (sensor writes-via-aggregate).`));
199
+ }
200
+ }
201
+ return out;
202
+ }
190
203
  function evaluateNoAnemicModel(rule, shapes, layerForFile) {
191
204
  // Tier-2: always advisory.
192
205
  const out = [];
@@ -223,6 +236,9 @@ export function evaluateArkRuleSensors(input) {
223
236
  case 'thin-adapter':
224
237
  violations.push(...evaluateThinAdapter(rule, input));
225
238
  break;
239
+ case 'writes-via-aggregate':
240
+ violations.push(...evaluateWritesViaAggregate(rule, input));
241
+ break;
226
242
  case 'no-anemic-model':
227
243
  violations.push(...evaluateNoAnemicModel(rule, input.classShapes, input.layerForFile));
228
244
  break;
@@ -292,7 +308,9 @@ export function collectEmptyAppliesToFindings(arkRules, files) {
292
308
  a.message.localeCompare(b.message));
293
309
  }
294
310
  /** IO / ORM import evidence (mirrors design-smells; kept local for Domain purity). */
295
- const IO_IMPORT_HINT_RE = /\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|better-sqlite3|ioredis|redis)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm)/;
311
+ const IO_IMPORT_HINT_RE = /\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm|mongoose)/;
312
+ /** Write tokens that skip the aggregate when paired with a persistence driver import. */
313
+ const PERSISTENCE_WRITE_HINT_RE = /\.(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))\s*\(|\bINSERT\s+INTO\b|\bUPDATE\s+[A-Za-z_][\w.]*\s+SET\b|\bDELETE\s+FROM\b/i;
296
314
  const HANDLER_SHAPE_HINT_RE = /\b(?:@Controller|@Get|@Post|@Put|@Delete|Router\(\)|createRouter|express\.Router|fastify\.(?:get|post)|export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|DELETE|PATCH)\b|export\s+const\s+(?:GET|POST|PUT|DELETE|PATCH)\s*=)/;
297
315
  const FRAMEWORK_HTTP_HINT_RE = /(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/;
298
316
  /** Business-predicate / domain branching signals (conservative). */
@@ -324,11 +342,13 @@ export function deriveArkRuleFileHints(_file, content) {
324
342
  (hasHandler && hasDomainSignal) ||
325
343
  (hasIo && hasMapping && (ifCount >= 4 || domainPredicates.length >= 1)) ||
326
344
  (hasHandler && hasIo); // hollow-persistence style: HTTP + persistence together
327
- if (!orchestrationHeavy && !adapterThick)
345
+ const persistenceWrite = hasIo && PERSISTENCE_WRITE_HINT_RE.test(content);
346
+ if (!orchestrationHeavy && !adapterThick && !persistenceWrite)
328
347
  return null;
329
348
  return {
330
349
  ...(orchestrationHeavy ? { orchestrationHeavy: true } : {}),
331
350
  ...(adapterThick ? { adapterThick: true } : {}),
351
+ ...(persistenceWrite ? { persistenceWrite: true } : {}),
332
352
  };
333
353
  }
334
354
  /**
@@ -51,6 +51,10 @@ export function parseArgs(argv) {
51
51
  migrateCommands: false,
52
52
  doctor: false,
53
53
  plan: false,
54
+ pathDrift: false,
55
+ sensors: false,
56
+ promote: undefined,
57
+ apply: false,
54
58
  recommend: false,
55
59
  writePlan: false,
56
60
  listPolicyPacks: false,
@@ -112,6 +116,24 @@ export function parseArgs(argv) {
112
116
  else if (arg === '--doctor') args.doctor = true;
113
117
  else if (arg === '--plan') args.plan = true;
114
118
  else if (arg === '--rules-inventory') args.rulesInventory = true;
119
+ else if (arg === '--path-drift') args.pathDrift = true;
120
+ else if (arg === '--sensors') args.sensors = true;
121
+ else if (arg === '--promote' || arg.startsWith('--promote=')) {
122
+ // Optional value, same shape as --report / --baseline: bare --promote
123
+ // previews every declared rule from ONE run, which is the point (the loop
124
+ // it replaces was one full run per attempted promotion); a value narrows
125
+ // to that rule id.
126
+ // `--promote=<id>` too: a rule id may legally begin with '-', and the
127
+ // lookahead form can never pass one.
128
+ const eq = arg.indexOf('=');
129
+ if (eq > 0) {
130
+ args.promote = arg.slice(eq + 1);
131
+ } else {
132
+ const next = argv[i + 1];
133
+ args.promote = next && !next.startsWith('-') ? argv[++i] : true;
134
+ }
135
+ }
136
+ else if (arg === '--apply') args.apply = true;
115
137
  else if (arg === '--recommend') args.recommend = true;
116
138
  else if (arg === '--write-plan') args.writePlan = true;
117
139
  else if (arg === '--list-policy-packs') args.listPolicyPacks = true;
@@ -170,5 +192,49 @@ export function parseArgs(argv) {
170
192
  else if (arg === '--version' || arg === '-V') args.version = true;
171
193
  else throw new Error(`Unknown argument: ${arg}. Run arkgate-check --help for usage.`);
172
194
  }
195
+ // A write flag that silently does nothing is how a caller comes to believe a
196
+ // change landed. --apply belongs to --promote; the other write surfaces use
197
+ // --write.
198
+ if (args.apply && !args.promote) {
199
+ throw new Error(
200
+ '--apply applies to --promote. Run `arkgate-check --promote <ruleId> --apply`; the other write surfaces use --write.'
201
+ );
202
+ }
203
+ // Every report mode below returns from main() BEFORE --promote is reached, so
204
+ // pairing one with --promote --apply printed that report and exited 0 having
205
+ // written nothing. Same defect the guard above exists for, one level up.
206
+ if (args.promote) {
207
+ const shadowing = [
208
+ args.sensors && '--sensors',
209
+ args.pathDrift && '--path-drift',
210
+ args.coverage && '--coverage',
211
+ args.recommend && '--recommend',
212
+ args.doctor && '--doctor',
213
+ args.plan && '--plan',
214
+ args.rulesInventory && '--rules-inventory',
215
+ args.suggestInclude && '--suggest-include',
216
+ args.adoptContract && '--adopt-contract',
217
+ args.migrateContract && '--migrate-contract',
218
+ ].filter(Boolean);
219
+ if (shadowing.length > 0) {
220
+ throw new Error(
221
+ `--promote cannot be combined with ${shadowing.join(', ')}: that mode answers first and --promote would silently do nothing. Run them separately.`
222
+ );
223
+ }
224
+ // A narrowed scope cannot price a promotion. --changed counts findings over
225
+ // the changed files only and --baseline suppresses findings AFTER --promote
226
+ // has already returned, so either one turns the cost into an undercount
227
+ // printed as a fact.
228
+ const narrowing = [
229
+ args.changed && '--changed',
230
+ args.against && '--against',
231
+ args.baseline && '--baseline',
232
+ ].filter(Boolean);
233
+ if (narrowing.length > 0) {
234
+ throw new Error(
235
+ `--promote cannot be combined with ${narrowing.join(', ')}: the promotion cost must be measured over the whole governed tree, and a narrowed or baselined scope would report an undercount as the price.`
236
+ );
237
+ }
238
+ }
173
239
  return args;
174
240
  }
@@ -105,6 +105,8 @@ export const ARK_CONFIG_SCHEMA = {
105
105
  allowDisabledPeerIsolation: false,
106
106
  },
107
107
  },
108
+ /** Invariant-coverage scan controls (test globs + file budget). Absence keeps defaults. */
109
+ coverage: { $ref: '#/$defs/coverage' },
108
110
  /** ADR 0012 — layer name → relative path to arkrules/<Layer>.json */
109
111
  arkRules: {
110
112
  type: 'object',
@@ -172,6 +174,20 @@ export const ARK_CONFIG_SCHEMA = {
172
174
  message: { type: 'string', minLength: 1 },
173
175
  peerIsolation: { type: 'boolean' },
174
176
  sliceFolders: { ...stringArraySchema, minItems: 1 },
177
+ sharedRoots: { ...stringArraySchema, minItems: 1 },
178
+ allowedCrossSlice: {
179
+ type: 'array',
180
+ minItems: 1,
181
+ items: {
182
+ type: 'object',
183
+ additionalProperties: false,
184
+ required: ['from', 'to'],
185
+ properties: {
186
+ from: { type: 'string', minLength: 1 },
187
+ to: { type: 'string', minLength: 1 },
188
+ },
189
+ },
190
+ },
175
191
  },
176
192
  },
177
193
  safety: {
@@ -184,6 +200,16 @@ export const ARK_CONFIG_SCHEMA = {
184
200
  allowDisabledPeerIsolation: { type: 'boolean', default: false },
185
201
  },
186
202
  },
203
+ coverage: {
204
+ type: 'object',
205
+ additionalProperties: false,
206
+ description: 'Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget; coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.',
207
+ properties: {
208
+ testGlobs: { ...stringArraySchema, minItems: 1 },
209
+ maxFiles: { type: 'integer', minimum: 1 },
210
+ coverageRoots: { ...stringArraySchema, minItems: 1 },
211
+ },
212
+ },
187
213
  arkRun: ARK_RUN_SCHEMA_DEF,
188
214
  arkOrder: ARK_ORDER_SCHEMA_DEF,
189
215
  },
@@ -41,6 +41,7 @@ export const ARK_ORDER_SCHEMA_DEF = {
41
41
  planeRoots: { ...stringArraySchema, default: [] },
42
42
  managedLayers: { ...stringArraySchema, default: [] },
43
43
  maxXiKeys: { type: 'integer', minimum: 1, default: 7 },
44
+ xiKeys: { ...stringArraySchema, default: [] },
44
45
  },
45
46
  };
46
47
  function isObject(value) {
@@ -83,6 +84,7 @@ export function defaultedArkOrder(value) {
83
84
  planeRoots: value.planeRoots === undefined ? [] : value.planeRoots,
84
85
  managedLayers: value.managedLayers === undefined ? [] : value.managedLayers,
85
86
  maxXiKeys: max,
87
+ xiKeys: value.xiKeys === undefined ? [] : value.xiKeys,
86
88
  };
87
89
  }
88
90
  export function validateArkRunExtra(config, issues) {
@@ -490,6 +490,91 @@ export function summarizeDesignFitness(smells, ctx = {}) {
490
490
  };
491
491
  }
492
492
 
493
+ /** How many smell ids the green-run pointer names before it counts the rest. */
494
+ export const GREEN_PLAN_POINTER_MAX_IDS = 4;
495
+
496
+ /**
497
+ * Name `--plan` on a run that passed.
498
+ *
499
+ * `--plan` is where the design bets live, and a green run never pointed at it:
500
+ * a whole adopter session went by without opening it, because `✔ Ark check
501
+ * passed` reads as *finished*. Clean import edges are not a settled design, and
502
+ * the summary was saying only the first half of what the run already knows.
503
+ *
504
+ * Report only, and deliberately quiet. Its weakness test is `isDesignWeak` with
505
+ * the **blocking** violation count, the same input doctor uses, so the two
506
+ * surfaces can never disagree about `designWeak`. It never changes the exit
507
+ * code, and it stays silent when there is nothing behind the pass — a line that
508
+ * always prints is a line nobody reads. The caller passes the runner-correct
509
+ * command so this stays pure.
510
+ *
511
+ * A baselined run is not a clean run: violations suppressed by the ratchet are
512
+ * still violations, and the summary line directly above says so. The opening
513
+ * clause reports which of the two it is.
514
+ *
515
+ * @param {DesignSmell[]} smells
516
+ * @param {{ blockingViolations?: number, governedPercent?: number|null, totalFiles?: number|null, suppressedCount?: number }} ctx
517
+ * @param {string} planCommand
518
+ * @returns {string | null}
519
+ */
520
+ export function formatGreenPlanPointer(smells, ctx = {}, planCommand = 'ark-check --plan') {
521
+ const weak = isDesignWeak(smells, {
522
+ activeViolations: ctx.blockingViolations ?? 0,
523
+ governedPercent: ctx.governedPercent ?? null,
524
+ totalFiles: ctx.totalFiles ?? null,
525
+ });
526
+ if (!weak) return null;
527
+ const ids = [...new Set((smells || []).map((smell) => smell?.id).filter(Boolean))].sort();
528
+ if (ids.length === 0) return null;
529
+ const shown = ids.slice(0, GREEN_PLAN_POINTER_MAX_IDS);
530
+ const hidden = ids.length - shown.length;
531
+ const named = hidden > 0 ? `${shown.join(', ')}, +${hidden} more` : shown.join(', ');
532
+ const plural = ids.length === 1 ? '' : 's';
533
+ const suppressed = ctx.suppressedCount ?? 0;
534
+ const opening =
535
+ suppressed > 0
536
+ ? `No blocking import-rule violations (${suppressed} suppressed by baseline)`
537
+ : 'Import rules are clean';
538
+ return (
539
+ `${opening}; the design bets are not settled — ${ids.length} design smell${plural} ` +
540
+ `(${named}). They never fail this check: ${planCommand}`
541
+ );
542
+ }
543
+
544
+ /**
545
+ * The same pointer, composed against the tree the run just analyzed.
546
+ *
547
+ * Kept here rather than in the CLI entry: the smell scan is filesystem work and
548
+ * `bin/ark-check-runtime.mjs` is orchestration under a line budget. A failure
549
+ * is swallowed on purpose — a discoverability hint must never change the
550
+ * outcome of a green run — but it is not silent under `ARK_DEBUG`, or a
551
+ * refactor could leave this permanently dead with no signal anywhere.
552
+ *
553
+ * @param {{ root: string, config: object, files: string[], coverage: object|null,
554
+ * blockingViolations: number, suppressedCount?: number, planCommand: string }} options
555
+ * @returns {string | null}
556
+ */
557
+ export function greenPlanPointer(options) {
558
+ try {
559
+ const { root, config, files, coverage } = options;
560
+ return formatGreenPlanPointer(
561
+ detectDesignSmells(root, config, files, coverage),
562
+ {
563
+ blockingViolations: options.blockingViolations,
564
+ governedPercent: coverage?.governed?.percent ?? null,
565
+ totalFiles: coverage?.totalFiles ?? null,
566
+ suppressedCount: options.suppressedCount ?? 0,
567
+ },
568
+ options.planCommand
569
+ );
570
+ } catch (error) {
571
+ if (process.env.ARK_DEBUG === '1') {
572
+ console.error(`[ark-check] green --plan pointer skipped: ${error?.message ?? error}`);
573
+ }
574
+ return null;
575
+ }
576
+ }
577
+
493
578
  /**
494
579
  * Build plan-B pattern bets from smells (P03). Never mechanical-safe.
495
580
  *
@@ -52,10 +52,11 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
52
52
  entry('IN_MEMORY_STORE_IN_PRODUCTION_SOURCE', 'safety', 'In-memory store in production source', 'Governed production source references an Ark InMemory* store without safety.allowInMemory — durable systems should not ship ephemeral stores by accident.', 'Provide a durable store implementation, or set safety.allowInMemory only for an explicitly ephemeral service.'),
53
53
  entry('PEER_ISOLATION_DISABLED', 'safety', 'peerIsolation disabled on a rule', 'A same-layer or peer rule disables peerIsolation (or omits it where required), which allows cross-slice coupling the contract otherwise blocks.', 'Restore peerIsolation: true, or set safety.allowDisabledPeerIsolation only with a documented production exception.'),
54
54
  // ── ArkRules ─────────────────────────────────────────────────────────────
55
- entry('ARKRULE_STRUCTURE', 'arkrules', 'ArkRule structure sensor failed', 'An opt-in ArkRules structure sensor (private state, factory shape, event publish, …) failed on a governed file for a declared arkruleId.', 'Restore the declared structure for the ArkRule (see arkruleSource), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.'),
55
+ entry('ARKRULE_STRUCTURE', 'arkrules', 'ArkRule structure sensor failed', 'An opt-in ArkRules structure sensor (private state, factory shape, event publish, persistence write outside an aggregate, …) failed on a governed file for a declared arkruleId.', 'Restore the declared structure for the ArkRule (see arkruleSource), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.'),
56
56
  entry('ARKRULE_INVARIANT', 'arkrules', 'ArkRule invariant failed', 'Reserved / remediation-recognized code for invariant-plane failures bound to an ArkRule id (coverage path also emits INVARIANT_UNCOVERED).', 'Fix the invariant for the ArkRule declared in arkrules/<Layer>.json, then preflight again. Do not demote without acknowledgement.'),
57
57
  entry('ARKRULE_SCOPE_EMPTY', 'arkrules', 'ArkRule appliesTo matched zero files', 'An ArkRule’s appliesTo globs matched no governed files — the rule cannot observe what it claims to protect.', 'Fix appliesTo globs so they match governed files, or remove the rule. Enforced empty scope fails; advisory empty scope warns.', { oftenAdvisory: true }),
58
- entry('INVARIANT_UNCOVERED', 'arkrules', 'Invariant without coverage evidence', 'An ArkRules invariant is under contract but no covering test title or declared symbol evidence was found (or coverage is partial). Kind is never-had-tests (adopt residual) vs tests-disappeared (suite exists).', 'Add a test title or declared symbol covering the arkruleId, then preflight again. Treat never-had-tests as adopt residual; treat tests-disappeared as a regression. Missing test globs report partial — never fake green.'),
58
+ entry('INVARIANT_UNCOVERED', 'arkrules', 'Invariant without coverage evidence', 'An ArkRules invariant is under contract but no covering test title or declared symbol evidence was found (or coverage is partial). Kind is never-had-tests (adopt residual) vs tests-disappeared (suite exists).', 'Add a test title or declared symbol covering the arkruleId, then preflight again. Treat never-had-tests as adopt residual; treat tests-disappeared as a regression. Missing test globs report partial — never fake green. When the message reports an exhausted file budget, raise coverage.maxFiles (or narrow coverage.testGlobs) in ark.config.json.'),
59
+ entry('INVARIANT_COVERAGE_OUTSIDE_ROOTS', 'arkrules', 'Covering test outside the declared coverage roots', 'The only test naming this invariant sits outside coverage.coverageRoots — the places the project declares its runner executes. ArkGate matches declared text and never executes tests, so it cannot tell whether that file is ever run: coverage there is a test that exists, not a test that runs.', 'Move the test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json. Advisory: it never fails strict, but promotion to enforced refuses on it.', { oftenAdvisory: true }),
59
60
  // ── ArkRun (opt-in extra; RN05 dual-depth nextAction) ────────────────────
60
61
  entry('ARKRUN_MISSING_ROOT', 'arkrun', 'No kernel factory in composition roots', 'The ArkRun extra is on but no createArkKernel / createStrictArkKernel / createArkKernelFromConfig / createStrictArkKernelFromConfig factory was found in arkRun.compositionRoots, so agents can skip the kernel while the write gate stays green.', 'Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe — factory placement is a design decision.'),
61
62
  entry('ARKRUN_KERNEL_IN_DOMAIN', 'arkrun', 'Domain-role layer imports the kernel', 'A Domain-role layer imports arkgate/runtime, @arkgate/runtime, or kernel types. Domain stays kernel-free; composition roots and adapters own the factory.', 'Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.'),
@@ -69,6 +70,7 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
69
70
  entry('ARKORDER_GENERIC_UPDATE', 'arkorder', 'Generic update of ξ', 'A call to update/patch/set on the order plane rewrites the slow pattern. Haken slaving forbids generic ξ mutation.', 'Use release() to freeze ξ or proposeRelease() for a pattern change with blast radius, then preflight again. Never mechanical-safe.'),
70
71
  entry('ARKORDER_TOO_MANY_PARAMS', 'arkorder', 'Too many slow keys', 'ξ has more keys than arkOrder.maxXiKeys. Haken requires a few slow modes, not a dump of microstate.', 'Cut ξ to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.'),
71
72
  entry('ARKORDER_INGEST_WRITES_XI', 'arkorder', 'ingest assigned into ξ', 'An ingest() result is written into a Release or ξ store. ingest may absorb or escalate; it never mints a pattern.', 'Keep ingest results as absorb/escalate only. Change ξ with proposeRelease + release. Never mechanical-safe.'),
73
+ entry('ARKORDER_XI_FIELD_WRITE', 'arkorder', 'Slow key written around the order plane', 'A managed-layer file imports a persistence driver and writes a declared arkOrder.xiKeys name. Field events absorb or escalate; they do not PATCH the slow pattern.', 'Keep invoices, seats, hours, and logs on ingest. Change the slow key with proposeRelease + release, then preflight again. Never mechanical-safe.'),
72
74
  // ── atomic preflight / change set ────────────────────────────────────────
73
75
  entry('INVALID_CHANGE_PATH', 'preflight', 'Unsafe change path', 'A change set entry is not a safe, non-empty project-relative path (absolute, escape, empty, or NUL).', 'Use canonical project-relative paths only in the atomic change set, then preflight again.'),
74
76
  entry('DUPLICATE_CHANGE_PATH', 'preflight', 'Duplicate path in change set', 'The atomic change set lists more than one operation for the same path.', 'Collapse to one create/update/delete per path, then preflight again.'),
@@ -84,6 +86,7 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
84
86
  // ── analysis completeness / host ─────────────────────────────────────────
85
87
  entry('ANALYSIS_PARSE_INCOMPLETE', 'analysis', 'Parse incomplete', 'Governed source could not be fully parsed; evidence includes the TypeScript diagnostic (line + message). Incremental mid-edit parse is normal for agents. Contract exclude paths skip the write hook.', 'Finish the source or fix the reported syntax error, then re-run `npx arkgate-check`. The write hook does not deny solely on mid-edit parse. Partial never means pass.'),
86
88
  entry('LEXICAL_EVIDENCE_INCOMPLETE', 'analysis', 'Lexical evidence incomplete', 'Single-file validation cannot prove project module resolution. The write hook is already the verdict.', 'Re-run `npx arkgate-check --root . --config ark.config.json`, or treat the hook deny as final. Do not call ark_prepare_change from a hook deny.'),
89
+ entry('ANALYSIS_COVERS_NO_FILES', 'analysis', 'Analysis covered no files', 'No file matched the contract include and layer patterns under the analyzed root, so the run had nothing to check. Every rule is vacuously satisfied on an empty set: a green here would read exactly like a green over a governed tree while certifying nothing. Usual causes are a --root that is not the tree the contract describes (including a contract found outside the requested root, whose directory is then adopted as the project root), include / exclude patterns that match nothing, or layer patterns written for a different layout.', 'Point --root at the tree the contract describes, or keep the contract inside that tree, or fix the include / exclude / layer patterns so they match real files — then re-run `npx arkgate-check --root . --config ark.config.json`. This is a refusal about ArkGate\u2019s own inputs, not a finding about your code; no baseline or policy acknowledgement can suppress it.'),
87
90
  entry('ANALYSIS_HOST_UNAVAILABLE', 'analysis', 'Analysis host unavailable', 'No usable TypeScript / analysis host was available for this invocation.', 'Install a supported TypeScript version visible to the project, then re-run. Unavailable analysis is fail-closed.'),
88
91
  entry('ADAPTER_NOT_ALLOWED_FOR_PORT', 'adapter', 'Adapter not allowed for port', 'Runtime/port wiring selected an adapter implementation that the architecture profile does not allow for that port.', 'Bind an allowed adapter for the port, or adjust the profile with an explicit policy decision — then re-run.'),
89
92
  // ── AI snippet gate policy surface ───────────────────────────────────────
@@ -108,6 +111,9 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
108
111
  entry('CONFIG_RULE_UNKNOWN_TO_LAYER', 'config', 'Rule unknown to layer', 'A dependency rule references a target layer name that is not declared.', 'Fix the rule’s to field to a declared layer name.', { oftenAdvisory: true }),
109
112
  entry('CONFIG_AMBIGUOUS_LAYERS', 'config', 'Ambiguous layer classification', 'Some files match multiple layers at equal specificity; classification falls back to declaration order.', 'Disambiguate overlapping patterns so each file has one clear layer owner.', { oftenAdvisory: true }),
110
113
  entry('CONFIG_UNCLASSIFIED_FILES', 'config', 'Unclassified included files', 'Included source files match no layer pattern; import rules will not enforce on them.', 'Extend layer patterns or narrow include so every governed file is classified.', { oftenAdvisory: true }),
114
+ // ── literal path drift ───────────────────────────────────────────────────
115
+ entry('LITERAL_PATH_DRIFT', 'drift', 'Literal path moved by a rename', 'A repo path written inside a string, a comment or a docstring no longer resolves, and the rename set says where it went. Nothing in the gate sees this class: `tsc` resolves imports, not strings, and ESLint does not either, so the rename compiles green and the reference lies afterwards. It appears in four forms — the tsconfig alias, a relative literal, a path written without the include-root prefix, and prose — and a hand sweep reliably covers one of them.', 'Apply the suggested replacement, or re-run `npx arkgate-check --path-drift --base-ref <ref> --write` to apply every writable anchored replacement at once. The rewrite is mechanical and one-directional: the destination comes from the rename, it must itself resolve and be path-shaped, and the token is rewritten in the form the author wrote it in. A destination that leaves the alias root of the literal is reported with the target only and must be rewritten by hand.'),
116
+ entry('LITERAL_PATH_UNRESOLVED', 'drift', 'Literal path does not resolve', 'A literal that looks like a repo path does not resolve under this root, and no rename explains where it went. Unlike LITERAL_PATH_DRIFT this is a candidate, not a verdict: with nothing to anchor it, ArkGate cannot tell a dead reference from an illustrative path in a comment, an example in documentation, or a path belonging to another tree.', 'Read the candidate and decide: fix the path, or leave it. Advisory only — it never fails a run and is never rewritten by --write, because there is no destination to propose. Run `--path-drift --all` to list the sweep.', { oftenAdvisory: true }),
111
117
  // ── meta ─────────────────────────────────────────────────────────────────
112
118
  entry('ARK_UNKNOWN', 'meta', 'Unknown diagnostic', 'A diagnostic lacked a stable ruleId/code; adapters may emit this fallback so agents never see an empty id.', 'Resolve the underlying finding without weakening ark.config.json, then run Ark again. Prefer fixing the producer to emit a catalogued ruleId.'),
113
119
  ]);
@@ -117,6 +117,18 @@ export function checkUsageAll() {
117
117
  ' ark-check --coverage [--json] per-layer file counts + full unclassified list (report only, exit 0)',
118
118
  ' ark-check --plan [--json] classified remediation plan (mechanical-safe / judgment / deferred) + goal; report only',
119
119
  ' ark-check --rules-inventory [--json] brownfield rules inventory (AR13; deterministic candidates, not a score)',
120
+ ' ark-check --path-drift [--base-ref <git-ref>] [--all] [--json] [--write]',
121
+ ' literal path drift: repo paths inside strings, comments and docstrings that no longer resolve.',
122
+ ' Anchored on the rename set vs --base-ref, so each finding carries a replacement; --write applies them.',
123
+ ' --all adds the unanchored advisory sweep (candidates, not a verdict; never written).',
124
+ ' Exit 0 ran and clean, 1 drift remains, 2 could not run (no usable base ref).',
125
+ ' ark-check --sensors [--json] every sensor with its tier and whether it can EVER be enforced, plus every declared rule',
126
+ ' with its local id, the sensor it delegates to, its source file, its mode and why it can or cannot be promoted.',
127
+ ' Contract + coverage-evidence only: no TypeScript, no analysis. Exit 0 on a report, 2 if the contract will not load.',
128
+ ' ark-check --promote [<ruleId>] [--json] [--apply]',
129
+ ' what enforcing would cost: the findings each advisory rule already produces, from ONE run rather than one run per attempt.',
130
+ ' Plan by default; --promote <ruleId> --apply (or --promote=<ruleId>) writes mode "enforced" into the ArkRules file that declares it.',
131
+ ' A cost the run could not measure (incomplete analysis, classification floor) is named and --apply refuses. Exit 0 / 1 refused / 2 bad args.',
120
132
  ' ark-check --recommend [--json] [--write-plan] application-shape plan; --write-plan emits ark-adoption-plan.json',
121
133
  ' ark-check --list-policy-packs enthusiast packs (hexagonal, layered, feature-sliced, monorepo, ui-surface, vertical-slice, ddd-bounded-contexts)',
122
134
  ' ark-check --apply-policy-pack <id> [--force] write ark.config.json from templates/policy-packs/ (uses preset factory)',