arkgate 2.4.0 → 2.5.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to ArkGate (`arkgate`; formerly `ark-runtime-kernel`) are documented here.
4
4
 
5
+ ## 2.5.0 — 2026-07-09
6
+
7
+ ### Added — ESLint ↔ CI layer parity
8
+
9
+ - **`arkgate/eslint`** `no-domain-infra-imports` is **config-driven**: loads
10
+ `ark.config.json` (walk-up from the linted file), classifies layers with the same
11
+ glob specificity + `exclude` semantics as `arkgate-check`, and denies edges from
12
+ `rules[]` — not path-token “domain/infra” heuristics alone.
13
+ - Relative imports resolve to on-disk TS/JS targets; type-only and value imports both
14
+ fail when the edge is denied (same pass/fail as CI).
15
+ - **`no-forbidden-globals`** reads `forbiddenGlobals` from the matched layer in
16
+ `ark.config.json` (no invented defaults for layers without a purity list). Optional
17
+ rule option `globals` still overrides. Domain path heuristic + defaults only when
18
+ no config is found.
19
+ - Dual-driver tests: same fixtures → ESLint rule + `ark-check --json` agree.
20
+ - Recommended config enables `ark/no-forbidden-globals`.
21
+ - Without `ark.config.json`, legacy domain→infra path heuristic remains for bare trees.
22
+ - **ESLint 8–10 filename API:** rules read `physicalFilename` → `filename` → `getFilename()`
23
+ so config walk-up works on ESLint 10 (where `getFilename` was removed).
24
+
5
25
  ## 2.4.0 — 2026-07-08
6
26
 
7
27
  ### Added — Adoption completeness (P0–P2)
package/README.md CHANGED
@@ -167,6 +167,7 @@ ark.config.json
167
167
  | Classified plan (`mechanical-safe` / judgment) | ✅ | ❌ |
168
168
  | TypeScript 5 / 6 / 7 project compilers | ✅ | varies |
169
169
  | Adoption scorecard (hosts / MCP / origin) | ✅ | ❌ |
170
+ | **Editor ESLint same layer contract as CI** | ✅ (`arkgate/eslint`) | varies |
170
171
 
171
172
  ---
172
173
 
@@ -210,7 +211,7 @@ NestJS: `arkgate/nestjs` (optional peer `@nestjs/common`).
210
211
  | Audience | Link |
211
212
  |----------|------|
212
213
  | New builders (plain language) | [docs/enthusiast/](docs/enthusiast/README.md) |
213
- | Wire Claude / Cursor / Codex / Grok | [docs/ai-gates.md](docs/ai-gates.md) |
214
+ | Wire Claude / Cursor / Codex / Grok + **ESLint (CI-parity)** | [docs/ai-gates.md](docs/ai-gates.md) |
214
215
  | **TypeScript 5 / 6 / 7 support** | [docs/typescript-support.md](docs/typescript-support.md) |
215
216
  | Migrate from `ark-runtime-kernel` | [docs/migrate-from-ark-runtime-kernel.md](docs/migrate-from-ark-runtime-kernel.md) |
216
217
  | Messy existing repo | [docs/brownfield-adoption.md](docs/brownfield-adoption.md) |
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,19 +17,191 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/eslint/index.ts
21
31
  var eslint_exports = {};
22
32
  __export(eslint_exports, {
23
33
  default: () => eslint_default,
34
+ findConfigPath: () => findConfigPath,
35
+ globToRegExp: () => globToRegExp,
36
+ isEdgeDenied: () => isEdgeDenied,
37
+ layerForRelativePath: () => layerForRelativePath,
38
+ loadArkConfig: () => loadArkConfig,
24
39
  noDomainInfraImports: () => noDomainInfraImports,
25
40
  noForbiddenGlobals: () => noForbiddenGlobals,
26
41
  noRawEventPublish: () => noRawEventPublish,
42
+ patternSpecificity: () => patternSpecificity,
27
43
  plugin: () => plugin,
28
- requirePublishSource: () => requirePublishSource
44
+ requirePublishSource: () => requirePublishSource,
45
+ resolveRelativeImport: () => resolveRelativeImport
29
46
  });
30
47
  module.exports = __toCommonJS(eslint_exports);
