arkgate 4.8.13 → 4.8.14
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 +86 -4
- package/README.md +23 -20
- package/SECURITY.md +5 -3
- package/bin/ark-check-runtime.mjs +9 -9
- package/bin/lib/agent-projection-formatters.mjs +2 -0
- package/bin/lib/agent-skills-package.mjs +63 -8
- package/bin/lib/analysis-engine.mjs +1 -1
- package/bin/lib/architecture-scan.mjs +8 -2
- package/bin/lib/ark-order-doctor.mjs +7 -1
- package/bin/lib/ark-order-report.mjs +2 -1
- package/bin/lib/ci-and-commands.mjs +7 -2
- package/bin/lib/design-smells.mjs +21 -1
- package/bin/lib/diagnostic-catalog.mjs +2 -2
- package/bin/lib/doctor-advisories.mjs +15 -7
- package/bin/lib/doctor-human.mjs +2 -1
- package/bin/lib/first-run-help.mjs +11 -2
- package/bin/lib/gate-files.mjs +40 -3
- package/bin/lib/install-migrate.mjs +23 -0
- package/bin/lib/mcp-hook-payload.mjs +1 -1
- package/bin/lib/product-copy.mjs +4 -0
- package/bin/lib/remediation.mjs +2 -2
- package/bin/lib/resolved-candidate-facts.mjs +144 -36
- package/bin/lib/scan-files.mjs +39 -0
- package/bin/lib/start-preview.mjs +3 -0
- package/bin/lib/upgrade-whats-new.mjs +3 -3
- package/bin/lib/violations.mjs +30 -0
- package/dist/{diagnosticCatalog-DA565Lja.d.ts → diagnosticCatalog-DVx_2RmF.d.ts} +1 -1
- package/dist/eslint/index.cjs +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/index.cjs +23 -23
- package/dist/index.d.ts +60 -14
- package/dist/index.js +17 -17
- package/dist/nestjs/index.cjs +1 -1
- package/dist/nestjs/index.js +1 -1
- package/dist/runtime/index.cjs +11 -11
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +11 -11
- package/docs/README.md +8 -6
- package/docs/agent-guide.md +29 -13
- package/docs/ai-gates.md +3 -1
- package/docs/arkorder.md +11 -4
- package/docs/configuration.md +7 -6
- package/docs/develop.md +3 -1
- package/docs/diagnostics.md +7 -7
- package/docs/enthusiast/README.md +6 -1
- package/docs/enthusiast/how-to-gallery-starter.md +2 -1
- package/docs/package-surface.md +6 -4
- package/docs/product-voice.md +32 -6
- package/docs/threat-model.md +2 -2
- package/docs/typescript-support.md +3 -3
- package/docs/use.md +18 -11
- package/package.json +1 -1
- package/server.json +2 -2
- package/templates/agent-skills/README.md +7 -4
- package/templates/agent-skills/ark-adopt/SKILL.md +9 -5
- package/templates/agent-skills/ark-architect/SKILL.md +5 -18
- package/templates/agent-skills/ark-autopilot/SKILL.md +8 -4
- package/templates/agent-skills/ark-contract/SKILL.md +9 -20
- package/templates/agent-skills/ark-coverage/SKILL.md +12 -8
- package/templates/agent-skills/ark-explain/SKILL.md +7 -3
- package/templates/agent-skills/ark-explore/SKILL.md +25 -4
- package/templates/agent-skills/ark-fix/SKILL.md +15 -20
- package/templates/agent-skills/ark-loop/SKILL.md +14 -20
- package/templates/agent-skills/ark-order/SKILL.md +200 -0
- package/templates/agent-skills/ark-place/SKILL.md +11 -8
- package/templates/agent-skills/ark-runtime/SKILL.md +17 -4
- package/templates/agent-skills/ark-think/SKILL.md +24 -126
- package/templates/agent-skills/ark-upgrade/SKILL.md +13 -2
- package/templates/skills/ark-adopt.md +9 -5
- package/templates/skills/ark-architect.md +5 -18
- package/templates/skills/ark-autopilot.md +8 -4
- package/templates/skills/ark-contract.md +9 -20
- package/templates/skills/ark-coverage.md +12 -8
- package/templates/skills/ark-explain.md +7 -3
- package/templates/skills/ark-explore.md +25 -4
- package/templates/skills/ark-fix.md +15 -20
- package/templates/skills/ark-loop.md +14 -20
- package/templates/skills/ark-order.md +200 -0
- package/templates/skills/ark-place.md +11 -8
- package/templates/skills/ark-runtime.md +17 -4
- package/templates/skills/ark-think.md +24 -126
- package/templates/skills/ark-upgrade.md +13 -2
- package/templates/tests/ark-adoption-gaps.test.ts +5 -4
package/bin/lib/scan-files.mjs
CHANGED
|
@@ -115,6 +115,45 @@ export function walk(dir, files = [], options = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/** Walk include roots then drop codegen / config.exclude (universal scan filter). */
|
|
118
|
+
export function isIncludeMatch(relativePath, include) {
|
|
119
|
+
return (include ?? []).some((entry) => {
|
|
120
|
+
const includeRoot = String(entry)
|
|
121
|
+
.replace(/\\/g, '/')
|
|
122
|
+
.replace(/^\.\//, '')
|
|
123
|
+
.replace(/\/$/, '');
|
|
124
|
+
return (
|
|
125
|
+
includeRoot === '.' ||
|
|
126
|
+
relativePath === includeRoot ||
|
|
127
|
+
relativePath.startsWith(`${includeRoot}/`)
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Path-only governed check — no tree walk. Matches `collectGovernedFiles` membership. */
|
|
133
|
+
export function isGovernedSourcePath(root, relativePath, config) {
|
|
134
|
+
const rel = normalize(String(relativePath || ''))
|
|
135
|
+
.replace(/^\.\//, '')
|
|
136
|
+
.replace(/\\/g, '/');
|
|
137
|
+
if (!rel || !isGovernableSourceFile(path.basename(rel))) return false;
|
|
138
|
+
if (!isIncludeMatch(rel, config?.include) || isScanExcludedRelative(rel, config)) return false;
|
|
139
|
+
return fs.existsSync(path.join(root, ...rel.split('/')));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Map diff paths to absolute governed files without walking the include tree. */
|
|
143
|
+
export function governedFilesFromRelativePaths(root, relativePaths, config) {
|
|
144
|
+
const out = [];
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
for (const raw of relativePaths ?? []) {
|
|
147
|
+
const rel = normalize(String(raw || ''))
|
|
148
|
+
.replace(/^\.\//, '')
|
|
149
|
+
.replace(/\\/g, '/');
|
|
150
|
+
if (!rel || seen.has(rel) || !isGovernedSourcePath(root, rel, config)) continue;
|
|
151
|
+
seen.add(rel);
|
|
152
|
+
out.push(path.resolve(root, ...rel.split('/')));
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
118
157
|
export function collectGovernedFiles(root, config, options = {}) {
|
|
119
158
|
options.observeInput?.(path.resolve(root), 'realpath');
|
|
120
159
|
const state = {
|
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { arkCommand, buildArchitectureRecommendation } from '../ark-shared.mjs';
|
|
7
|
+
import { ARKORDER_FIRST_CONTACT_NEXT, ARKORDER_ONE_BREATH } from './ark-order-doctor.mjs';
|
|
7
8
|
import { compactAgentInstructions, instructionRule, mcpJson } from './ci-and-commands.mjs';
|
|
8
9
|
import {
|
|
9
10
|
antigravityHooks,
|
|
@@ -163,6 +164,8 @@ export function renderStartPreview(preview, options = {}) {
|
|
|
163
164
|
console.log('Setup: install package + host gates (see --json).');
|
|
164
165
|
console.log('Preview does not write. Apply installs CI.');
|
|
165
166
|
console.log('Optional extras stay off. This start is layers only — they stop bad imports.');
|
|
167
|
+
console.log(ARKORDER_ONE_BREATH);
|
|
168
|
+
console.log(ARKORDER_FIRST_CONTACT_NEXT);
|
|
166
169
|
}
|
|
167
170
|
if (preview.runtimeActivation) {
|
|
168
171
|
console.log('Host: Codex is configured but not verified yet. Restart the host, then confirm this project.');
|
|
@@ -36,10 +36,10 @@ export function buildUpgradeWhatsNewSuggestions() {
|
|
|
36
36
|
{
|
|
37
37
|
id: 'five-door-autonomy',
|
|
38
38
|
title: 'Five doors (invoke = write or map)',
|
|
39
|
-
try: '/ark-adopt · /ark-place · /ark-autopilot · /ark-explore · /ark-upgrade',
|
|
40
|
-
inspect: 'Skill bodies + doctor next action (other /ark-* names are shortcuts)',
|
|
39
|
+
try: '/ark-adopt · /ark-place · /ark-autopilot · /ark-explore · /ark-upgrade · /ark-runtime · /ark-order',
|
|
40
|
+
inspect: 'Skill bodies + doctor next action (other /ark-* names are one-release shortcuts)',
|
|
41
41
|
why:
|
|
42
|
-
'Invoking a door is the approval. The CLI is sensor + gate — it does not apply the change. Explore maps only.
|
|
42
|
+
'Invoking a door is the approval. The CLI is sensor + gate — it does not apply the change. Explore maps only. Closed catalog: first-class doors plus stubs. Contener · Guiar · Ordenar.',
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
id: 'team-parliament',
|
package/bin/lib/violations.mjs
CHANGED
|
@@ -67,6 +67,36 @@ export function violationPlaneLabel(ruleId) {
|
|
|
67
67
|
return '';
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Where a warning came from, in the same `path:line` shape as a deny.
|
|
72
|
+
* Sensors already carry `file` / `line`; the human printer used to drop them.
|
|
73
|
+
* No file means the finding is about the project rules, not a line you edited.
|
|
74
|
+
*/
|
|
75
|
+
export const WARNING_UNATTRIBUTED =
|
|
76
|
+
'not a file — this is about the project rules, not a line you just edited';
|
|
77
|
+
|
|
78
|
+
export function formatWarningAttribution(warning) {
|
|
79
|
+
const file = typeof warning?.file === 'string' ? warning.file.trim() : '';
|
|
80
|
+
if (!file) return WARNING_UNATTRIBUTED;
|
|
81
|
+
const line =
|
|
82
|
+
Number.isInteger(warning.line) && warning.line > 0 ? warning.line : 1;
|
|
83
|
+
return `${file}:${line}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function formatWarningLine(warning) {
|
|
87
|
+
const ruleId = typeof warning?.ruleId === 'string' ? warning.ruleId : 'WARNING';
|
|
88
|
+
const message = typeof warning?.message === 'string' ? warning.message : '';
|
|
89
|
+
return `warning ${ruleId} ${formatWarningAttribution(warning)} ${message}`.trimEnd();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function printWarning(warning) {
|
|
93
|
+
const ruleId = typeof warning?.ruleId === 'string' ? warning.ruleId : 'WARNING';
|
|
94
|
+
const message = typeof warning?.message === 'string' ? warning.message : '';
|
|
95
|
+
console.error(
|
|
96
|
+
`${color.yellow('warning')} ${ruleId} ${formatWarningAttribution(warning)} ${message}`.trimEnd()
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
70
100
|
export function printViolation(violation) {
|
|
71
101
|
const location = `${violation.file}:${violation.line}`;
|
|
72
102
|
const plane = violationPlaneLabel(violation.ruleId);
|
|
@@ -392,7 +392,7 @@ declare function createAdapterResult(input: {
|
|
|
392
392
|
}): CurrentAdapterResult;
|
|
393
393
|
|
|
394
394
|
/** ArkGate library version — single source of truth. */
|
|
395
|
-
declare const version = "4.8.
|
|
395
|
+
declare const version = "4.8.14";
|
|
396
396
|
|
|
397
397
|
/**
|
|
398
398
|
* AI Code Gate (basic).
|
package/dist/eslint/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var Zt=Object.create;var H=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Jt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var c=(e,t)=>H(e,"name",{value:t,configurable:!0});var er=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},we=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xt(t))!Qt.call(e,s)&&s!==r&&H(e,s,{get:()=>t[s],enumerable:!(n=Yt(t,s))||n.enumerable});return e};var Y=(e,t,r)=>(r=e!=null?Zt(Jt(e)):{},we(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),tr=e=>we(H({},"__esModule",{value:!0}),e);var Gn={};er(Gn,{default:()=>Bn,findConfigPath:()=>$,globToRegExp:()=>x,isEdgeDenied:()=>Ue,layerForRelativePath:()=>b,loadArkConfig:()=>U,noArkOrderGenericUpdate:()=>qt,noArkOrderKernelInDomain:()=>zt,noArkRunDirectNew:()=>Gt,noArkRunKernelInDomain:()=>Bt,noArkRunTransportBypass:()=>Wt,noDeniedCapabilities:()=>Vt,noDomainInfraImports:()=>$t,noForbiddenGlobals:()=>jt,noRawEventPublish:()=>Ut,patternSpecificity:()=>ce,plugin:()=>ie,readTsconfigPathAliases:()=>Lt,requirePublishSource:()=>Ht,resolveImportSpecifier:()=>Oe,resolveRelativeImport:()=>Dt});module.exports=tr(Gn);var O=Y(require("fs"),1),m=Y(require("path"),1);var Te=new Map;function Le(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(Le,"escapeLiteral");function X(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(X,"normalizeGlobSeparators");function rr(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(rr,"bracesBalanced");function x(e){let t=Te.get(e);if(t)return t;let r=X(e),n=rr(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=Le(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=Le(l)}let i=new RegExp(`^${s}$`);return Te.set(e,i),i}c(x,"globToRegExp");function nr(e){return X(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}c(nr,"concreteGlobSegments");function ce(e,t){let r=X(String(e)),n=nr(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let p of n){let d=-1;for(let u=a;u<i.length;u+=1)if(i[u]===p){d=u;break}if(d<0)return o;l=d,a=d+1}return(l+1)*1e6+n.length*1e4+s}c(ce,"patternSpecificity");function b(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>x(i).test(r))){for(let i of o.patterns??[])if(x(i).test(r)){let a=ce(i,r);a>s&&(s=a,n=o.name)}}return n}c(b,"layerForRelativePath");function De(e,t){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean),n=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<r.length-1;s+=1)if(n.has(r[s].toLowerCase()))return`${r[s].toLowerCase()}/${r[s+1].toLowerCase()}`}c(De,"sliceIdForPath");function sr(e){let t=new Set;for(let r of e??[]){let s=X(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}c(sr,"inferSliceFoldersFromPatterns");function or(e,t,r){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let n=(r??[]).find(s=>s.name===t);return sr(n?.patterns)}c(or,"resolveSliceFolders");function Fe(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}c(Fe,"normalizeSegments");function Me(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}c(Me,"trimTrailingSlashes");var ir=["src","app"];function ar(e){let t=Me(e.replace(/^[./]+/,""));return t==="*"||t==="**"}c(ar,"isBlanketRoot");function Pe(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Fe(r);for(let o of t){if(typeof o!="string"||o.length===0||ar(o))continue;if(o.includes("*")){let l=Me(o.toLowerCase());if(x(l).test(n)||x(`${l}/**`).test(n))return!0;continue}let i=Fe(o);if(i.length===0)continue;let a=ir.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let l of a){if(l+i.length>s.length)continue;let p=!0;for(let d=0;d<i.length;d+=1)if(s[l+d]!==i[d]){p=!1;break}if(p)return!0}}return!1}c(Pe,"pathUnderSharedRoot");function Ke(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}c(Ke,"sliceMatchesDeclaration");function lr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Ke(n.from,t)&&Ke(n.to,r))}c(lr,"crossSliceEdgeAllowed");function cr(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}c(cr,"peerIsolationDecision");function $e(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}c($e,"peerIsolationDenyExplanation");function dr(e,t,r,n){return de(e,t,r,n)?.rule}c(dr,"findDeniedEdgeRule");function de(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=or(s,t,n?.layers),l=o?De(o,a):void 0,p=i?De(i,a):void 0,d=cr({fromPath:o,toPath:i,folderCount:a.length,fromSlice:l,toSlice:p,fromShared:!l&&Pe(o,s.sharedRoots),toShared:!p&&Pe(i,s.sharedRoots),crossSliceAllowed:lr(s.allowedCrossSlice,l,p)});if(d.denied)return{rule:s,peerIsolationReason:d.reason,fromSlice:l,toSlice:p};continue}if(t!==r)return{rule:s}}}c(de,"findDeniedEdgeDecision");function Ue(e,t,r,n){return dr(e,t,r,n)!==void 0}c(Ue,"isEdgeDenied");var ur=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function pr(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:ur,...t]}c(pr,"scanExcludePatterns");function He(e,t){let r=String(e).split(/[/\\]/).join("/");return pr(t).some(n=>x(n).test(r))}c(He,"isScanExcludedRelative");var je=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),fr=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Zn=Object.freeze(Object.keys(fr).sort()),ue=Object.freeze({fs:"filesystem","node:fs":"filesystem","fs/promises":"filesystem","node:fs/promises":"filesystem","fs-extra":"filesystem","graceful-fs":"filesystem",memfs:"filesystem",chokidar:"filesystem",http:"network",https:"network",http2:"network",net:"network",tls:"network",dgram:"network",dns:"network","node:http":"network","node:https":"network","node:http2":"network","node:net":"network","node:tls":"network","node:dgram":"network","node:dns":"network",axios:"network",undici:"network","node-fetch":"network",got:"network",ky:"network",superagent:"network",ws:"network",process:"process","node:process":"process",child_process:"process","node:child_process":"process","@prisma/client":"persistence",prisma:"persistence",pg:"persistence",mysql:"persistence",mysql2:"persistence",mongodb:"persistence",mongoose:"persistence",sqlite3:"persistence","better-sqlite3":"persistence",redis:"persistence",ioredis:"persistence",typeorm:"persistence",knex:"persistence","drizzle-orm":"persistence",sequelize:"persistence",kysely:"persistence","@supabase/supabase-js":"persistence"}),gr=Object.freeze({process:Object.freeze(["process","node:process"])});function Ve(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=ue[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=ue[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:ue[e.slice(0,o)]??null}c(Ve,"capabilityForModuleSpecifier");function pe(e,t){for(let r of t)if(gr[r]?.includes(e))return r;return null}c(pe,"forbiddenGlobalForModuleSpecifier");function Be(e){if(e?.pure===!0)return[...je].sort();let r=(e?.capabilities?.deny??[]).filter(n=>je.includes(n));return[...new Set(r)].sort()}c(Be,"effectiveCapabilityDeny");var T={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Ge={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...T,default:[]},kernelRoots:{...T},managedLayers:{...T,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},We={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...T,default:[]},managedLayers:{...T,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...T,default:[]},appliesTo:{...T,default:[]}}};function j(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(j,"isObject");function ze(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)j(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}c(ze,"declaredLayerNames");function qe(e){if(!j(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}c(qe,"defaultedArkRun");function Ze(e){if(!j(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}c(Ze,"defaultedArkOrder");function Ye(e,t){let r=e.arkRun;if(r===void 0||!j(r))return;let n=ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Ye,"validateArkRunExtra");function Xe(e,t){let r=e.arkOrder;if(r===void 0||!j(r))return;let n=ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Xe,"validateArkOrderExtra");var I="1.3",fe="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Je=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],mr=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function yr(){let e=[];for(let t of Je)for(let r of Je)t===r||mr.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}c(yr,"createDefaultRules");var et=yr(),ge=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],S={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Qe={$schema:"https://json-schema.org/draft/2020-12/schema",$id:fe,title:"ArkGate architecture contract",description:"Versioned contract consumed identically by ArkGate CLI, MCP, and ESLint surfaces.",type:"object",additionalProperties:!1,required:["$schema","schemaVersion","include","layers","rules"],properties:{$schema:{type:"string",minLength:1,default:fe,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...S,minItems:1,default:["src"]},exclude:{...S,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:et,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...S,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...S,default:[]}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...S,minItems:1},exclude:S,intentPrefixes:S,description:{type:"string",minLength:1},forbiddenGlobals:S,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...S,minItems:1},sharedRoots:{...S,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}},coverage:{type:"object",additionalProperties:!1,description:"Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget and also bounds structural-hint preload for orchestration-only, thin-adapter, and writes-via-aggregate (default 400; there is no arkrules.hintBudget); coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.",properties:{testGlobs:{...S,minItems:1},maxFiles:{type:"integer",minimum:1,description:"Evidence file budget (default 400) and structural-hint preload cap for orchestration-only, thin-adapter, and writes-via-aggregate. Raise this when hinted/governed counts show truncated sensors. There is no separate arkrules.hintBudget."},coverageRoots:{...S,minItems:1}}},arkRun:Ge,arkOrder:We}},_=class extends Error{static{c(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
|
|
2
2
|
${r.map(n=>`- ${n.path}: ${n.message}`).join(`
|
|
3
|
-
`)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function tt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(tt,"isObject");function J(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}c(J,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(P,"valueType");function hr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}c(hr,"resolveSchemaRef");function V(e,t,r,n,s){if(t.$ref){let o=hr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}V(e,o,r,n,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:r,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!tt(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:J(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:J(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||V(e[a],i,J(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,J(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>V(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}c(V,"validateNode");function Rr(e){let t={...e,$schema:e.$schema===void 0?fe:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?et.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=qe(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Ze(e.arkOrder)),t}c(Rr,"defaultedConfig");function Ar(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(Ar,"migratedFromOf");function kr(){let e=new Set([I]);for(let t of ge)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}c(kr,"knownInputVersions");function Er(e,t="ark.config.json"){if(!tt(e))throw new _(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=kr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ge.length+1;){i+=1;let a=ge.find(l=>l.from===s);if(!a)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:Rr(o),migratedFrom:Ar(n)}}c(Er,"migrateArkConfig");function br(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Er(e,t),s=[];if(V(r,Qe,"$",Qe,s),Ye(r,s),Xe(r,s),s.length>0)throw new _(t,s);return{config:r,migratedFrom:n}}c(br,"loadArkConfigContract");function rt(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new _(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return br(r,t)}c(rt,"parseArkConfigJson");var Sr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Ir=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,xr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function _r(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Sr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Ir.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":xr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(_r,"classifyLayerImportKind");function Nr(e){if(e.typeOnly||e.targetTypeOnlyExports||e.namedBindingsTypeOnly)return"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.";if(e.peerIsolation)return"Extract the shared dependency to a shared layer, test at the public interface, then preflight again.";let t=_r(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}c(Nr,"layerImportNextAction");function Or(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(Or,"arkRunCallSiteName");function vr(e){let t=Or(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"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 \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"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.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(vr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Nr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return vr(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change \u03BE with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(K,"deterministicNextAction");var me="docs/diagnostics.md";function ye(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}c(ye,"adapterFindingTargetKey");function he(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}c(he,"adapterFindingRefFromTargetKey");function Re(e){return`${me}#${e}`}c(Re,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}c(h,"text");function nt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}c(nt,"positiveInteger");function Tr(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}c(Tr,"nextActionForDiagnostic");function st(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??ye(e),a=he(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:nt(e.line,1),column:nt(e.column,1)},evidence:o,nextAction:h(e.nextAction)??Tr(n,o,e),findingRef:a,targetKey:i,docsCodePath:Re(n)}}c(st,"toAdapterDiagnostic");var ot={RAW_EVENT_PUBLISH:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts and tooling.",PUBLISH_MISSING_SOURCE:"Strict Ark publish calls must include metadata.source."},hs=Object.freeze([{layer:"DomainModel",prefixes:["Domain."]},{layer:"ApplicationOrchestration",prefixes:["Application."]},{layer:"PersistenceAdapters",prefixes:["Adapter.Persistence.","Adapter.Repository."]},{layer:"IntegrationAdapters",prefixes:["Adapter.Integration.","Adapter.External."]},{layer:"WorkflowSagaEngine",prefixes:["Workflow."]},{layer:"BackgroundJobsScheduling",prefixes:["Job."]},{layer:"PresentationAdapters",prefixes:["Presentation.","Adapter.Presentation.","Adapter.Api."]},{layer:"ReportingReadModels",prefixes:["Reporting."]},{layer:"ExtensibilityMetadata",prefixes:["Metadata."]},{layer:"SecurityAuditObservability",prefixes:["Security.","Audit.","Observability."]},{layer:"Kernel",prefixes:["Kernel."]}]);function Lr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(Lr,"looksLikeArkIntent");function Ae(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Lr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:ot.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:ot.PUBLISH_MISSING_SOURCE}),t}c(Ae,"classifyPublishFacts");var _e=Y(require("fs"),1),v=Y(require("path"),1);var Dr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Fr=new Set(Dr),Pr=new Set(["AggregateError","Array","ArrayBuffer","BigInt64Array","BigUint64Array","Boolean","DataView","Date","Error","EvalError","FinalizationRegistry","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Number","Object","Promise","Proxy","RangeError","ReferenceError","RegExp","Set","SharedArrayBuffer","String","Symbol","SyntaxError","TypeError","URIError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","WeakRef","WeakSet"]),Kr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function M(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c(M,"isArkRunKernelModuleSpecifier");var Mr=["events","node:events","eventemitter2","eventemitter3","emittery","kafkajs","kafka-node","amqplib","amqp","bull","bullmq","mqtt","nats","@aws-sdk/client-sqs","@aws-sdk/client-sns","@aws-sdk/client-eventbridge","@google-cloud/pubsub","@azure/service-bus"],ke=new Set(Mr);function lt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ke.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(ke.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:ke.has(e.slice(0,n))}c(lt,"isArkRunTransportBypassSpecifier");function it(e){if(Fr.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}c(it,"arkRunKernelCallKind");function ct(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}c(ct,"lineAt");function Ee(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(Ee,"stripCommentsPreservingLines");function $r(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}c($r,"firstStringLiteralArg");function at(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}c(at,"keywordBefore");function Q(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}c(Q,"parseValueImportClause");function dt(e,t){Q(Ee(e),t)}c(dt,"forEachArkRunValueImportClause");function Ur(e){let t=new Map,r=new Set;return Q(e,(n,s)=>{if(!M(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let p=l.trim();if(!p||p.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);if(d){t.set(d[2],d[1]);continue}let u=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);u?.[1]&&t.set(u[1],u[1])}}),{named:t,namespaces:r}}c(Ur,"collectKernelImportBindings");function Hr(e,t){let r=new Set(t);return Q(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),p=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=l?.[1]??p;!p||!d||!/^[A-Z]/.test(d)||(M(s)||t.has(d)||t.has(p))&&(r.add(p),r.add(d))}}),r}c(Hr,"collectImportedConstructors");function jr(e,t){let r;return Q(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}c(jr,"importedFromForName");function ee(e,t){let r=Ee(t),n=Ur(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],l=i.index;if(at(r,l,"function")||at(r,l,"class"))continue;let d=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],u=n.named.get(a)??a,f=it(u)??it(a);if(!f)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(f!=="factory"&&(!g&&d===void 0||d&&Kr.has(d)&&!g))continue;let y=$r(r,l+i[0].length);s.push({file:e,line:ct(t,l),kind:f,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}c(ee,"extractArkRunKernelCallsFromSource");function be(e,t,r){let n=Ee(t),s=Hr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(Pr.has(l)||!s.has(l))continue;let p=jr(n,l);o.push({file:e,line:ct(t,a.index),typeName:l,...p?{importedFrom:p}:{}})}return o}c(be,"extractArkRunManagedNewsFromSource");var Vr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Br=new RegExp(`\\b(${Vr.join("|")})\\b`),pt="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",Gr=new RegExp(`\\bthis\\.${pt}\\.push\\s*\\(`),Wr=new RegExp(`^this\\.${pt}\\s*=\\s*\\[\\s*\\]`),zr=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,qr=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,Zr="truncatedUntil";function Yr(e){return Br.test(e)||Gr.test(e)}c(Yr,"referencesGuardOrPublish");function Xr(e,t,r){let n=e.slice(t);if(Wr.test(n))return!0;if(!zr.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}c(Xr,"isIdiomaticEventsReset");function Jr(e,t){let r=new RegExp(qr.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!Xr(t,n.index,e))return!0;return!1}c(Jr,"methodAssignsThis");function Qr(e,t){return t==null||Object.defineProperty(e,Zr,{value:t,enumerable:!1,configurable:!0}),e}c(Qr,"attachShapeTruncation");var en=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),tn=new Set(["if","match","when"]);function te(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
|
|
3
|
+
`)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function tt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(tt,"isObject");function J(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}c(J,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(P,"valueType");function hr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}c(hr,"resolveSchemaRef");function V(e,t,r,n,s){if(t.$ref){let o=hr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}V(e,o,r,n,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:r,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!tt(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:J(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:J(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||V(e[a],i,J(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,J(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>V(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}c(V,"validateNode");function Rr(e){let t={...e,$schema:e.$schema===void 0?fe:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?et.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=qe(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Ze(e.arkOrder)),t}c(Rr,"defaultedConfig");function Ar(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(Ar,"migratedFromOf");function kr(){let e=new Set([I]);for(let t of ge)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}c(kr,"knownInputVersions");function Er(e,t="ark.config.json"){if(!tt(e))throw new _(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=kr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ge.length+1;){i+=1;let a=ge.find(l=>l.from===s);if(!a)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new _(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:Rr(o),migratedFrom:Ar(n)}}c(Er,"migrateArkConfig");function br(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Er(e,t),s=[];if(V(r,Qe,"$",Qe,s),Ye(r,s),Xe(r,s),s.length>0)throw new _(t,s);return{config:r,migratedFrom:n}}c(br,"loadArkConfigContract");function rt(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new _(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return br(r,t)}c(rt,"parseArkConfigJson");var Sr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Ir=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,xr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function _r(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Sr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Ir.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":xr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(_r,"classifyLayerImportKind");function Nr(e){if(e.typeOnly||e.targetTypeOnlyExports||e.namedBindingsTypeOnly)return"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.";if(e.peerIsolation)return"Extract the shared dependency to a shared layer, test at the public interface, then preflight again.";let t=_r(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}c(Nr,"layerImportNextAction");function Or(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(Or,"arkRunCallSiteName");function vr(e){let t=Or(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"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 \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"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.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(vr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Nr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return vr(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(K,"deterministicNextAction");var me="docs/diagnostics.md";function ye(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}c(ye,"adapterFindingTargetKey");function he(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}c(he,"adapterFindingRefFromTargetKey");function Re(e){return`${me}#${e}`}c(Re,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}c(h,"text");function nt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}c(nt,"positiveInteger");function Tr(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}c(Tr,"nextActionForDiagnostic");function st(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??ye(e),a=he(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:nt(e.line,1),column:nt(e.column,1)},evidence:o,nextAction:h(e.nextAction)??Tr(n,o,e),findingRef:a,targetKey:i,docsCodePath:Re(n)}}c(st,"toAdapterDiagnostic");var ot={RAW_EVENT_PUBLISH:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts and tooling.",PUBLISH_MISSING_SOURCE:"Strict Ark publish calls must include metadata.source."},hs=Object.freeze([{layer:"DomainModel",prefixes:["Domain."]},{layer:"ApplicationOrchestration",prefixes:["Application."]},{layer:"PersistenceAdapters",prefixes:["Adapter.Persistence.","Adapter.Repository."]},{layer:"IntegrationAdapters",prefixes:["Adapter.Integration.","Adapter.External."]},{layer:"WorkflowSagaEngine",prefixes:["Workflow."]},{layer:"BackgroundJobsScheduling",prefixes:["Job."]},{layer:"PresentationAdapters",prefixes:["Presentation.","Adapter.Presentation.","Adapter.Api."]},{layer:"ReportingReadModels",prefixes:["Reporting."]},{layer:"ExtensibilityMetadata",prefixes:["Metadata."]},{layer:"SecurityAuditObservability",prefixes:["Security.","Audit.","Observability."]},{layer:"Kernel",prefixes:["Kernel."]}]);function Lr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(Lr,"looksLikeArkIntent");function Ae(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Lr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:ot.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:ot.PUBLISH_MISSING_SOURCE}),t}c(Ae,"classifyPublishFacts");var _e=Y(require("fs"),1),v=Y(require("path"),1);var Dr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Fr=new Set(Dr),Pr=new Set(["AggregateError","Array","ArrayBuffer","BigInt64Array","BigUint64Array","Boolean","DataView","Date","Error","EvalError","FinalizationRegistry","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Number","Object","Promise","Proxy","RangeError","ReferenceError","RegExp","Set","SharedArrayBuffer","String","Symbol","SyntaxError","TypeError","URIError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","WeakRef","WeakSet"]),Kr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function M(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c(M,"isArkRunKernelModuleSpecifier");var Mr=["events","node:events","eventemitter2","eventemitter3","emittery","kafkajs","kafka-node","amqplib","amqp","bull","bullmq","mqtt","nats","@aws-sdk/client-sqs","@aws-sdk/client-sns","@aws-sdk/client-eventbridge","@google-cloud/pubsub","@azure/service-bus"],ke=new Set(Mr);function lt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ke.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(ke.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:ke.has(e.slice(0,n))}c(lt,"isArkRunTransportBypassSpecifier");function it(e){if(Fr.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}c(it,"arkRunKernelCallKind");function ct(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}c(ct,"lineAt");function Ee(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(Ee,"stripCommentsPreservingLines");function $r(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}c($r,"firstStringLiteralArg");function at(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}c(at,"keywordBefore");function Q(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}c(Q,"parseValueImportClause");function dt(e,t){Q(Ee(e),t)}c(dt,"forEachArkRunValueImportClause");function Ur(e){let t=new Map,r=new Set;return Q(e,(n,s)=>{if(!M(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let p=l.trim();if(!p||p.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);if(d){t.set(d[2],d[1]);continue}let u=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);u?.[1]&&t.set(u[1],u[1])}}),{named:t,namespaces:r}}c(Ur,"collectKernelImportBindings");function Hr(e,t){let r=new Set(t);return Q(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),p=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=l?.[1]??p;!p||!d||!/^[A-Z]/.test(d)||(M(s)||t.has(d)||t.has(p))&&(r.add(p),r.add(d))}}),r}c(Hr,"collectImportedConstructors");function jr(e,t){let r;return Q(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}c(jr,"importedFromForName");function ee(e,t){let r=Ee(t),n=Ur(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],l=i.index;if(at(r,l,"function")||at(r,l,"class"))continue;let d=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],u=n.named.get(a)??a,f=it(u)??it(a);if(!f)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(f!=="factory"&&(!g&&d===void 0||d&&Kr.has(d)&&!g))continue;let y=$r(r,l+i[0].length);s.push({file:e,line:ct(t,l),kind:f,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}c(ee,"extractArkRunKernelCallsFromSource");function be(e,t,r){let n=Ee(t),s=Hr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(Pr.has(l)||!s.has(l))continue;let p=jr(n,l);o.push({file:e,line:ct(t,a.index),typeName:l,...p?{importedFrom:p}:{}})}return o}c(be,"extractArkRunManagedNewsFromSource");var Vr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Br=new RegExp(`\\b(${Vr.join("|")})\\b`),pt="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",Gr=new RegExp(`\\bthis\\.${pt}\\.push\\s*\\(`),Wr=new RegExp(`^this\\.${pt}\\s*=\\s*\\[\\s*\\]`),zr=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,qr=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,Zr="truncatedUntil";function Yr(e){return Br.test(e)||Gr.test(e)}c(Yr,"referencesGuardOrPublish");function Xr(e,t,r){let n=e.slice(t);if(Wr.test(n))return!0;if(!zr.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}c(Xr,"isIdiomaticEventsReset");function Jr(e,t){let r=new RegExp(qr.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!Xr(t,n.index,e))return!0;return!1}c(Jr,"methodAssignsThis");function Qr(e,t){return t==null||Object.defineProperty(e,Zr,{value:t,enumerable:!1,configurable:!0}),e}c(Qr,"attachShapeTruncation");var en=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),tn=new Set(["if","match","when"]);function te(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
|
|
4
4
|
`,t);return n===-1?e.length:n}if(r==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2}if(r==="'"||r==='"'||r==="`"){let n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===r)return n+1;n+=1}return e.length}return t}c(te,"skipStringOrComment");function B(e,t){let r=t;for(;r<e.length;){if(/\s/.test(e[r])){r+=1;continue}if(e[r]==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=te(e,r);continue}break}return r}c(B,"skipWsAndComments");function ut(e,t){let r=e[t];if(!r||!/[A-Za-z_]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_]/.test(e[n]);)n+=1;return{ident:e.slice(t,n),end:n}}c(ut,"readIdent");function Se(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=te(e,o);if(i!==o){o=i;continue}let a=e[o];a===r?s+=1:a===n&&(s-=1),o+=1}return s===0?o:null}c(Se,"skipBalanced");function rn(e){let t=[],r=0,n;for(;r<e.length&&(r=B(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let d=ut(e,o);if(!d||!en.has(d.ident))break;s.push(d.ident),o=B(e,d.end)}let i=ut(e,o);if(!i){r+=1;continue}if(o=B(e,i.end),e[o]==="<"){let d=Se(e,o,"<",">");if(d==null){n=e.length;break}o=B(e,d)}if(e[o]==="("){let d=Se(e,o,"(",")");if(d==null){n=e.length;break}if(o=B(e,d),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let u=te(e,o);if(u!==o){o=u;continue}o+=1}if(e[o]==="{"){let u=Se(e,o,"{","}");if(u==null){n=e.length;break}t.push({name:i.ident,modifiers:s,kind:"method",body:e.slice(o+1,u-1)}),r=u;continue}if(e[o]===";"){r=o+1;continue}r=o+1;continue}let a=0,l=0,p=0;for(;o<e.length;){let d=te(e,o);if(d!==o){o=d;continue}let u=e[o];if(u==="{")a+=1;else if(u==="}"){if(a===0)break;a-=1}else if(u==="(")l+=1;else if(u===")")l-=1;else if(u==="[")p+=1;else if(u==="]")p-=1;else if(u===";"&&a===0&&l===0&&p===0){o+=1;break}o+=1}t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o}return{members:t,truncatedAt:n}}c(rn,"scanClassMembers");function Ie(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,l=i;for(;l<t.length&&a>0;){let A=t[l];A==="{"?a+=1:A==="}"&&(a-=1),l+=1}let p=t.slice(i,l-1),d=a>0,u=rn(p),f=d?t.length:u.truncatedAt==null?void 0:i+u.truncatedAt,g=u.members.filter(A=>!(A.kind!=="field"||A.name==="constructor"||A.modifiers.includes("private")||A.modifiers.includes("protected")||A.modifiers.includes("readonly")||A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set"))),y=g.length>0,R=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(p),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(p),E=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(p)&&!k,Z=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(p)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(p),D=[];for(let A of u.members)A.kind==="method"&&A.name!=="constructor"&&(A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set")||tn.has(A.name)||Jr(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:Yr(A.body)}));let F=u.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(Qr({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:R,hasPublicConstructor:E,hasStaticFactory:Z,mutatingMethods:[...D],dataOnly:F},f))}return r}c(Ie,"extractClassShapesFromSource");function nn(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}c(nn,"normalizeExtraMergeTeethClassification");function re(e){let t=nn(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}c(re,"extraMergeTeethAllowed");var sn=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],on=new Set(sn);function an(e){return on.has(e)}c(an,"isArkRunEditorSensor");var ft={"arkrun-missing-root":"ARKRUN_MISSING_ROOT","arkrun-kernel-in-domain":"ARKRUN_KERNEL_IN_DOMAIN","arkrun-direct-new":"ARKRUN_DIRECT_NEW","arkrun-undeclared-emit":"ARKRUN_UNDECLARED_EMIT","arkrun-undeclared-handle":"ARKRUN_UNDECLARED_HANDLE","arkrun-undeclared-depend":"ARKRUN_UNDECLARED_DEPEND","arkrun-transport-bypass":"ARKRUN_TRANSPORT_BYPASS"},ln="ARKRUN_INTERACTION_NAME_INCOMPLETE";function yt(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(yt,"isDomainRoleLayer");function cn(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}c(cn,"compareFindings");function N(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:ft[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:ft[t],fromLayer:o?.fromLayer,target:o?.target})}}c(N,"finding");function dn(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}c(dn,"bagForFile");function gt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}c(gt,"emitKinds");function mt(e){return e==="subscribe"||e==="register-handler"}c(mt,"handleKinds");function un(e){return e==="resolve"||e==="resolve-singleton"}c(un,"dependKinds");function pn(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(N(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let a=o.get(i.matchedRoot)??[];a.push(i),o.set(i.matchedRoot,a)}for(let i of s){let a=[...o.get(i)??[]].sort((p,d)=>p.file.localeCompare(d.file));if(a.length===0){n.push(N(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(a.some(p=>p.hasKernelFactory))continue;let l=a[0];n.push(N(e,"arkrun-missing-root",l.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}c(pn,"evaluateMissingRoot");function fn(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let l=a.specifier;if(!l||!M(l))continue;let p=n(a.from);p&&yt(p,o.get(p)??[])&&i.push(N(e,"arkrun-kernel-in-domain",a.from,a.line,`${p} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:p,target:l},s))}return i}c(fn,"evaluateKernelInDomain");function gn(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(t.map(d=>[d.name,d.intentPrefixes??[]])),l=new Set(n.filter(d=>d.hasKernelFactory).map(d=>d.file)),p=[];for(let d of r){if(l.has(d.file))continue;let u=d.typeName;if(e.ignoreDirectNewForErrors!==!1&&(u.endsWith("Error")||u==="Error")||u.endsWith("DTO")||u.endsWith("VO"))continue;let f=s(d.file);!f||!i.has(f)||yt(f,a.get(f)??[])||p.push(N(e,"arkrun-direct-new",d.file,d.line,`${f} must not construct ${d.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:f,target:d.typeName},o))}return p}c(gn,"evaluateDirectNew");function mn(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let l of t){if(!gt(l.kind)&&!mt(l.kind)&&!un(l.kind))continue;let p=n(l.file);if(!p||!a.has(p))continue;if(!l.nameLiteral){e.mode==="enforced"&&i.push({code:ln,file:l.file,message:`ArkRun ${l.kind} call in ${l.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let d=dn(r,l.file);if(gt(l.kind)){if(d.raises.has(l.nameLiteral)||d.sends.has(l.nameLiteral))continue;o.push(N(e,"arkrun-undeclared-emit",l.file,l.line,`Emit ${JSON.stringify(l.nameLiteral)} is not declared in raises or sends.`,{fromLayer:p,target:l.nameLiteral},s));continue}if(mt(l.kind)){if(d.reactsTo.has(l.nameLiteral))continue;o.push(N(e,"arkrun-undeclared-handle",l.file,l.line,`Handle ${JSON.stringify(l.nameLiteral)} is not declared in reactsTo.`,{fromLayer:p,target:l.nameLiteral},s));continue}d.uses.has(l.nameLiteral)||o.push(N(e,"arkrun-undeclared-depend",l.file,l.line,`Depend ${JSON.stringify(l.nameLiteral)} is not declared in uses.`,{fromLayer:p,target:l.nameLiteral},s))}return{findings:o,completenessReasons:i}}c(mn,"evaluateUndeclared");function yn(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let a=i.specifier;if(!a||!lt(a))continue;let l=r(i.from);!l||!s.has(l)||o.push(N(e,"arkrun-transport-bypass",i.from,i.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return o}c(yn,"evaluateTransportBypass");function hn(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=re(e.classification),n=mn(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...pn(t,e.compositionRootHits,r),...fn(t,e.layers,e.dependencies,e.layerForFile,r),...gn(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...yn(t,e.dependencies,e.layerForFile,r)].sort(cn),o=[...n.completenessReasons].sort((i,a)=>{let l=`${i.code}\0${i.file??""}\0${i.message}`,p=`${a.code}\0${a.file??""}\0${a.message}`;return l<p?-1:l>p?1:0});return{findings:s,completenessReasons:o}}c(hn,"evaluateArkRunSensors");function xe(e){return{findings:hn(e).findings.filter(r=>an(r.sensor)),completenessReasons:[]}}c(xe,"evaluateArkRunEditorSensors");function Rn(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(Rn,"declarationIsTypeOnly");function Rt(e){try{return _e.default.existsSync(e)?_e.default.readFileSync(e,"utf8"):null}catch{return null}}c(Rt,"readUtf8");function ht(e,t){let r=e.lintedFilename(t),n=e.findConfigPath(r),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!r)return null;let o=v.default.dirname(n),i=v.default.isAbsolute(r)?r:v.default.resolve(r),a=v.default.relative(o,i).split(v.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=b(a,s.layers);return l?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:l}:null}c(ht,"loadEditorFile");function An(e,t,r){let n=ee(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!x(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}c(An,"compositionRootHitsForFile");function kn(e,t,r){let n=new Set(Ie(t.relFile,r).map(s=>s.className));return dt(r,(s,o)=>{if(M(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=v.default.relative(t.root,i).split(v.default.sep).join("/");if(a.startsWith(".."))return;let l=Rt(i);if(l!==null)for(let p of Ie(a,l))n.add(p.className)}),n}c(kn,"admittedTypeNamesForEditor");function At(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}c(At,"reportFinding");function En(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}c(En,"constructedTypeName");function bn(e,t){return e.type?.startsWith("Export")?"export":t}c(bn,"specifierEdgeKind");function Sn(e,t,r,n,s){let o=c((i,a,l,p)=>{if(typeof a!="string"||a.length===0)return;let d=i.loc?.start?.line??1,u={from:r.relFile,specifier:a,kind:p,typeOnly:l,line:d,resolution:"resolved-external"},{findings:f}=xe({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[u],layerForFile:c(g=>g===r.relFile?r.fromLayer:b(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&At(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,l=(a.specifiers??[]).filter(d=>d.type==="ImportSpecifier"),p=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(d=>d.importKind==="type");o(i,a.source?.value,a.importKind==="type"||p||Rn(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let l=a.specifiers??[],p=l.length>0&&l.every(d=>d.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||p,bn(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}c(Sn,"importListeners");function In(e,t,r){let n=Rt(r.absFile)??"",s=kn(e,r,n),o=be(r.relFile,n,s),{findings:i}=xe({arkRun:r.extra,layers:r.config.layers,kernelCalls:ee(r.relFile,n),managedNews:o,compositionRootHits:An(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:c(l=>l===r.relFile?r.fromLayer:b(l,r.config.layers),"layerForFile")}),a=i.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let p=En(l);if(!p)return;let d=l.loc?.start?.line,u=a.find(f=>f.target===p&&(d===void 0||f.line===d))??a.find(f=>f.target===p);u&&At(e,t,l,"directNew",u,{fromLayer:u.fromLayer??r.fromLayer,typeName:p,target:u.target??p})}}}c(In,"directNewListener");function kt(e){let t=c((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=ht(e,i);return a?Sn(e,i,a,r,s):{}}}),"createImportRule");return{noArkRunKernelInDomain:t("arkrun-kernel-in-domain","Disallow Domain-role imports of arkgate/runtime when arkRun is on (same sensor as ark-check).","kernelInDomain",'{{fromLayer}} must not import kernel module "{{specifier}}".'),noArkRunTransportBypass:t("arkrun-transport-bypass","Disallow homemade broker/queue/emitter imports in arkRun managed layers (same sensor as ark-check).","transportBypass",'{{fromLayer}} must not import broker/queue/emitter "{{specifier}}"; use the ArkRun kernel transport.'),noArkRunDirectNew:{meta:{type:"problem",docs:{description:"Disallow `new` of ArkRun-admitted types outside a composition-root factory (on-disk import/`new` envelope)."},messages:{directNew:"{{fromLayer}} must not construct {{typeName}} with new outside an ArkRun composition-root factory."},schema:[]},create(r){let n=ht(e,r);return n?In(e,r,n):{}}}}}c(kt,"createArkRunEslintRules");var xn="createOrderPlane";var _n=/\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm(?:\/[^'"]+)?|postgres(?:\/[^'"]+)?|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|postgres(?:\/[^'"]+)?|drizzle-orm(?:\/[^'"]+)?|knex|typeorm|mongoose)/,Nn=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,On=/\b(?:db|tx|client|prisma(?:Client)?|drizzle)\b(?:\s*\.\s*[A-Za-z_]\w*)*\s*\.\s*(?: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;function vn(e){return _n.test(e)||Nn.test(e)}c(vn,"sourceImportsPersistenceDriver");function ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(ne,"escapeRegExp");function se(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}c(se,"isArkOrderModuleSpecifier");function G(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
|
|
5
5
|
`&&(r+=1);return r}c(G,"lineAt");function W(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(W,"stripCommentsPreservingLines");function Et(e,t){let r=W(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:G(t,o.index),callee:xn});return n}c(Et,"extractArkOrderPlaneCallsFromSource");function bt(e,t){let r=W(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],a=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane)\s*(?:\?|!)?$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:G(t,o.index),method:i})}return n}c(bt,"extractArkOrderGenericUpdatesFromSource");function St(e,t,r){if(r.length===0)return[];let n=W(t);if(!vn(n)||!On.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${ne(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${ne(i)}['"]\\s*:|[{\\,]\\s*${ne(i)}\\s*[\\,}]|\\.${ne(i)}\\s*=)`,"g"),l;for(;(l=a.exec(n))!==null;){let p=`${i}:${l.index}`;if(!o.has(p)){o.add(p),s.push({file:e,line:G(t,l.index),key:i});break}}}return s}c(St,"extractArkOrderXiFieldWritesFromSource");function It(e,t){let r=W(t),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:G(t,o.index)});return n}c(It,"extractArkOrderIngestWritesXiFromSource");function xt(e,t){let r=W(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:G(t,o.index),keyCount:a.length})}return n}c(xt,"extractArkOrderReleaseKeyCountsFromSource");var _t=new Map;function Nt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(Nt,"escapeAppliesToLiteral");function Cn(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(Cn,"normalizeAppliesToGlob");function wn(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(wn,"appliesToBracesBalanced");function Tn(e){let t=_t.get(e);if(t)return t;let r=Cn(e),n=wn(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=Nt(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=Nt(l)}let i=new RegExp(`^${s}$`);return _t.set(e,i),i}c(Tn,"globToRegExp");var Ot={"arkorder-missing-plane":"ARKORDER_MISSING_PLANE","arkorder-kernel-in-domain":"ARKORDER_KERNEL_IN_DOMAIN","arkorder-generic-update":"ARKORDER_GENERIC_UPDATE","arkorder-too-many-params":"ARKORDER_TOO_MANY_PARAMS","arkorder-ingest-writes-xi":"ARKORDER_INGEST_WRITES_XI","arkorder-xi-field-write":"ARKORDER_XI_FIELD_WRITE","arkorder-information-budget":"ARKORDER_INFORMATION_BUDGET","arkorder-xi-ttl":"ARKORDER_XI_TTL"};function Ln(e,t){return!t||t.length===0?!0:t.some(r=>Tn(r).test(e))}c(Ln,"matchesArkOrderAppliesTo");function Dn(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(Dn,"isDomainRoleLayer");function C(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Ot[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:Ot[t],fromLayer:o?.fromLayer,target:o?.target})}}c(C,"finding");function Fn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=re(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(C(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let l=new Map;for(let p of e.planeRootHits){let d=l.get(p.matchedRoot)??[];d.push(p),l.set(p.matchedRoot,d)}for(let p of s){let d=l.get(p)??[];if(d.length===0){n.push(C(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(p)} matched no governed files and has no createOrderPlane factory.`,{target:p},r));continue}d.some(u=>u.hasPlaneFactory)||n.push(C(t,"arkorder-missing-plane",d[0].file,1,`ArkOrder plane root ${JSON.stringify(p)} has no createOrderPlane factory.`,{target:p},r))}}let o=new Map(e.layers.map(l=>[l.name,l.intentPrefixes??[]]));for(let l of e.dependencies){let p=l.specifier;if(!p||!se(p))continue;let d=e.layerForFile(l.from);d&&Dn(d,o.get(d)??[])&&n.push(C(t,"arkorder-kernel-in-domain",l.from,l.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:d,target:p},r))}for(let l of e.genericUpdates)n.push(C(t,"arkorder-generic-update",l.file,l.line,`Generic ${l.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:l.method},r));let i=t.xiKeys??[];for(let l of e.releaseKeyCounts??[])l.keyCount<=t.maxXiKeys||n.push(C(t,"arkorder-too-many-params",l.file,l.line,`release() freezes ${l.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(l.keyCount)},r));for(let l of e.ingestWritesXi??[])n.push(C(t,"arkorder-ingest-writes-xi",l.file,l.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let l of i.length===0?[]:e.xiFieldWrites??[]){let p=e.layerForFile(l.file);!p||!a.has(p)||Ln(l.file,t.appliesTo)&&n.push(C(t,"arkorder-xi-field-write",l.file,l.line,`This file writes ${JSON.stringify(l.key)} the same way it would write a seat count. Take the event in, or change that choice through the valve (propose, then apply).`,{fromLayer:p,target:l.key},r))}return n.sort((l,p)=>l.file.localeCompare(p.file)||l.ruleId.localeCompare(p.ruleId)||l.line-p.line),{findings:n,completenessReasons:[]}}c(Fn,"evaluateArkOrderSensors");function vt(e){if(!e.arkOrder)return[];let t=Et(e.file,e.source),r=bt(e.file,e.source),n=e.arkOrder.xiKeys??[];return Fn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:St(e.file,e.source,n),ingestWritesXi:It(e.file,e.source),releaseKeyCounts:xt(e.file,e.source),dependencies:[],layerForFile:c(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}c(vt,"evaluateArkOrderEditorSensors");function Pn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}c(Pn,"eslintSourceText");function Ct(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let l=b(a,i.layers);return{ImportDeclaration(p){let d=typeof p.source?.value=="string"?p.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!se(d)||l!=="DomainModel"&&!/^domain/i.test(l??""))return;e.reportAdapterDiagnostic(n,p,"denied",{ruleId:r,file:a,line:p.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let p=Pn(n),d=vt({arkOrder:i.arkOrder,file:a,source:p,fromLayer:l}).filter(u=>u.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let u of d)e.reportAdapterDiagnostic(n,{loc:{start:{line:u.line}}},"denied",{ruleId:u.ruleId,file:u.file,line:u.line,message:u.message})}}}}}return c(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}c(Ct,"createArkOrderEslintRules");function L(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}c(L,"lintedFilename");function w(e,t,r,n,s){let o=st({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}c(w,"reportAdapterDiagnostic");function $(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.default.dirname(m.default.resolve(e));for(;;){let r=m.default.join(t,"ark.config.json");if(O.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}c($,"findConfigPath");var wt=new Map;function U(e){if(!O.default.existsSync(e))return null;let t=O.default.readFileSync(e,"utf8"),r=wt.get(e);if(r?.source===t)return r.config;let n=rt(t,e).config;return wt.set(e,{source:t,config:n}),n}c(U,"loadArkConfig");function q(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!He(t,e)}c(q,"sourceIsInAnalysisScope");function Tt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.default.join(e,"index.ts"),m.default.join(e,"index.tsx"),m.default.join(e,"index.js")];for(let r of t)try{if(O.default.existsSync(r)&&O.default.statSync(r).isFile())return r}catch{}return null}c(Tt,"existingSourceFile");function Lt(e){let t=m.default.resolve(e),r=null;for(;;){let p=m.default.join(t,"tsconfig.json");if(O.default.existsSync(p)){r=p;break}let d=m.default.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=c(p=>{try{let d=O.default.readFileSync(p,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},"loadJsonc"),s=c((p,d)=>{if(d>4)return{};let u=n(p);if(!u)return{};let f=u.compilerOptions??{},g=f.baseUrl,y=f.paths,R=u.extends;if(typeof R=="string"&&!R.startsWith("@")){let k=m.default.resolve(m.default.dirname(p),R.endsWith(".json")?R:`${R}.json`);if(O.default.existsSync(k)){let E=s(k,d+1);g=g??E.baseUrl,y={...E.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),a=m.default.resolve(i,o.baseUrl||"."),l=[];for(let[p,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let u=p.replace(/\*$/,"");u&&l.push({from:u,to:String(d[0]).replace(/\*$/,"")})}return l.sort((p,d)=>d.from.length-p.from.length),{baseUrl:a,aliases:l}}c(Lt,"readTsconfigPathAliases");function Dt(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return Tt(r)}c(Dt,"resolveRelativeImport");function Oe(e,t,r){if(!t)return null;if(t.startsWith("."))return Dt(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=Lt(n),i=o.find(l=>t.startsWith(l.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Tt(a)}c(Oe,"resolveImportSpecifier");function ae(e){return typeof e?.value=="string"?e.value:void 0}c(ae,"stringValue");function ve(e){return e?.name??ae(e)}c(ve,"propertyName");function Ce(e){return e.sourceCode??e.getSourceCode?.()}c(Ce,"sourceCodeFor");function Ft(e,t){let r=Ce(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}c(Ft,"referenceFor");function z(e,t,r){let n=Ft(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Ce(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}c(z,"isLocallyBound");function Kn(e,t){let r=Ft(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}c(Kn,"isValueIdentifierReference");function Pt(e){if(e?.type==="Identifier"&&e.name)return{root:e,segments:[e.name]};if(!e||!(e.type==="MemberExpression"||!!(e.object&&e.property))||e.computed===!0)return;let r=Pt(e.object),n=ve(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}c(Pt,"memberExpressionPath");function Mn(e){return ve(e.callee?.property)}c(Mn,"calleePropertyName");function Kt(e,t){return e?.properties?.find(r=>ve(r.key)===t)}c(Kt,"objectProperty");function oe(e,t){return Kt(e,t)!==void 0}c(oe,"objectHasProperty");function $n(e){let t=Kt(e,"metadata")?.value;return oe(t,"source")}c($n,"objectHasMetadataSource");function Mt(e){return Mn(e)==="publish"}c(Mt,"isPublishCall");function Ne(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(Ne,"declarationIsTypeOnly");function Un(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}c(Un,"containingProgram");function Hn(e){let t=Un(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Ne(n))return!1;continue}if(!(n.type==="TSInterfaceDeclaration"||n.type==="TSTypeAliasDeclaration")){if(n.type==="ExportNamedDeclaration"){if(n.declaration){if(n.declaration.type!=="TSInterfaceDeclaration"&&n.declaration.type!=="TSTypeAliasDeclaration")return!1}else if(!Ne(n))return!1;r=!0;continue}return!1}}return r}c(Hn,"sourceProgramExportsOnlyTypes");var $t={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null,o=c(i=>{let a=ae(i.source);if(a&&n&&s&&t){let l=m.default.isAbsolute(t)?t:m.default.resolve(t),p=m.default.relative(s,l).split(m.default.sep).join("/");if(!q(n,p))return;let d=b(p,n.layers);if(!d)return;let u=Oe(l,a,s);if(!u)return;let f=m.default.relative(s,u).split(m.default.sep).join("/");if(f.startsWith(".."))return;let g=b(f,n.layers);if(!g)return;let y={fromPath:p,toPath:f,layers:n.layers},R=de(n.rules,d,g,y),k=R?.rule;if(k){let E=i.type?.startsWith("Export")?"export":"import",Z=Ne(i),D=!!k?.peerIsolation,le=Z&&!D,F=D&&R?$e(R.peerIsolationReason??"cross-slice",{fromPath:p,toPath:f,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${d} must not ${E} another slice of ${g} (${p} \u2192 ${f}): ${F}`:`${d} must not ${E} ${g}.`;w(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:p,fromLayer:d,toLayer:g,target:f,edgeKind:E,...D?{peerIsolation:!0}:{},...Z?{typeOnly:!0}:{},...le?{severity:"warning"}:{},...Hn(i)?{sourcePureTypeModule:!0}:{},message:le?`${A} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:A},{fromLayer:d,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},Ut={meta:{type:"problem",docs:{description:"Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."},messages:{rawPublish:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=ae(r),s=Ae({publishCall:Mt(t),rawIntentName:n,objectHasIntent:oe(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");w(e,t,"rawPublish",{...o,file:L(e)})}}}}},Ht={meta:{type:"problem",docs:{description:"Require event bus publish calls to include source metadata."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=t.arguments?.[2],o=Ae({publishCall:Mt(t),rawIntentName:ae(r),objectHasIntent:oe(r,"intent"),arkPublishCandidate:!0,hasSource:$n(r)||oe(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&w(e,t,"missingSource",{...o,file:L(e)})}}}},jt={meta:{type:"problem",docs:{description:"Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as ark-check). Option `globals` is a standalone fallback when no project config applies."},messages:{forbiddenGlobal:'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',forbiddenGlobalDefault:'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.',forbiddenModule:'{{layer}} must not use module "{{specifier}}" because it is the import form of forbidden global "{{name}}".'},schema:[{type:"object",properties:{globals:{type:"array",items:{type:"string"}}},additionalProperties:!1}]},create(e){let t=L(e),r=e.options?.[0],n=$(t),s=n?U(n):null,o=n?m.default.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let u=m.default.isAbsolute(t)?t:m.default.resolve(t),f=m.default.relative(o,u).split(m.default.sep).join("/");if(!q(s,f))return{};let g=s.layers?.find(y=>y.name===b(f,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let l=typeof Ce(e)?.getScope=="function",p=c((u,f)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;w(e,u,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:f,message:`${a} must not use the ambient global "${f}".`},{name:f,layer:a})},"report"),d=c((u,f,g,y)=>{if(g||typeof f!="string")return;let R=pe(f,i);if(!R)return;let k=m.default.isAbsolute(t)?t:m.default.resolve(t),E=o?m.default.relative(o,k).split(m.default.sep).join("/"):t;w(e,u,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:E,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:f,importKind:y})},"reportModule");return{MemberExpression(u){if(u.parent?.type==="MemberExpression"&&u.parent.object===u)return;let f=Pt(u);if(!f||z(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,R;for(let k=y.length;k>=(g?1:2);k-=1){let E=y.slice(0,k).join(".");if(i.has(E)){R=E;break}}R?p(u,R):!l&&i.has(f.segments[0])&&p(u,f.segments[0])},CallExpression(u){let f=u;if(f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!z(e,u,"require")&&d(u,f.arguments[0].value,!1,"require"),l)return;let g=f.callee?.type==="Identifier"?f.callee.name:void 0;g&&i.has(g)&&p(u,g)},ImportDeclaration(u){let f=u,g=(f.specifiers??[]).filter(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(R=>R.importKind==="type");d(u,f.source?.value,f.importKind==="type"||y,"import")},ImportExpression(u){let f=u;f.source?.type==="Literal"&&d(u,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let f=u;d(u,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let f=u;if(!f.source)return;let g=f.specifiers??[],y=g.length>0&&g.every(R=>R.exportKind==="type");d(u,f.source.value,f.exportKind==="type"||y,"export")},ExportAllDeclaration(u){let f=u;d(u,f.source?.value,f.exportKind==="type","export")},NewExpression(u){if(l)return;let f=u.callee?.type==="Identifier"?u.callee.name:void 0;f&&i.has(f)&&p(u,f)},Identifier(u){!l||!u.name||!i.has(u.name)||!Kn(e,u)||z(e,u,u.name)||p(u,u.name)}}}},Vt={meta:{type:"problem",docs:{description:"Disallow importing modules whose effect capability the layer denies (ark.config.json capabilities.deny / pure \u2014 same wall surface as ark-check). Import dimension only: ambient globals stay with no-forbidden-globals and the CLI/hook symbol path."},messages:{deniedCapability:'{{layer}} denies the {{capability}} capability (ark.config.json); "{{specifier}}" imports it. Define a port and bind the implementation in an adapter layer.'},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null;if(!n||!s||!t)return{};let o=m.default.isAbsolute(t)?t:m.default.resolve(t),i=m.default.relative(s,o).split(m.default.sep).join("/");if(!q(n,i))return{};let a=n.layers?.find(d=>d.name===b(i,n.layers));if(!a)return{};let l=new Set(Be(a));if(l.size===0)return{};let p=c((d,u,f,g)=>{if(f||typeof u!="string"||pe(u,a.forbiddenGlobals??[]))return;let y=Ve(u);!y||!l.has(y)||w(e,d,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:u,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${u}".`},{layer:a.name,capability:y,specifier:u})},"check");return{ImportDeclaration(d){let u=d,f=(u.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=f.length>0&&f.length===(u.specifiers??[]).length&&f.every(y=>y.importKind==="type");p(d,u.source?.value,u.importKind==="type"||g,"import")},ImportExpression(d){let u=d;u.source?.type==="Literal"&&p(d,u.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let u=d;p(d,u.moduleReference?.expression?.value,u.importKind==="type"||u.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let u=d;if(!u.source)return;let f=u.specifiers??[],g=f.length>0&&f.every(y=>y.exportKind==="type");p(d,u.source.value,u.exportKind==="type"||g,"export")},ExportAllDeclaration(d){let u=d;p(d,u.source?.value,u.exportKind==="type","export")},CallExpression(d){let u=d;u.callee?.type==="Identifier"&&u.callee.name==="require"&&u.arguments?.[0]?.type==="Literal"&&!z(e,d,"require")&&p(d,u.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:Bt,noArkRunDirectNew:Gt,noArkRunTransportBypass:Wt}=kt({findConfigPath:$,loadArkConfig:U,resolveImportSpecifier:Oe,lintedFilename:L,sourceIsInAnalysisScope:q,isLocallyBound:z,reportAdapterDiagnostic:w});function jn(e,t){let r=m.default.dirname(m.default.resolve(e));return m.default.relative(r,m.default.resolve(t)).split(m.default.sep).join("/")}c(jn,"toProjectRelative");var{noArkOrderKernelInDomain:zt,noArkOrderGenericUpdate:qt}=Ct({findConfigPath:$,loadArkConfig:U,lintedFilename:L,sourceIsInAnalysisScope:q,reportAdapterDiagnostic:w,toProjectRelative:jn});var Vn={"no-domain-infra-imports":$t,"no-raw-event-publish":Ut,"require-publish-source":Ht,"no-forbidden-globals":jt,"no-denied-capabilities":Vt,"no-arkrun-kernel-in-domain":Bt,"no-arkrun-direct-new":Gt,"no-arkrun-transport-bypass":Wt,"no-arkorder-kernel-in-domain":zt,"no-arkorder-generic-update":qt},ie={rules:Vn};ie.configs={recommended:{plugins:{ark:ie},rules:{"ark/no-domain-infra-imports":"error","ark/no-raw-event-publish":"error","ark/require-publish-source":"error","ark/no-forbidden-globals":"error","ark/no-denied-capabilities":"error","ark/no-arkrun-kernel-in-domain":"error","ark/no-arkrun-direct-new":"error","ark/no-arkrun-transport-bypass":"error","ark/no-arkorder-kernel-in-domain":"error","ark/no-arkorder-generic-update":"error"}}};var Bn=ie;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
|