arkgate 4.8.3 → 4.8.5

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 (70) hide show
  1. package/CHANGELOG.md +279 -1
  2. package/README.md +17 -7
  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/agent-homes.mjs +41 -6
  7. package/bin/lib/analysis-completeness.mjs +86 -0
  8. package/bin/lib/analysis-engine.mjs +8 -8
  9. package/bin/lib/architecture-scan.mjs +2 -0
  10. package/bin/lib/ark-order-invariants.mjs +37 -0
  11. package/bin/lib/ark-order-sensors.mjs +4 -0
  12. package/bin/lib/arkrules-contract.mjs +8 -1
  13. package/bin/lib/check-args.mjs +68 -0
  14. package/bin/lib/config-contract.mjs +26 -0
  15. package/bin/lib/design-smells.mjs +85 -0
  16. package/bin/lib/diagnostic-catalog.mjs +9 -1
  17. package/bin/lib/first-run-help.mjs +16 -4
  18. package/bin/lib/invariant-coverage-io.mjs +175 -19
  19. package/bin/lib/invariant-coverage.mjs +110 -7
  20. package/bin/lib/literal-path-drift-io.mjs +569 -0
  21. package/bin/lib/literal-path-drift.mjs +761 -0
  22. package/bin/lib/policy-delta-io.mjs +5 -0
  23. package/bin/lib/remediation.mjs +25 -1
  24. package/bin/lib/rules-under-contract.mjs +5 -0
  25. package/bin/lib/scan-files.mjs +54 -0
  26. package/bin/lib/sensor-promote-cli.mjs +372 -0
  27. package/bin/lib/sensor-promote-io.mjs +246 -0
  28. package/bin/lib/sensor-promotion.mjs +363 -0
  29. package/bin/lib/skill-catalog-apply.mjs +18 -1
  30. package/bin/lib/skill-install.mjs +4 -3
  31. package/bin/lib/upgrade-whats-new.mjs +1 -1
  32. package/dist/{configTypes-dNJ2C0yx.d.ts → configTypes-dy5PfTqS.d.ts} +31 -0
  33. package/dist/{diagnosticCatalog-C5GgeyEE.d.ts → diagnosticCatalog-DMO30svh.d.ts} +75 -7
  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 +30 -30
  38. package/dist/index.d.ts +68 -5
  39. package/dist/index.js +29 -29
  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/order/index.cjs +1 -1
  44. package/dist/order/index.d.ts +11 -2
  45. package/dist/order/index.js +1 -1
  46. package/dist/runtime/index.cjs +11 -11
  47. package/dist/runtime/index.d.ts +30 -7
  48. package/dist/runtime/index.js +11 -11
  49. package/dist/{types-dK24fDZa.d.ts → types-BuM8WNqe.d.ts} +1 -1
  50. package/dist/{types-DeK7SYGC.d.ts → types-CzE6LMaW.d.ts} +2 -2
  51. package/docs/README.md +5 -4
  52. package/docs/agent-guide.md +186 -4
  53. package/docs/ai-gates.md +13 -2
  54. package/docs/arkorder.md +210 -0
  55. package/docs/configuration.md +88 -5
  56. package/docs/develop.md +4 -2
  57. package/docs/diagnostics.md +97 -1
  58. package/docs/enthusiast/how-to-agent-gates.md +1 -1
  59. package/docs/package-surface.md +37 -5
  60. package/docs/use.md +1 -1
  61. package/package.json +3 -2
  62. package/schemas/ark.config.schema.json +63 -0
  63. package/server.json +3 -3
  64. package/templates/agent-skills/README.md +1 -1
  65. package/templates/agent-skills/ark-adopt/SKILL.md +5 -0
  66. package/templates/agent-skills/ark-coverage/SKILL.md +1 -0
  67. package/templates/agent-skills/ark-upgrade/SKILL.md +1 -1
  68. package/templates/skills/ark-adopt.md +5 -0
  69. package/templates/skills/ark-coverage.md +1 -0
  70. package/templates/skills/ark-upgrade.md +1 -1