48
+ var import_node_fs = __toESM(require("fs"), 1);
49
+ var import_node_path = __toESM(require("path"), 1);
50
+ function lintedFilename(context) {
51
+ if (typeof context.physicalFilename === "string" && context.physicalFilename.length > 0) {
52
+ return context.physicalFilename;
53
+ }
54
+ if (typeof context.filename === "string" && context.filename.length > 0) {
55
+ return context.filename;
56
+ }
57
+ if (typeof context.getFilename === "function") {
58
+ try {
59
+ const name = context.getFilename();
60
+ if (typeof name === "string" && name.length > 0) return name;
61
+ } catch {
62
+ }
63
+ }
64
+ return "";
65
+ }
66
+ var _regexpCache = /* @__PURE__ */ new Map();
67
+ function bracesBalanced(glob) {
68
+ let depth = 0;
69
+ for (let i = 0; i < glob.length; i += 1) {
70
+ if (glob[i] === "\\" && i + 1 < glob.length) {
71
+ i += 1;
72
+ continue;
73
+ }
74
+ if (glob[i] === "{") depth += 1;
75
+ else if (glob[i] === "}") {
76
+ depth -= 1;
77
+ if (depth < 0) return false;
78
+ }
79
+ }
80
+ return depth === 0;
81
+ }
82
+ function escapeLiteral(c) {
83
+ return c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
84
+ }
85
+ function globToRegExp(pattern) {
86
+ const cached = _regexpCache.get(pattern);
87
+ if (cached) return cached;
88
+ const glob = pattern.split(import_node_path.default.sep).join("/");
89
+ const useBraces = bracesBalanced(glob);
90
+ let out = "";
91
+ let braceDepth = 0;
92
+ for (let i = 0; i < glob.length; i += 1) {
93
+ const c = glob[i];
94
+ if (c === "\\" && i + 1 < glob.length) {
95
+ out += escapeLiteral(glob[i + 1]);
96
+ i += 1;
97
+ } else if (c === "*") {
98
+ if (glob[i + 1] === "*") {
99
+ if (glob[i + 2] === "/") {
100
+ out += "(?:.*/)?";
101
+ i += 2;
102
+ } else {
103
+ out += ".*";
104
+ i += 1;
105
+ }
106
+ } else {
107
+ out += "[^/]*";
108
+ }
109
+ } else if (c === "?") {
110
+ out += "[^/]";
111
+ } else if (c === "{" && useBraces) {
112
+ out += "(?:";
113
+ braceDepth += 1;
114
+ } else if (c === "}" && useBraces && braceDepth > 0) {
115
+ out += ")";
116
+ braceDepth -= 1;
117
+ } else if (c === "," && useBraces && braceDepth > 0) {
118
+ out += "|";
119
+ } else {
120
+ out += escapeLiteral(c);
121
+ }
122
+ }
123
+ const re = new RegExp(`^${out}$`);
124
+ _regexpCache.set(pattern, re);
125
+ return re;
126
+ }
127
+ function patternSpecificity(pattern) {
128
+ const glob = String(pattern).split(import_node_path.default.sep).join("/");
129
+ const beforeWildcard = glob.split("*")[0];
130
+ const literalSegments = beforeWildcard.split("/").filter(Boolean).length;
131
+ const literalLength = glob.replace(/\*/g, "").length;
132
+ return literalSegments * 1e4 + literalLength;
133
+ }
134
+ function layerForRelativePath(relPath, layers) {
135
+ const rel = relPath.split(import_node_path.default.sep).join("/");
136
+ let bestName;
137
+ let bestScore = -1;
138
+ for (const layer of layers ?? []) {
139
+ if ((layer.exclude ?? []).some((pattern) => globToRegExp(pattern).test(rel))) {
140
+ continue;
141
+ }
142
+ for (const pattern of layer.patterns ?? []) {
143
+ if (globToRegExp(pattern).test(rel)) {
144
+ const score = patternSpecificity(pattern);
145
+ if (score > bestScore) {
146
+ bestScore = score;
147
+ bestName = layer.name;
148
+ }
149
+ }
150
+ }
151
+ }
152
+ return bestName;
153
+ }
154
+ function isEdgeDenied(rules2, from, to) {
155
+ if (from === to) return false;
156
+ const hit = (rules2 ?? []).find((r) => r.from === from && r.to === to);
157
+ return hit?.allowed === false;
158
+ }
159
+ function findConfigPath(startFile) {
160
+ if (!startFile || startFile === "<input>" || startFile.startsWith("stdin")) return null;
161
+ let dir = import_node_path.default.dirname(import_node_path.default.resolve(startFile));
162
+ for (; ; ) {
163
+ const candidate = import_node_path.default.join(dir, "ark.config.json");
164
+ if (import_node_fs.default.existsSync(candidate)) return candidate;
165
+ const parent = import_node_path.default.dirname(dir);
166
+ if (parent === dir) return null;
167
+ dir = parent;
168
+ }
169
+ }
170
+ var _configCache = /* @__PURE__ */ new Map();
171
+ function loadArkConfig(configPath) {
172
+ if (_configCache.has(configPath)) return _configCache.get(configPath) ?? null;
173
+ try {
174
+ const raw = JSON.parse(import_node_fs.default.readFileSync(configPath, "utf8"));
175
+ _configCache.set(configPath, raw);
176
+ return raw;
177
+ } catch {
178
+ _configCache.set(configPath, null);
179
+ return null;
180
+ }
181
+ }
182
+ function resolveRelativeImport(fromFile, specifier) {
183
+ if (!specifier.startsWith(".")) return null;
184
+ const base = import_node_path.default.resolve(import_node_path.default.dirname(fromFile), specifier);
185
+ const candidates = [
186
+ base,
187
+ `${base}.ts`,
188
+ `${base}.tsx`,
189
+ `${base}.mts`,
190
+ `${base}.cts`,
191
+ `${base}.js`,
192
+ `${base}.jsx`,
193
+ import_node_path.default.join(base, "index.ts"),
194
+ import_node_path.default.join(base, "index.tsx"),
195
+ import_node_path.default.join(base, "index.js")
196
+ ];
197
+ for (const c of candidates) {
198
+ try {
199
+ if (import_node_fs.default.existsSync(c) && import_node_fs.default.statSync(c).isFile()) return c;
200
+ } catch {
201
+ }
202
+ }
203
+ return `${base}.ts`;
204
+ }
31
205
  function stringValue(node) {
32
206
  return typeof node?.value === "string" ? node.value : void 0;
33
207
  }
@@ -48,14 +222,18 @@ function objectHasMetadataSource(node) {
48
222
  return objectHasProperty(metadata, "source");
49
223
  }
50
224
  function looksLikeIntent(value) {
51
- return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(value);
225
+ return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(
226
+ value
227
+ );
228
+ }
229
+ function isPublishCall(node) {
230
+ return calleePropertyName(node) === "publish";
52
231
  }
