arkgate 4.8.21 → 4.8.23
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 +71 -0
- package/README.md +2 -2
- package/bin/ark-check-runtime.mjs +4 -2
- package/bin/ark-layer-match.mjs +606 -11
- package/bin/lib/analysis-engine.mjs +11 -11
- package/bin/lib/config-contract.mjs +492 -1
- package/bin/lib/diagnostic-catalog.mjs +32 -0
- package/bin/lib/doctor-advisories.mjs +60 -1
- package/bin/lib/doctor-plan.mjs +2 -2
- package/bin/lib/enforcement-honesty.mjs +22 -0
- package/bin/lib/flat-parent-pilot.mjs +252 -0
- package/bin/lib/html-report-advisories.mjs +2 -0
- package/bin/lib/html-report-depth.mjs +3 -1
- package/bin/lib/invariant-coverage.mjs +27 -3
- package/bin/lib/physical-cohesion.mjs +16 -18
- package/bin/lib/pilot-loop.mjs +21 -8
- package/bin/lib/team-parliament-io.mjs +4 -2
- package/dist/{configTypes-CTELo87-.d.ts → configTypes-Bbf_MFGe.d.ts} +36 -2
- package/dist/{diagnosticCatalog-B7BXlet6.d.ts → diagnosticCatalog-35mrwAHe.d.ts} +20 -5
- package/dist/eslint/index.cjs +4 -4
- package/dist/eslint/index.d.ts +51 -5
- package/dist/eslint/index.js +4 -4
- package/dist/index.cjs +36 -36
- package/dist/index.d.ts +104 -5
- package/dist/index.js +36 -36
- package/dist/nestjs/index.cjs +9 -9
- package/dist/nestjs/index.d.ts +3 -3
- package/dist/nestjs/index.js +9 -9
- package/dist/runtime/index.cjs +19 -19
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +19 -19
- package/dist/{types-yDNEQ603.d.ts → types-Bdj32QwA.d.ts} +1 -1
- package/dist/{types-fQ9-KrBj.d.ts → types-Ik_OakcI.d.ts} +1 -1
- package/docs/README.md +3 -1
- package/docs/agent-guide.md +9 -1
- package/docs/configuration.md +92 -1
- package/docs/diagnostics.md +32 -0
- package/docs/product-voice.md +1 -1
- package/package.json +2 -1
- package/schemas/ark.config.schema.json +124 -2
- package/server.json +2 -2
- package/templates/agent-skills/README.md +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-
|
|
2
|
-
import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-
|
|
1
|
+
import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-Ik_OakcI.js';
|
|
2
|
+
import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-Bbf_MFGe.js';
|
|
3
3
|
|
|
4
4
|
/** Versioned public result contract types + JSON Schema (adapter envelope). */
|
|
5
5
|
/**
|
|
@@ -38,6 +38,12 @@ type AdapterViolationInput = {
|
|
|
38
38
|
severity?: unknown;
|
|
39
39
|
/** When false, finding is non-blocking (e.g. type-only placement debt). */
|
|
40
40
|
failsStrict?: unknown;
|
|
41
|
+
/** Nested-wall reason. The ruleId stays LAYER_IMPORT_VIOLATION. Not part of the baseline key. */
|
|
42
|
+
reasonId?: unknown;
|
|
43
|
+
/** Last segment of the importer universe id, when the finding has a reasonId. */
|
|
44
|
+
universeFrom?: unknown;
|
|
45
|
+
/** Last segment of the importee universe id, when the finding has a reasonId. */
|
|
46
|
+
universeTo?: unknown;
|
|
41
47
|
nextAction?: unknown;
|
|
42
48
|
/** U04: the denied capability id on CAPABILITY_VIOLATION. */
|
|
43
49
|
capability?: unknown;
|
|
@@ -392,7 +398,7 @@ declare function createAdapterResult(input: {
|
|
|
392
398
|
}): CurrentAdapterResult;
|
|
393
399
|
|
|
394
400
|
/** ArkGate library version — single source of truth. */
|
|
395
|
-
declare const version = "4.8.
|
|
401
|
+
declare const version = "4.8.23";
|
|
396
402
|
|
|
397
403
|
/**
|
|
398
404
|
* AI Code Gate (basic).
|
|
@@ -412,6 +418,10 @@ interface AICodeGateViolation {
|
|
|
412
418
|
target?: string;
|
|
413
419
|
fromLayer?: string;
|
|
414
420
|
toLayer?: string;
|
|
421
|
+
/** Nested-wall reason. Absent on a classic layer deny and on a child-only parent import. */
|
|
422
|
+
reasonId?: string;
|
|
423
|
+
/** False for an advisory sibling crossing. Omitted findings still block the snippet. */
|
|
424
|
+
failsStrict?: boolean;
|
|
415
425
|
details?: unknown;
|
|
416
426
|
}
|
|
417
427
|
/** Extension point for external analyzers (AST, semantic, etc.). */
|
|
@@ -1738,8 +1748,10 @@ type DeclarationShape = 'function' | 'class' | 'const' | 'method' | 'type' | 'in
|
|
|
1738
1748
|
type MentionContext = 'test-body' | 'comment' | 'string' | 'import';
|
|
1739
1749
|
/**
|
|
1740
1750
|
* One coverage verdict. Best evidence wins: test-title, then declaration,
|
|
1741
|
-
* then mention-only, then none.
|
|
1742
|
-
* `
|
|
1751
|
+
* then mention-only, then none. A comment in another file, when the symbol
|
|
1752
|
+
* still occurs in code, is `declaration-miss` and does not count.
|
|
1753
|
+
* Regexes, the test-file vs source split, and `Aggregate.method` lookup stay
|
|
1754
|
+
* behind this value.
|
|
1743
1755
|
*/
|
|
1744
1756
|
type CoverageEvidence = {
|
|
1745
1757
|
kind: 'test-title';
|
|
@@ -1753,6 +1765,9 @@ type CoverageEvidence = {
|
|
|
1753
1765
|
kind: 'mention-only';
|
|
1754
1766
|
file: string;
|
|
1755
1767
|
context: MentionContext;
|
|
1768
|
+
} | {
|
|
1769
|
+
kind: 'declaration-miss';
|
|
1770
|
+
symbol: string;
|
|
1756
1771
|
} | {
|
|
1757
1772
|
kind: 'none';
|
|
1758
1773
|
};
|
package/dist/eslint/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var er=Object.create;var j=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,sr=Object.prototype.hasOwnProperty;var l=(e,t)=>j(e,"name",{value:t,configurable:!0});var or=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of rr(t))!sr.call(e,s)&&s!==r&&j(e,s,{get:()=>t[s],enumerable:!(n=tr(t,s))||n.enumerable});return e};var Y=(e,t,r)=>(r=e!=null?er(nr(e)):{},Le(t||!e||!e.__esModule?j(r,"default",{value:e,enumerable:!0}):r,e)),ir=e=>Le(j({},"__esModule",{value:!0}),e);var os={};or(os,{default:()=>ss,findConfigPath:()=>M,globToRegExp:()=>x,isEdgeDenied:()=>Ve,layerForRelativePath:()=>S,loadArkConfig:()=>U,noArkOrderGenericUpdate:()=>Qt,noArkOrderKernelInDomain:()=>Jt,noArkRunDirectNew:()=>Yt,noArkRunKernelInDomain:()=>Zt,noArkRunTransportBypass:()=>Xt,noDeniedCapabilities:()=>qt,noDomainInfraImports:()=>Gt,noForbiddenGlobals:()=>zt,noRawEventPublish:()=>Bt,patternSpecificity:()=>de,plugin:()=>ae,readTsconfigPathAliases:()=>$t,requirePublishSource:()=>Wt,resolveImportSpecifier:()=>Oe,resolveRelativeImport:()=>Mt});module.exports=ir(os);var N=Y(require("fs"),1),m=Y(require("path"),1);var De=new Map;function Fe(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(Fe,"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}l(X,"normalizeGlobSeparators");function ar(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}l(ar,"bracesBalanced");function x(e){let t=De.get(e);if(t)return t;let r=X(e),n=ar(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=Fe(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Fe(c)}let i=new RegExp(`^${s}$`);return De.set(e,i),i}l(x,"globToRegExp");function lr(e){return X(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}l(lr,"concreteGlobSegments");function de(e,t){let r=X(String(e)),n=lr(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,c=-1;for(let f of n){let d=-1;for(let u=a;u<i.length;u+=1)if(i[u]===f){d=u;break}if(d<0)return o;c=d,a=d+1}return(c+1)*1e6+n.length*1e4+s}l(de,"patternSpecificity");function S(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=de(i,r);a>s&&(s=a,n=o.name)}}return n}l(S,"layerForRelativePath");function Pe(e,t,r){if(!t?.length)return;let n=r==="stars"?"stars":"path",s=String(e).split(/[/\\]/).filter(Boolean);if(s.length===0)return;let o=new Set;for(let i of t)if(!(typeof i!="string"||i.length===0)){if(cr(i)){let a=dr(s,i,n);if(a)return a;continue}!i.includes("/")&&!i.includes("\\")&&!i.includes("*")&&o.add(i.toLowerCase())}return fr(s,o)}l(Pe,"sliceIdForPath");function cr(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(r=>r==="*")}l(cr,"isAnchoredSliceEntry");function dr(e,t,r){let n=t.split(/[/\\]/).filter(o=>o.length>0).map(o=>o.toLowerCase()),s=je(e,n[0]??"");for(let o of s){let i=ur(e,n,o,r);if(i)return i}}l(dr,"anchoredSliceId");function ur(e,t,r,n="path"){let s=[],o=-1,i=r;for(let a=0;a<t.length;a+=1){let c=t[a];if(c==="*"){if(i>=e.length-1){for(let f=a;f<t.length;f+=1)if(t[f]!=="*")return;break}s.push(e[i].toLowerCase()),i+=1;continue}if(c==="**"||i>=e.length||e[i].toLowerCase()!==c)return;s.push(e[i].toLowerCase()),o=s.length-1,i+=1}if(s.length!==0)return n==="stars"?o<0?void 0:s.slice(o).join("/"):s.join("/")}l(ur,"bindAnchoredSlice");function fr(e,t){if(t.size!==0){for(let r=0;r<e.length-1;r+=1)if(t.has(e[r].toLowerCase())&&!(r+1>=e.length-1))return`${e[r].toLowerCase()}/${e[r+1].toLowerCase()}`}}l(fr,"bareSliceId");function pr(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]}l(pr,"inferSliceFoldersFromPatterns");function gr(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 pr(n?.patterns)}l(gr,"resolveSliceFolders");function Ke(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}l(Ke,"normalizeSegments");function Ue(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}l(Ue,"trimTrailingSlashes");var mr=["src","app"];function je(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return mr.includes(r)&&n!==r?[0,1]:[0]}l(je,"anchorOffsets");function yr(e){let t=Ue(e.replace(/^[./]+/,""));return t==="*"||t==="**"}l(yr,"isBlanketRoot");function $e(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ke(r);for(let o of t){if(typeof o!="string"||o.length===0||yr(o))continue;if(o.includes("*")){let c=Ue(o.toLowerCase());if(x(c).test(n)||x(`${c}/**`).test(n))return!0;continue}let i=Ke(o);if(i.length===0)continue;let a=je(s,i[0]??"");for(let c of a){if(c+i.length>s.length)continue;let f=!0;for(let d=0;d<i.length;d+=1)if(s[c+d]!==i[d]){f=!1;break}if(f)return!0}}return!1}l($e,"pathUnderSharedRoot");function Me(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}`)}l(Me,"sliceMatchesDeclaration");function hr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Me(n.from,t)&&Me(n.to,r))}l(hr,"crossSliceEdgeAllowed");function Rr(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.sharedImportsSlice==="deny"&&e.fromShared===!0&&e.toSlice&&!e.fromSlice?{denied:!0,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}l(Rr,"peerIsolationDecision");function He(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"shared-imports-slice":return`shared root imports slice ${t.toSlice??"?"} (${t.fromPath??"?"} \u2192 ${t.toPath??"?"}). The wall is direct-only.`;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."}}l(He,"peerIsolationDenyExplanation");function Ar(e,t,r,n){return ue(e,t,r,n)?.rule}l(Ar,"findDeniedEdgeRule");function ue(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=gr(s,t,n?.layers),c=o?Pe(o,a,s.sliceIdentity):void 0,f=i?Pe(i,a,s.sliceIdentity):void 0,d=Rr({fromPath:o,toPath:i,folderCount:a.length,fromSlice:c,toSlice:f,fromShared:!c&&$e(o,s.sharedRoots),toShared:!f&&$e(i,s.sharedRoots),crossSliceAllowed:hr(s.allowedCrossSlice,c,f),sharedImportsSlice:s.sharedImportsSlice});if(d.denied)return{rule:s,peerIsolationReason:d.reason,fromSlice:c,toSlice:f};continue}if(t!==r)return{rule:s}}}l(ue,"findDeniedEdgeDecision");function Ve(e,t,r,n){return Ar(e,t,r,n)!==void 0}l(Ve,"isEdgeDenied");var kr=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function br(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:kr,...t]}l(br,"scanExcludePatterns");function Ge(e,t){let r=String(e).split(/[/\\]/).join("/");return br(t).some(n=>x(n).test(r))}l(Ge,"isScanExcludedRelative");var Be=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Er=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),cs=Object.freeze(Object.keys(Er).sort()),fe=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"}),Sr=Object.freeze({process:Object.freeze(["process","node:process"])});function We(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=fe[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=fe[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:fe[e.slice(0,o)]??null}l(We,"capabilityForModuleSpecifier");function pe(e,t){for(let r of t)if(Sr[r]?.includes(e))return r;return null}l(pe,"forbiddenGlobalForModuleSpecifier");function ze(e){if(e?.pure===!0)return[...Be].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Be.includes(n));return[...new Set(r)].sort()}l(ze,"effectiveCapabilityDeny");var T={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},qe={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}}},Ze={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 H(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(H,"isObject");function Ye(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)H(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}l(Ye,"declaredLayerNames");function Xe(e){if(!H(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}}l(Xe,"defaultedArkRun");function Je(e){if(!H(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}}l(Je,"defaultedArkOrder");function Qe(e,t){let r=e.arkRun;if(r===void 0||!H(r))return;let n=Ye(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"})}}l(Qe,"validateArkRunExtra");function et(e,t){let r=e.arkOrder;if(r===void 0||!H(r))return;let n=Ye(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"})}}l(et,"validateArkOrderExtra");function J(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}l(J,"normalizeStewardId");function tt(e){let t=J(e);return!t||ge(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}l(tt,"isGitHubHandle");function Ir(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return!t.includes("@")||t.includes(" ")||ge(t)?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}l(Ir,"isGitHubEmail");function xr(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&tt(t[1])?J(t[1]):null}l(xr,"githubHandleFromEmail");function rt(e){let t=xr(e);if(t)return t;let r=J(e);return!r||ge(r)?null:tt(r)||Ir(r)?r:null}l(rt,"canonicalStewardId");var wr=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function ge(e){let t=J(e);return!t||wr.test(t)}l(ge,"isAutomationAuthor");var I="1.3",_r=["public","auth","admin","internal"];var me="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",nt=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Nr=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Cr(){let e=[];for(let t of nt)for(let r of nt)t===r||Nr.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}l(Cr,"createDefaultRules");var ot=Cr(),ye=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],E={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},st={$schema:"https://json-schema.org/draft/2020-12/schema",$id:me,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:me,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...E,minItems:1,default:["src"]},exclude:{...E,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:ot,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...E,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:{...E,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...E,minItems:1},exclude:E,intentPrefixes:E,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[..._r]},owners:{...E,minItems:1},forbiddenGlobals:E,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:{...E,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"],description:"How a starred sliceFolders prefix is named. Absent and path keep today's ids (every literal and star binding). stars keeps the last literal plus the star bindings, so parallel trees share one feature id. Bare names are unchanged."},sharedRoots:{...E,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}}}},sharedImportsSlice:{type:"string",enum:["deny"]}}},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. When any invariant is enforced, missing coverageRoots fails closed.",properties:{testGlobs:{...E,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:{...E,minItems:1}}},arkRun:qe,arkOrder:Ze}},w=class extends Error{static{l(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
|
|
1
|
+
"use strict";var hr=Object.create;var z=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty;var a=(e,t)=>z(e,"name",{value:t,configurable:!0});var br=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},je=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ar(t))!Sr.call(e,s)&&s!==r&&z(e,s,{get:()=>t[s],enumerable:!(n=Rr(t,s))||n.enumerable});return e};var ne=(e,t,r)=>(r=e!=null?hr(kr(e)):{},je(t||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e)),Er=e=>je(z({},"__esModule",{value:!0}),e);var to={};br(to,{default:()=>eo,findConfigPath:()=>V,globToRegExp:()=>x,isEdgeDenied:()=>rt,layerForRelativePath:()=>E,loadArkConfig:()=>G,noArkOrderGenericUpdate:()=>yr,noArkOrderKernelInDomain:()=>mr,noArkRunDirectNew:()=>pr,noArkRunKernelInDomain:()=>fr,noArkRunTransportBypass:()=>gr,noDeniedCapabilities:()=>ur,noDomainInfraImports:()=>ar,noForbiddenGlobals:()=>dr,noRawEventPublish:()=>lr,patternSpecificity:()=>Re,plugin:()=>pe,readTsconfigPathAliases:()=>tr,requirePublishSource:()=>cr,resolveImportSpecifier:()=>Ke,resolveRelativeImport:()=>rr});module.exports=Er(to);var _=ne(require("fs"),1),m=ne(require("path"),1);var He=new Map;function Ve(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Ve,"escapeLiteral");function se(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}a(se,"normalizeGlobSeparators");function Ir(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}a(Ir,"bracesBalanced");function x(e){let t=He.get(e);if(t)return t;let r=se(e),n=Ir(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Ve(r[l+1]),l+=1):c==="*"?r[l+1]==="*"?r[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Ve(c)}let i=new RegExp(`^${s}$`);return He.set(e,i),i}a(x,"globToRegExp");function wr(e){return se(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}a(wr,"concreteGlobSegments");function Re(e,t){let r=se(String(e)),n=wr(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 l=0,c=-1;for(let u of n){let f=-1;for(let d=l;d<i.length;d+=1)if(i[d]===u){f=d;break}if(f<0)return o;c=f,l=f+1}return(c+1)*1e6+n.length*1e4+s}a(Re,"patternSpecificity");function E(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 l=Re(i,r);l>s&&(s=l,n=o.name)}}return n}a(E,"layerForRelativePath");function Xe(e,t,r){if(!t?.length)return;let n=r==="stars"?"stars":"path",s=String(e).split(/[/\\]/).filter(Boolean);if(s.length===0)return;let o=new Set;for(let i of t)if(!(typeof i!="string"||i.length===0)){if(xr(i)){let l=Cr(s,i,n);if(l)return l;continue}!i.includes("/")&&!i.includes("\\")&&!i.includes("*")&&o.add(i.toLowerCase())}return _r(s,o)}a(Xe,"sliceIdForPath");function xr(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(r=>r==="*")}a(xr,"isAnchoredSliceEntry");function Cr(e,t,r){let n=t.split(/[/\\]/).filter(o=>o.length>0).map(o=>o.toLowerCase()),s=Je(e,n[0]??"");for(let o of s){let i=vr(e,n,o,r);if(i)return i}}a(Cr,"anchoredSliceId");function vr(e,t,r,n="path"){let s=[],o=-1,i=r;for(let l=0;l<t.length;l+=1){let c=t[l];if(c==="*"){if(i>=e.length-1){for(let u=l;u<t.length;u+=1)if(t[u]!=="*")return;break}s.push(e[i].toLowerCase()),i+=1;continue}if(c==="**"||i>=e.length||e[i].toLowerCase()!==c)return;s.push(e[i].toLowerCase()),o=s.length-1,i+=1}if(s.length!==0)return n==="stars"?o<0?void 0:s.slice(o).join("/"):s.join("/")}a(vr,"bindAnchoredSlice");function _r(e,t){if(t.size!==0){for(let r=0;r<e.length-1;r+=1)if(t.has(e[r].toLowerCase())&&!(r+1>=e.length-1))return`${e[r].toLowerCase()}/${e[r+1].toLowerCase()}`}}a(_r,"bareSliceId");function Nr(e){let t=new Set;for(let r of e??[]){let s=se(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let l=s[o-1];l&&!l.includes("*")&&!l.includes("{")&&!l.includes("}")&&t.add(l)}}}return[...t]}a(Nr,"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 Nr(n?.patterns)}a(Or,"resolveSliceFolders");function Ge(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(Ge,"normalizeSegments");function q(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(q,"trimTrailingSlashes");var Lr=["src","app"];function Je(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return Lr.includes(r)&&n!==r?[0,1]:[0]}a(Je,"anchorOffsets");function Tr(e){let t=q(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(Tr,"isBlanketRoot");function Be(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ge(r);for(let o of t){if(typeof o!="string"||o.length===0||Tr(o))continue;if(o.includes("*")){let c=q(o.toLowerCase());if(x(c).test(n)||x(`${c}/**`).test(n))return!0;continue}let i=Ge(o);if(i.length===0)continue;let l=Je(s,i[0]??"");for(let c of l){if(c+i.length>s.length)continue;let u=!0;for(let f=0;f<i.length;f+=1)if(s[c+f]!==i[f]){u=!1;break}if(u)return!0}}return!1}a(Be,"pathUnderSharedRoot");function We(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}`)}a(We,"sliceMatchesDeclaration");function Dr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&We(n.from,t)&&We(n.to,r))}a(Dr,"crossSliceEdgeAllowed");function Fr(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.sharedImportsSlice==="deny"&&e.fromShared===!0&&e.toSlice&&!e.fromSlice?{denied:!0,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}a(Fr,"peerIsolationDecision");function Qe(e){return q(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Qe,"aliasGlobPattern");function Pr(e,t){let r=Qe(e);if(!r||r==="*"||r==="**")return!1;let n=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=he(n),o=x(r);return o.test(n)||s!==n&&o.test(s)}a(Pr,"aliasGlobMatches");function $r(e){let t=Qe(e).split("/").filter(Boolean);return t.length<2||t.some(r=>r.includes("*")||r==="."||r==="..")?null:{universeId:t.slice(0,-1).join("/"),childId:t.join("/")}}a($r,"splitAliasTarget");function Kr(e,t){for(let r of t.childSlices?.sliceAliases??[])if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&Pr(r.from,e))return $r(r.to);return null}a(Kr,"firstSliceAlias");function ze(e,t,r){if(!e)return{};let n=r??t.sliceFolders,s=Xe(e,n?[...n]:void 0,t.sliceIdentity),o=ye(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=Kr(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(ze,"resolveGovernedSlice");function Mr(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"shared-imports-slice":return`shared root imports slice ${t.toSlice??"?"} (${t.fromPath??"?"} \u2192 ${t.toPath??"?"}). The wall is direct-only.`;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."}}a(Mr,"peerIsolationDenyExplanation");function Ur(e,t){return`cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(Ur,"crossParentExplanation");function jr(e,t,r){return`cross-sibling slice ${e} \u2192 ${t} inside ${r}.`}a(jr,"crossSiblingExplanation");function Hr(e){return`universe common imports child ${e}. parentMayImportChild is off.`}a(Hr,"parentImportsChildExplanation");function qe(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(qe,"universePairLabel");function Vr(e){return String(e).split(/[/\\]/).filter(Boolean).slice(0,-1)}a(Vr,"directorySegments");function Gr(e,t){if(!t?.length)return!1;let r=new Set;for(let n of t)typeof n=="string"&&n.length>0&&r.add(n.toLowerCase());return r.size===0?!1:Vr(e).some(n=>r.has(n.toLowerCase()))}a(Gr,"pathHasCommonFolder");function ye(e,t,r){if(!e||!r?.sliceFolders?.length)return{};if(Gr(e,r.commonFolders))return{};let n=Xe(e,r.sliceFolders,r.sliceIdentity);if(!n||!t)return{};let s=n.toLowerCase(),o=t.toLowerCase();return s===o?{}:s.startsWith(`${o}/`)?{childId:n}:{mismatched:{childId:n,universeId:t}}}a(ye,"resolveChildSliceId");function Br(e){return q(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Br,"siblingEntryKey");function he(e){return e.replace(/^(?:src|app)\//,"")}a(he,"stripSrcOrApp");function Wr(e,t){let r=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),n=he(t);if(!n)return!1;let s=he(r);return r===n||r.startsWith(`${n}/`)||s===n||s.startsWith(`${n}/`)}a(Wr,"pathUnderSubtree");function zr(e,t,r){if(!t||!r?.length)return!1;let n=t.toLowerCase();for(let s of r){if(typeof s!="string")continue;let o=Br(s);if(!(!o||o.includes("*"))&&(n===o||e&&Wr(e,o)))return!0}return!1}a(zr,"importerInEnforcedSubtree");function qr(e,t,r){return e==null||e==="deny"?!1:e==="advisory"?!0:e.default==="deny"?!1:!zr(t,r,e.enforce)}a(qr,"siblingCrossingAdvisory");function Ze(e){if(typeof e!="string")return null;let t=q(e.trim().replace(/\\/g,"/")).toLowerCase();if(!t.includes("/"))return null;let r=t.split("/");for(let n of r)if(n.length===0||n==="."||n===".."||n.includes("*")&&n!=="*")return null;return r}a(Ze,"childSlicePatternSegments");function Ye(e,t){let r=Ze(e),n=Ze(t);if(!r||!n||r.length!==n.length)return!1;for(let s=0;s<r.length;s+=1){let o=r[s];if(o!=="*"&&o!==n[s])return!1}return!0}a(Ye,"childSlicePatternMatches");function Zr(e,t,r){if(!e?.length)return!1;for(let n of e)if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&Ye(n.from,t)&&Ye(n.to,r))return!0;return!1}a(Zr,"childCrossSliceAllowed");function Yr(e){let t=Fr({fromPath:e.fromPath,toPath:e.toPath,folderCount:e.folderCount,fromSlice:e.fromSlice,toSlice:e.toSlice,fromShared:e.fromShared,toShared:e.toShared,crossSliceAllowed:e.crossSliceAllowed,sharedImportsSlice:e.rule.sharedImportsSlice});if(t.denied){let i=!!e.rule.childSlices&&t.reason==="cross-slice";return{crossing:t.reason==="cross-slice"?"cross-parent":"fail-closed",decision:"deny",...i?{reasonId:"CROSS_PARENT_SLICE"}:{},explanation:i?Ur(e.fromSlice,e.toSlice):Mr(t.reason??"missing-path",{fromPath:e.fromPath,toPath:e.toPath,fromSlice:e.fromSlice,toSlice:e.toSlice}),peerIsolationReason:t.reason,fromUniverse:e.fromSlice,toUniverse:e.toSlice}}let r=e.rule.childSlices;if(!r||!e.fromSlice||!e.toSlice||e.fromSlice!==e.toSlice||!e.toPath)return{crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};let n=e.fromChild??ye(e.fromPath,e.fromSlice,r).childId,s=e.toChild??ye(e.toPath,e.toSlice,r).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return n&&s&&n!==s?Zr(r.allowedCrossSlice,n,s)?o:{crossing:"cross-sibling",decision:qr(r.siblings,e.fromPath,n)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:jr(n,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!n&&s&&r.parentMayImportChild!==!0?{crossing:"parent-imports-child",decision:"deny",explanation:Hr(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(Yr,"evaluateNestedSliceWall");function et(e){let t=e.verdict.explanation;if(e.surface==="intent"){let r=e.defaultMessage??`${e.fromLayer} must not reference ${e.toLayer} intent.`;return e.verdict.reasonId&&t?`${r} ${t}`:t&&e.verdict.peerIsolationReason!=="cross-slice"?`${r} ${t}`:e.ruleMessage?t?`${e.ruleMessage} (${t})`:e.ruleMessage:r}if(e.ruleMessage)return t?`${e.ruleMessage} (${t})`:e.ruleMessage;if(t){let r=e.kind??"import";return`${e.fromLayer} must not ${r} another slice of ${e.toLayer} (${e.fromPath} \u2192 ${e.toPath}): ${t}`}return`${e.fromLayer} must not ${e.kind??"import"} ${e.toLayer}.`}a(et,"composeSliceDenialMessage");function tt(e){if(!e||e.decision==="allow")return{};let t=qe(e.fromUniverse),r=qe(e.toUniverse);return{...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&r?{universeFrom:t,universeTo:r}:{},...e.decision==="advisory"?{failsStrict:!1,severity:"warning"}:{}}}a(tt,"sliceFindingExtras");function Xr(e,t,r,n){return Ae(e,t,r,n)?.rule}a(Xr,"findDeniedEdgeRule");function Ae(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,l=Or(s,t,n?.layers),c=ze(o,s,l),u=ze(i,s,l),f=c.universeId,d=u.universeId,p=Yr({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:d,fromChild:c.childId,toChild:u.childId,fromShared:!f&&Be(o,s.sharedRoots),toShared:!d&&Be(i,s.sharedRoots),crossSliceAllowed:Dr(s.allowedCrossSlice,f,d)});if(p.decision!=="allow")return{rule:s,peerIsolationReason:p.peerIsolationReason,fromSlice:f,toSlice:d,sliceVerdict:p};continue}if(t!==r)return{rule:s}}}a(Ae,"findDeniedEdgeDecision");function rt(e,t,r,n){return Xr(e,t,r,n)!==void 0}a(rt,"isEdgeDenied");var Jr=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Qr(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Jr,...t]}a(Qr,"scanExcludePatterns");function nt(e,t){let r=String(e).split(/[/\\]/).join("/");return Qr(t).some(n=>x(n).test(r))}a(nt,"isScanExcludedRelative");var st=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),en=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),oo=Object.freeze(Object.keys(en).sort()),ke=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"}),tn=Object.freeze({process:Object.freeze(["process","node:process"])});function ot(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=ke[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=ke[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:ke[e.slice(0,o)]??null}a(ot,"capabilityForModuleSpecifier");function Se(e,t){for(let r of t)if(tn[r]?.includes(e))return r;return null}a(Se,"forbiddenGlobalForModuleSpecifier");function it(e){if(e?.pure===!0)return[...st].sort();let r=(e?.capabilities?.deny??[]).filter(n=>st.includes(n));return[...new Set(r)].sort()}a(it,"effectiveCapabilityDeny");var D={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},at={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...D,default:[]},kernelRoots:{...D},managedLayers:{...D,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},lt={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...D,default:[]},managedLayers:{...D,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...D,default:[]},appliesTo:{...D,default:[]}}};function Z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Z,"isObject");function ct(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)Z(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}a(ct,"declaredLayerNames");function dt(e){if(!Z(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}}a(dt,"defaultedArkRun");function ut(e){if(!Z(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}}a(ut,"defaultedArkOrder");function ft(e,t){let r=e.arkRun;if(r===void 0||!Z(r))return;let n=ct(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"})}}a(ft,"validateArkRunExtra");function pt(e,t){let r=e.arkOrder;if(r===void 0||!Z(r))return;let n=ct(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"})}}a(pt,"validateArkOrderExtra");function oe(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(oe,"normalizeStewardId");function gt(e){let t=oe(e);return!t||be(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(gt,"isGitHubHandle");function rn(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return!t.includes("@")||t.includes(" ")||be(t)?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}a(rn,"isGitHubEmail");function nn(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&>(t[1])?oe(t[1]):null}a(nn,"githubHandleFromEmail");function mt(e){let t=nn(e);if(t)return t;let r=oe(e);return!r||be(r)?null:gt(r)||rn(r)?r:null}a(mt,"canonicalStewardId");var sn=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function be(e){let t=oe(e);return!t||sn.test(t)}a(be,"isAutomationAuthor");var I="1.3",on=["public","auth","admin","internal"];var Ee="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",yt=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],an=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function ln(){let e=[];for(let t of yt)for(let r of yt)t===r||an.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}a(ln,"createDefaultRules");var bt=ln(),Ie=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],b={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ht={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Ee,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:Ee,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...b,minItems:1,default:["src"]},exclude:{...b,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:bt,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...b,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:{...b,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...b,minItems:1},exclude:b,intentPrefixes:b,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...on]},owners:{...b,minItems:1},forbiddenGlobals:b,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:{...b,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"],description:"How a starred sliceFolders prefix is named. Absent and path keep today's ids (every literal and star binding). stars keeps the last literal plus the star bindings, so parallel trees share one feature id. Bare names are unchanged."},sharedRoots:{...b,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}}}},sharedImportsSlice:{type:"string",enum:["deny","deny-cross-parent"],description:"deny blocks every shared-root import of a slice. deny-cross-parent leaves that hop as a warning and, in ark-check and CI only, reports a slice that reaches another universe through a shared root. The write hook and ESLint see one edge and do not block it. arkgate 4.8.22 and older reject deny-cross-parent."},childSlices:{type:"object",additionalProperties:!1,required:["sliceFolders"],description:`Optional inner wall under this rule. Absent keeps today's universe wall. sliceFolders names children. commonFolders and flat files are universe common. siblings is "deny" (default), "advisory", or { default, enforce }. parentMayImportChild defaults to false. allowedCrossSlice may use a whole-segment *. It clears only a sibling crossing. Cross-parent has no advisory knob. arkgate 4.8.22 and older reject this key. A build that still rejects unknown childSlices fields rejects allowedCrossSlice at config load. A build that still types siblings as a string enum rejects the object at config load.`,properties:{sliceFolders:{...b,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...b,minItems:1},siblings:{description:'"deny" or "advisory", or { default, enforce } so listed subtrees are errors while the default stays advisory. A string-enum build rejects the object at config load (must be one of deny, advisory).',oneOf:[{type:"string",enum:["deny","advisory"]},{type:"object",additionalProperties:!1,required:["default"],properties:{default:{type:"string",enum:["deny","advisory"]},enforce:{...b}}}]},parentMayImportChild:{type:"boolean"},sliceAliases:{type:"array",minItems:1,description:"Maps a source path glob onto a child slice id (universe id plus one child segment) so files outside the slice trees take that universe and child for both walls. A bare name, a universe id alone, an unknown universe, and a wildcard in to are rejected. The glob may not overlap a slice folder, and two aliases may not match the same file. Doctor lists each alias as an owed move. A build that rejects unknown childSlices fields fails at config load (unknown field). arkgate 4.8.22 and older reject childSlices.",items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}},allowedCrossSlice:{type:"array",minItems:1,description:"Directed child-slice allowances. * matches one whole path segment (features/projects/*). ** and a partial segment are rejected. A bare name is rejected. This list clears only CROSS_SIBLING_SLICE. It cannot clear CROSS_PARENT_SLICE or CROSS_PARENT_VIA_SHARED. The universe allowedCrossSlice still treats * as a literal. A build that rejects unknown childSlices fields fails at config load (unknown field).",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. When any invariant is enforced, missing coverageRoots fails closed.",properties:{testGlobs:{...b,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:{...b,minItems:1}}},arkRun:at,arkOrder:lt}},C=class extends Error{static{a(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 it(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(it,"isObject");function Q(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}l(Q,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}l(P,"valueType");function Or(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}l(Or,"resolveSchemaRef");function V(e,t,r,n,s){if(t.$ref){let o=Or(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(!it(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:Q(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Q(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,Q(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,Q(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}`})}}l(V,"validateNode");function vr(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,a)=>{typeof i=="string"&&(rt(i)||t.push({path:`$.layers[${s}].owners[${a}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}l(vr,"validateLayerOwners");function Tr(e){let t={...e,$schema:e.$schema===void 0?me: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?ot.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Xe(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Je(e.arkOrder)),t}l(Tr,"defaultedConfig");function Lr(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}l(Lr,"migratedFromOf");function Dr(){let e=new Set([I]);for(let t of ye)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}l(Dr,"knownInputVersions");function Fr(e,t="ark.config.json"){if(!it(e))throw new w(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=Dr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ye.length+1;){i+=1;let a=ye.find(c=>c.from===s);if(!a)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:Tr(o),migratedFrom:Lr(n)}}l(Fr,"migrateArkConfig");function Pr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Fr(e,t),s=[];if(V(r,st,"$",st,s),Qe(r,s),et(r,s),vr(r,s),s.length>0)throw new w(t,s);return{config:r,migratedFrom:n}}l(Pr,"loadArkConfigContract");function at(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new w(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Pr(r,t)}l(at,"parseArkConfigJson");var Kr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,$r=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Mr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Ur(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Kr.test(r)?"pure-shared":n==="PersistenceAdapters"&&($r.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Mr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}l(Ur,"classifyLayerImportKind");function jr(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=Ur(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."}l(jr,"layerImportNextAction");function Hr(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}l(Hr,"arkRunCallSiteName");function Vr(e){let t=Hr(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.`}}l(Vr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return jr(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"INVARIANT_CATALOG_EMPTY":return typeof e.file=="string"&&e.file.length>0?`Add 1\u20132 short phrases to invariants[] in ${e.file}, then run ark-check --doctor. Starters show the shape.`:"Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json, then run ark-check --doctor. Starters show the shape.";case"INVARIANT_TESTS_PATH_MISSING":return"Add coverage.testGlobs or coverage.coverageRoots in ark.config.json pointing at a real tests folder, then re-run. Adopted mode fails closed until that path is present.";case"INVARIANT_COVERAGE_ROOTS_MISSING":return"Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. An enforced invariant fails closed until that path is present.";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.`}}l(K,"deterministicNextAction");var he="docs/diagnostics.md";function Re(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("|")}l(Re,"adapterFindingTargetKey");function Ae(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")}`}l(Ae,"adapterFindingRefFromTargetKey");function ke(e){return`${he}#${e}`}l(ke,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}l(h,"text");function lt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}l(lt,"positiveInteger");function Wr(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})}l(Wr,"nextActionForDiagnostic");function ct(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??Re(e),a=Ae(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:lt(e.line,1),column:lt(e.column,1)},evidence:o,nextAction:h(e.nextAction)??Wr(n,o,e),findingRef:a,targetKey:i,docsCodePath:ke(n)}}l(ct,"toAdapterDiagnostic");var dt={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."},Ds=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 zr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}l(zr,"looksLikeArkIntent");function be(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&zr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:dt.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:dt.PUBLISH_MISSING_SOURCE}),t}l(be,"classifyPublishFacts");var Ne=Y(require("fs"),1),C=Y(require("path"),1);var qr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Zr=new Set(qr),Yr=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"]),Xr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function $(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}l($,"isArkRunKernelModuleSpecifier");var Jr=["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"],Ee=new Set(Jr);function pt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(Ee.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(Ee.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:Ee.has(e.slice(0,n))}l(pt,"isArkRunTransportBypassSpecifier");function ut(e){if(Zr.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}}l(ut,"arkRunKernelCallKind");function gt(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}l(gt,"lineAt");function Se(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(Se,"stripCommentsPreservingLines");function Qr(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}l(Qr,"firstStringLiteralArg");function ft(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)}l(ft,"keywordBefore");function ee(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]??"")}l(ee,"parseValueImportClause");function mt(e,t){ee(Se(e),t)}l(mt,"forEachArkRunValueImportClause");function en(e){let t=new Map,r=new Set;return ee(e,(n,s)=>{if(!$(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 c of a[1].split(",")){let f=c.trim();if(!f||f.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(f);if(d){t.set(d[2],d[1]);continue}let u=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(f);u?.[1]&&t.set(u[1],u[1])}}),{named:t,namespaces:r}}l(en,"collectKernelImportBindings");function tn(e,t){let r=new Set(t);return ee(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 c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),f=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=c?.[1]??f;!f||!d||!/^[A-Z]/.test(d)||($(s)||t.has(d)||t.has(f))&&(r.add(f),r.add(d))}}),r}l(tn,"collectImportedConstructors");function rn(e,t){let r;return ee(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}l(rn,"importedFromForName");function te(e,t){let r=Se(t),n=en(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],c=i.index;if(ft(r,c,"function")||ft(r,c,"class"))continue;let d=r.slice(0,c).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],u=n.named.get(a)??a,p=ut(u)??ut(a);if(!p)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(p!=="factory"&&(!g&&d===void 0||d&&Xr.has(d)&&!g))continue;let y=Qr(r,c+i[0].length);s.push({file:e,line:gt(t,c),kind:p,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}l(te,"extractArkRunKernelCallsFromSource");function Ie(e,t,r){let n=Se(t),s=tn(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 c=a[1];if(Yr.has(c)||!s.has(c))continue;let f=rn(n,c);o.push({file:e,line:gt(t,a.index),typeName:c,...f?{importedFrom:f}:{}})}return o}l(Ie,"extractArkRunManagedNewsFromSource");var nn=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],sn=new RegExp(`\\b(${nn.join("|")})\\b`),ht="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",on=new RegExp(`\\bthis\\.${ht}\\.push\\s*\\(`),an=new RegExp(`^this\\.${ht}\\s*=\\s*\\[\\s*\\]`),ln=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,cn=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,dn="truncatedUntil";function un(e){return sn.test(e)||on.test(e)}l(un,"referencesGuardOrPublish");function fn(e,t,r){let n=e.slice(t);if(an.test(n))return!0;if(!ln.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))}l(fn,"isIdiomaticEventsReset");function pn(e,t){let r=new RegExp(cn.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!fn(t,n.index,e))return!0;return!1}l(pn,"methodAssignsThis");function gn(e,t){return t==null||Object.defineProperty(e,dn,{value:t,enumerable:!1,configurable:!0}),e}l(gn,"attachShapeTruncation");var mn=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),yn=new Set(["if","match","when"]);function re(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
|
|
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}l(re,"skipStringOrComment");function G(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=re(e,r);continue}break}return r}l(G,"skipWsAndComments");function yt(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}}l(yt,"readIdent");function xe(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=re(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}l(xe,"skipBalanced");function hn(e){let t=[],r=0,n;for(;r<e.length&&(r=G(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let d=yt(e,o);if(!d||!mn.has(d.ident))break;s.push(d.ident),o=G(e,d.end)}let i=yt(e,o);if(!i){r+=1;continue}if(o=G(e,i.end),e[o]==="<"){let d=xe(e,o,"<",">");if(d==null){n=e.length;break}o=G(e,d)}if(e[o]==="("){let d=xe(e,o,"(",")");if(d==null){n=e.length;break}if(o=G(e,d),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let u=re(e,o);if(u!==o){o=u;continue}o+=1}if(e[o]==="{"){let u=xe(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,c=0,f=0;for(;o<e.length;){let d=re(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==="(")c+=1;else if(u===")")c-=1;else if(u==="[")f+=1;else if(u==="]")f-=1;else if(u===";"&&a===0&&c===0&&f===0){o+=1;break}o+=1}t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o}return{members:t,truncatedAt:n}}l(hn,"scanClassMembers");function we(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,c=i;for(;c<t.length&&a>0;){let A=t[c];A==="{"?a+=1:A==="}"&&(a-=1),c+=1}let f=t.slice(i,c-1),d=a>0,u=hn(f),p=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(f),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(f),b=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(f)&&!k,Z=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(f)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(f),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")||yn.has(A.name)||pn(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:un(A.body)}));let F=u.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(gn({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:R,hasPublicConstructor:b,hasStaticFactory:Z,mutatingMethods:[...D],dataOnly:F},p))}return r}l(we,"extractClassShapesFromSource");function Rn(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}}l(Rn,"normalizeExtraMergeTeethClassification");function ne(e){let t=Rn(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}l(ne,"extraMergeTeethAllowed");var An=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],kn=new Set(An);function bn(e){return kn.has(e)}l(bn,"isArkRunEditorSensor");var Rt={"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"},En="ARKRUN_INTERACTION_NAME_INCOMPLETE";function bt(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.")})}l(bt,"isDomainRoleLayer");function Sn(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}l(Sn,"compareFindings");function _(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Rt[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:Rt[t],fromLayer:o?.fromLayer,target:o?.target})}}l(_,"finding");function In(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)}}l(In,"bagForFile");function At(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}l(At,"emitKinds");function kt(e){return e==="subscribe"||e==="register-handler"}l(kt,"handleKinds");function xn(e){return e==="resolve"||e==="resolve-singleton"}l(xn,"dependKinds");function wn(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(_(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((f,d)=>f.file.localeCompare(d.file));if(a.length===0){n.push(_(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(f=>f.hasKernelFactory))continue;let c=a[0];n.push(_(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}l(wn,"evaluateMissingRoot");function _n(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let c=a.specifier;if(!c||!$(c))continue;let f=n(a.from);f&&bt(f,o.get(f)??[])&&i.push(_(e,"arkrun-kernel-in-domain",a.from,a.line,`${f} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:f,target:c},s))}return i}l(_n,"evaluateKernelInDomain");function Nn(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??[]])),c=new Set(n.filter(d=>d.hasKernelFactory).map(d=>d.file)),f=[];for(let d of r){if(c.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 p=s(d.file);!p||!i.has(p)||bt(p,a.get(p)??[])||f.push(_(e,"arkrun-direct-new",d.file,d.line,`${p} must not construct ${d.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:p,target:d.typeName},o))}return f}l(Nn,"evaluateDirectNew");function Cn(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 c of t){if(!At(c.kind)&&!kt(c.kind)&&!xn(c.kind))continue;let f=n(c.file);if(!f||!a.has(f))continue;if(!c.nameLiteral){e.mode==="enforced"&&i.push({code:En,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let d=In(r,c.file);if(At(c.kind)){if(d.raises.has(c.nameLiteral)||d.sends.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:f,target:c.nameLiteral},s));continue}if(kt(c.kind)){if(d.reactsTo.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:f,target:c.nameLiteral},s));continue}d.uses.has(c.nameLiteral)||o.push(_(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:f,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}l(Cn,"evaluateUndeclared");function On(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||!pt(a))continue;let c=r(i.from);!c||!s.has(c)||o.push(_(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:c,target:a},n))}return o}l(On,"evaluateTransportBypass");function vn(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=Cn(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...wn(t,e.compositionRootHits,r),..._n(t,e.layers,e.dependencies,e.layerForFile,r),...Nn(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...On(t,e.dependencies,e.layerForFile,r)].sort(Sn),o=[...n.completenessReasons].sort((i,a)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,f=`${a.code}\0${a.file??""}\0${a.message}`;return c<f?-1:c>f?1:0});return{findings:s,completenessReasons:o}}l(vn,"evaluateArkRunSensors");function _e(e){return{findings:vn(e).findings.filter(r=>bn(r.sensor)),completenessReasons:[]}}l(_e,"evaluateArkRunEditorSensors");function Tn(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")}l(Tn,"declarationIsTypeOnly");function St(e){try{return Ne.default.existsSync(e)?Ne.default.readFileSync(e,"utf8"):null}catch{return null}}l(St,"readUtf8");function Et(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=C.default.dirname(n),i=C.default.isAbsolute(r)?r:C.default.resolve(r),a=C.default.relative(o,i).split(C.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let c=S(a,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:c}:null}l(Et,"loadEditorFile");function Ln(e,t,r){let n=te(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}l(Ln,"compositionRootHitsForFile");function Dn(e,t,r){let n=new Set(we(t.relFile,r).map(s=>s.className));return mt(r,(s,o)=>{if($(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=C.default.relative(t.root,i).split(C.default.sep).join("/");if(a.startsWith(".."))return;let c=St(i);if(c!==null)for(let f of we(a,c))n.add(f.className)}),n}l(Dn,"admittedTypeNamesForEditor");function It(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)}l(It,"reportFinding");function Fn(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}l(Fn,"constructedTypeName");function Pn(e,t){return e.type?.startsWith("Export")?"export":t}l(Pn,"specifierEdgeKind");function Kn(e,t,r,n,s){let o=l((i,a,c,f)=>{if(typeof a!="string"||a.length===0)return;let d=i.loc?.start?.line??1,u={from:r.relFile,specifier:a,kind:f,typeOnly:c,line:d,resolution:"resolved-external"},{findings:p}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[u],layerForFile:l(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of p)g.sensor===n&&It(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,c=(a.specifiers??[]).filter(d=>d.type==="ImportSpecifier"),f=c.length>0&&c.length===(a.specifiers??[]).length&&c.every(d=>d.importKind==="type");o(i,a.source?.value,a.importKind==="type"||f||Tn(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 c=a.specifiers??[],f=c.length>0&&c.every(d=>d.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||f,Pn(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")}}}l(Kn,"importListeners");function $n(e,t,r){let n=St(r.absFile)??"",s=Dn(e,r,n),o=Ie(r.relFile,n,s),{findings:i}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:te(r.relFile,n),managedNews:o,compositionRootHits:Ln(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:l(c=>c===r.relFile?r.fromLayer:S(c,r.config.layers),"layerForFile")}),a=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let f=Fn(c);if(!f)return;let d=c.loc?.start?.line,u=a.find(p=>p.target===f&&(d===void 0||p.line===d))??a.find(p=>p.target===f);u&&It(e,t,c,"directNew",u,{fromLayer:u.fromLayer??r.fromLayer,typeName:f,target:u.target??f})}}}l($n,"directNewListener");function xt(e){let t=l((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=Et(e,i);return a?Kn(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=Et(e,r);return n?$n(e,r,n):{}}}}}l(xt,"createArkRunEslintRules");var Mn="createOrderPlane";var Un=/\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)/,jn=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,Hn=/\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 Un.test(e)||jn.test(e)}l(Vn,"sourceImportsPersistenceDriver");function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(se,"escapeRegExp");function oe(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}l(oe,"isArkOrderModuleSpecifier");function B(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
|
|
5
|
-
`&&(r+=1);return r}l(B,"lineAt");function W(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(W,"stripCommentsPreservingLines");function wt(e,t){let r=W(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:B(t,o.index),callee:Mn});return n}l(wt,"extractArkOrderPlaneCallsFromSource");function _t(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:B(t,o.index),method:i})}return n}l(_t,"extractArkOrderGenericUpdatesFromSource");function Nt(e,t,r){if(r.length===0)return[];let n=W(t);if(!Vn(n)||!Hn.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${se(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${se(i)}['"]\\s*:|[{\\,]\\s*${se(i)}\\s*[\\,}]|\\.${se(i)}\\s*=)`,"g"),c;for(;(c=a.exec(n))!==null;){let f=`${i}:${c.index}`;if(!o.has(f)){o.add(f),s.push({file:e,line:B(t,c.index),key:i});break}}}return s}l(Nt,"extractArkOrderXiFieldWritesFromSource");function Ct(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:B(t,o.index)});return n}l(Ct,"extractArkOrderIngestWritesXiFromSource");function Ot(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:B(t,o.index),keyCount:a.length})}return n}l(Ot,"extractArkOrderReleaseKeyCountsFromSource");var vt=new Map;function Tt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(Tt,"escapeAppliesToLiteral");function Gn(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}l(Gn,"normalizeAppliesToGlob");function Bn(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}l(Bn,"appliesToBracesBalanced");function Wn(e){let t=vt.get(e);if(t)return t;let r=Gn(e),n=Bn(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=Tt(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Tt(c)}let i=new RegExp(`^${s}$`);return vt.set(e,i),i}l(Wn,"globToRegExp");var Lt={"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 zn(e,t){return!t||t.length===0?!0:t.some(r=>Wn(r).test(e))}l(zn,"matchesArkOrderAppliesTo");function qn(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.")})}l(qn,"isDomainRoleLayer");function O(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Lt[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:Lt[t],fromLayer:o?.fromLayer,target:o?.target})}}l(O,"finding");function Zn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(O(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let c=new Map;for(let f of e.planeRootHits){let d=c.get(f.matchedRoot)??[];d.push(f),c.set(f.matchedRoot,d)}for(let f of s){let d=c.get(f)??[];if(d.length===0){n.push(O(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(f)} matched no governed files and has no createOrderPlane factory.`,{target:f},r));continue}d.some(u=>u.hasPlaneFactory)||n.push(O(t,"arkorder-missing-plane",d[0].file,1,`ArkOrder plane root ${JSON.stringify(f)} has no createOrderPlane factory.`,{target:f},r))}}let o=new Map(e.layers.map(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let f=c.specifier;if(!f||!oe(f))continue;let d=e.layerForFile(c.from);d&&qn(d,o.get(d)??[])&&n.push(O(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:d,target:f},r))}for(let c of e.genericUpdates)n.push(O(t,"arkorder-generic-update",c.file,c.line,`Generic ${c.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:c.method},r));let i=t.xiKeys??[];for(let c of e.releaseKeyCounts??[])c.keyCount<=t.maxXiKeys||n.push(O(t,"arkorder-too-many-params",c.file,c.line,`release() freezes ${c.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(c.keyCount)},r));for(let c of e.ingestWritesXi??[])n.push(O(t,"arkorder-ingest-writes-xi",c.file,c.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 c of i.length===0?[]:e.xiFieldWrites??[]){let f=e.layerForFile(c.file);!f||!a.has(f)||zn(c.file,t.appliesTo)&&n.push(O(t,"arkorder-xi-field-write",c.file,c.line,`This file writes ${JSON.stringify(c.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:f,target:c.key},r))}return n.sort((c,f)=>c.file.localeCompare(f.file)||c.ruleId.localeCompare(f.ruleId)||c.line-f.line),{findings:n,completenessReasons:[]}}l(Zn,"evaluateArkOrderSensors");function Dt(e){if(!e.arkOrder)return[];let t=wt(e.file,e.source),r=_t(e.file,e.source),n=e.arkOrder.xiKeys??[];return Zn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:Nt(e.file,e.source,n),ingestWritesXi:Ct(e.file,e.source),releaseKeyCounts:Ot(e.file,e.source),dependencies:[],layerForFile:l(()=>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")}l(Dt,"evaluateArkOrderEditorSensors");function Yn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}l(Yn,"eslintSourceText");function Ft(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 c=S(a,i.layers);return{ImportDeclaration(f){let d=typeof f.source?.value=="string"?f.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!oe(d)||c!=="DomainModel"&&!/^domain/i.test(c??""))return;e.reportAdapterDiagnostic(n,f,"denied",{ruleId:r,file:a,line:f.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let f=Yn(n),d=Dt({arkOrder:i.arkOrder,file:a,source:f,fromLayer:c}).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 l(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}l(Ft,"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""}l(L,"lintedFilename");function v(e,t,r,n,s){let o=ct({...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}l(v,"reportAdapterDiagnostic");function M(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(N.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}l(M,"findConfigPath");var Pt=new Map;function U(e){if(!N.default.existsSync(e))return null;let t=N.default.readFileSync(e,"utf8"),r=Pt.get(e);if(r?.source===t)return r.config;let n=at(t,e).config;return Pt.set(e,{source:t,config:n}),n}l(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}/`)})&&!Ge(t,e)}l(q,"sourceIsInAnalysisScope");function Kt(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(N.default.existsSync(r)&&N.default.statSync(r).isFile())return r}catch{}return null}l(Kt,"existingSourceFile");function $t(e){let t=m.default.resolve(e),r=null;for(;;){let f=m.default.join(t,"tsconfig.json");if(N.default.existsSync(f)){r=f;break}let d=m.default.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=l(f=>{try{let d=N.default.readFileSync(f,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},"loadJsonc"),s=l((f,d)=>{if(d>4)return{};let u=n(f);if(!u)return{};let p=u.compilerOptions??{},g=p.baseUrl,y=p.paths,R=u.extends;if(typeof R=="string"&&!R.startsWith("@")){let k=m.default.resolve(m.default.dirname(f),R.endsWith(".json")?R:`${R}.json`);if(N.default.existsSync(k)){let b=s(k,d+1);g=g??b.baseUrl,y={...b.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),a=m.default.resolve(i,o.baseUrl||"."),c=[];for(let[f,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let u=f.replace(/\*$/,"");u&&c.push({from:u,to:String(d[0]).replace(/\*$/,"")})}return c.sort((f,d)=>d.from.length-f.from.length),{baseUrl:a,aliases:c}}l($t,"readTsconfigPathAliases");function Mt(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return Kt(r)}l(Mt,"resolveRelativeImport");function Oe(e,t,r){if(!t)return null;if(t.startsWith("."))return Mt(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=$t(n),i=o.find(c=>t.startsWith(c.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Kt(a)}l(Oe,"resolveImportSpecifier");function le(e){return typeof e?.value=="string"?e.value:void 0}l(le,"stringValue");function ve(e){return e?.name??le(e)}l(ve,"propertyName");function Te(e){return e.sourceCode??e.getSourceCode?.()}l(Te,"sourceCodeFor");function Ut(e,t){let r=Te(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}l(Ut,"referenceFor");function z(e,t,r){let n=Ut(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Te(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}l(z,"isLocallyBound");function Xn(e,t){let r=Ut(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}l(Xn,"isValueIdentifierReference");function jt(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=jt(e.object),n=ve(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}l(jt,"memberExpressionPath");function Jn(e){return ve(e.callee?.property)}l(Jn,"calleePropertyName");function Ht(e,t){return e?.properties?.find(r=>ve(r.key)===t)}l(Ht,"objectProperty");function ie(e,t){return Ht(e,t)!==void 0}l(ie,"objectHasProperty");function Qn(e){let t=Ht(e,"metadata")?.value;return ie(t,"source")}l(Qn,"objectHasMetadataSource");function Vt(e){return Jn(e)==="publish"}l(Vt,"isPublishCall");function Ce(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")}l(Ce,"declarationIsTypeOnly");function es(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}l(es,"containingProgram");function ts(e){let t=es(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Ce(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(!Ce(n))return!1;r=!0;continue}return!1}}return r}l(ts,"sourceProgramExportsOnlyTypes");var Gt={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=M(t),n=r?U(r):null,s=r?m.default.dirname(r):null,o=l(i=>{let a=le(i.source);if(a&&n&&s&&t){let c=m.default.isAbsolute(t)?t:m.default.resolve(t),f=m.default.relative(s,c).split(m.default.sep).join("/");if(!q(n,f))return;let d=S(f,n.layers);if(!d)return;let u=Oe(c,a,s);if(!u)return;let p=m.default.relative(s,u).split(m.default.sep).join("/");if(p.startsWith(".."))return;let g=S(p,n.layers);if(!g)return;let y={fromPath:f,toPath:p,layers:n.layers},R=ue(n.rules,d,g,y),k=R?.rule;if(k){let b=i.type?.startsWith("Export")?"export":"import",Z=Ce(i),D=!!k?.peerIsolation,ce=Z&&!D,F=D&&R?He(R.peerIsolationReason??"cross-slice",{fromPath:f,toPath:p,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${d} must not ${b} another slice of ${g} (${f} \u2192 ${p}): ${F}`:`${d} must not ${b} ${g}.`;v(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:f,fromLayer:d,toLayer:g,target:p,edgeKind:b,...D?{peerIsolation:!0}:{},...Z?{typeOnly:!0}:{},...ce?{severity:"warning"}:{},...ts(i)?{sourcePureTypeModule:!0}:{},message:ce?`${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}}},Bt={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=le(r),s=be({publishCall:Vt(t),rawIntentName:n,objectHasIntent:ie(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");v(e,t,"rawPublish",{...o,file:L(e)})}}}}},Wt={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=be({publishCall:Vt(t),rawIntentName:le(r),objectHasIntent:ie(r,"intent"),arkPublishCandidate:!0,hasSource:Qn(r)||ie(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&v(e,t,"missingSource",{...o,file:L(e)})}}}},zt={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=M(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),p=m.default.relative(o,u).split(m.default.sep).join("/");if(!q(s,p))return{};let g=s.layers?.find(y=>y.name===S(p,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 c=typeof Te(e)?.getScope=="function",f=l((u,p)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;v(e,u,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:p,message:`${a} must not use the ambient global "${p}".`},{name:p,layer:a})},"report"),d=l((u,p,g,y)=>{if(g||typeof p!="string")return;let R=pe(p,i);if(!R)return;let k=m.default.isAbsolute(t)?t:m.default.resolve(t),b=o?m.default.relative(o,k).split(m.default.sep).join("/"):t;v(e,u,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:b,fromLayer:a,target:p,edgeKind:y,message:`${a} must not use module "${p}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:p,importKind:y})},"reportModule");return{MemberExpression(u){if(u.parent?.type==="MemberExpression"&&u.parent.object===u)return;let p=jt(u);if(!p||z(e,p.root,p.segments[0]))return;let g=p.segments[0]==="globalThis",y=g?p.segments.slice(1):p.segments,R;for(let k=y.length;k>=(g?1:2);k-=1){let b=y.slice(0,k).join(".");if(i.has(b)){R=b;break}}R?f(u,R):!c&&i.has(p.segments[0])&&f(u,p.segments[0])},CallExpression(u){let p=u;if(p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!z(e,u,"require")&&d(u,p.arguments[0].value,!1,"require"),c)return;let g=p.callee?.type==="Identifier"?p.callee.name:void 0;g&&i.has(g)&&f(u,g)},ImportDeclaration(u){let p=u,g=(p.specifiers??[]).filter(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(p.specifiers??[]).length&&g.every(R=>R.importKind==="type");d(u,p.source?.value,p.importKind==="type"||y,"import")},ImportExpression(u){let p=u;p.source?.type==="Literal"&&d(u,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let p=u;d(u,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let p=u;if(!p.source)return;let g=p.specifiers??[],y=g.length>0&&g.every(R=>R.exportKind==="type");d(u,p.source.value,p.exportKind==="type"||y,"export")},ExportAllDeclaration(u){let p=u;d(u,p.source?.value,p.exportKind==="type","export")},NewExpression(u){if(c)return;let p=u.callee?.type==="Identifier"?u.callee.name:void 0;p&&i.has(p)&&f(u,p)},Identifier(u){!c||!u.name||!i.has(u.name)||!Xn(e,u)||z(e,u,u.name)||f(u,u.name)}}}},qt={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=M(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===S(i,n.layers));if(!a)return{};let c=new Set(ze(a));if(c.size===0)return{};let f=l((d,u,p,g)=>{if(p||typeof u!="string"||pe(u,a.forbiddenGlobals??[]))return;let y=We(u);!y||!c.has(y)||v(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,p=(u.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=p.length>0&&p.length===(u.specifiers??[]).length&&p.every(y=>y.importKind==="type");f(d,u.source?.value,u.importKind==="type"||g,"import")},ImportExpression(d){let u=d;u.source?.type==="Literal"&&f(d,u.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let u=d;f(d,u.moduleReference?.expression?.value,u.importKind==="type"||u.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let u=d;if(!u.source)return;let p=u.specifiers??[],g=p.length>0&&p.every(y=>y.exportKind==="type");f(d,u.source.value,u.exportKind==="type"||g,"export")},ExportAllDeclaration(d){let u=d;f(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")&&f(d,u.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:Zt,noArkRunDirectNew:Yt,noArkRunTransportBypass:Xt}=xt({findConfigPath:M,loadArkConfig:U,resolveImportSpecifier:Oe,lintedFilename:L,sourceIsInAnalysisScope:q,isLocallyBound:z,reportAdapterDiagnostic:v});function rs(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("/")}l(rs,"toProjectRelative");var{noArkOrderKernelInDomain:Jt,noArkOrderGenericUpdate:Qt}=Ft({findConfigPath:M,loadArkConfig:U,lintedFilename:L,sourceIsInAnalysisScope:q,reportAdapterDiagnostic:v,toProjectRelative:rs});var ns={"no-domain-infra-imports":Gt,"no-raw-event-publish":Bt,"require-publish-source":Wt,"no-forbidden-globals":zt,"no-denied-capabilities":qt,"no-arkrun-kernel-in-domain":Zt,"no-arkrun-direct-new":Yt,"no-arkrun-transport-bypass":Xt,"no-arkorder-kernel-in-domain":Jt,"no-arkorder-generic-update":Qt},ae={rules:ns};ae.configs={recommended:{plugins:{ark:ae},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 ss=ae;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
|
|
3
|
+
`)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(w,"isObject");function P(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(P,"propertyPath");function K(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(K,"valueType");function cn(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(cn,"resolveSchemaRef");function X(e,t,r,n,s){if(t.$ref){let o=cn(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}X(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(!w(e)){s.push({path:r,message:`must be an object; received ${K(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:P(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:P(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||X(e[l],i,P(r,l),n,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&X(e[i],l,P(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${K(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)=>X(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 ${K(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 ${K(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${K(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}a(X,"validateNode");var dn=["deny","advisory"],Rt='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"] }';function un(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!w(n))return;let o=n.childSlices;if(!w(o)||o.siblings===void 0)return;let i=o.siblings,l=`$.rules[${s}].childSlices.siblings`;if(typeof i=="string"){dn.includes(i)||t.push({path:l,message:Rt});return}if(!w(i)){t.push({path:l,message:Rt});return}for(let u of Object.keys(i))u!=="default"&&u!=="enforce"&&t.push({path:P(l,u),message:"unknown field"});if(i.default===void 0?t.push({path:`${l}.default`,message:"is required"}):i.default!=="deny"&&i.default!=="advisory"&&t.push({path:`${l}.default`,message:"must be deny or advisory"}),i.enforce===void 0)return;if(!Array.isArray(i.enforce)){t.push({path:`${l}.enforce`,message:"must be an array of child slice ids or subtree paths"});return}let c=new Set;i.enforce.forEach((u,f)=>{let d=`${l}.enforce[${f}]`;if(typeof u!="string"||u.trim().length===0){t.push({path:d,message:"must be a non-empty child slice id or subtree path"});return}let p=U(u.trim().replace(/\\/g,"/"));if(p.split("/").some(g=>g.length===0||g==="."||g==="..")){t.push({path:d,message:"must be a child slice id or subtree path without . or .."});return}if(p.includes("*")){t.push({path:d,message:"must be a child slice id or subtree path. * is not a wildcard on siblings.enforce"});return}if(c.has(p)){t.push({path:d,message:"duplicate enforce entry"});return}c.add(p)})})}a(un,"validateChildSliceSiblings");var fn="must be a slice id with a slash. A bare name is ambiguous across universes.",pn="* matches one whole path segment. ** and a partial segment are not wildcards.";function gn(e){let t=U(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty slice id";if(!t.includes("/"))return fn;let r=t.split("/");for(let n of r){if(n.length===0||n==="."||n==="..")return"must be a slice id without empty, . or .. segments";if(n.includes("*")&&n!=="*")return pn}return null}a(gn,"childCrossSlicePatternIssue");function At(e){return U(e.trim().replace(/\\/g,"/")).toLowerCase()}a(At,"childCrossSlicePatternKey");function mn(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!w(n))return;let o=n.childSlices;if(!w(o)||o.allowedCrossSlice===void 0)return;let i=o.allowedCrossSlice,l=`$.rules[${s}].childSlices.allowedCrossSlice`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } child slice ids"});return}let c=new Set;i.forEach((u,f)=>{let d=`${l}[${f}]`;if(!w(u)){t.push({path:d,message:"must be an object with from and to"});return}for(let g of Object.keys(u))g!=="from"&&g!=="to"&&t.push({path:P(d,g),message:"unknown field"});for(let g of["from","to"]){let y=u[g],h=`${d}.${g}`;if(typeof y!="string"||y.trim().length===0){t.push({path:h,message:"must be a non-empty slice id"});continue}let R=gn(y);R&&t.push({path:h,message:R})}if(typeof u.from!="string"||typeof u.to!="string")return;let p=`${At(u.from)}\0${At(u.to)}`;if(!p.startsWith("\0")&&!p.endsWith("\0")){if(c.has(p)){t.push({path:d,message:"duplicate child slice allowance"});return}c.add(p)}})})}a(mn,"validateChildSliceAllowedCrossSlice");var M="must be a child of an existing universe (the universe id this rule already names, plus one child segment). A bare name, a universe id alone, an unknown universe, and a wildcard are rejected.",yn="overlaps a slice folder. An alias covers only files outside the slice trees.",hn="two slice aliases match the same file";function Rn(e){return U(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(Rn,"aliasPathSegments");function Et(e){let t=[];for(let r of e){if(r.includes("*"))break;t.push(r)}return t}a(Et,"concreteGlobPrefix");function Y(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0}a(Y,"segmentsArePrefix");function An(e){let t=e.split(/[/\\]/).filter(Boolean).map(n=>n.toLowerCase());if(t.length<2||t[0]==="*"||t[0]==="**"||!t.some(n=>n==="*"))return null;let r=[];for(let n of t){if(n==="*"||n==="**")break;if(n.includes("*"))return null;r.push(n)}return r.length>0?r:null}a(An,"anchoredSlicePrefix");function kn(e,t){let r=Et(e),n=r.length<e.length,s=r[0]==="src"||r[0]==="app"?r.slice(1):r;return Y(t,r)||Y(t,s)?!0:n?Y(r,t)&&r.length<t.length||Y(r,["src",...t])&&r.length<t.length+1||Y(r,["app",...t])&&r.length<t.length+1:!1}a(kn,"globOverlapsAnchored");function Sn(e,t){for(let n=0;n<e.length;n+=1){if(e[n]!==t&&e[n]!=="*")continue;let s=e.slice(n+1);if(s.length>=2||s.some(o=>o==="*"||o==="**"))return!0}let r=Et(e);return r.length<e.length&&(r.length===0||r.length===1&&(r[0]==="src"||r[0]==="app"))}a(Sn,"globOverlapsBare");function bn(e,t){let r=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(r.length===1&&r[0]&&!r[0].includes("*"))return Sn(e,r[0]);let n=An(t);return n?kn(e,n):!1}a(bn,"globOverlapsSliceEntry");function En(e){let t=U(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty path glob";if(t==="*"||t==="**")return"must not cover the whole tree";for(let r of t.split("/")){if(r.length===0||r==="."||r==="..")return"must be a path glob without empty, . or .. segments";if(!(r==="*"||r==="**")&&(r.includes("*")||r.includes("?")||r.includes("{")||r.includes("[")))return"* matches one whole path segment. ** is a whole segment. A partial segment is not a wildcard."}return null}a(En,"aliasGlobIssue");function In(e,t){let r=[];if(!Array.isArray(e))return r;let n=t==="stars";for(let s of e){if(typeof s!="string"||s.length===0)continue;let o=s.split(/[/\\]/).filter(Boolean).map(i=>i.toLowerCase());if(o.length===1&&o[0]&&!o[0].includes("*")){r.push({literals:[o[0],null]});continue}if(!o.some(i=>i==="**"||i.includes("*")&&i!=="*")&&o.includes("*")){if(n){let i=-1;for(let l=0;l<o.length;l+=1)o[l]!=="*"&&(i=l);if(i<0)continue;r.push({literals:o.slice(i).map(l=>l==="*"?null:l)});continue}r.push({literals:o.map(i=>i==="*"?null:i)})}}return r}a(In,"universeShapes");function kt(e,t){return e.literals.length!==t.length?!1:e.literals.every((r,n)=>r===null||r===t[n])}a(kt,"shapeMatches");function wn(e,t){let r=U(e.trim().replace(/\\/g,"/"));if(r.length===0||r.split("/").some(s=>s.length===0||s==="."||s==="..")||r.includes("*")||!r.includes("/"))return M;let n=r.split("/").map(s=>s.toLowerCase());return t.length===0||t.some(s=>kt(s,n))?M:t.some(s=>kt(s,n.slice(0,-1)))?null:M}a(wn,"aliasTargetIssue");function St(e){let t=e[0];return(t==="src"||t==="app")&&e.length>1?[e,e.slice(1)]:[e]}a(St,"aliasGlobVariants");function xn(e,t){let r=St(e),n=St(t);for(let s of r)if(F(s,t,0,0,new Map))return!0;for(let s of n)if(F(e,s,0,0,new Map))return!0;return!1}a(xn,"aliasesCanMatchSameFile");function F(e,t,r,n,s){let o=`${r}:${n}`,i=s.get(o);if(i!==void 0)return i;let l=!1;if(r===e.length&&n===t.length)l=!0;else if(r<e.length&&e[r]==="**")l=F(e,t,r+1,n,s)||n<t.length&&F(e,t,r,n+1,s);else if(n<t.length&&t[n]==="**")l=F(e,t,r,n+1,s)||r<e.length&&F(e,t,r+1,n,s);else if(r<e.length&&n<t.length){let c=e[r],u=t[n];(c===u||c==="*"||u==="*")&&(l=F(e,t,r+1,n+1,s))}return s.set(o,l),l}a(F,"globsCanMatchSame");function Cn(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!w(n))return;let o=n.childSlices;if(!w(o)||o.sliceAliases===void 0)return;let i=o.sliceAliases,l=`$.rules[${s}].childSlices.sliceAliases`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } slice aliases"});return}let c=In(n.sliceFolders,n.sliceIdentity),u=[...Array.isArray(n.sliceFolders)?n.sliceFolders:[],...Array.isArray(o.sliceFolders)?o.sliceFolders:[]].filter(d=>typeof d=="string"&&d.length>0),f=[];i.forEach((d,p)=>{let g=`${l}[${p}]`;if(!w(d)){t.push({path:g,message:"must be an object with from and to"});return}for(let R of Object.keys(d))R!=="from"&&R!=="to"&&t.push({path:P(g,R),message:"unknown field"});let y=d.from,h=d.to;if(typeof y!="string"||y.trim().length===0)t.push({path:`${g}.from`,message:"must be a non-empty path glob"});else{let R=En(y);if(R)t.push({path:`${g}.from`,message:R});else{let S=Rn(y);u.some(N=>bn(S,N))&&t.push({path:`${g}.from`,message:yn});for(let N of f)if(xn(N,S)){t.push({path:g,message:hn});break}f.push(S)}}if(typeof h!="string"||h.trim().length===0)t.push({path:`${g}.to`,message:M});else{let R=wn(h,c);R&&t.push({path:`${g}.to`,message:R})}})})}a(Cn,"validateChildSliceAliases");function vn(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,l)=>{typeof i=="string"&&(mt(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}a(vn,"validateLayerOwners");function _n(e){let t={...e,$schema:e.$schema===void 0?Ee: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?bt.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=dt(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=ut(e.arkOrder)),t}a(_n,"defaultedConfig");function Nn(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(Nn,"migratedFromOf");function On(){let e=new Set([I]);for(let t of Ie)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(On,"knownInputVersions");function Ln(e,t="ark.config.json"){if(!w(e))throw new C(t,[{path:"$",message:`must be an object; received ${K(e)}`}]);let r=On(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new C(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new C(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<Ie.length+1;){i+=1;let l=Ie.find(c=>c.from===s);if(!l)throw new C(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=l.to,o.schemaVersion=s}if(s!==I)throw new C(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:_n(o),migratedFrom:Nn(n)}}a(Ln,"migrateArkConfig");function Tn(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Ln(e,t),s=[];if(X(r,ht,"$",ht,s),ft(r,s),pt(r,s),vn(r,s),un(r,s),mn(r,s),Cn(r,s),s.length>0)throw new C(t,s);return{config:r,migratedFrom:n}}a(Tn,"loadArkConfigContract");function It(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new C(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Tn(r,t)}a(It,"parseArkConfigJson");function U(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(U,"trimTrailingSlashes");var Dn=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Fn=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Pn=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function $n(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Dn.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Fn.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Pn.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a($n,"classifyLayerImportKind");function Kn(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=$n(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."}a(Kn,"layerImportNextAction");function Mn(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a(Mn,"arkRunCallSiteName");function Un(e){let t=Mn(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.`}}a(Un,"arkRunNextAction");function j(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Kn(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"INVARIANT_CATALOG_EMPTY":return typeof e.file=="string"&&e.file.length>0?`Add 1\u20132 short phrases to invariants[] in ${e.file}, then run ark-check --doctor. Starters show the shape.`:"Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json, then run ark-check --doctor. Starters show the shape.";case"INVARIANT_TESTS_PATH_MISSING":return"Add coverage.testGlobs or coverage.coverageRoots in ark.config.json pointing at a real tests folder, then re-run. Adopted mode fails closed until that path is present.";case"INVARIANT_COVERAGE_ROOTS_MISSING":return"Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. An enforced invariant fails closed until that path is present.";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 Un(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.`}}a(j,"deterministicNextAction");var we="docs/diagnostics.md";function xe(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("|")}a(xe,"adapterFindingTargetKey");function Ce(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")}`}a(Ce,"adapterFindingRefFromTargetKey");function ve(e){return`${we}#${e}`}a(ve,"adapterDocsCodePath");function A(e){return typeof e=="string"&&e.length>0?e:void 0}a(A,"text");function wt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(wt,"positiveInteger");function Vn(e,t,r){return j({ruleId:e,target:A(t.target)??A(r.target)??void 0,fromLayer:A(t.fromLayer)??void 0,toLayer:A(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:A(t.edgeKind)??void 0,capability:A(t.capability)??A(r.capability)??void 0,arkruleId:A(t.arkruleId)??void 0,arkruleSource:A(t.arkruleSource)??void 0})}a(Vn,"nextActionForDiagnostic");function xt(e,t="error",r){let n=A(e.ruleId)??A(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...A(e.target)?{target:A(e.target)}:{},...A(e.fromLayer)?{fromLayer:A(e.fromLayer)}:{},...A(e.toLayer)?{toLayer:A(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}:{},...A(e.capability)?{capability:A(e.capability)}:{},...A(e.edgeKind)?{edgeKind:A(e.edgeKind)}:{},...A(e.arkruleId)?{arkruleId:A(e.arkruleId)}:{},...A(e.arkruleSource)?{arkruleSource:A(e.arkruleSource)}:{}},i=r??xe(e),l=Ce(i);return{ruleId:n,severity:s,message:A(e.message)??n,location:{file:A(e.file)??"<unknown>",line:wt(e.line,1),column:wt(e.column,1)},evidence:o,nextAction:A(e.nextAction)??Vn(n,o,e),findingRef:l,targetKey:i,docsCodePath:ve(n)}}a(xt,"toAdapterDiagnostic");var Ct={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."},Oo=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 Gn(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(Gn,"looksLikeArkIntent");function _e(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Gn(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Ct.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Ct.PUBLISH_MISSING_SOURCE}),t}a(_e,"classifyPublishFacts");var Pe=ne(require("fs"),1),O=ne(require("path"),1);var Bn=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Wn=new Set(Bn),zn=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"]),qn=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function H(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}a(H,"isArkRunKernelModuleSpecifier");var Zn=["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"],Ne=new Set(Zn);function Nt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(Ne.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(Ne.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:Ne.has(e.slice(0,n))}a(Nt,"isArkRunTransportBypassSpecifier");function vt(e){if(Wn.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}}a(vt,"arkRunKernelCallKind");function Ot(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}a(Ot,"lineAt");function Oe(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(Oe,"stripCommentsPreservingLines");function Yn(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}a(Yn,"firstStringLiteralArg");function _t(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)}a(_t,"keywordBefore");function ie(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]??"")}a(ie,"parseValueImportClause");function Lt(e,t){ie(Oe(e),t)}a(Lt,"forEachArkRunValueImportClause");function Xn(e){let t=new Map,r=new Set;return ie(e,(n,s)=>{if(!H(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 l=/\{([^}]*)\}/.exec(n);if(l?.[1])for(let c of l[1].split(",")){let u=c.trim();if(!u||u.startsWith("type "))continue;let f=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);if(f){t.set(f[2],f[1]);continue}let d=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);d?.[1]&&t.set(d[1],d[1])}}),{named:t,namespaces:r}}a(Xn,"collectKernelImportBindings");function Jn(e,t){let r=new Set(t);return ie(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let l=i.trim();if(!l||l.startsWith("type "))continue;let c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(l),u=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(l)?.[1],f=c?.[1]??u;!u||!f||!/^[A-Z]/.test(f)||(H(s)||t.has(f)||t.has(u))&&(r.add(u),r.add(f))}}),r}a(Jn,"collectImportedConstructors");function Qn(e,t){let r;return ie(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}a(Qn,"importedFromForName");function ae(e,t){let r=Oe(t),n=Xn(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let l=i[1],c=i.index;if(_t(r,c,"function")||_t(r,c,"class"))continue;let f=r.slice(0,c).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],d=n.named.get(l)??l,p=vt(d)??vt(l);if(!p)continue;let g=n.named.has(l)||f!==void 0&&n.namespaces.has(f);if(p!=="factory"&&(!g&&f===void 0||f&&qn.has(f)&&!g))continue;let y=Yn(r,c+i[0].length);s.push({file:e,line:Ot(t,c),kind:p,callee:l,viaImport:g,...f?{receiver:f}:{},...y?{nameLiteral:y}:{}})}return s}a(ae,"extractArkRunKernelCallsFromSource");function Le(e,t,r){let n=Oe(t),s=Jn(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,l;for(;(l=i.exec(n))!==null;){let c=l[1];if(zn.has(c)||!s.has(c))continue;let u=Qn(n,c);o.push({file:e,line:Ot(t,l.index),typeName:c,...u?{importedFrom:u}:{}})}return o}a(Le,"extractArkRunManagedNewsFromSource");var es=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],ts=new RegExp(`\\b(${es.join("|")})\\b`),Dt="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",rs=new RegExp(`\\bthis\\.${Dt}\\.push\\s*\\(`),ns=new RegExp(`^this\\.${Dt}\\s*=\\s*\\[\\s*\\]`),ss=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,os=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,is="truncatedUntil";function as(e){return ts.test(e)||rs.test(e)}a(as,"referencesGuardOrPublish");function ls(e,t,r){let n=e.slice(t);if(ns.test(n))return!0;if(!ss.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))}a(ls,"isIdiomaticEventsReset");function cs(e,t){let r=new RegExp(os.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!ls(t,n.index,e))return!0;return!1}a(cs,"methodAssignsThis");function ds(e,t){return t==null||Object.defineProperty(e,is,{value:t,enumerable:!1,configurable:!0}),e}a(ds,"attachShapeTruncation");var us=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),fs=new Set(["if","match","when"]);function le(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
|
|
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}a(le,"skipStringOrComment");function J(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=le(e,r);continue}break}return r}a(J,"skipWsAndComments");function Tt(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}}a(Tt,"readIdent");function Te(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=le(e,o);if(i!==o){o=i;continue}let l=e[o];l===r?s+=1:l===n&&(s-=1),o+=1}return s===0?o:null}a(Te,"skipBalanced");function ps(e){let t=[],r=0,n;for(;r<e.length&&(r=J(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let f=Tt(e,o);if(!f||!us.has(f.ident))break;s.push(f.ident),o=J(e,f.end)}let i=Tt(e,o);if(!i){r+=1;continue}if(o=J(e,i.end),e[o]==="<"){let f=Te(e,o,"<",">");if(f==null){n=e.length;break}o=J(e,f)}if(e[o]==="("){let f=Te(e,o,"(",")");if(f==null){n=e.length;break}if(o=J(e,f),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let d=le(e,o);if(d!==o){o=d;continue}o+=1}if(e[o]==="{"){let d=Te(e,o,"{","}");if(d==null){n=e.length;break}t.push({name:i.ident,modifiers:s,kind:"method",body:e.slice(o+1,d-1)}),r=d;continue}if(e[o]===";"){r=o+1;continue}r=o+1;continue}let l=0,c=0,u=0;for(;o<e.length;){let f=le(e,o);if(f!==o){o=f;continue}let d=e[o];if(d==="{")l+=1;else if(d==="}"){if(l===0)break;l-=1}else if(d==="(")c+=1;else if(d===")")c-=1;else if(d==="[")u+=1;else if(d==="]")u-=1;else if(d===";"&&l===0&&c===0&&u===0){o+=1;break}o+=1}t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o}return{members:t,truncatedAt:n}}a(ps,"scanClassMembers");function De(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,l=1,c=i;for(;c<t.length&&l>0;){let k=t[c];k==="{"?l+=1:k==="}"&&(l-=1),c+=1}let u=t.slice(i,c-1),f=l>0,d=ps(u),p=f?t.length:d.truncatedAt==null?void 0:i+d.truncatedAt,g=d.members.filter(k=>!(k.kind!=="field"||k.name==="constructor"||k.modifiers.includes("private")||k.modifiers.includes("protected")||k.modifiers.includes("readonly")||k.modifiers.includes("static")||k.modifiers.includes("get")||k.modifiers.includes("set"))),y=g.length>0,h=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(u),R=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(u),S=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(u)&&!R,N=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(u)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(u),B=[];for(let k of d.members)k.kind==="method"&&k.name!=="constructor"&&(k.modifiers.includes("static")||k.modifiers.includes("get")||k.modifiers.includes("set")||fs.has(k.name)||cs(k.name,k.body)&&B.push({name:k.name,referencesGuardOrPublish:as(k.body)}));let W=d.members.filter(k=>k.kind==="method").length<=1&&g.length>=2&&y;r.push(ds({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:h,hasPublicConstructor:S,hasStaticFactory:N,mutatingMethods:[...B],dataOnly:W},p))}return r}a(De,"extractClassShapesFromSource");function gs(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}}a(gs,"normalizeExtraMergeTeethClassification");function ce(e){let t=gs(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}a(ce,"extraMergeTeethAllowed");var ms=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],ys=new Set(ms);function hs(e){return ys.has(e)}a(hs,"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"},Rs="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Kt(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.")})}a(Kt,"isDomainRoleLayer");function As(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(As,"compareFindings");function v(e,t,r,n,s,o,i){let l=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:l?"error":"warning",failsStrict:l,nextAction:j({ruleId:Ft[t],fromLayer:o?.fromLayer,target:o?.target})}}a(v,"finding");function ks(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)}}a(ks,"bagForFile");function Pt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Pt,"emitKinds");function $t(e){return e==="subscribe"||e==="register-handler"}a($t,"handleKinds");function Ss(e){return e==="resolve"||e==="resolve-singleton"}a(Ss,"dependKinds");function bs(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(v(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 l=o.get(i.matchedRoot)??[];l.push(i),o.set(i.matchedRoot,l)}for(let i of s){let l=[...o.get(i)??[]].sort((u,f)=>u.file.localeCompare(f.file));if(l.length===0){n.push(v(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(l.some(u=>u.hasKernelFactory))continue;let c=l[0];n.push(v(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}a(bs,"evaluateMissingRoot");function Es(e,t,r,n,s){let o=new Map(t.map(l=>[l.name,l.intentPrefixes??[]])),i=[];for(let l of r){let c=l.specifier;if(!c||!H(c))continue;let u=n(l.from);u&&Kt(u,o.get(u)??[])&&i.push(v(e,"arkrun-kernel-in-domain",l.from,l.line,`${u} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:u,target:c},s))}return i}a(Es,"evaluateKernelInDomain");function Is(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let l=new Map(t.map(f=>[f.name,f.intentPrefixes??[]])),c=new Set(n.filter(f=>f.hasKernelFactory).map(f=>f.file)),u=[];for(let f of r){if(c.has(f.file))continue;let d=f.typeName;if(e.ignoreDirectNewForErrors!==!1&&(d.endsWith("Error")||d==="Error")||d.endsWith("DTO")||d.endsWith("VO"))continue;let p=s(f.file);!p||!i.has(p)||Kt(p,l.get(p)??[])||u.push(v(e,"arkrun-direct-new",f.file,f.line,`${p} must not construct ${f.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:p,target:f.typeName},o))}return u}a(Is,"evaluateDirectNew");function ws(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let l=new Set(e.managedLayers);if(l.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!Pt(c.kind)&&!$t(c.kind)&&!Ss(c.kind))continue;let u=n(c.file);if(!u||!l.has(u))continue;if(!c.nameLiteral){e.mode==="enforced"&&i.push({code:Rs,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let f=ks(r,c.file);if(Pt(c.kind)){if(f.raises.has(c.nameLiteral)||f.sends.has(c.nameLiteral))continue;o.push(v(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:u,target:c.nameLiteral},s));continue}if($t(c.kind)){if(f.reactsTo.has(c.nameLiteral))continue;o.push(v(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:u,target:c.nameLiteral},s));continue}f.uses.has(c.nameLiteral)||o.push(v(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:u,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}a(ws,"evaluateUndeclared");function xs(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 l=i.specifier;if(!l||!Nt(l))continue;let c=r(i.from);!c||!s.has(c)||o.push(v(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(l)}; use the ArkRun kernel transport.`,{fromLayer:c,target:l},n))}return o}a(xs,"evaluateTransportBypass");function Cs(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ce(e.classification),n=ws(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...bs(t,e.compositionRootHits,r),...Es(t,e.layers,e.dependencies,e.layerForFile,r),...Is(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...xs(t,e.dependencies,e.layerForFile,r)].sort(As),o=[...n.completenessReasons].sort((i,l)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,u=`${l.code}\0${l.file??""}\0${l.message}`;return c<u?-1:c>u?1:0});return{findings:s,completenessReasons:o}}a(Cs,"evaluateArkRunSensors");function Fe(e){return{findings:Cs(e).findings.filter(r=>hs(r.sensor)),completenessReasons:[]}}a(Fe,"evaluateArkRunEditorSensors");function vs(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")}a(vs,"declarationIsTypeOnly");function Ut(e){try{return Pe.default.existsSync(e)?Pe.default.readFileSync(e,"utf8"):null}catch{return null}}a(Ut,"readUtf8");function Mt(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=O.default.dirname(n),i=O.default.isAbsolute(r)?r:O.default.resolve(r),l=O.default.relative(o,i).split(O.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,l))return null;let c=E(l,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:l,fromLayer:c}:null}a(Mt,"loadEditorFile");function _s(e,t,r){let n=ae(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}a(_s,"compositionRootHitsForFile");function Ns(e,t,r){let n=new Set(De(t.relFile,r).map(s=>s.className));return Lt(r,(s,o)=>{if(H(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=O.default.relative(t.root,i).split(O.default.sep).join("/");if(l.startsWith(".."))return;let c=Ut(i);if(c!==null)for(let u of De(l,c))n.add(u.className)}),n}a(Ns,"admittedTypeNamesForEditor");function jt(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)}a(jt,"reportFinding");function Os(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}a(Os,"constructedTypeName");function Ls(e,t){return e.type?.startsWith("Export")?"export":t}a(Ls,"specifierEdgeKind");function Ts(e,t,r,n,s){let o=a((i,l,c,u)=>{if(typeof l!="string"||l.length===0)return;let f=i.loc?.start?.line??1,d={from:r.relFile,specifier:l,kind:u,typeOnly:c,line:f,resolution:"resolved-external"},{findings:p}=Fe({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[d],layerForFile:a(g=>g===r.relFile?r.fromLayer:E(g,r.config.layers),"layerForFile")});for(let g of p)g.sensor===n&&jt(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:l,target:g.target??l})},"check");return{ImportDeclaration(i){let l=i,c=(l.specifiers??[]).filter(f=>f.type==="ImportSpecifier"),u=c.length>0&&c.length===(l.specifiers??[]).length&&c.every(f=>f.importKind==="type");o(i,l.source?.value,l.importKind==="type"||u||vs(i),"import")},ImportExpression(i){let l=i;l.source?.type==="Literal"&&o(i,l.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let l=i;o(i,l.moduleReference?.expression?.value,l.importKind==="type"||l.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let l=i;if(!l.source)return;let c=l.specifiers??[],u=c.length>0&&c.every(f=>f.exportKind==="type");o(i,l.source.value,l.exportKind==="type"||u,Ls(i,"export"))},ExportAllDeclaration(i){let l=i;o(i,l.source?.value,l.exportKind==="type","export")},CallExpression(i){let l=i;l.callee?.type==="Identifier"&&l.callee.name==="require"&&l.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,l.arguments[0].value,!1,"require")}}}a(Ts,"importListeners");function Ds(e,t,r){let n=Ut(r.absFile)??"",s=Ns(e,r,n),o=Le(r.relFile,n,s),{findings:i}=Fe({arkRun:r.extra,layers:r.config.layers,kernelCalls:ae(r.relFile,n),managedNews:o,compositionRootHits:_s(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:a(c=>c===r.relFile?r.fromLayer:E(c,r.config.layers),"layerForFile")}),l=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let u=Os(c);if(!u)return;let f=c.loc?.start?.line,d=l.find(p=>p.target===u&&(f===void 0||p.line===f))??l.find(p=>p.target===u);d&&jt(e,t,c,"directNew",d,{fromLayer:d.fromLayer??r.fromLayer,typeName:u,target:d.target??u})}}}a(Ds,"directNewListener");function Ht(e){let t=a((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let l=Mt(e,i);return l?Ts(e,i,l,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=Mt(e,r);return n?Ds(e,r,n):{}}}}}a(Ht,"createArkRunEslintRules");var Fs="createOrderPlane";var Ps=/\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)/,$s=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,Ks=/\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 Ms(e){return Ps.test(e)||$s.test(e)}a(Ms,"sourceImportsPersistenceDriver");function de(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(de,"escapeRegExp");function ue(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(ue,"isArkOrderModuleSpecifier");function Q(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
|
|
5
|
+
`&&(r+=1);return r}a(Q,"lineAt");function ee(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(ee,"stripCommentsPreservingLines");function Vt(e,t){let r=ee(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:Q(t,o.index),callee:Fs});return n}a(Vt,"extractArkOrderPlaneCallsFromSource");function Gt(e,t){let r=ee(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],l=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane)\s*(?:\?|!)?$/.test(l)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:Q(t,o.index),method:i})}return n}a(Gt,"extractArkOrderGenericUpdatesFromSource");function Bt(e,t,r){if(r.length===0)return[];let n=ee(t);if(!Ms(n)||!Ks.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let l=new RegExp(`(?:\\b${de(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${de(i)}['"]\\s*:|[{\\,]\\s*${de(i)}\\s*[\\,}]|\\.${de(i)}\\s*=)`,"g"),c;for(;(c=l.exec(n))!==null;){let u=`${i}:${c.index}`;if(!o.has(u)){o.add(u),s.push({file:e,line:Q(t,c.index),key:i});break}}}return s}a(Bt,"extractArkOrderXiFieldWritesFromSource");function Wt(e,t){let r=ee(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:Q(t,o.index)});return n}a(Wt,"extractArkOrderIngestWritesXiFromSource");function zt(e,t){let r=ee(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let l=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];l.length!==0&&n.push({file:e,line:Q(t,o.index),keyCount:l.length})}return n}a(zt,"extractArkOrderReleaseKeyCountsFromSource");var qt=new Map;function Zt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Zt,"escapeAppliesToLiteral");function Us(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}a(Us,"normalizeAppliesToGlob");function js(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}a(js,"appliesToBracesBalanced");function Hs(e){let t=qt.get(e);if(t)return t;let r=Us(e),n=js(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Zt(r[l+1]),l+=1):c==="*"?r[l+1]==="*"?r[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Zt(c)}let i=new RegExp(`^${s}$`);return qt.set(e,i),i}a(Hs,"globToRegExp");var Yt={"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 Vs(e,t){return!t||t.length===0?!0:t.some(r=>Hs(r).test(e))}a(Vs,"matchesArkOrderAppliesTo");function Gs(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.")})}a(Gs,"isDomainRoleLayer");function L(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Yt[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:l?"error":"warning",failsStrict:l,nextAction:j({ruleId:Yt[t],fromLayer:o?.fromLayer,target:o?.target})}}a(L,"finding");function Bs(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ce(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(L(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let c=new Map;for(let u of e.planeRootHits){let f=c.get(u.matchedRoot)??[];f.push(u),c.set(u.matchedRoot,f)}for(let u of s){let f=c.get(u)??[];if(f.length===0){n.push(L(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(u)} matched no governed files and has no createOrderPlane factory.`,{target:u},r));continue}f.some(d=>d.hasPlaneFactory)||n.push(L(t,"arkorder-missing-plane",f[0].file,1,`ArkOrder plane root ${JSON.stringify(u)} has no createOrderPlane factory.`,{target:u},r))}}let o=new Map(e.layers.map(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let u=c.specifier;if(!u||!ue(u))continue;let f=e.layerForFile(c.from);f&&Gs(f,o.get(f)??[])&&n.push(L(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:f,target:u},r))}for(let c of e.genericUpdates)n.push(L(t,"arkorder-generic-update",c.file,c.line,`Generic ${c.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:c.method},r));let i=t.xiKeys??[];for(let c of e.releaseKeyCounts??[])c.keyCount<=t.maxXiKeys||n.push(L(t,"arkorder-too-many-params",c.file,c.line,`release() freezes ${c.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(c.keyCount)},r));for(let c of e.ingestWritesXi??[])n.push(L(t,"arkorder-ingest-writes-xi",c.file,c.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let l=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let u=e.layerForFile(c.file);!u||!l.has(u)||Vs(c.file,t.appliesTo)&&n.push(L(t,"arkorder-xi-field-write",c.file,c.line,`This file writes ${JSON.stringify(c.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:u,target:c.key},r))}return n.sort((c,u)=>c.file.localeCompare(u.file)||c.ruleId.localeCompare(u.ruleId)||c.line-u.line),{findings:n,completenessReasons:[]}}a(Bs,"evaluateArkOrderSensors");function Xt(e){if(!e.arkOrder)return[];let t=Vt(e.file,e.source),r=Gt(e.file,e.source),n=e.arkOrder.xiKeys??[];return Bs({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:Bt(e.file,e.source,n),ingestWritesXi:Wt(e.file,e.source),releaseKeyCounts:zt(e.file,e.source),dependencies:[],layerForFile:a(()=>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")}a(Xt,"evaluateArkOrderEditorSensors");function Ws(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}a(Ws,"eslintSourceText");function Jt(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 l=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,l))return{};let c=E(l,i.layers);return{ImportDeclaration(u){let f=typeof u.source?.value=="string"?u.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!ue(f)||c!=="DomainModel"&&!/^domain/i.test(c??""))return;e.reportAdapterDiagnostic(n,u,"denied",{ruleId:r,file:l,line:u.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let u=Ws(n),f=Xt({arkOrder:i.arkOrder,file:l,source:u,fromLayer:c}).filter(d=>d.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let d of f)e.reportAdapterDiagnostic(n,{loc:{start:{line:d.line}}},"denied",{ruleId:d.ruleId,file:d.file,line:d.line,message:d.message})}}}}}return a(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}a(Jt,"createArkOrderEslintRules");function $(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""}a($,"lintedFilename");function T(e,t,r,n,s){let o=xt({...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}a(T,"reportAdapterDiagnostic");function V(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(_.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}a(V,"findConfigPath");var Qt=new Map;function G(e){if(!_.default.existsSync(e))return null;let t=_.default.readFileSync(e,"utf8"),r=Qt.get(e);if(r?.source===t)return r.config;let n=It(t,e).config;return Qt.set(e,{source:t,config:n}),n}a(G,"loadArkConfig");function re(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!nt(t,e)}a(re,"sourceIsInAnalysisScope");function er(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(_.default.existsSync(r)&&_.default.statSync(r).isFile())return r}catch{}return null}a(er,"existingSourceFile");function tr(e){let t=m.default.resolve(e),r=null;for(;;){let u=m.default.join(t,"tsconfig.json");if(_.default.existsSync(u)){r=u;break}let f=m.default.dirname(t);if(f===t)break;t=f}if(!r)return{baseUrl:e,aliases:[]};let n=a(u=>{try{let f=_.default.readFileSync(u,"utf8");return f=f.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(f)}catch{return null}},"loadJsonc"),s=a((u,f)=>{if(f>4)return{};let d=n(u);if(!d)return{};let p=d.compilerOptions??{},g=p.baseUrl,y=p.paths,h=d.extends;if(typeof h=="string"&&!h.startsWith("@")){let R=m.default.resolve(m.default.dirname(u),h.endsWith(".json")?h:`${h}.json`);if(_.default.existsSync(R)){let S=s(R,f+1);g=g??S.baseUrl,y={...S.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),l=m.default.resolve(i,o.baseUrl||"."),c=[];for(let[u,f]of Object.entries(o.paths||{})){if(!Array.isArray(f)||f.length===0)continue;let d=u.replace(/\*$/,"");d&&c.push({from:d,to:String(f[0]).replace(/\*$/,"")})}return c.sort((u,f)=>f.from.length-u.from.length),{baseUrl:l,aliases:c}}a(tr,"readTsconfigPathAliases");function rr(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return er(r)}a(rr,"resolveRelativeImport");function Ke(e,t,r){if(!t)return null;if(t.startsWith("."))return rr(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=tr(n),i=o.find(c=>t.startsWith(c.from));if(!i)return null;let l=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return er(l)}a(Ke,"resolveImportSpecifier");function ge(e){return typeof e?.value=="string"?e.value:void 0}a(ge,"stringValue");function Me(e){return e?.name??ge(e)}a(Me,"propertyName");function Ue(e){return e.sourceCode??e.getSourceCode?.()}a(Ue,"sourceCodeFor");function nr(e,t){let r=Ue(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}a(nr,"referenceFor");function te(e,t,r){let n=nr(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Ue(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}a(te,"isLocallyBound");function zs(e,t){let r=nr(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(zs,"isValueIdentifierReference");function sr(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=sr(e.object),n=Me(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}a(sr,"memberExpressionPath");function qs(e){return Me(e.callee?.property)}a(qs,"calleePropertyName");function or(e,t){return e?.properties?.find(r=>Me(r.key)===t)}a(or,"objectProperty");function fe(e,t){return or(e,t)!==void 0}a(fe,"objectHasProperty");function Zs(e){let t=or(e,"metadata")?.value;return fe(t,"source")}a(Zs,"objectHasMetadataSource");function ir(e){return qs(e)==="publish"}a(ir,"isPublishCall");function $e(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")}a($e,"declarationIsTypeOnly");function Ys(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(Ys,"containingProgram");function Xs(e){let t=Ys(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!$e(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(!$e(n))return!1;r=!0;continue}return!1}}return r}a(Xs,"sourceProgramExportsOnlyTypes");var ar={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=$(e),r=V(t),n=r?G(r):null,s=r?m.default.dirname(r):null,o=a(i=>{let l=ge(i.source);if(l&&n&&s&&t){let c=m.default.isAbsolute(t)?t:m.default.resolve(t),u=m.default.relative(s,c).split(m.default.sep).join("/");if(!re(n,u))return;let f=E(u,n.layers);if(!f)return;let d=Ke(c,l,s);if(!d)return;let p=m.default.relative(s,d).split(m.default.sep).join("/");if(p.startsWith(".."))return;let g=E(p,n.layers);if(!g)return;let y={fromPath:u,toPath:p,layers:n.layers},h=Ae(n.rules,f,g,y),R=h?.rule;if(R){let S=i.type?.startsWith("Export")?"export":"import",N=$e(i),B=!!R?.peerIsolation,me=N&&!B,W=h?.sliceVerdict,k=W?et({surface:"import",verdict:W,fromLayer:f,toLayer:g,kind:S,fromPath:u,toPath:p,ruleMessage:R?.message}):R?.message??`${f} must not ${S} ${g}.`;T(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:u,fromLayer:f,toLayer:g,target:p,edgeKind:S,...B?{peerIsolation:!0}:{},...N?{typeOnly:!0}:{},...tt(W),...me?{failsStrict:!1,severity:"warning"}:{},...Xs(i)?{sourcePureTypeModule:!0}:{},message:me?`${k} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:k},{fromLayer:f,toLayer:g,specifier:l})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},lr={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=ge(r),s=_e({publishCall:ir(t),rawIntentName:n,objectHasIntent:fe(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");T(e,t,"rawPublish",{...o,file:$(e)})}}}}},cr={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=_e({publishCall:ir(t),rawIntentName:ge(r),objectHasIntent:fe(r,"intent"),arkPublishCandidate:!0,hasSource:Zs(r)||fe(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&T(e,t,"missingSource",{...o,file:$(e)})}}}},dr={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=$(e),r=e.options?.[0],n=V(t),s=n?G(n):null,o=n?m.default.dirname(n):null,i=null,l="this layer";if(s&&o&&t){let d=m.default.isAbsolute(t)?t:m.default.resolve(t),p=m.default.relative(o,d).split(m.default.sep).join("/");if(!re(s,p))return{};let g=s.layers?.find(y=>y.name===E(p,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),l=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let c=typeof Ue(e)?.getScope=="function",u=a((d,p)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;T(e,d,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:l,target:p,message:`${l} must not use the ambient global "${p}".`},{name:p,layer:l})},"report"),f=a((d,p,g,y)=>{if(g||typeof p!="string")return;let h=Se(p,i);if(!h)return;let R=m.default.isAbsolute(t)?t:m.default.resolve(t),S=o?m.default.relative(o,R).split(m.default.sep).join("/"):t;T(e,d,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:S,fromLayer:l,target:p,edgeKind:y,message:`${l} must not use module "${p}" because it is the import form of forbidden global "${h}".`},{layer:l,name:h,specifier:p,importKind:y})},"reportModule");return{MemberExpression(d){if(d.parent?.type==="MemberExpression"&&d.parent.object===d)return;let p=sr(d);if(!p||te(e,p.root,p.segments[0]))return;let g=p.segments[0]==="globalThis",y=g?p.segments.slice(1):p.segments,h;for(let R=y.length;R>=(g?1:2);R-=1){let S=y.slice(0,R).join(".");if(i.has(S)){h=S;break}}h?u(d,h):!c&&i.has(p.segments[0])&&u(d,p.segments[0])},CallExpression(d){let p=d;if(p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!te(e,d,"require")&&f(d,p.arguments[0].value,!1,"require"),c)return;let g=p.callee?.type==="Identifier"?p.callee.name:void 0;g&&i.has(g)&&u(d,g)},ImportDeclaration(d){let p=d,g=(p.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),y=g.length>0&&g.length===(p.specifiers??[]).length&&g.every(h=>h.importKind==="type");f(d,p.source?.value,p.importKind==="type"||y,"import")},ImportExpression(d){let p=d;p.source?.type==="Literal"&&f(d,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let p=d;f(d,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let p=d;if(!p.source)return;let g=p.specifiers??[],y=g.length>0&&g.every(h=>h.exportKind==="type");f(d,p.source.value,p.exportKind==="type"||y,"export")},ExportAllDeclaration(d){let p=d;f(d,p.source?.value,p.exportKind==="type","export")},NewExpression(d){if(c)return;let p=d.callee?.type==="Identifier"?d.callee.name:void 0;p&&i.has(p)&&u(d,p)},Identifier(d){!c||!d.name||!i.has(d.name)||!zs(e,d)||te(e,d,d.name)||u(d,d.name)}}}},ur={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=$(e),r=V(t),n=r?G(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(!re(n,i))return{};let l=n.layers?.find(f=>f.name===E(i,n.layers));if(!l)return{};let c=new Set(it(l));if(c.size===0)return{};let u=a((f,d,p,g)=>{if(p||typeof d!="string"||Se(d,l.forbiddenGlobals??[]))return;let y=ot(d);!y||!c.has(y)||T(e,f,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:l.name,target:d,capability:y,edgeKind:g,message:`${l.name} denies the ${y} capability; found import of "${d}".`},{layer:l.name,capability:y,specifier:d})},"check");return{ImportDeclaration(f){let d=f,p=(d.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=p.length>0&&p.length===(d.specifiers??[]).length&&p.every(y=>y.importKind==="type");u(f,d.source?.value,d.importKind==="type"||g,"import")},ImportExpression(f){let d=f;d.source?.type==="Literal"&&u(f,d.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(f){let d=f;u(f,d.moduleReference?.expression?.value,d.importKind==="type"||d.isTypeOnly===!0,"require")},ExportNamedDeclaration(f){let d=f;if(!d.source)return;let p=d.specifiers??[],g=p.length>0&&p.every(y=>y.exportKind==="type");u(f,d.source.value,d.exportKind==="type"||g,"export")},ExportAllDeclaration(f){let d=f;u(f,d.source?.value,d.exportKind==="type","export")},CallExpression(f){let d=f;d.callee?.type==="Identifier"&&d.callee.name==="require"&&d.arguments?.[0]?.type==="Literal"&&!te(e,f,"require")&&u(f,d.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:fr,noArkRunDirectNew:pr,noArkRunTransportBypass:gr}=Ht({findConfigPath:V,loadArkConfig:G,resolveImportSpecifier:Ke,lintedFilename:$,sourceIsInAnalysisScope:re,isLocallyBound:te,reportAdapterDiagnostic:T});function Js(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("/")}a(Js,"toProjectRelative");var{noArkOrderKernelInDomain:mr,noArkOrderGenericUpdate:yr}=Jt({findConfigPath:V,loadArkConfig:G,lintedFilename:$,sourceIsInAnalysisScope:re,reportAdapterDiagnostic:T,toProjectRelative:Js});var Qs={"no-domain-infra-imports":ar,"no-raw-event-publish":lr,"require-publish-source":cr,"no-forbidden-globals":dr,"no-denied-capabilities":ur,"no-arkrun-kernel-in-domain":fr,"no-arkrun-direct-new":pr,"no-arkrun-transport-bypass":gr,"no-arkorder-kernel-in-domain":mr,"no-arkorder-generic-update":yr},pe={rules:Qs};pe.configs={recommended:{plugins:{ark:pe},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 eo=pe;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
|