@@ -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).
@@ -76,6 +76,7 @@ export function hashReleasePayload(xi, sigma) {
76
76
  export function createFrozenRelease(input) {
77
77
  assertXiKeyCap(input.xi, input.maxXiKeys);
78
78
  const xi = freezeRecord(input.xi, 'ξ');
79
+ assertXiHasNoTtl(xi);
79
80
  assertXiSchema(xi, input.xiSchema);
80
81
  const sigma = freezeRecord(input.sigma ?? {}, 'σ');
81
82
  const release = Object.freeze({
@@ -87,14 +88,49 @@ export function createFrozenRelease(input) {
87
88
  });
88
89
  return release;
89
90
  }
91
+ const XI_TTL_KEY_RE = /^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;
92
+ export function assertXiHasNoTtl(xi) {
93
+ for (const key of Object.keys(xi)) {
94
+ if (XI_TTL_KEY_RE.test(key)) {
95
+ throw new ArkOrderError('ARKORDER_XI_TTL', `ξ key ${JSON.stringify(key)} is a freshness field; TTL belongs on σ, never on ξ`);
96
+ }
97
+ }
98
+ }
99
+ export function assertInformationBudget(projection, budget) {
100
+ if (!budget || budget.cannotObserve.length === 0)
101
+ return;
102
+ const denied = new Set(budget.cannotObserve);
103
+ for (const kind of projection.allowedKinds) {
104
+ if (denied.has(kind)) {
105
+ throw new ArkOrderError('ARKORDER_INFORMATION_BUDGET', `projection allows ${JSON.stringify(kind)}; informationBudget.cannotObserve forbids it`);
106
+ }
107
+ }
108
+ }
109
+ export function assertSigmaFresh(input) {
110
+ if (input.maxAgeMs === undefined)
111
+ return;
112
+ const until = input.sigma.freshUntil;
113
+ if (typeof until === 'number') {
114
+ if (input.now > until) {
115
+ throw new ArkOrderError('ARKORDER_STALE_SIGMA', 'σ freshUntil has elapsed; ξ does not TTL');
116
+ }
117
+ return;
118
+ }
119
+ const origin = typeof input.sigma.releasedAt === 'number' ? input.sigma.releasedAt : input.releasedAt;
120
+ if (typeof origin === 'number' && input.now - origin > input.maxAgeMs) {
121
+ throw new ArkOrderError('ARKORDER_STALE_SIGMA', 'σ is older than sigmaMaxAgeMs; ξ does not TTL');
122
+ }
123
+ }
90
124
  export function classifyIngest(projection, event, packs = []) {
91
125
  const kind = event.kind;
92
126
  for (const pack of packs) {
93
127
  if (pack.escalateKinds?.includes(kind)) {
128
+ const target = pack.escalateTarget ?? 'human';
94
129
  return {
95
130
  kind: 'escalate',
96
131
  event,
97
132
  reason: `pack ${pack.id} slaves kind ${JSON.stringify(kind)} to a pattern change`,
133
+ target,
98
134
  };
99
135
  }
100
136
  }
@@ -105,6 +141,7 @@ export function classifyIngest(projection, event, packs = []) {
105
141
  kind: 'escalate',
106
142
  event,
107
143
  reason: `kind ${JSON.stringify(kind)} is not allowed by h(ξ); field cannot rewrite the pattern`,
144
+ target: 'human',
108
145
  };
109
146
  }
110
147
  export function blastRadiusOf(previous, next) {
@@ -18,6 +18,8 @@ export const ARKORDER_TIER1_SENSOR_IDS = [
18
18
  'arkorder-too-many-params',
19
19
  'arkorder-ingest-writes-xi',
20
20
  'arkorder-xi-field-write',
21
+ 'arkorder-information-budget',
22
+ 'arkorder-xi-ttl',
21
23
  ];
22
24
  export const ARKORDER_RULE_IDS = {
23
25
  'arkorder-missing-plane': 'ARKORDER_MISSING_PLANE',
@@ -26,6 +28,8 @@ export const ARKORDER_RULE_IDS = {
26
28
  'arkorder-too-many-params': 'ARKORDER_TOO_MANY_PARAMS',
27
29
  'arkorder-ingest-writes-xi': 'ARKORDER_INGEST_WRITES_XI',
28
30
  'arkorder-xi-field-write': 'ARKORDER_XI_FIELD_WRITE',
31
+ 'arkorder-information-budget': 'ARKORDER_INFORMATION_BUDGET',
32
+ 'arkorder-xi-ttl': 'ARKORDER_XI_TTL',
29
33
  };
30
34
  function isDomainRoleLayer(layer, intentPrefixes = []) {
31
35
  const name = layer.trim();
@@ -251,9 +251,16 @@ function validateSemantics(candidate, issues) {
251
251
  if (typeof entry.sensor === 'string' &&
252
252
  isTier2Sensor(entry.sensor) &&
253
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.
254
259
  issues.push({
255
260
  path: `$.structure[${index}].mode`,
256
- 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)' : ''}`,
257
264
  });
258
265
  }
259
266
  if (Array.isArray(entry.appliesTo) && entry.appliesTo.length === 0) {
@@ -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;
@@ -127,11 +149,13 @@ export function parseArgs(argv) {
127
149
  else if (arg === '--prune-home-duplicates') args.pruneHomeDuplicates = true;
128
150
  else if (arg === '--claude-home') args.claudeHome = true;
129
151
  else if (arg === '--grok-home') args.grokHome = true;
152
+ else if (arg === '--antigravity-home') args.antigravityHome = true;
130
153
  else if (arg === '--agent-homes') {
131
154
  args.agentHomes = true;
132
155
  args.codexHome = true;
133
156
  args.claudeHome = true;
134
157
  args.grokHome = true;
158
+ args.antigravityHome = true;
135
159
  }
136
160
  else if (arg === '--migrate-commands') args.migrateCommands = true;
137
161
  else if (arg === '--no-cache') args.noCache = true;
@@ -170,5 +194,49 @@ export function parseArgs(argv) {
170
194
  else if (arg === '--version' || arg === '-V') args.version = true;
171
195
  else throw new Error(`Unknown argument: ${arg}. Run arkgate-check --help for usage.`);
172
196
  }
197
+ // A write flag that silently does nothing is how a caller comes to believe a
198
+ // change landed. --apply belongs to --promote; the other write surfaces use
199
+ // --write.
200
+ if (args.apply && !args.promote) {
201
+ throw new Error(
202
+ '--apply applies to --promote. Run `arkgate-check --promote <ruleId> --apply`; the other write surfaces use --write.'
203
+ );
204
+ }
205
+ // Every report mode below returns from main() BEFORE --promote is reached, so
206
+ // pairing one with --promote --apply printed that report and exited 0 having
207
+ // written nothing. Same defect the guard above exists for, one level up.
208
+ if (args.promote) {
209
+ const shadowing = [
210
+ args.sensors && '--sensors',
211
+ args.pathDrift && '--path-drift',
212
+ args.coverage && '--coverage',
213
+ args.recommend && '--recommend',
214
+ args.doctor && '--doctor',
215
+ args.plan && '--plan',
216
+ args.rulesInventory && '--rules-inventory',
217
+ args.suggestInclude && '--suggest-include',
218
+ args.adoptContract && '--adopt-contract',
219
+ args.migrateContract && '--migrate-contract',
220
+ ].filter(Boolean);
221
+ if (shadowing.length > 0) {
222
+ throw new Error(
223
+ `--promote cannot be combined with ${shadowing.join(', ')}: that mode answers first and --promote would silently do nothing. Run them separately.`
224
+ );
225
+ }
226
+ // A narrowed scope cannot price a promotion. --changed counts findings over
227
+ // the changed files only and --baseline suppresses findings AFTER --promote
228
+ // has already returned, so either one turns the cost into an undercount
229
+ // printed as a fact.
230
+ const narrowing = [
231
+ args.changed && '--changed',
232
+ args.against && '--against',
233
+ args.baseline && '--baseline',
234
+ ].filter(Boolean);
235
+ if (narrowing.length > 0) {
236
+ throw new Error(
237
+ `--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.`
238
+ );
239
+ }
240
+ }
173
241
  return args;
174
242
  }
@@ -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
  },
@@ -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
  *
@@ -55,7 +55,8 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
55
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.'),
@@ -70,6 +71,9 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
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.'),
72
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.'),
74
+ entry('ARKORDER_INFORMATION_BUDGET', 'arkorder', 'Projection observes a forbidden kind', 'h(ξ) allowedKinds includes a kind listed in informationBudget.cannotObserve. A scale may not look at what it was told not to see.', 'Cut that kind from the projector or from cannotObserve, then preflight again. Never mechanical-safe.'),
75
+ entry('ARKORDER_XI_TTL', 'arkorder', 'Slow key carries a freshness field', 'ξ named ttl/freshUntil/maxAge. Freshness belongs on σ. A slow parameter that expires per transaction is not slow.', 'Move freshness onto σ (freshUntil) and keep ξ stable, then preflight again. Never mechanical-safe.'),
76
+ entry('ARKORDER_STALE_SIGMA', 'arkorder', 'σ is stale', 'ingest ran after σ.freshUntil (or sigmaMaxAgeMs). ξ does not TTL.', 'Refresh σ and ingest again, or freeze a new release if the pattern changed. Never mechanical-safe.'),
73
77
  // ── atomic preflight / change set ────────────────────────────────────────
74
78
  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.'),
75
79
  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.'),
@@ -85,6 +89,7 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
85
89
  // ── analysis completeness / host ─────────────────────────────────────────
86
90
  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.'),
87
91
  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.'),
92
+ 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.'),
88
93
  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.'),
89
94
  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.'),
90
95
  // ── AI snippet gate policy surface ───────────────────────────────────────
@@ -109,6 +114,9 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
109
114
  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 }),
110
115
  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 }),
111
116
  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 }),