53
- function isDomainFile(context) {
54
- const filename = context.getFilename?.() ?? "";
232
+ function isDomainFileHeuristic(filename) {
55
233
  const normalized = filename.split("\\").join("/").toLowerCase();
56
234
  return normalized.includes("/domain/") || normalized.endsWith("/domain.ts");
57
235
  }
58
- function isInfraImport(specifier) {
236
+ function isInfraImportHeuristic(specifier) {
59
237
  const normalized = specifier.toLowerCase();
60
238
  return [
61
239
  "adapter",
@@ -69,26 +247,49 @@ function isInfraImport(specifier) {
69
247
  "db"
70
248
  ].some((token) => normalized.includes(token));
71
249
  }
72
- function isPublishCall(node) {
73
- return calleePropertyName(node) === "publish";
74
- }
250
+ var DEFAULT_FORBIDDEN_GLOBALS = ["fetch", "process", "Date.now", "Math.random"];
75
251
  var noDomainInfraImports = {
76
252
  meta: {
77
253
  type: "problem",
78
254
  docs: {
79
- description: "Disallow importing infrastructure or adapters from domain files."
255
+ description: "Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check). Falls back to domain\u2192infra path heuristics when no config is found."
80
256
  },
81
257
  messages: {
82
- forbiddenImport: "Domain code must not import infrastructure, adapters, repositories, or database modules."
258
+ forbiddenImport: "Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",
259
+ forbiddenImportHeuristic: "Domain code must not import infrastructure, adapters, repositories, or database modules."
83
260
  },
84
261
  schema: []
85
262
  },
86
263
  create(context) {
264
+ const filename = lintedFilename(context);
265
+ const configPath = findConfigPath(filename);
266
+ const config = configPath ? loadArkConfig(configPath) : null;
267
+ const root = configPath ? import_node_path.default.dirname(configPath) : null;
87
268
  const check = (node) => {
88
- if (!isDomainFile(context)) return;
89
269
  const source = stringValue(node.source);
90
- if (source && isInfraImport(source)) {
91
- context.report({ node, messageId: "forbiddenImport" });
270
+ if (!source) return;
271
+ if (config && root && filename) {
272
+ const absFile = import_node_path.default.isAbsolute(filename) ? filename : import_node_path.default.resolve(filename);
273
+ const relFile = import_node_path.default.relative(root, absFile).split(import_node_path.default.sep).join("/");
274
+ const fromLayer = layerForRelativePath(relFile, config.layers);
275
+ if (!fromLayer) return;
276
+ const targetAbs = resolveRelativeImport(absFile, source);
277
+ if (!targetAbs) return;
278
+ const relTarget = import_node_path.default.relative(root, targetAbs).split(import_node_path.default.sep).join("/");
279
+ if (relTarget.startsWith("..")) return;
280
+ const toLayer = layerForRelativePath(relTarget, config.layers);
281
+ if (!toLayer) return;
282
+ if (isEdgeDenied(config.rules, fromLayer, toLayer)) {
283
+ context.report({
284
+ node,
285
+ messageId: "forbiddenImport",
286
+ data: { fromLayer, toLayer, specifier: source }
287
+ });
288
+ }
289
+ return;
290
+ }
291
+ if (isDomainFileHeuristic(filename) && isInfraImportHeuristic(source)) {
292
+ context.report({ node, messageId: "forbiddenImportHeuristic" });
92
293
  }
93
294
  };
94
295
  return {
@@ -147,15 +348,15 @@ var requirePublishSource = {
147
348
  };
148
349
  }
149
350
  };
150
- var DEFAULT_FORBIDDEN_GLOBALS = ["fetch", "process", "Date.now", "Math.random"];
151
351
  var noForbiddenGlobals = {
152
352
  meta: {
153
353
  type: "problem",
154
354
  docs: {
155
- description: 'Disallow ambient globals (e.g. fetch, Date.now) in architecture-governed code; scope the rule to layer directories via ESLint "files" patterns.'
355
+ description: "Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as arkgate-check). Option `globals` overrides. Without config, defaults apply only on domain-like paths."
156
356
  },
157
357
  messages: {
158
- forbiddenGlobal: 'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.'
358
+ forbiddenGlobal: 'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',
359
+ forbiddenGlobalDefault: 'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.'
159
360
  },
160
361
  schema: [
161
362
  {
@@ -168,13 +369,39 @@ var noForbiddenGlobals = {
168
369
  ]
169
370
  },
170
371
  create(context) {
372
+ const filename = lintedFilename(context);
171
373
  const option = context.options?.[0];
172
- const globals = new Set(option?.globals ?? DEFAULT_FORBIDDEN_GLOBALS);
173
- const report = (node, name) => context.report({ node, messageId: "forbiddenGlobal", data: { name } });
374
+ const configPath = findConfigPath(filename);
375
+ const config = configPath ? loadArkConfig(configPath) : null;
376
+ const root = configPath ? import_node_path.default.dirname(configPath) : null;
377
+ let globals = null;
378
+ let layerName = "this layer";
379
+ if (option?.globals) {
380
+ globals = new Set(option.globals);
381
+ } else if (config && root && filename) {
382
+ const absFile = import_node_path.default.isAbsolute(filename) ? filename : import_node_path.default.resolve(filename);
383
+ const relFile = import_node_path.default.relative(root, absFile).split(import_node_path.default.sep).join("/");
384
+ const layer = config.layers?.find(
385
+ (l) => l.name === layerForRelativePath(relFile, config.layers)
386
+ );
387
+ if (layer?.forbiddenGlobals?.length) {
388
+ globals = new Set(layer.forbiddenGlobals);
389
+ layerName = layer.name;
390
+ } else {
391
+ globals = null;
392
+ }
393
+ } else if (isDomainFileHeuristic(filename)) {
394
+ globals = new Set(DEFAULT_FORBIDDEN_GLOBALS);
395
+ }
396
+ if (!globals) {
397
+ return {};
398
+ }
399
+ const report = (node, name) => context.report({
400
+ node,
401
+ messageId: config ? "forbiddenGlobal" : "forbiddenGlobalDefault",
402
+ data: { name, layer: layerName }
403
+ });
174
404
  return {
175
- // Same positional detection as ark-check's FORBIDDEN_GLOBAL: property accesses on a
176
- // forbidden base (console.log, Date.now), direct calls, and constructions. Bare
177
- // identifier mentions elsewhere are not flagged (avoids shadowed-local false positives).
178
405
  MemberExpression(node) {
179
406
  const base = node.object?.type === "Identifier" ? node.object.name : void 0;
180
407
  if (!base) return;
@@ -206,17 +433,25 @@ plugin.configs = {
206
433
  rules: {
207
434
  "ark/no-domain-infra-imports": "error",
208
435
  "ark/no-raw-event-publish": "error",
209
- "ark/require-publish-source": "error"
436
+ "ark/require-publish-source": "error",
437
+ "ark/no-forbidden-globals": "error"
210
438
  }
211
439
  }
212
440
  };
213
441
  var eslint_default = plugin;
214
442
  // Annotate the CommonJS export names for ESM import in node:
215
443
  0 && (module.exports = {
444
+ findConfigPath,
445
+ globToRegExp,
446
+ isEdgeDenied,
447
+ layerForRelativePath,
448
+ loadArkConfig,
216
449
  noDomainInfraImports,
217
450
  noForbiddenGlobals,
218
451
  noRawEventPublish,
452
+ patternSpecificity,
219
453
  plugin,
220
- requirePublishSource
454
+ requirePublishSource,
455
+ resolveRelativeImport
221
456
  });
222
457
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/eslint/index.ts"],"sourcesContent":["type RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n getFilename?: () => string;\n options?: unknown[];\n};\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n object?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(value);\n}\n\nfunction isDomainFile(context: RuleContext): boolean {\n const filename = context.getFilename?.() ?? '';\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImport(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow importing infrastructure or adapters from domain files.',\n },\n messages: {\n forbiddenImport: 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const check = (node: AstNode) => {\n if (!isDomainFile(context)) return;\n const source = stringValue(node.source);\n if (source && isInfraImport(source)) {\n context.report({ node, messageId: 'forbiddenImport' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish: 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if (\n firstValue && looksLikeIntent(firstValue) ||\n objectHasProperty(firstArg, 'intent')\n ) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nconst DEFAULT_FORBIDDEN_GLOBALS = ['fetch', 'process', 'Date.now', 'Math.random'];\n\nexport const noForbiddenGlobals: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow ambient globals (e.g. fetch, Date.now) in architecture-governed code; scope the rule to layer directories via ESLint \"files\" patterns.',\n },\n messages: {\n forbiddenGlobal: 'Ambient global \"{{name}}\" is forbidden here; inject the capability through a port instead.',\n },\n schema: [\n {\n type: 'object',\n properties: {\n globals: { type: 'array', items: { type: 'string' } },\n },\n additionalProperties: false,\n },\n ],\n },\n create(context) {\n const option = context.options?.[0] as { globals?: string[] } | undefined;\n const globals = new Set(option?.globals ?? DEFAULT_FORBIDDEN_GLOBALS);\n const report = (node: AstNode, name: string) =>\n context.report({ node, messageId: 'forbiddenGlobal', data: { name } });\n\n return {\n // Same positional detection as ark-check's FORBIDDEN_GLOBAL: property accesses on a\n // forbidden base (console.log, Date.now), direct calls, and constructions. Bare\n // identifier mentions elsewhere are not flagged (avoids shadowed-local false positives).\n MemberExpression(node) {\n const base = node.object?.type === 'Identifier' ? node.object.name : undefined;\n if (!base) return;\n const dotted = `${base}.${propertyName(node.property) ?? ''}`;\n if (globals.has(dotted)) report(node, dotted);\n else if (globals.has(base)) report(node, base);\n },\n CallExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals.has(callee)) report(node, callee);\n },\n NewExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals.has(callee)) report(node, callee);\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n 'no-forbidden-globals': noForbiddenGlobals,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCA,SAAS,YAAY,MAA+C;AAClE,SAAO,OAAO,MAAM,UAAU,WAAW,KAAK,QAAQ;AACxD;AAEA,SAAS,aAAa,MAA+C;AACnE,SAAO,MAAM,QAAQ,YAAY,IAAI;AACvC;AAEA,SAAS,mBAAmB,MAAmC;AAC7D,SAAO,aAAa,KAAK,QAAQ,QAAQ;AAC3C;AAEA,SAAS,eAAe,MAA2B,MAAmC;AACpF,SAAO,MAAM,YAAY,KAAK,CAAC,aAAa,aAAa,SAAS,GAAG,MAAM,IAAI;AACjF;AAEA,SAAS,kBAAkB,MAA2B,MAAuB;AAC3E,SAAO,eAAe,MAAM,IAAI,MAAM;AACxC;AAEA,SAAS,wBAAwB,MAAoC;AACnE,QAAM,WAAW,eAAe,MAAM,UAAU,GAAG;AACnD,SAAO,kBAAkB,UAAU,QAAQ;AAC7C;AAEA,SAAS,gBAAgB,OAAwB;AAC/C,SAAO,kIAAkI,KAAK,KAAK;AACrJ;AAEA,SAAS,aAAa,SAA+B;AACnD,QAAM,WAAW,QAAQ,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architecture gate.\n *\n * Layer / import / forbidden-globals rules load `ark.config.json` from the linted\n * project (walk-up from the file) and use the same glob specificity + edge semantics\n * as ark-check. Tooling layer: pure Node + local helpers only (no Kernel imports).\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\ntype RuleContext = {\n report(descriptor: Record<string, unknown>): void;\n /** ESLint 9+ / 10: preferred path on the context object. */\n filename?: string;\n /** ESLint 8-style physical path when linting with processors / virtual files. */\n physicalFilename?: string;\n /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */\n getFilename?: () => string;\n options?: unknown[];\n};\n\n/** Resolve the file path being linted across ESLint 8–10 context shapes. */\nfunction lintedFilename(context: RuleContext): string {\n if (typeof context.physicalFilename === 'string' && context.physicalFilename.length > 0) {\n return context.physicalFilename;\n }\n if (typeof context.filename === 'string' && context.filename.length > 0) {\n return context.filename;\n }\n if (typeof context.getFilename === 'function') {\n try {\n const name = context.getFilename();\n if (typeof name === 'string' && name.length > 0) return name;\n } catch {\n /* ignore */\n }\n }\n return '';\n}\n\ntype RuleListener = Record<string, (node: AstNode) => void>;\n\ntype AstNode = {\n type?: string;\n name?: string;\n value?: unknown;\n source?: AstNode;\n callee?: AstNode;\n object?: AstNode;\n property?: AstNode;\n key?: AstNode;\n arguments?: AstNode[];\n properties?: AstNode[];\n importKind?: string;\n specifiers?: AstNode[];\n};\n\ntype ArkRule = {\n meta: {\n type: 'problem';\n docs: { description: string };\n messages: Record<string, string>;\n schema: unknown[];\n };\n create(context: RuleContext): RuleListener;\n};\n\ntype ArkEslintPlugin = {\n rules: Record<string, ArkRule>;\n configs?: Record<string, unknown>;\n};\n\ntype LayerConfig = {\n name: string;\n patterns?: string[];\n exclude?: string[];\n forbiddenGlobals?: string[];\n};\n\ntype EdgeRule = { from: string; to: string; allowed?: boolean };\n\ntype ArkConfig = {\n layers?: LayerConfig[];\n rules?: EdgeRule[];\n};\n\n// ── Pure helpers (mirror bin/ark-shared.mjs layer matching; no CLI imports) ──\n\nconst _regexpCache = new Map<string, RegExp>();\n\nfunction bracesBalanced(glob: string): boolean {\n let depth = 0;\n for (let i = 0; i < glob.length; i += 1) {\n if (glob[i] === '\\\\' && i + 1 < glob.length) {\n i += 1;\n continue;\n }\n if (glob[i] === '{') depth += 1;\n else if (glob[i] === '}') {\n depth -= 1;\n if (depth < 0) return false;\n }\n }\n return depth === 0;\n}\n\nfunction escapeLiteral(c: string): string {\n return c.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Same glob → RegExp semantics as ark-check / ark-shared.mjs. */\nexport function globToRegExp(pattern: string): RegExp {\n const cached = _regexpCache.get(pattern);\n if (cached) return cached;\n const glob = pattern.split(path.sep).join('/');\n const useBraces = bracesBalanced(glob);\n let out = '';\n let braceDepth = 0;\n for (let i = 0; i < glob.length; i += 1) {\n const c = glob[i];\n if (c === '\\\\' && i + 1 < glob.length) {\n out += escapeLiteral(glob[i + 1]);\n i += 1;\n } else if (c === '*') {\n if (glob[i + 1] === '*') {\n if (glob[i + 2] === '/') {\n out += '(?:.*/)?';\n i += 2;\n } else {\n out += '.*';\n i += 1;\n }\n } else {\n out += '[^/]*';\n }\n } else if (c === '?') {\n out += '[^/]';\n } else if (c === '{' && useBraces) {\n out += '(?:';\n braceDepth += 1;\n } else if (c === '}' && useBraces && braceDepth > 0) {\n out += ')';\n braceDepth -= 1;\n } else if (c === ',' && useBraces && braceDepth > 0) {\n out += '|';\n } else {\n out += escapeLiteral(c);\n }\n }\n const re = new RegExp(`^${out}$`);\n _regexpCache.set(pattern, re);\n return re;\n}\n\nexport function patternSpecificity(pattern: string): number {\n const glob = String(pattern).split(path.sep).join('/');\n const beforeWildcard = glob.split('*')[0];\n const literalSegments = beforeWildcard.split('/').filter(Boolean).length;\n const literalLength = glob.replace(/\\*/g, '').length;\n return literalSegments * 10000 + literalLength;\n}\n\n/** Same file→layer resolution as ark-check (most-specific pattern wins; exclude honored). */\nexport function layerForRelativePath(relPath: string, layers: LayerConfig[] | undefined): string | undefined {\n const rel = relPath.split(path.sep).join('/');\n let bestName: string | undefined;\n let bestScore = -1;\n for (const layer of layers ?? []) {\n if ((layer.exclude ?? []).some((pattern) => globToRegExp(pattern).test(rel))) {\n continue;\n }\n for (const pattern of layer.patterns ?? []) {\n if (globToRegExp(pattern).test(rel)) {\n const score = patternSpecificity(pattern);\n if (score > bestScore) {\n bestScore = score;\n bestName = layer.name;\n }\n }\n }\n }\n return bestName;\n}\n\nexport function isEdgeDenied(rules: EdgeRule[] | undefined, from: string, to: string): boolean {\n if (from === to) return false;\n const hit = (rules ?? []).find((r) => r.from === from && r.to === to);\n return hit?.allowed === false;\n}\n\nexport function findConfigPath(startFile: string): string | null {\n if (!startFile || startFile === '<input>' || startFile.startsWith('stdin')) return null;\n let dir = path.dirname(path.resolve(startFile));\n for (;;) {\n const candidate = path.join(dir, 'ark.config.json');\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nconst _configCache = new Map<string, ArkConfig | null>();\n\nexport function loadArkConfig(configPath: string): ArkConfig | null {\n if (_configCache.has(configPath)) return _configCache.get(configPath) ?? null;\n try {\n const raw = JSON.parse(fs.readFileSync(configPath, 'utf8')) as ArkConfig;\n _configCache.set(configPath, raw);\n return raw;\n } catch {\n _configCache.set(configPath, null);\n return null;\n }\n}\n\n/** Resolve relative import specifier to an absolute path candidate (TS-oriented). */\nexport function resolveRelativeImport(fromFile: string, specifier: string): string | null {\n if (!specifier.startsWith('.')) return null;\n const base = path.resolve(path.dirname(fromFile), specifier);\n const candidates = [\n base,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}.js`,\n `${base}.jsx`,\n path.join(base, 'index.ts'),\n path.join(base, 'index.tsx'),\n path.join(base, 'index.js'),\n ];\n for (const c of candidates) {\n try {\n if (fs.existsSync(c) && fs.statSync(c).isFile()) return c;\n } catch {\n /* continue */\n }\n }\n // Prefer .ts for layer matching when the target is not on disk yet (editor typing).\n return `${base}.ts`;\n}\n\n// ── AST helpers ────────────────────────────────────────────────────────────\n\nfunction stringValue(node: AstNode | undefined): string | undefined {\n return typeof node?.value === 'string' ? node.value : undefined;\n}\n\nfunction propertyName(node: AstNode | undefined): string | undefined {\n return node?.name ?? stringValue(node);\n}\n\nfunction calleePropertyName(node: AstNode): string | undefined {\n return propertyName(node.callee?.property);\n}\n\nfunction objectProperty(node: AstNode | undefined, name: string): AstNode | undefined {\n return node?.properties?.find((property) => propertyName(property.key) === name);\n}\n\nfunction objectHasProperty(node: AstNode | undefined, name: string): boolean {\n return objectProperty(node, name) !== undefined;\n}\n\nfunction objectHasMetadataSource(node: AstNode | undefined): boolean {\n const metadata = objectProperty(node, 'metadata')?.value as AstNode | undefined;\n return objectHasProperty(metadata, 'source');\n}\n\nfunction looksLikeIntent(value: string): boolean {\n return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\\.[A-Za-z0-9_.]+$/.test(\n value\n );\n}\n\nfunction isPublishCall(node: AstNode): boolean {\n return calleePropertyName(node) === 'publish';\n}\n\n/** Heuristic fallback when no ark.config.json (pre-contract projects). */\nfunction isDomainFileHeuristic(filename: string): boolean {\n const normalized = filename.split('\\\\').join('/').toLowerCase();\n return normalized.includes('/domain/') || normalized.endsWith('/domain.ts');\n}\n\nfunction isInfraImportHeuristic(specifier: string): boolean {\n const normalized = specifier.toLowerCase();\n return [\n 'adapter',\n 'adapters',\n 'infrastructure',\n 'persistence',\n 'repository',\n 'repositories',\n 'integration',\n 'database',\n 'db',\n ].some((token) => normalized.includes(token));\n}\n\nconst DEFAULT_FORBIDDEN_GLOBALS = ['fetch', 'process', 'Date.now', 'Math.random'];\n\n// ── Rules ──────────────────────────────────────────────────────────────────\n\n/**\n * Config-driven layer import boundary (primary editor gate).\n * Replaces path-token domain/infra heuristics when ark.config.json is present.\n * Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.\n */\nexport const noDomainInfraImports: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check). Falls back to domain→infra path heuristics when no config is found.',\n },\n messages: {\n forbiddenImport:\n 'Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}',\n forbiddenImportHeuristic:\n 'Domain code must not import infrastructure, adapters, repositories, or database modules.',\n },\n schema: [],\n },\n create(context) {\n const filename = lintedFilename(context);\n const configPath = findConfigPath(filename);\n const config = configPath ? loadArkConfig(configPath) : null;\n const root = configPath ? path.dirname(configPath) : null;\n\n const check = (node: AstNode) => {\n const source = stringValue(node.source);\n if (!source) return;\n\n if (config && root && filename) {\n const absFile = path.isAbsolute(filename) ? filename : path.resolve(filename);\n const relFile = path.relative(root, absFile).split(path.sep).join('/');\n const fromLayer = layerForRelativePath(relFile, config.layers);\n if (!fromLayer) return;\n\n const targetAbs = resolveRelativeImport(absFile, source);\n if (!targetAbs) return; // package import — CI resolves via TS; editor skips non-relative\n\n const relTarget = path.relative(root, targetAbs).split(path.sep).join('/');\n // Outside project or up-and-out: skip\n if (relTarget.startsWith('..')) return;\n\n const toLayer = layerForRelativePath(relTarget, config.layers);\n if (!toLayer) return;\n if (isEdgeDenied(config.rules, fromLayer, toLayer)) {\n context.report({\n node,\n messageId: 'forbiddenImport',\n data: { fromLayer, toLayer, specifier: source },\n });\n }\n return;\n }\n\n // No contract: legacy heuristic so bare domain folders still get a signal.\n if (isDomainFileHeuristic(filename) && isInfraImportHeuristic(source)) {\n context.report({ node, messageId: 'forbiddenImportHeuristic' });\n }\n };\n\n return {\n ImportDeclaration: check,\n ExportNamedDeclaration: check,\n ExportAllDeclaration: check,\n };\n },\n};\n\nexport const noRawEventPublish: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings.',\n },\n messages: {\n rawPublish:\n 'Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const firstValue = stringValue(firstArg);\n if ((firstValue && looksLikeIntent(firstValue)) || objectHasProperty(firstArg, 'intent')) {\n context.report({ node, messageId: 'rawPublish' });\n }\n },\n };\n },\n};\n\nexport const requirePublishSource: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Require event bus publish calls to include source metadata.',\n },\n messages: {\n missingSource: 'Strict Ark publish calls must include metadata.source.',\n },\n schema: [],\n },\n create(context) {\n return {\n CallExpression(node) {\n if (!isPublishCall(node)) return;\n const firstArg = node.arguments?.[0];\n const metadataArg = node.arguments?.[2];\n if (objectHasMetadataSource(firstArg) || objectHasProperty(metadataArg, 'source')) {\n return;\n }\n context.report({ node, messageId: 'missingSource' });\n },\n };\n },\n};\n\nexport const noForbiddenGlobals: ArkRule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow ambient globals from the layer’s forbiddenGlobals in ark.config.json (same purity surface as arkgate-check). Option `globals` overrides. Without config, defaults apply only on domain-like paths.',\n },\n messages: {\n forbiddenGlobal:\n 'Ambient global \"{{name}}\" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',\n forbiddenGlobalDefault:\n 'Ambient global \"{{name}}\" is forbidden here; inject the capability through a port instead.',\n },\n schema: [\n {\n type: 'object',\n properties: {\n globals: { type: 'array', items: { type: 'string' } },\n },\n additionalProperties: false,\n },\n ],\n },\n create(context) {\n const filename = lintedFilename(context);\n const option = context.options?.[0] as { globals?: string[] } | undefined;\n const configPath = findConfigPath(filename);\n const config = configPath ? loadArkConfig(configPath) : null;\n const root = configPath ? path.dirname(configPath) : null;\n\n let globals: Set<string> | null = null;\n let layerName = 'this layer';\n\n if (option?.globals) {\n globals = new Set(option.globals);\n } else if (config && root && filename) {\n const absFile = path.isAbsolute(filename) ? filename : path.resolve(filename);\n const relFile = path.relative(root, absFile).split(path.sep).join('/');\n const layer = config.layers?.find(\n (l) => l.name === layerForRelativePath(relFile, config.layers)\n );\n if (layer?.forbiddenGlobals?.length) {\n globals = new Set(layer.forbiddenGlobals);\n layerName = layer.name;\n } else {\n // Layer has no purity list — do not invent defaults (matches CI).\n globals = null;\n }\n } else if (isDomainFileHeuristic(filename)) {\n globals = new Set(DEFAULT_FORBIDDEN_GLOBALS);\n }\n\n if (!globals) {\n return {} as RuleListener;\n }\n\n const report = (node: AstNode, name: string) =>\n context.report({\n node,\n messageId: config ? 'forbiddenGlobal' : 'forbiddenGlobalDefault',\n data: { name, layer: layerName },\n });\n\n return {\n MemberExpression(node) {\n const base = node.object?.type === 'Identifier' ? node.object.name : undefined;\n if (!base) return;\n const dotted = `${base}.${propertyName(node.property) ?? ''}`;\n if (globals!.has(dotted)) report(node, dotted);\n else if (globals!.has(base)) report(node, base);\n },\n CallExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals!.has(callee)) report(node, callee);\n },\n NewExpression(node) {\n const callee = node.callee?.type === 'Identifier' ? node.callee.name : undefined;\n if (callee && globals!.has(callee)) report(node, callee);\n },\n };\n },\n};\n\nconst rules = {\n 'no-domain-infra-imports': noDomainInfraImports,\n 'no-raw-event-publish': noRawEventPublish,\n 'require-publish-source': requirePublishSource,\n 'no-forbidden-globals': noForbiddenGlobals,\n};\n\nconst plugin: ArkEslintPlugin = { rules };\n\nplugin.configs = {\n recommended: {\n plugins: { ark: plugin },\n rules: {\n 'ark/no-domain-infra-imports': 'error',\n 'ark/no-raw-event-publish': 'error',\n 'ark/require-publish-source': 'error',\n 'ark/no-forbidden-globals': 'error',\n },\n },\n};\n\nexport { plugin };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qBAAe;AACf,uBAAiB;AAcj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,cAAM,SAAS,KAAK,QAAQ,SAAS,eAAe,KAAK,OAAO,OAAO;AACvE,YAAI,UAAU,QAAS,IAAI,MAAM,EAAG,QAAO,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAM,QAAQ;AAAA,EACZ,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,wBAAwB;AAC1B;AAEA,IAAM,SAA0B,EAAE,MAAM;AAExC,OAAO,UAAU;AAAA,EACf,aAAa;AAAA,IACX,SAAS,EAAE,KAAK,OAAO;AAAA,IACvB,OAAO;AAAA,MACL,+BAA+B;AAAA,MAC/B,4BAA4B;AAAA,MAC5B,8BAA8B;AAAA,MAC9B,4BAA4B;AAAA,IAC9B;AAAA,EACF;AACF;AAGA,IAAO,iBAAQ;","names":["path","rules","fs"]}
@@ -1,5 +1,10 @@
1
1
  type RuleContext = {
2
2
  report(descriptor: Record<string, unknown>): void;
3
+ /** ESLint 9+ / 10: preferred path on the context object. */
4
+ filename?: string;
5
+ /** ESLint 8-style physical path when linting with processors / virtual files. */
6
+ physicalFilename?: string;
7
+ /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
3
8
  getFilename?: () => string;
4
9
  options?: unknown[];
5
10
  };
@@ -15,6 +20,8 @@ type AstNode = {
15
20
  key?: AstNode;
16
21
  arguments?: AstNode[];
17
22
  properties?: AstNode[];
23
+ importKind?: string;
24
+ specifiers?: AstNode[];
18
25
  };
19
26
  type ArkRule = {
20
27
  meta: {
@@ -31,6 +38,36 @@ type ArkEslintPlugin = {
31
38
  rules: Record<string, ArkRule>;
32
39
  configs?: Record<string, unknown>;
33
40
  };
41
+ type LayerConfig = {
42
+ name: string;
43
+ patterns?: string[];
44
+ exclude?: string[];
45
+ forbiddenGlobals?: string[];
46
+ };
47
+ type EdgeRule = {
48
+ from: string;
49
+ to: string;
50
+ allowed?: boolean;
51
+ };
52
+ type ArkConfig = {
53
+ layers?: LayerConfig[];
54
+ rules?: EdgeRule[];
55
+ };
56
+ /** Same glob → RegExp semantics as ark-check / ark-shared.mjs. */
57
+ declare function globToRegExp(pattern: string): RegExp;
58
+ declare function patternSpecificity(pattern: string): number;
59
+ /** Same file→layer resolution as ark-check (most-specific pattern wins; exclude honored). */
60
+ declare function layerForRelativePath(relPath: string, layers: LayerConfig[] | undefined): string | undefined;
61
+ declare function isEdgeDenied(rules: EdgeRule[] | undefined, from: string, to: string): boolean;
62
+ declare function findConfigPath(startFile: string): string | null;
63
+ declare function loadArkConfig(configPath: string): ArkConfig | null;
64
+ /** Resolve relative import specifier to an absolute path candidate (TS-oriented). */
65
+ declare function resolveRelativeImport(fromFile: string, specifier: string): string | null;
66
+ /**
67
+ * Config-driven layer import boundary (primary editor gate).
68
+ * Replaces path-token domain/infra heuristics when ark.config.json is present.
69
+ * Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.
70
+ */
34
71
  declare const noDomainInfraImports: ArkRule;
35
72
  declare const noRawEventPublish: ArkRule;
36
73
  declare const requirePublishSource: ArkRule;
@@ -39,4 +76,4 @@ declare const plugin: ArkEslintPlugin;
39
76
 
40
77
  // @ts-ignore
41
78
  export = plugin;
42
- export { noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, plugin, requirePublishSource };
79
+ export { findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, requirePublishSource, resolveRelativeImport };
@@ -1,5 +1,10 @@
1
1
  type RuleContext = {
2
2
  report(descriptor: Record<string, unknown>): void;
3
+ /** ESLint 9+ / 10: preferred path on the context object. */
4
+ filename?: string;
5
+ /** ESLint 8-style physical path when linting with processors / virtual files. */
6
+ physicalFilename?: string;
7
+ /** ESLint ≤8 API — still present on some hosts; removed in ESLint 10. */
3
8
  getFilename?: () => string;
4
9
  options?: unknown[];
5
10
  };
@@ -15,6 +20,8 @@ type AstNode = {
15
20
  key?: AstNode;
16
21
  arguments?: AstNode[];
17
22
  properties?: AstNode[];
23
+ importKind?: string;
24
+ specifiers?: AstNode[];
18
25
  };
19
26
  type ArkRule = {
20
27
  meta: {
@@ -31,10 +38,40 @@ type ArkEslintPlugin = {
31
38
  rules: Record<string, ArkRule>;
32
39
  configs?: Record<string, unknown>;
33
40
  };
41
+ type LayerConfig = {
42
+ name: string;
43
+ patterns?: string[];
44
+ exclude?: string[];
45
+ forbiddenGlobals?: string[];
46
+ };
47
+ type EdgeRule = {
48
+ from: string;
49
+ to: string;
50
+ allowed?: boolean;
51
+ };
52
+ type ArkConfig = {
53
+ layers?: LayerConfig[];
54
+ rules?: EdgeRule[];
55
+ };
56
+ /** Same glob → RegExp semantics as ark-check / ark-shared.mjs. */
57
+ declare function globToRegExp(pattern: string): RegExp;
58
+ declare function patternSpecificity(pattern: string): number;
59
+ /** Same file→layer resolution as ark-check (most-specific pattern wins; exclude honored). */
60
+ declare function layerForRelativePath(relPath: string, layers: LayerConfig[] | undefined): string | undefined;
61
+ declare function isEdgeDenied(rules: EdgeRule[] | undefined, from: string, to: string): boolean;
62
+ declare function findConfigPath(startFile: string): string | null;
63
+ declare function loadArkConfig(configPath: string): ArkConfig | null;
64
+ /** Resolve relative import specifier to an absolute path candidate (TS-oriented). */
65
+ declare function resolveRelativeImport(fromFile: string, specifier: string): string | null;
66
+ /**
67
+ * Config-driven layer import boundary (primary editor gate).
68
+ * Replaces path-token domain/infra heuristics when ark.config.json is present.
69
+ * Rule id kept as `no-domain-infra-imports` for recommended-config / upgrade stability.
70
+ */
34
71
  declare const noDomainInfraImports: ArkRule;
35
72
  declare const noRawEventPublish: ArkRule;
36
73
  declare const requirePublishSource: ArkRule;
37
74
  declare const noForbiddenGlobals: ArkRule;
38
75
  declare const plugin: ArkEslintPlugin;
39
76
 
40
- export { plugin as default, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, plugin, requirePublishSource };
77
+ export { plugin as default, findConfigPath, globToRegExp, isEdgeDenied, layerForRelativePath, loadArkConfig, noDomainInfraImports, noForbiddenGlobals, noRawEventPublish, patternSpecificity, plugin, requirePublishSource, resolveRelativeImport };