117
+ // ── literal path drift ───────────────────────────────────────────────────
118
+ 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.'),
119
+ 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 }),
112
120
  // ── meta ─────────────────────────────────────────────────────────────────
113
121
  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.'),
114
122
  ]);
@@ -82,7 +82,7 @@ Options:
82
82
  Valid ids: crud-product, api-backend, frontend-surface, library-sdk, cli-utility,
83
83
  worker-pipeline, event-coordinator, integration-bridge, multi-app-workspace, prototype-spike,
84
84
  vertical-slice-product, ddd-bounded-contexts.
85
- --tools One active agent host for start (claude,cursor,codex,grok,windsurf,cline,copilot,kiro,roo,continue,gemini).
85
+ --tools One active agent host for start (claude,cursor,codex,grok,antigravity,windsurf,cline,copilot,kiro,roo,continue,gemini).
86
86
  Omit to use the active host; an unknown host creates only the shared compact router.
87
87
  --remove-host <host>
88
88
  Preview or apply removal of that compact host integration; re-add it with --tools <host>.
@@ -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)',
@@ -130,7 +142,7 @@ export function checkUsageAll() {
130
142
  ' Best-effort open in browser (local TTY). No-op if open fails. --no-open / ARK_NO_OPEN_REPORT=1 to skip; --open forces open.',
131
143
  ' ark-check --init [--preset hexagonal|layered|feature-sliced|monorepo|ui-surface|vertical-slice|ddd-bounded-contexts|vite-vercel-spa|clean-architecture|onion-architecture] [--force] [--follow-config-root]',
132
144
  ' --follow-config-root On writes (init/install-agent-gates/migrate --write/…), adopt walked-up monorepo config root (default: keep explicit --root)',
133
- ' ark-check --install-agent-gates [--tools claude,cursor,codex,grok] [--require-write-hook <host>] [--skills-only] [--codex-home] [--claude-home] [--grok-home] [--agent-homes] [--force]',
145
+ ' ark-check --install-agent-gates [--tools claude,cursor,codex,grok,antigravity] [--require-write-hook <host>] [--skills-only] [--codex-home] [--claude-home] [--grok-home] [--antigravity-home] [--agent-homes] [--force]',
134
146
  ' ark-check --update-baseline [file] freeze current violations (default .ark-baseline.json)',
135
147
  ' ark-check --print-config eleven-layer',
136
148
  '',
@@ -196,7 +208,7 @@ export function checkUsageAll() {
196
208
  'Included but unclassified source files therefore stay red instead of false-green.',
197
209
  '',
198
210
  '--install-agent-gates writes AGENTS.md, .mcp.json, and the CI workflow for every',
199
- 'project, plus tool-specific templates. Known tools: claude, cursor, codex, grok',
211
+ 'project, plus tool-specific templates. Known tools: claude, cursor, codex, grok, antigravity',
200
212
  '(Claude/Grok/Antigravity/Cursor hard-write hooks when covered; Codex hard local apply_patch;',
201
213
  'shared CI check for all) and',
202
214
  'windsurf, cline, copilot, kiro, roo, continue, gemini',
@@ -213,7 +225,7 @@ export function checkUsageAll() {
213
225
  'Pass --tools to pick which tool configs to write; otherwise they are auto-detected',
214
226
  'from their config directories (.claude/, .cursor/, .codex/, .grok/, .windsurf/,',
215
227
  '.clinerules/, .kiro/, .roo/, .continue/, .gemini/; copilot is explicit-only).',
216
- 'claude+cursor+codex+grok are written when nothing is detected.',
228
+ 'claude+cursor+codex+grok+antigravity are written when nothing is detected.',
217
229
  '',
218
230
  'Generate a starter 11-layer config:',
219
231
  ' ark-check --print-config eleven-layer > ark.config.json',