arkgate 4.8.9 → 4.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +111 -3
  2. package/README.md +5 -4
  3. package/bin/ark-check-runtime.mjs +8 -2
  4. package/bin/ark-check.mjs +3 -0
  5. package/bin/ark.mjs +18 -10
  6. package/bin/lib/adapter-contract-types.mjs +137 -0
  7. package/bin/lib/adapter-contract.mjs +4 -180
  8. package/bin/lib/adapter-finding-refs.mjs +63 -0
  9. package/bin/lib/agent-projection-formatters.mjs +151 -0
  10. package/bin/lib/agent-projection-merge.mjs +148 -0
  11. package/bin/lib/agent-projection-types.mjs +42 -0
  12. package/bin/lib/agent-projection.mjs +3 -309
  13. package/bin/lib/analysis-engine.mjs +6 -6
  14. package/bin/lib/architecture-scan.mjs +91 -4
  15. package/bin/lib/ark-order-facts.mjs +11 -4
  16. package/bin/lib/arkrule-file-hints.mjs +255 -20
  17. package/bin/lib/arkrules-sensors.mjs +364 -68
  18. package/bin/lib/baseline-key.mjs +45 -1
  19. package/bin/lib/config-contract.mjs +9 -3
  20. package/bin/lib/diagnostic-catalog.mjs +1 -0
  21. package/bin/lib/doctor-human.mjs +3 -3
  22. package/bin/lib/doctor-next-actions.mjs +3 -1
  23. package/bin/lib/field-install.mjs +23 -2
  24. package/bin/lib/first-run-help.mjs +69 -5
  25. package/bin/lib/project-root.mjs +70 -4
  26. package/bin/lib/resolved-candidate-facts.mjs +82 -1
  27. package/bin/lib/rules-inventory.mjs +7 -3
  28. package/bin/lib/upstream-report.mjs +330 -0
  29. package/bin/lib/violations.mjs +51 -15
  30. package/dist/{diagnosticCatalog-BrkOiwCk.d.ts → diagnosticCatalog-DiflIock.d.ts} +30 -41
  31. package/dist/eslint/index.cjs +4 -7
  32. package/dist/eslint/index.js +4 -7
  33. package/dist/index.cjs +28 -31
  34. package/dist/index.d.ts +52 -13
  35. package/dist/index.js +28 -31
  36. package/dist/nestjs/index.cjs +1 -1
  37. package/dist/nestjs/index.js +1 -1
  38. package/dist/runtime/index.cjs +11 -11
  39. package/dist/runtime/index.d.ts +1 -1
  40. package/dist/runtime/index.js +11 -11
  41. package/docs/README.md +3 -3
  42. package/docs/agent-guide.md +25 -1
  43. package/docs/ai-gates.md +8 -0
  44. package/docs/brownfield-adoption.md +30 -0
  45. package/docs/configuration.md +14 -1
  46. package/docs/diagnostics.md +10 -0
  47. package/docs/package-surface.md +5 -3
  48. package/docs/use.md +11 -0
  49. package/package.json +3 -2
  50. package/schemas/ark.config.schema.json +3 -2
  51. package/server.json +2 -2
  52. package/templates/agent-skills/ark-explore/SKILL.md +22 -1
  53. package/templates/skills/ark-explore.md +22 -1
@@ -1,8 +1,5 @@
1
- var vt=Object.defineProperty;var c=(e,t)=>vt(e,"name",{value:t,configurable:!0});import C from"fs";import m from"path";var Ie=new Map;function xe(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(xe,"escapeLiteral");function X(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(X,"normalizeGlobSeparators");function Lt(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(Lt,"bracesBalanced");function _(e){let t=Ie.get(e);if(t)return t;let r=X(e),n=Lt(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=xe(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=xe(l)}let i=new RegExp(`^${s}$`);return Ie.set(e,i),i}c(_,"globToRegExp");function Tt(e){return X(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}c(Tt,"concreteGlobSegments");function we(e,t){let r=X(String(e)),n=Tt(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let u of n){let d=-1;for(let p=a;p<i.length;p+=1)if(i[p]===u){d=p;break}if(d<0)return o;l=d,a=d+1}return(l+1)*1e6+n.length*1e4+s}c(we,"patternSpecificity");function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>_(i).test(r))){for(let i of o.patterns??[])if(_(i).test(r)){let a=we(i,r);a>s&&(s=a,n=o.name)}}return n}c(S,"layerForRelativePath");function Ne(e,t){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean),n=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<r.length-1;s+=1)if(n.has(r[s].toLowerCase()))return`${r[s].toLowerCase()}/${r[s+1].toLowerCase()}`}c(Ne,"sliceIdForPath");function Dt(e){let t=new Set;for(let r of e??[]){let s=X(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}c(Dt,"inferSliceFoldersFromPatterns");function Ft(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 Dt(n?.patterns)}c(Ft,"resolveSliceFolders");function _e(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}c(_e,"normalizeSegments");function ve(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}c(ve,"trimTrailingSlashes");var Kt=["src","app"];function Pt(e){let t=ve(e.replace(/^[./]+/,""));return t==="*"||t==="**"}c(Pt,"isBlanketRoot");function Oe(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=_e(r);for(let o of t){if(typeof o!="string"||o.length===0||Pt(o))continue;if(o.includes("*")){let l=ve(o.toLowerCase());if(_(l).test(n)||_(`${l}/**`).test(n))return!0;continue}let i=_e(o);if(i.length===0)continue;let a=Kt.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let l of a){if(l+i.length>s.length)continue;let u=!0;for(let d=0;d<i.length;d+=1)if(s[l+d]!==i[d]){u=!1;break}if(u)return!0}}return!1}c(Oe,"pathUnderSharedRoot");function Ce(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}c(Ce,"sliceMatchesDeclaration");function Mt(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Ce(n.from,t)&&Ce(n.to,r))}c(Mt,"crossSliceEdgeAllowed");function $t(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}c($t,"peerIsolationDecision");function Le(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}c(Le,"peerIsolationDenyExplanation");function Ut(e,t,r,n){return ae(e,t,r,n)?.rule}c(Ut,"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,a=Ft(s,t,n?.layers),l=o?Ne(o,a):void 0,u=i?Ne(i,a):void 0,d=$t({fromPath:o,toPath:i,folderCount:a.length,fromSlice:l,toSlice:u,fromShared:!l&&Oe(o,s.sharedRoots),toShared:!u&&Oe(i,s.sharedRoots),crossSliceAllowed:Mt(s.allowedCrossSlice,l,u)});if(d.denied)return{rule:s,peerIsolationReason:d.reason,fromSlice:l,toSlice:u};continue}if(t!==r)return{rule:s}}}c(ae,"findDeniedEdgeDecision");function Ht(e,t,r,n){return Ut(e,t,r,n)!==void 0}c(Ht,"isEdgeDenied");var jt=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Vt(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:jt,...t]}c(Vt,"scanExcludePatterns");function Te(e,t){let r=String(e).split(/[/\\]/).join("/");return Vt(t).some(n=>_(n).test(r))}c(Te,"isScanExcludedRelative");var De=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Bt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Sn=Object.freeze(Object.keys(Bt).sort()),le=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"}),Gt=Object.freeze({process:Object.freeze(["process","node:process"])});function Fe(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=le[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=le[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:le[e.slice(0,o)]??null}c(Fe,"capabilityForModuleSpecifier");function ce(e,t){for(let r of t)if(Gt[r]?.includes(e))return r;return null}c(ce,"forbiddenGlobalForModuleSpecifier");function Ke(e){if(e?.pure===!0)return[...De].sort();let r=(e?.capabilities?.deny??[]).filter(n=>De.includes(n));return[...new Set(r)].sort()}c(Ke,"effectiveCapabilityDeny");var L={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Pe={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...L,default:[]},kernelRoots:{...L},managedLayers:{...L,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Me={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...L,default:[]},managedLayers:{...L,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...L,default:[]},appliesTo:{...L,default:[]}}};function H(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(H,"isObject");function $e(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}c($e,"declaredLayerNames");function Ue(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}}c(Ue,"defaultedArkRun");function He(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}}c(He,"defaultedArkOrder");function je(e,t){let r=e.arkRun;if(r===void 0||!H(r))return;let n=$e(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(je,"validateArkRunExtra");function Ve(e,t){let r=e.arkOrder;if(r===void 0||!H(r))return;let n=$e(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Ve,"validateArkOrderExtra");var I="1.3",de="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",Be=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Wt=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function zt(){let e=[];for(let t of Be)for(let r of Be)t===r||Wt.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}c(zt,"createDefaultRules");var We=zt(),ue=[{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},Ge={$schema:"https://json-schema.org/draft/2020-12/schema",$id:de,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:de,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:We,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:[]}},$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},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},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}}}}}},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; coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.",properties:{testGlobs:{...E,minItems:1},maxFiles:{type:"integer",minimum:1},coverageRoots:{...E,minItems:1}}},arkRun:Pe,arkOrder:Me}},x=class extends Error{static{c(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
1
+ var Lt=Object.defineProperty;var c=(e,t)=>Lt(e,"name",{value:t,configurable:!0});import C from"fs";import m from"path";var _e=new Map;function Ne(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(Ne,"escapeLiteral");function Z(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(Z,"normalizeGlobSeparators");function Dt(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(Dt,"bracesBalanced");function N(e){let t=_e.get(e);if(t)return t;let r=Z(e),n=Dt(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=Ne(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=Ne(l)}let i=new RegExp(`^${s}$`);return _e.set(e,i),i}c(N,"globToRegExp");function Ft(e){return Z(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}c(Ft,"concreteGlobSegments");function Te(e,t){let r=Z(String(e)),n=Ft(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,l=-1;for(let p of n){let u=-1;for(let d=a;d<i.length;d+=1)if(i[d]===p){u=d;break}if(u<0)return o;l=u,a=u+1}return(l+1)*1e6+n.length*1e4+s}c(Te,"patternSpecificity");function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>N(i).test(r))){for(let i of o.patterns??[])if(N(i).test(r)){let a=Te(i,r);a>s&&(s=a,n=o.name)}}return n}c(S,"layerForRelativePath");function Oe(e,t){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean),n=new Set(t.map(s=>String(s).toLowerCase()));for(let s=0;s<r.length-1;s+=1)if(n.has(r[s].toLowerCase()))return`${r[s].toLowerCase()}/${r[s+1].toLowerCase()}`}c(Oe,"sliceIdForPath");function Pt(e){let t=new Set;for(let r of e??[]){let s=Z(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}c(Pt,"inferSliceFoldersFromPatterns");function Kt(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 Pt(n?.patterns)}c(Kt,"resolveSliceFolders");function Ce(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}c(Ce,"normalizeSegments");function Le(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}c(Le,"trimTrailingSlashes");var Mt=["src","app"];function $t(e){let t=Le(e.replace(/^[./]+/,""));return t==="*"||t==="**"}c($t,"isBlanketRoot");function we(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ce(r);for(let o of t){if(typeof o!="string"||o.length===0||$t(o))continue;if(o.includes("*")){let l=Le(o.toLowerCase());if(N(l).test(n)||N(`${l}/**`).test(n))return!0;continue}let i=Ce(o);if(i.length===0)continue;let a=Mt.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let l of a){if(l+i.length>s.length)continue;let p=!0;for(let u=0;u<i.length;u+=1)if(s[l+u]!==i[u]){p=!1;break}if(p)return!0}}return!1}c(we,"pathUnderSharedRoot");function ve(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}c(ve,"sliceMatchesDeclaration");function Ut(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&ve(n.from,t)&&ve(n.to,r))}c(Ut,"crossSliceEdgeAllowed");function Ht(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}c(Ht,"peerIsolationDecision");function De(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}c(De,"peerIsolationDenyExplanation");function jt(e,t,r,n){return ie(e,t,r,n)?.rule}c(jt,"findDeniedEdgeRule");function ie(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=Kt(s,t,n?.layers),l=o?Oe(o,a):void 0,p=i?Oe(i,a):void 0,u=Ht({fromPath:o,toPath:i,folderCount:a.length,fromSlice:l,toSlice:p,fromShared:!l&&we(o,s.sharedRoots),toShared:!p&&we(i,s.sharedRoots),crossSliceAllowed:Ut(s.allowedCrossSlice,l,p)});if(u.denied)return{rule:s,peerIsolationReason:u.reason,fromSlice:l,toSlice:p};continue}if(t!==r)return{rule:s}}}c(ie,"findDeniedEdgeDecision");function Vt(e,t,r,n){return jt(e,t,r,n)!==void 0}c(Vt,"isEdgeDenied");var Bt=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Gt(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Bt,...t]}c(Gt,"scanExcludePatterns");function Fe(e,t){let r=String(e).split(/[/\\]/).join("/");return Gt(t).some(n=>N(n).test(r))}c(Fe,"isScanExcludedRelative");var Pe=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),Wt=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Mn=Object.freeze(Object.keys(Wt).sort()),ae=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"}),zt=Object.freeze({process:Object.freeze(["process","node:process"])});function Ke(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=ae[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=ae[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:ae[e.slice(0,o)]??null}c(Ke,"capabilityForModuleSpecifier");function le(e,t){for(let r of t)if(zt[r]?.includes(e))return r;return null}c(le,"forbiddenGlobalForModuleSpecifier");function Me(e){if(e?.pure===!0)return[...Pe].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Pe.includes(n));return[...new Set(r)].sort()}c(Me,"effectiveCapabilityDeny");var v={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},$e={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...v,default:[]},kernelRoots:{...v},managedLayers:{...v,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Ue={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...v,default:[]},managedLayers:{...v,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...v,default:[]},appliesTo:{...v,default:[]}}};function $(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c($,"isObject");function He(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)$(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}c(He,"declaredLayerNames");function je(e){if(!$(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}c(je,"defaultedArkRun");function Ve(e){if(!$(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}c(Ve,"defaultedArkOrder");function Be(e,t){let r=e.arkRun;if(r===void 0||!$(r))return;let n=He(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Be,"validateArkRunExtra");function Ge(e,t){let r=e.arkOrder;if(r===void 0||!$(r))return;let n=He(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}c(Ge,"validateArkOrderExtra");var I="1.3",ce="https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",We=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],qt=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Zt(){let e=[];for(let t of We)for(let r of We)t===r||qt.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}c(Zt,"createDefaultRules");var qe=Zt(),ue=[{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},ze={$schema:"https://json-schema.org/draft/2020-12/schema",$id:ce,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:ce,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:qe,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:[]}},$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},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},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}}}}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}},coverage:{type:"object",additionalProperties:!1,description:"Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget and also bounds structural-hint preload for orchestration-only, thin-adapter, and writes-via-aggregate (default 400; there is no arkrules.hintBudget); coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant.",properties:{testGlobs:{...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:$e,arkOrder:Ue}},x=class extends Error{static{c(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
2
2
  ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
3
- `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function ze(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(ze,"isObject");function J(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}c(J,"propertyPath");function K(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(K,"valueType");function qt(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}c(qt,"resolveSchemaRef");function j(e,t,r,n,s){if(t.$ref){let o=qt(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}j(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(!ze(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:J(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:J(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||j(e[a],i,J(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&j(e[i],a,J(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${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)=>j(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}`})}}c(j,"validateNode");function Zt(e){let t={...e,$schema:e.$schema===void 0?de: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?We.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Ue(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=He(e.arkOrder)),t}c(Zt,"defaultedConfig");function Yt(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(Yt,"migratedFromOf");function Xt(){let e=new Set([I]);for(let t of ue)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}c(Xt,"knownInputVersions");function Jt(e,t="ark.config.json"){if(!ze(e))throw new x(t,[{path:"$",message:`must be an object; received ${K(e)}`}]);let r=Xt(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ue.length+1;){i+=1;let a=ue.find(l=>l.from===s);if(!a)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:Zt(o),migratedFrom:Yt(n)}}c(Jt,"migrateArkConfig");function Qt(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Jt(e,t),s=[];if(j(r,Ge,"$",Ge,s),je(r,s),Ve(r,s),s.length>0)throw new x(t,s);return{config:r,migratedFrom:n}}c(Qt,"loadArkConfigContract");function qe(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new x(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Qt(r,t)}c(qe,"parseArkConfigJson");var er=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,tr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,rr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function nr(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return er.test(r)?"pure-shared":n==="PersistenceAdapters"&&(tr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":rr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(nr,"classifyLayerImportKind");function sr(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=nr(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}c(sr,"layerImportNextAction");function or(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(or,"arkRunCallSiteName");function ir(e){let t=or(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(ir,"arkRunNextAction");function P(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return sr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return ir(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"Use release() for the first freeze of \u03BE. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.";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?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again. Never mechanical-safe.";case"ARKORDER_UNVALVED_RELEASE":return"Change \u03BE with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(P,"deterministicNextAction");var ar="docs/diagnostics.md";function R(e){return typeof e=="string"&&e.length>0?e:void 0}c(R,"text");function Ze(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}c(Ze,"positiveInteger");function lr(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}c(lr,"adapterFindingTargetKey");function cr(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}c(cr,"adapterFindingRefFromTargetKey");function dr(e){return`${ar}#${e}`}c(dr,"adapterDocsCodePath");function ur(e,t,r){return P({ruleId:e,target:R(t.target)??R(r.target)??void 0,fromLayer:R(t.fromLayer)??void 0,toLayer:R(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:R(t.edgeKind)??void 0,capability:R(t.capability)??R(r.capability)??void 0,arkruleId:R(t.arkruleId)??void 0,arkruleSource:R(t.arkruleSource)??void 0})}c(ur,"nextActionForDiagnostic");function Ye(e,t="error",r){let n=R(e.ruleId)??R(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...R(e.target)?{target:R(e.target)}:{},...R(e.fromLayer)?{fromLayer:R(e.fromLayer)}:{},...R(e.toLayer)?{toLayer:R(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}:{},...R(e.capability)?{capability:R(e.capability)}:{},...R(e.edgeKind)?{edgeKind:R(e.edgeKind)}:{},...R(e.arkruleId)?{arkruleId:R(e.arkruleId)}:{},...R(e.arkruleSource)?{arkruleSource:R(e.arkruleSource)}:{}},i=r??lr(e),a=cr(i);return{ruleId:n,severity:s,message:R(e.message)??n,location:{file:R(e.file)??"<unknown>",line:Ze(e.line,1),column:Ze(e.column,1)},evidence:o,nextAction:R(e.nextAction)??ur(n,o,e),findingRef:a,targetKey:i,docsCodePath:dr(n)}}c(Ye,"toAdapterDiagnostic");var Xe={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."},Kn=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 pr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(pr,"looksLikeArkIntent");function pe(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&pr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Xe.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Xe.PUBLISH_MISSING_SOURCE}),t}c(pe,"classifyPublishFacts");import at from"fs";import T from"path";var fr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var gr=new Set(fr),mr=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"]),yr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function M(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c(M,"isArkRunKernelModuleSpecifier");var Rr=["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"],fe=new Set(Rr);function et(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(fe.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(fe.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:fe.has(e.slice(0,n))}c(et,"isArkRunTransportBypassSpecifier");function Je(e){if(gr.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}c(Je,"arkRunKernelCallKind");function tt(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}c(tt,"lineAt");function ge(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(ge,"stripCommentsPreservingLines");function hr(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}c(hr,"firstStringLiteralArg");function Qe(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}c(Qe,"keywordBefore");function Q(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}c(Q,"parseValueImportClause");function rt(e,t){Q(ge(e),t)}c(rt,"forEachArkRunValueImportClause");function Ar(e){let t=new Map,r=new Set;return Q(e,(n,s)=>{if(!M(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let u=l.trim();if(!u||u.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);if(d){t.set(d[2],d[1]);continue}let p=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(u);p?.[1]&&t.set(p[1],p[1])}}),{named:t,namespaces:r}}c(Ar,"collectKernelImportBindings");function kr(e,t){let r=new Set(t);return Q(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),u=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=l?.[1]??u;!u||!d||!/^[A-Z]/.test(d)||(M(s)||t.has(d)||t.has(u))&&(r.add(u),r.add(d))}}),r}c(kr,"collectImportedConstructors");function br(e,t){let r;return Q(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}c(br,"importedFromForName");function ee(e,t){let r=ge(t),n=Ar(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],l=i.index;if(Qe(r,l,"function")||Qe(r,l,"class"))continue;let d=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],p=n.named.get(a)??a,f=Je(p)??Je(a);if(!f)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(f!=="factory"&&(!g&&d===void 0||d&&yr.has(d)&&!g))continue;let y=hr(r,l+i[0].length);s.push({file:e,line:tt(t,l),kind:f,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}c(ee,"extractArkRunKernelCallsFromSource");function me(e,t,r){let n=ge(t),s=kr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(mr.has(l)||!s.has(l))continue;let u=br(n,l);o.push({file:e,line:tt(t,a.index),typeName:l,...u?{importedFrom:u}:{}})}return o}c(me,"extractArkRunManagedNewsFromSource");function ye(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,l=i;for(;l<t.length&&a>0;){let b=t[l];b==="{"?a+=1:b==="}"&&(a-=1),l+=1}let u=t.slice(i,l-1),d=u.split(`
4
- `).map(b=>/^\s*\/\//.test(b)||/^\s*\/\*|\*\//.test(b)?b:b.replace(/(?:public\s+|protected\s+)?readonly\s+[a-zA-Z_][a-zA-Z0-9_]*\s*(?::[^=;]+)?(?:=\s*[^;]+)?[;,]?/g,"").replace(/(?:^|[\s;{])readonly\s+[a-zA-Z_][a-zA-Z0-9_]*\s*(?::[^=;]+)?(?:=\s*[^;]+)?[;,]?/g," ")).join(`
5
- `),p=/(?:^|\n)\s*(?:public\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/m.test(d.replace(/(?:public\s+|private\s+|protected\s+|static\s+|async\s+|get\s+|set\s+)/g,""))&&/(?:^|\n)\s*(public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/m.test(d),f=/(?:^|\n)\s*public\s+(?!static|async|get|set|constructor|readonly)[a-zA-Z_]/.test(d)||/(?:^|[\n;])\s*[a-zA-Z_][a-zA-Z0-9_]*\s*:\s*[^=;\n]+[;=]/m.test(d.split(`
6
- `).filter(b=>!/^\s*(private|protected|static|constructor|get |set |async |\/)/.test(b)).join(`
7
- `)),g=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(u),y=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(u),h=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(u)&&!y,A=/(?:^|[\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),k=[],Z=new Set(["if","match","when"]),$=/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+|async\s+)*(?!constructor|get|set|static)([a-zA-Z_][a-zA-Z0-9_]*)\s*\([^)]*\)\s*(?::\s*[^{]+)?\{/g,v;for(;(v=$.exec(u))!==null;){let b=v[1];if(Z.has(b))continue;let Ee=v.index+v[0].length,ie=1,U=Ee;for(;U<u.length&&ie>0;)u[U]==="{"?ie+=1:u[U]==="}"&&(ie-=1),U+=1;let Se=u.slice(Ee,U-1);if(!/this\.\w+\s*=/.test(Se))continue;let wt=/\b(ensureInvariants|assertInvariants|validate|publish|emit|raise|record)\b/.test(Se);k.push({name:b,referencesGuardOrPublish:wt})}let F=(u.match(/(?:^|\n)\s*(?:public\s+|private\s+|protected\s+)?(?:async\s+)?[a-zA-Z_][a-zA-Z0-9_]*\s*\(/g)??[]).length,Y=(d.match(/(?:^|[\n;])\s*(?:public\s+)?(?!constructor|static|get|set|private|protected|readonly)[a-zA-Z_][a-zA-Z0-9_]*\s*[:=]/g)??[]).length,Ct=F<=1&&Y>=2&&(f||p);r.push({file:e,className:o,exported:!0,hasPublicMutableFields:f||p,hasPublicSetters:g,hasPublicConstructor:h,hasStaticFactory:A,mutatingMethods:[...k],dataOnly:Ct})}return r}c(ye,"extractClassShapesFromSource");function Er(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}c(Er,"normalizeExtraMergeTeethClassification");function te(e){let t=Er(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}c(te,"extraMergeTeethAllowed");var Sr=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],Ir=new Set(Sr);function xr(e){return Ir.has(e)}c(xr,"isArkRunEditorSensor");var nt={"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"},Nr="ARKRUN_INTERACTION_NAME_INCOMPLETE";function it(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(it,"isDomainRoleLayer");function _r(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}c(_r,"compareFindings");function N(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:nt[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:P({ruleId:nt[t],fromLayer:o?.fromLayer,target:o?.target})}}c(N,"finding");function Or(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}c(Or,"bagForFile");function st(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}c(st,"emitKinds");function ot(e){return e==="subscribe"||e==="register-handler"}c(ot,"handleKinds");function Cr(e){return e==="resolve"||e==="resolve-singleton"}c(Cr,"dependKinds");function wr(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(N(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let a=o.get(i.matchedRoot)??[];a.push(i),o.set(i.matchedRoot,a)}for(let i of s){let a=[...o.get(i)??[]].sort((u,d)=>u.file.localeCompare(d.file));if(a.length===0){n.push(N(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(a.some(u=>u.hasKernelFactory))continue;let l=a[0];n.push(N(e,"arkrun-missing-root",l.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}c(wr,"evaluateMissingRoot");function vr(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let l=a.specifier;if(!l||!M(l))continue;let u=n(a.from);u&&it(u,o.get(u)??[])&&i.push(N(e,"arkrun-kernel-in-domain",a.from,a.line,`${u} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:u,target:l},s))}return i}c(vr,"evaluateKernelInDomain");function Lr(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(t.map(d=>[d.name,d.intentPrefixes??[]])),l=new Set(n.filter(d=>d.hasKernelFactory).map(d=>d.file)),u=[];for(let d of r){if(l.has(d.file))continue;let p=d.typeName;if(e.ignoreDirectNewForErrors!==!1&&(p.endsWith("Error")||p==="Error")||p.endsWith("DTO")||p.endsWith("VO"))continue;let f=s(d.file);!f||!i.has(f)||it(f,a.get(f)??[])||u.push(N(e,"arkrun-direct-new",d.file,d.line,`${f} must not construct ${d.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:f,target:d.typeName},o))}return u}c(Lr,"evaluateDirectNew");function Tr(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let l of t){if(!st(l.kind)&&!ot(l.kind)&&!Cr(l.kind))continue;let u=n(l.file);if(!u||!a.has(u))continue;if(!l.nameLiteral){e.mode==="enforced"&&i.push({code:Nr,file:l.file,message:`ArkRun ${l.kind} call in ${l.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let d=Or(r,l.file);if(st(l.kind)){if(d.raises.has(l.nameLiteral)||d.sends.has(l.nameLiteral))continue;o.push(N(e,"arkrun-undeclared-emit",l.file,l.line,`Emit ${JSON.stringify(l.nameLiteral)} is not declared in raises or sends.`,{fromLayer:u,target:l.nameLiteral},s));continue}if(ot(l.kind)){if(d.reactsTo.has(l.nameLiteral))continue;o.push(N(e,"arkrun-undeclared-handle",l.file,l.line,`Handle ${JSON.stringify(l.nameLiteral)} is not declared in reactsTo.`,{fromLayer:u,target:l.nameLiteral},s));continue}d.uses.has(l.nameLiteral)||o.push(N(e,"arkrun-undeclared-depend",l.file,l.line,`Depend ${JSON.stringify(l.nameLiteral)} is not declared in uses.`,{fromLayer:u,target:l.nameLiteral},s))}return{findings:o,completenessReasons:i}}c(Tr,"evaluateUndeclared");function Dr(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||!et(a))continue;let l=r(i.from);!l||!s.has(l)||o.push(N(e,"arkrun-transport-bypass",i.from,i.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return o}c(Dr,"evaluateTransportBypass");function Fr(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=te(e.classification),n=Tr(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...wr(t,e.compositionRootHits,r),...vr(t,e.layers,e.dependencies,e.layerForFile,r),...Lr(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...Dr(t,e.dependencies,e.layerForFile,r)].sort(_r),o=[...n.completenessReasons].sort((i,a)=>{let l=`${i.code}\0${i.file??""}\0${i.message}`,u=`${a.code}\0${a.file??""}\0${a.message}`;return l<u?-1:l>u?1:0});return{findings:s,completenessReasons:o}}c(Fr,"evaluateArkRunSensors");function Re(e){return{findings:Fr(e).findings.filter(r=>xr(r.sensor)),completenessReasons:[]}}c(Re,"evaluateArkRunEditorSensors");function Kr(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(Kr,"declarationIsTypeOnly");function ct(e){try{return at.existsSync(e)?at.readFileSync(e,"utf8"):null}catch{return null}}c(ct,"readUtf8");function lt(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=T.dirname(n),i=T.isAbsolute(r)?r:T.resolve(r),a=T.relative(o,i).split(T.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=S(a,s.layers);return l?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:l}:null}c(lt,"loadEditorFile");function Pr(e,t,r){let n=ee(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!_(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}c(Pr,"compositionRootHitsForFile");function Mr(e,t,r){let n=new Set(ye(t.relFile,r).map(s=>s.className));return rt(r,(s,o)=>{if(M(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=T.relative(t.root,i).split(T.sep).join("/");if(a.startsWith(".."))return;let l=ct(i);if(l!==null)for(let u of ye(a,l))n.add(u.className)}),n}c(Mr,"admittedTypeNamesForEditor");function dt(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}c(dt,"reportFinding");function $r(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}c($r,"constructedTypeName");function Ur(e,t){return e.type?.startsWith("Export")?"export":t}c(Ur,"specifierEdgeKind");function Hr(e,t,r,n,s){let o=c((i,a,l,u)=>{if(typeof a!="string"||a.length===0)return;let d=i.loc?.start?.line??1,p={from:r.relFile,specifier:a,kind:u,typeOnly:l,line:d,resolution:"resolved-external"},{findings:f}=Re({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[p],layerForFile:c(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&dt(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,l=(a.specifiers??[]).filter(d=>d.type==="ImportSpecifier"),u=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(d=>d.importKind==="type");o(i,a.source?.value,a.importKind==="type"||u||Kr(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let l=a.specifiers??[],u=l.length>0&&l.every(d=>d.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||u,Ur(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}c(Hr,"importListeners");function jr(e,t,r){let n=ct(r.absFile)??"",s=Mr(e,r,n),o=me(r.relFile,n,s),{findings:i}=Re({arkRun:r.extra,layers:r.config.layers,kernelCalls:ee(r.relFile,n),managedNews:o,compositionRootHits:Pr(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:c(l=>l===r.relFile?r.fromLayer:S(l,r.config.layers),"layerForFile")}),a=i.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let u=$r(l);if(!u)return;let d=l.loc?.start?.line,p=a.find(f=>f.target===u&&(d===void 0||f.line===d))??a.find(f=>f.target===u);p&&dt(e,t,l,"directNew",p,{fromLayer:p.fromLayer??r.fromLayer,typeName:u,target:p.target??u})}}}c(jr,"directNewListener");function ut(e){let t=c((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=lt(e,i);return a?Hr(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=lt(e,r);return n?jr(e,r,n):{}}}}}c(ut,"createArkRunEslintRules");var Vr="createOrderPlane";var Br=/\bfrom\s+['"](?:@?prisma\/client|@supabase\/|drizzle-orm|typeorm|knex|mongodb|pg|mysql2|mongoose|better-sqlite3|ioredis|redis|kysely|sequelize)['"]|require\(\s*['"](?:@?prisma\/client|pg|knex|typeorm|mongoose)/,Gr=/\.(?: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 re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(re,"escapeRegExp");function ne(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}c(ne,"isArkOrderModuleSpecifier");function V(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
8
- `&&(r+=1);return r}c(V,"lineAt");function B(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(B,"stripCommentsPreservingLines");function pt(e,t){let r=B(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:V(t,o.index),callee:Vr});return n}c(pt,"extractArkOrderPlaneCallsFromSource");function ft(e,t){let r=B(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|order)\s*$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:V(t,o.index),method:i})}return n}c(ft,"extractArkOrderGenericUpdatesFromSource");function gt(e,t,r){if(r.length===0)return[];let n=B(t);if(!Br.test(n)||!Gr.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${re(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${re(i)}['"]\\s*:|[{\\,]\\s*${re(i)}\\s*[\\,}]|\\.${re(i)}\\s*=)`,"g"),l;for(;(l=a.exec(n))!==null;){let u=`${i}:${l.index}`;if(!o.has(u)){o.add(u),s.push({file:e,line:V(t,l.index),key:i});break}}}return s}c(gt,"extractArkOrderXiFieldWritesFromSource");function mt(e,t){let r=B(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:V(t,o.index)});return n}c(mt,"extractArkOrderIngestWritesXiFromSource");function yt(e,t){let r=B(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:V(t,o.index),keyCount:a.length})}return n}c(yt,"extractArkOrderReleaseKeyCountsFromSource");var Rt=new Map;function ht(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(ht,"escapeAppliesToLiteral");function Wr(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(Wr,"normalizeAppliesToGlob");function zr(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(zr,"appliesToBracesBalanced");function qr(e){let t=Rt.get(e);if(t)return t;let r=Wr(e),n=zr(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=ht(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=ht(l)}let i=new RegExp(`^${s}$`);return Rt.set(e,i),i}c(qr,"globToRegExp");var At={"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 Zr(e,t){return!t||t.length===0?!0:t.some(r=>qr(r).test(e))}c(Zr,"matchesArkOrderAppliesTo");function Yr(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(Yr,"isDomainRoleLayer");function O(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:At[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:P({ruleId:At[t],fromLayer:o?.fromLayer,target:o?.target})}}c(O,"finding");function Xr(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=te(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 l=new Map;for(let u of e.planeRootHits){let d=l.get(u.matchedRoot)??[];d.push(u),l.set(u.matchedRoot,d)}for(let u of s){let d=l.get(u)??[];if(d.length===0){n.push(O(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}d.some(p=>p.hasPlaneFactory)||n.push(O(t,"arkorder-missing-plane",d[0].file,1,`ArkOrder plane root ${JSON.stringify(u)} has no createOrderPlane factory.`,{target:u},r))}}let o=new Map(e.layers.map(l=>[l.name,l.intentPrefixes??[]]));for(let l of e.dependencies){let u=l.specifier;if(!u||!ne(u))continue;let d=e.layerForFile(l.from);d&&Yr(d,o.get(d)??[])&&n.push(O(t,"arkorder-kernel-in-domain",l.from,l.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:d,target:u},r))}for(let l of e.genericUpdates)n.push(O(t,"arkorder-generic-update",l.file,l.line,`Generic ${l.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:l.method},r));let i=t.xiKeys??[];for(let l of e.releaseKeyCounts??[])l.keyCount<=t.maxXiKeys||n.push(O(t,"arkorder-too-many-params",l.file,l.line,`release() freezes ${l.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(l.keyCount)},r));for(let l of e.ingestWritesXi??[])n.push(O(t,"arkorder-ingest-writes-xi",l.file,l.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let l of i.length===0?[]:e.xiFieldWrites??[]){let u=e.layerForFile(l.file);!u||!a.has(u)||Zr(l.file,t.appliesTo)&&n.push(O(t,"arkorder-xi-field-write",l.file,l.line,`File writes slow key ${JSON.stringify(l.key)} through a persistence driver; route the field through ingest or a pattern change through proposeRelease.`,{fromLayer:u,target:l.key},r))}return n.sort((l,u)=>l.file.localeCompare(u.file)||l.ruleId.localeCompare(u.ruleId)||l.line-u.line),{findings:n,completenessReasons:[]}}c(Xr,"evaluateArkOrderSensors");function kt(e){if(!e.arkOrder)return[];let t=pt(e.file,e.source),r=ft(e.file,e.source),n=e.arkOrder.xiKeys??[];return Xr({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:gt(e.file,e.source,n),ingestWritesXi:mt(e.file,e.source),releaseKeyCounts:yt(e.file,e.source),dependencies:[],layerForFile:c(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}c(kt,"evaluateArkOrderEditorSensors");function Jr(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}c(Jr,"eslintSourceText");function bt(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let l=S(a,i.layers);return{ImportDeclaration(u){let d=typeof u.source?.value=="string"?u.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!ne(d)||l!=="DomainModel"&&!/^domain/i.test(l??""))return;e.reportAdapterDiagnostic(n,u,"denied",{ruleId:r,file:a,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=Jr(n),d=kt({arkOrder:i.arkOrder,file:a,source:u,fromLayer:l}).filter(p=>p.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let p of d)e.reportAdapterDiagnostic(n,{loc:{start:{line:p.line}}},"denied",{ruleId:p.ruleId,file:p.file,line:p.line,message:p.message})}}}}}return c(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}c(bt,"createArkOrderEslintRules");function D(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}c(D,"lintedFilename");function w(e,t,r,n,s){let o=Ye({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}c(w,"reportAdapterDiagnostic");function W(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.dirname(m.resolve(e));for(;;){let r=m.join(t,"ark.config.json");if(C.existsSync(r))return r;let n=m.dirname(t);if(n===t)return null;t=n}}c(W,"findConfigPath");var Et=new Map;function z(e){if(!C.existsSync(e))return null;let t=C.readFileSync(e,"utf8"),r=Et.get(e);if(r?.source===t)return r.config;let n=qe(t,e).config;return Et.set(e,{source:t,config:n}),n}c(z,"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}/`)})&&!Te(t,e)}c(q,"sourceIsInAnalysisScope");function St(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.join(e,"index.ts"),m.join(e,"index.tsx"),m.join(e,"index.js")];for(let r of t)try{if(C.existsSync(r)&&C.statSync(r).isFile())return r}catch{}return null}c(St,"existingSourceFile");function Qr(e){let t=m.resolve(e),r=null;for(;;){let u=m.join(t,"tsconfig.json");if(C.existsSync(u)){r=u;break}let d=m.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=c(u=>{try{let d=C.readFileSync(u,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},"loadJsonc"),s=c((u,d)=>{if(d>4)return{};let p=n(u);if(!p)return{};let f=p.compilerOptions??{},g=f.baseUrl,y=f.paths,h=p.extends;if(typeof h=="string"&&!h.startsWith("@")){let A=m.resolve(m.dirname(u),h.endsWith(".json")?h:`${h}.json`);if(C.existsSync(A)){let k=s(A,d+1);g=g??k.baseUrl,y={...k.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.dirname(r),a=m.resolve(i,o.baseUrl||"."),l=[];for(let[u,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let p=u.replace(/\*$/,"");p&&l.push({from:p,to:String(d[0]).replace(/\*$/,"")})}return l.sort((u,d)=>d.from.length-u.from.length),{baseUrl:a,aliases:l}}c(Qr,"readTsconfigPathAliases");function en(e,t){if(!t.startsWith("."))return null;let r=m.resolve(m.dirname(e),t);return St(r)}c(en,"resolveRelativeImport");function It(e,t,r){if(!t)return null;if(t.startsWith("."))return en(e,t);let n=r||m.dirname(e),{baseUrl:s,aliases:o}=Qr(n),i=o.find(l=>t.startsWith(l.from));if(!i)return null;let a=m.resolve(s,`${i.to}${t.slice(i.from.length)}`);return St(a)}c(It,"resolveImportSpecifier");function oe(e){return typeof e?.value=="string"?e.value:void 0}c(oe,"stringValue");function ke(e){return e?.name??oe(e)}c(ke,"propertyName");function be(e){return e.sourceCode??e.getSourceCode?.()}c(be,"sourceCodeFor");function xt(e,t){let r=be(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}c(xt,"referenceFor");function G(e,t,r){let n=xt(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=be(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}c(G,"isLocallyBound");function tn(e,t){let r=xt(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}c(tn,"isValueIdentifierReference");function Nt(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=Nt(e.object),n=ke(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}c(Nt,"memberExpressionPath");function rn(e){return ke(e.callee?.property)}c(rn,"calleePropertyName");function _t(e,t){return e?.properties?.find(r=>ke(r.key)===t)}c(_t,"objectProperty");function se(e,t){return _t(e,t)!==void 0}c(se,"objectHasProperty");function nn(e){let t=_t(e,"metadata")?.value;return se(t,"source")}c(nn,"objectHasMetadataSource");function Ot(e){return rn(e)==="publish"}c(Ot,"isPublishCall");function he(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(he,"declarationIsTypeOnly");function sn(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}c(sn,"containingProgram");function on(e){let t=sn(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!he(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(!he(n))return!1;r=!0;continue}return!1}}return r}c(on,"sourceProgramExportsOnlyTypes");var an={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=D(e),r=W(t),n=r?z(r):null,s=r?m.dirname(r):null,o=c(i=>{let a=oe(i.source);if(a&&n&&s&&t){let l=m.isAbsolute(t)?t:m.resolve(t),u=m.relative(s,l).split(m.sep).join("/");if(!q(n,u))return;let d=S(u,n.layers);if(!d)return;let p=It(l,a,s);if(!p)return;let f=m.relative(s,p).split(m.sep).join("/");if(f.startsWith(".."))return;let g=S(f,n.layers);if(!g)return;let y={fromPath:u,toPath:f,layers:n.layers},h=ae(n.rules,d,g,y),A=h?.rule;if(A){let k=i.type?.startsWith("Export")?"export":"import",Z=he(i),$=!!A?.peerIsolation,v=Z&&!$,F=$&&h?Le(h.peerIsolationReason??"cross-slice",{fromPath:u,toPath:f,fromSlice:h.fromSlice,toSlice:h.toSlice}):void 0,Y=A?.message?F?`${A.message} (${F})`:A.message:F?`${d} must not ${k} another slice of ${g} (${u} \u2192 ${f}): ${F}`:`${d} must not ${k} ${g}.`;w(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:u,fromLayer:d,toLayer:g,target:f,edgeKind:k,...$?{peerIsolation:!0}:{},...Z?{typeOnly:!0}:{},...v?{severity:"warning"}:{},...on(i)?{sourcePureTypeModule:!0}:{},message:v?`${Y} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:Y},{fromLayer:d,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},ln={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=oe(r),s=pe({publishCall:Ot(t),rawIntentName:n,objectHasIntent:se(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");w(e,t,"rawPublish",{...o,file:D(e)})}}}}},cn={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=pe({publishCall:Ot(t),rawIntentName:oe(r),objectHasIntent:se(r,"intent"),arkPublishCandidate:!0,hasSource:nn(r)||se(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&w(e,t,"missingSource",{...o,file:D(e)})}}}},dn={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=D(e),r=e.options?.[0],n=W(t),s=n?z(n):null,o=n?m.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let p=m.isAbsolute(t)?t:m.resolve(t),f=m.relative(o,p).split(m.sep).join("/");if(!q(s,f))return{};let g=s.layers?.find(y=>y.name===S(f,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let l=typeof be(e)?.getScope=="function",u=c((p,f)=>{let g=m.isAbsolute(t)?t:m.resolve(t),y=o?m.relative(o,g).split(m.sep).join("/"):t;w(e,p,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:f,message:`${a} must not use the ambient global "${f}".`},{name:f,layer:a})},"report"),d=c((p,f,g,y)=>{if(g||typeof f!="string")return;let h=ce(f,i);if(!h)return;let A=m.isAbsolute(t)?t:m.resolve(t),k=o?m.relative(o,A).split(m.sep).join("/"):t;w(e,p,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:k,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${h}".`},{layer:a,name:h,specifier:f,importKind:y})},"reportModule");return{MemberExpression(p){if(p.parent?.type==="MemberExpression"&&p.parent.object===p)return;let f=Nt(p);if(!f||G(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,h;for(let A=y.length;A>=(g?1:2);A-=1){let k=y.slice(0,A).join(".");if(i.has(k)){h=k;break}}h?u(p,h):!l&&i.has(f.segments[0])&&u(p,f.segments[0])},CallExpression(p){let f=p;if(f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!G(e,p,"require")&&d(p,f.arguments[0].value,!1,"require"),l)return;let g=f.callee?.type==="Identifier"?f.callee.name:void 0;g&&i.has(g)&&u(p,g)},ImportDeclaration(p){let f=p,g=(f.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(h=>h.importKind==="type");d(p,f.source?.value,f.importKind==="type"||y,"import")},ImportExpression(p){let f=p;f.source?.type==="Literal"&&d(p,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(p){let f=p;d(p,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(p){let f=p;if(!f.source)return;let g=f.specifiers??[],y=g.length>0&&g.every(h=>h.exportKind==="type");d(p,f.source.value,f.exportKind==="type"||y,"export")},ExportAllDeclaration(p){let f=p;d(p,f.source?.value,f.exportKind==="type","export")},NewExpression(p){if(l)return;let f=p.callee?.type==="Identifier"?p.callee.name:void 0;f&&i.has(f)&&u(p,f)},Identifier(p){!l||!p.name||!i.has(p.name)||!tn(e,p)||G(e,p,p.name)||u(p,p.name)}}}},un={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=D(e),r=W(t),n=r?z(r):null,s=r?m.dirname(r):null;if(!n||!s||!t)return{};let o=m.isAbsolute(t)?t:m.resolve(t),i=m.relative(s,o).split(m.sep).join("/");if(!q(n,i))return{};let a=n.layers?.find(d=>d.name===S(i,n.layers));if(!a)return{};let l=new Set(Ke(a));if(l.size===0)return{};let u=c((d,p,f,g)=>{if(f||typeof p!="string"||ce(p,a.forbiddenGlobals??[]))return;let y=Fe(p);!y||!l.has(y)||w(e,d,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:p,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${p}".`},{layer:a.name,capability:y,specifier:p})},"check");return{ImportDeclaration(d){let p=d,f=(p.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=f.length>0&&f.length===(p.specifiers??[]).length&&f.every(y=>y.importKind==="type");u(d,p.source?.value,p.importKind==="type"||g,"import")},ImportExpression(d){let p=d;p.source?.type==="Literal"&&u(d,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let p=d;u(d,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let p=d;if(!p.source)return;let f=p.specifiers??[],g=f.length>0&&f.every(y=>y.exportKind==="type");u(d,p.source.value,p.exportKind==="type"||g,"export")},ExportAllDeclaration(d){let p=d;u(d,p.source?.value,p.exportKind==="type","export")},CallExpression(d){let p=d;p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!G(e,d,"require")&&u(d,p.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:pn,noArkRunDirectNew:fn,noArkRunTransportBypass:gn}=ut({findConfigPath:W,loadArkConfig:z,resolveImportSpecifier:It,lintedFilename:D,sourceIsInAnalysisScope:q,isLocallyBound:G,reportAdapterDiagnostic:w});function mn(e,t){let r=m.dirname(m.resolve(e));return m.relative(r,m.resolve(t)).split(m.sep).join("/")}c(mn,"toProjectRelative");var{noArkOrderKernelInDomain:yn,noArkOrderGenericUpdate:Rn}=bt({findConfigPath:W,loadArkConfig:z,lintedFilename:D,sourceIsInAnalysisScope:q,reportAdapterDiagnostic:w,toProjectRelative:mn});var hn={"no-domain-infra-imports":an,"no-raw-event-publish":ln,"require-publish-source":cn,"no-forbidden-globals":dn,"no-denied-capabilities":un,"no-arkrun-kernel-in-domain":pn,"no-arkrun-direct-new":fn,"no-arkrun-transport-bypass":gn,"no-arkorder-kernel-in-domain":yn,"no-arkorder-generic-update":Rn},Ae={rules:hn};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 Os=Ae;export{Os as default,W as findConfigPath,_ as globToRegExp,Ht as isEdgeDenied,S as layerForRelativePath,z as loadArkConfig,Rn as noArkOrderGenericUpdate,yn as noArkOrderKernelInDomain,fn as noArkRunDirectNew,pn as noArkRunKernelInDomain,gn as noArkRunTransportBypass,un as noDeniedCapabilities,an as noDomainInfraImports,dn as noForbiddenGlobals,ln as noRawEventPublish,we as patternSpecificity,Ae as plugin,Qr as readTsconfigPathAliases,cn as requirePublishSource,It as resolveImportSpecifier,en as resolveRelativeImport};
3
+ `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function Ze(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}c(Ze,"isObject");function Y(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}c(Y,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}c(P,"valueType");function Yt(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}c(Yt,"resolveSchemaRef");function U(e,t,r,n,s){if(t.$ref){let o=Yt(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}U(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(!Ze(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:Y(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Y(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||U(e[a],i,Y(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&U(e[i],a,Y(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)=>U(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}c(U,"validateNode");function Xt(e){let t={...e,$schema:e.$schema===void 0?ce: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?qe.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=je(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Ve(e.arkOrder)),t}c(Xt,"defaultedConfig");function Jt(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}c(Jt,"migratedFromOf");function Qt(){let e=new Set([I]);for(let t of ue)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}c(Qt,"knownInputVersions");function er(e,t="ark.config.json"){if(!Ze(e))throw new x(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=Qt(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ue.length+1;){i+=1;let a=ue.find(l=>l.from===s);if(!a)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:Xt(o),migratedFrom:Jt(n)}}c(er,"migrateArkConfig");function tr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=er(e,t),s=[];if(U(r,ze,"$",ze,s),Be(r,s),Ge(r,s),s.length>0)throw new x(t,s);return{config:r,migratedFrom:n}}c(tr,"loadArkConfigContract");function Ye(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new x(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return tr(r,t)}c(Ye,"parseArkConfigJson");var rr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,nr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,sr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function or(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return rr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(nr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":sr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}c(or,"classifyLayerImportKind");function ir(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=or(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}c(ir,"layerImportNextAction");function ar(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}c(ar,"arkRunCallSiteName");function lr(e){let t=ar(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(lr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return ir(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return lr(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"Use release() for the first freeze of \u03BE. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.";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?`Do not persist slow key ${e.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again.`:"Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again. Never mechanical-safe.";case"ARKORDER_UNVALVED_RELEASE":return"Change \u03BE with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}c(K,"deterministicNextAction");var de="docs/diagnostics.md";function pe(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}c(pe,"adapterFindingTargetKey");function fe(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}c(fe,"adapterFindingRefFromTargetKey");function ge(e){return`${de}#${e}`}c(ge,"adapterDocsCodePath");function R(e){return typeof e=="string"&&e.length>0?e:void 0}c(R,"text");function Xe(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}c(Xe,"positiveInteger");function dr(e,t,r){return K({ruleId:e,target:R(t.target)??R(r.target)??void 0,fromLayer:R(t.fromLayer)??void 0,toLayer:R(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:R(t.edgeKind)??void 0,capability:R(t.capability)??R(r.capability)??void 0,arkruleId:R(t.arkruleId)??void 0,arkruleSource:R(t.arkruleSource)??void 0})}c(dr,"nextActionForDiagnostic");function Je(e,t="error",r){let n=R(e.ruleId)??R(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...R(e.target)?{target:R(e.target)}:{},...R(e.fromLayer)?{fromLayer:R(e.fromLayer)}:{},...R(e.toLayer)?{toLayer:R(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}:{},...R(e.capability)?{capability:R(e.capability)}:{},...R(e.edgeKind)?{edgeKind:R(e.edgeKind)}:{},...R(e.arkruleId)?{arkruleId:R(e.arkruleId)}:{},...R(e.arkruleSource)?{arkruleSource:R(e.arkruleSource)}:{}},i=r??pe(e),a=fe(i);return{ruleId:n,severity:s,message:R(e.message)??n,location:{file:R(e.file)??"<unknown>",line:Xe(e.line,1),column:Xe(e.column,1)},evidence:o,nextAction:R(e.nextAction)??dr(n,o,e),findingRef:a,targetKey:i,docsCodePath:ge(n)}}c(Je,"toAdapterDiagnostic");var Qe={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."},is=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 pr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}c(pr,"looksLikeArkIntent");function me(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&pr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:Qe.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:Qe.PUBLISH_MISSING_SOURCE}),t}c(me,"classifyPublishFacts");import dt from"fs";import T from"path";var fr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var gr=new Set(fr),mr=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"]),yr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function M(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}c(M,"isArkRunKernelModuleSpecifier");var Rr=["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"],ye=new Set(Rr);function rt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ye.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(ye.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:ye.has(e.slice(0,n))}c(rt,"isArkRunTransportBypassSpecifier");function et(e){if(gr.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}c(et,"arkRunKernelCallKind");function nt(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}c(nt,"lineAt");function Re(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(Re,"stripCommentsPreservingLines");function hr(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}c(hr,"firstStringLiteralArg");function tt(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}c(tt,"keywordBefore");function X(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}c(X,"parseValueImportClause");function st(e,t){X(Re(e),t)}c(st,"forEachArkRunValueImportClause");function Ar(e){let t=new Map,r=new Set;return X(e,(n,s)=>{if(!M(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let l of a[1].split(",")){let p=l.trim();if(!p||p.startsWith("type "))continue;let u=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);if(u){t.set(u[2],u[1]);continue}let d=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(p);d?.[1]&&t.set(d[1],d[1])}}),{named:t,namespaces:r}}c(Ar,"collectKernelImportBindings");function kr(e,t){let r=new Set(t);return X(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let l=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),p=l?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],u=l?.[1]??p;!p||!u||!/^[A-Z]/.test(u)||(M(s)||t.has(u)||t.has(p))&&(r.add(p),r.add(u))}}),r}c(kr,"collectImportedConstructors");function Er(e,t){let r;return X(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}c(Er,"importedFromForName");function J(e,t){let r=Re(t),n=Ar(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],l=i.index;if(tt(r,l,"function")||tt(r,l,"class"))continue;let u=r.slice(0,l).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],d=n.named.get(a)??a,f=et(d)??et(a);if(!f)continue;let g=n.named.has(a)||u!==void 0&&n.namespaces.has(u);if(f!=="factory"&&(!g&&u===void 0||u&&yr.has(u)&&!g))continue;let y=hr(r,l+i[0].length);s.push({file:e,line:nt(t,l),kind:f,callee:a,viaImport:g,...u?{receiver:u}:{},...y?{nameLiteral:y}:{}})}return s}c(J,"extractArkRunKernelCallsFromSource");function he(e,t,r){let n=Re(t),s=kr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let l=a[1];if(mr.has(l)||!s.has(l))continue;let p=Er(n,l);o.push({file:e,line:nt(t,a.index),typeName:l,...p?{importedFrom:p}:{}})}return o}c(he,"extractArkRunManagedNewsFromSource");var br=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Sr=new RegExp(`\\b(${br.join("|")})\\b`),it="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",Ir=new RegExp(`\\bthis\\.${it}\\.push\\s*\\(`),xr=new RegExp(`^this\\.${it}\\s*=\\s*\\[\\s*\\]`),_r=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,Nr=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,Or="truncatedUntil";function Cr(e){return Sr.test(e)||Ir.test(e)}c(Cr,"referencesGuardOrPublish");function wr(e,t,r){let n=e.slice(t);if(xr.test(n))return!0;if(!_r.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}c(wr,"isIdiomaticEventsReset");function vr(e,t){let r=new RegExp(Nr.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!wr(t,n.index,e))return!0;return!1}c(vr,"methodAssignsThis");function Tr(e,t){return t==null||Object.defineProperty(e,Or,{value:t,enumerable:!1,configurable:!0}),e}c(Tr,"attachShapeTruncation");var Lr=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),Dr=new Set(["if","match","when"]);function Q(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}c(Q,"skipStringOrComment");function H(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=Q(e,r);continue}break}return r}c(H,"skipWsAndComments");function ot(e,t){let r=e[t];if(!r||!/[A-Za-z_]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_]/.test(e[n]);)n+=1;return{ident:e.slice(t,n),end:n}}c(ot,"readIdent");function Ae(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=Q(e,o);if(i!==o){o=i;continue}let a=e[o];a===r?s+=1:a===n&&(s-=1),o+=1}return s===0?o:null}c(Ae,"skipBalanced");function Fr(e){let t=[],r=0,n;for(;r<e.length&&(r=H(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=ot(e,o);if(!u||!Lr.has(u.ident))break;s.push(u.ident),o=H(e,u.end)}let i=ot(e,o);if(!i){r+=1;continue}if(o=H(e,i.end),e[o]==="<"){let u=Ae(e,o,"<",">");if(u==null){n=e.length;break}o=H(e,u)}if(e[o]==="("){let u=Ae(e,o,"(",")");if(u==null){n=e.length;break}if(o=H(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let d=Q(e,o);if(d!==o){o=d;continue}o+=1}if(e[o]==="{"){let d=Ae(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 a=0,l=0,p=0;for(;o<e.length;){let u=Q(e,o);if(u!==o){o=u;continue}let d=e[o];if(d==="{")a+=1;else if(d==="}"){if(a===0)break;a-=1}else if(d==="(")l+=1;else if(d===")")l-=1;else if(d==="[")p+=1;else if(d==="]")p-=1;else if(d===";"&&a===0&&l===0&&p===0){o+=1;break}o+=1}t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o}return{members:t,truncatedAt:n}}c(Fr,"scanClassMembers");function ke(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,l=i;for(;l<t.length&&a>0;){let A=t[l];A==="{"?a+=1:A==="}"&&(a-=1),l+=1}let p=t.slice(i,l-1),u=a>0,d=Fr(p),f=u?t.length:d.truncatedAt==null?void 0:i+d.truncatedAt,g=d.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,h=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(p),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(p),E=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(p)&&!k,q=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(p)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(p),D=[];for(let A of d.members)A.kind==="method"&&A.name!=="constructor"&&(A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set")||Dr.has(A.name)||vr(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:Cr(A.body)}));let F=d.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(Tr({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:h,hasPublicConstructor:E,hasStaticFactory:q,mutatingMethods:[...D],dataOnly:F},f))}return r}c(ke,"extractClassShapesFromSource");function Pr(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}c(Pr,"normalizeExtraMergeTeethClassification");function ee(e){let t=Pr(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}c(ee,"extraMergeTeethAllowed");var Kr=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],Mr=new Set(Kr);function $r(e){return Mr.has(e)}c($r,"isArkRunEditorSensor");var at={"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"},Ur="ARKRUN_INTERACTION_NAME_INCOMPLETE";function ut(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(ut,"isDomainRoleLayer");function Hr(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}c(Hr,"compareFindings");function _(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:at[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:at[t],fromLayer:o?.fromLayer,target:o?.target})}}c(_,"finding");function jr(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}c(jr,"bagForFile");function lt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}c(lt,"emitKinds");function ct(e){return e==="subscribe"||e==="register-handler"}c(ct,"handleKinds");function Vr(e){return e==="resolve"||e==="resolve-singleton"}c(Vr,"dependKinds");function Br(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((p,u)=>p.file.localeCompare(u.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(p=>p.hasKernelFactory))continue;let l=a[0];n.push(_(e,"arkrun-missing-root",l.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}c(Br,"evaluateMissingRoot");function Gr(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let l=a.specifier;if(!l||!M(l))continue;let p=n(a.from);p&&ut(p,o.get(p)??[])&&i.push(_(e,"arkrun-kernel-in-domain",a.from,a.line,`${p} must not import kernel module ${JSON.stringify(l)}.`,{fromLayer:p,target:l},s))}return i}c(Gr,"evaluateKernelInDomain");function Wr(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(t.map(u=>[u.name,u.intentPrefixes??[]])),l=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),p=[];for(let u of r){if(l.has(u.file))continue;let d=u.typeName;if(e.ignoreDirectNewForErrors!==!1&&(d.endsWith("Error")||d==="Error")||d.endsWith("DTO")||d.endsWith("VO"))continue;let f=s(u.file);!f||!i.has(f)||ut(f,a.get(f)??[])||p.push(_(e,"arkrun-direct-new",u.file,u.line,`${f} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:f,target:u.typeName},o))}return p}c(Wr,"evaluateDirectNew");function zr(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let l of t){if(!lt(l.kind)&&!ct(l.kind)&&!Vr(l.kind))continue;let p=n(l.file);if(!p||!a.has(p))continue;if(!l.nameLiteral){e.mode==="enforced"&&i.push({code:Ur,file:l.file,message:`ArkRun ${l.kind} call in ${l.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let u=jr(r,l.file);if(lt(l.kind)){if(u.raises.has(l.nameLiteral)||u.sends.has(l.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-emit",l.file,l.line,`Emit ${JSON.stringify(l.nameLiteral)} is not declared in raises or sends.`,{fromLayer:p,target:l.nameLiteral},s));continue}if(ct(l.kind)){if(u.reactsTo.has(l.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-handle",l.file,l.line,`Handle ${JSON.stringify(l.nameLiteral)} is not declared in reactsTo.`,{fromLayer:p,target:l.nameLiteral},s));continue}u.uses.has(l.nameLiteral)||o.push(_(e,"arkrun-undeclared-depend",l.file,l.line,`Depend ${JSON.stringify(l.nameLiteral)} is not declared in uses.`,{fromLayer:p,target:l.nameLiteral},s))}return{findings:o,completenessReasons:i}}c(zr,"evaluateUndeclared");function qr(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||!rt(a))continue;let l=r(i.from);!l||!s.has(l)||o.push(_(e,"arkrun-transport-bypass",i.from,i.line,`${l} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:l,target:a},n))}return o}c(qr,"evaluateTransportBypass");function Zr(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ee(e.classification),n=zr(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...Br(t,e.compositionRootHits,r),...Gr(t,e.layers,e.dependencies,e.layerForFile,r),...Wr(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...qr(t,e.dependencies,e.layerForFile,r)].sort(Hr),o=[...n.completenessReasons].sort((i,a)=>{let l=`${i.code}\0${i.file??""}\0${i.message}`,p=`${a.code}\0${a.file??""}\0${a.message}`;return l<p?-1:l>p?1:0});return{findings:s,completenessReasons:o}}c(Zr,"evaluateArkRunSensors");function Ee(e){return{findings:Zr(e).findings.filter(r=>$r(r.sensor)),completenessReasons:[]}}c(Ee,"evaluateArkRunEditorSensors");function Yr(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(Yr,"declarationIsTypeOnly");function ft(e){try{return dt.existsSync(e)?dt.readFileSync(e,"utf8"):null}catch{return null}}c(ft,"readUtf8");function pt(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=T.dirname(n),i=T.isAbsolute(r)?r:T.resolve(r),a=T.relative(o,i).split(T.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let l=S(a,s.layers);return l?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:l}:null}c(pt,"loadEditorFile");function Xr(e,t,r){let n=J(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!N(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}c(Xr,"compositionRootHitsForFile");function Jr(e,t,r){let n=new Set(ke(t.relFile,r).map(s=>s.className));return st(r,(s,o)=>{if(M(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=T.relative(t.root,i).split(T.sep).join("/");if(a.startsWith(".."))return;let l=ft(i);if(l!==null)for(let p of ke(a,l))n.add(p.className)}),n}c(Jr,"admittedTypeNamesForEditor");function gt(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}c(gt,"reportFinding");function Qr(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}c(Qr,"constructedTypeName");function en(e,t){return e.type?.startsWith("Export")?"export":t}c(en,"specifierEdgeKind");function tn(e,t,r,n,s){let o=c((i,a,l,p)=>{if(typeof a!="string"||a.length===0)return;let u=i.loc?.start?.line??1,d={from:r.relFile,specifier:a,kind:p,typeOnly:l,line:u,resolution:"resolved-external"},{findings:f}=Ee({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[d],layerForFile:c(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&gt(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,l=(a.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),p=l.length>0&&l.length===(a.specifiers??[]).length&&l.every(u=>u.importKind==="type");o(i,a.source?.value,a.importKind==="type"||p||Yr(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let l=a.specifiers??[],p=l.length>0&&l.every(u=>u.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||p,en(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}c(tn,"importListeners");function rn(e,t,r){let n=ft(r.absFile)??"",s=Jr(e,r,n),o=he(r.relFile,n,s),{findings:i}=Ee({arkRun:r.extra,layers:r.config.layers,kernelCalls:J(r.relFile,n),managedNews:o,compositionRootHits:Xr(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:c(l=>l===r.relFile?r.fromLayer:S(l,r.config.layers),"layerForFile")}),a=i.filter(l=>l.sensor==="arkrun-direct-new");return{NewExpression(l){let p=Qr(l);if(!p)return;let u=l.loc?.start?.line,d=a.find(f=>f.target===p&&(u===void 0||f.line===u))??a.find(f=>f.target===p);d&&gt(e,t,l,"directNew",d,{fromLayer:d.fromLayer??r.fromLayer,typeName:p,target:d.target??p})}}}c(rn,"directNewListener");function mt(e){let t=c((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=pt(e,i);return a?tn(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=pt(e,r);return n?rn(e,r,n):{}}}}}c(mt,"createArkRunEslintRules");var nn="createOrderPlane";var sn=/\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)/,on=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,an=/\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 ln(e){return sn.test(e)||on.test(e)}c(ln,"sourceImportsPersistenceDriver");function te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(te,"escapeRegExp");function re(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}c(re,"isArkOrderModuleSpecifier");function j(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
5
+ `&&(r+=1);return r}c(j,"lineAt");function V(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}c(V,"stripCommentsPreservingLines");function yt(e,t){let r=V(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:j(t,o.index),callee:nn});return n}c(yt,"extractArkOrderPlaneCallsFromSource");function Rt(e,t){let r=V(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:j(t,o.index),method:i})}return n}c(Rt,"extractArkOrderGenericUpdatesFromSource");function ht(e,t,r){if(r.length===0)return[];let n=V(t);if(!ln(n)||!an.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${te(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${te(i)}['"]\\s*:|[{\\,]\\s*${te(i)}\\s*[\\,}]|\\.${te(i)}\\s*=)`,"g"),l;for(;(l=a.exec(n))!==null;){let p=`${i}:${l.index}`;if(!o.has(p)){o.add(p),s.push({file:e,line:j(t,l.index),key:i});break}}}return s}c(ht,"extractArkOrderXiFieldWritesFromSource");function At(e,t){let r=V(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:j(t,o.index)});return n}c(At,"extractArkOrderIngestWritesXiFromSource");function kt(e,t){let r=V(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:j(t,o.index),keyCount:a.length})}return n}c(kt,"extractArkOrderReleaseKeyCountsFromSource");var Et=new Map;function bt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}c(bt,"escapeAppliesToLiteral");function cn(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}c(cn,"normalizeAppliesToGlob");function un(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}c(un,"appliesToBracesBalanced");function dn(e){let t=Et.get(e);if(t)return t;let r=cn(e),n=un(r),s="",o=0;for(let a=0;a<r.length;a+=1){let l=r[a];l==="\\"&&a+1<r.length?(s+=bt(r[a+1]),a+=1):l==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":l==="?"?s+="[^/]":l==="{"&&n?(s+="(?:",o+=1):l==="}"&&n&&o>0?(s+=")",o-=1):l===","&&n&&o>0?s+="|":s+=bt(l)}let i=new RegExp(`^${s}$`);return Et.set(e,i),i}c(dn,"globToRegExp");var St={"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 pn(e,t){return!t||t.length===0?!0:t.some(r=>dn(r).test(e))}c(pn,"matchesArkOrderAppliesTo");function fn(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}c(fn,"isDomainRoleLayer");function O(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:St[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:St[t],fromLayer:o?.fromLayer,target:o?.target})}}c(O,"finding");function gn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ee(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 l=new Map;for(let p of e.planeRootHits){let u=l.get(p.matchedRoot)??[];u.push(p),l.set(p.matchedRoot,u)}for(let p of s){let u=l.get(p)??[];if(u.length===0){n.push(O(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(p)} matched no governed files and has no createOrderPlane factory.`,{target:p},r));continue}u.some(d=>d.hasPlaneFactory)||n.push(O(t,"arkorder-missing-plane",u[0].file,1,`ArkOrder plane root ${JSON.stringify(p)} has no createOrderPlane factory.`,{target:p},r))}}let o=new Map(e.layers.map(l=>[l.name,l.intentPrefixes??[]]));for(let l of e.dependencies){let p=l.specifier;if(!p||!re(p))continue;let u=e.layerForFile(l.from);u&&fn(u,o.get(u)??[])&&n.push(O(t,"arkorder-kernel-in-domain",l.from,l.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:p},r))}for(let l of e.genericUpdates)n.push(O(t,"arkorder-generic-update",l.file,l.line,`Generic ${l.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:l.method},r));let i=t.xiKeys??[];for(let l of e.releaseKeyCounts??[])l.keyCount<=t.maxXiKeys||n.push(O(t,"arkorder-too-many-params",l.file,l.line,`release() freezes ${l.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(l.keyCount)},r));for(let l of e.ingestWritesXi??[])n.push(O(t,"arkorder-ingest-writes-xi",l.file,l.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let l of i.length===0?[]:e.xiFieldWrites??[]){let p=e.layerForFile(l.file);!p||!a.has(p)||pn(l.file,t.appliesTo)&&n.push(O(t,"arkorder-xi-field-write",l.file,l.line,`File writes slow key ${JSON.stringify(l.key)} through a persistence driver; route the field through ingest or a pattern change through proposeRelease.`,{fromLayer:p,target:l.key},r))}return n.sort((l,p)=>l.file.localeCompare(p.file)||l.ruleId.localeCompare(p.ruleId)||l.line-p.line),{findings:n,completenessReasons:[]}}c(gn,"evaluateArkOrderSensors");function It(e){if(!e.arkOrder)return[];let t=yt(e.file,e.source),r=Rt(e.file,e.source),n=e.arkOrder.xiKeys??[];return gn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:ht(e.file,e.source,n),ingestWritesXi:At(e.file,e.source),releaseKeyCounts:kt(e.file,e.source),dependencies:[],layerForFile:c(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}c(It,"evaluateArkOrderEditorSensors");function mn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}c(mn,"eslintSourceText");function xt(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let l=S(a,i.layers);return{ImportDeclaration(p){let u=typeof p.source?.value=="string"?p.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!re(u)||l!=="DomainModel"&&!/^domain/i.test(l??""))return;e.reportAdapterDiagnostic(n,p,"denied",{ruleId:r,file:a,line:p.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let p=mn(n),u=It({arkOrder:i.arkOrder,file:a,source:p,fromLayer:l}).filter(d=>d.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let d of u)e.reportAdapterDiagnostic(n,{loc:{start:{line:d.line}}},"denied",{ruleId:d.ruleId,file:d.file,line:d.line,message:d.message})}}}}}return c(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}c(xt,"createArkOrderEslintRules");function L(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}c(L,"lintedFilename");function w(e,t,r,n,s){let o=Je({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}c(w,"reportAdapterDiagnostic");function G(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.dirname(m.resolve(e));for(;;){let r=m.join(t,"ark.config.json");if(C.existsSync(r))return r;let n=m.dirname(t);if(n===t)return null;t=n}}c(G,"findConfigPath");var _t=new Map;function W(e){if(!C.existsSync(e))return null;let t=C.readFileSync(e,"utf8"),r=_t.get(e);if(r?.source===t)return r.config;let n=Ye(t,e).config;return _t.set(e,{source:t,config:n}),n}c(W,"loadArkConfig");function z(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!Fe(t,e)}c(z,"sourceIsInAnalysisScope");function Nt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.join(e,"index.ts"),m.join(e,"index.tsx"),m.join(e,"index.js")];for(let r of t)try{if(C.existsSync(r)&&C.statSync(r).isFile())return r}catch{}return null}c(Nt,"existingSourceFile");function yn(e){let t=m.resolve(e),r=null;for(;;){let p=m.join(t,"tsconfig.json");if(C.existsSync(p)){r=p;break}let u=m.dirname(t);if(u===t)break;t=u}if(!r)return{baseUrl:e,aliases:[]};let n=c(p=>{try{let u=C.readFileSync(p,"utf8");return u=u.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(u)}catch{return null}},"loadJsonc"),s=c((p,u)=>{if(u>4)return{};let d=n(p);if(!d)return{};let f=d.compilerOptions??{},g=f.baseUrl,y=f.paths,h=d.extends;if(typeof h=="string"&&!h.startsWith("@")){let k=m.resolve(m.dirname(p),h.endsWith(".json")?h:`${h}.json`);if(C.existsSync(k)){let E=s(k,u+1);g=g??E.baseUrl,y={...E.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.dirname(r),a=m.resolve(i,o.baseUrl||"."),l=[];for(let[p,u]of Object.entries(o.paths||{})){if(!Array.isArray(u)||u.length===0)continue;let d=p.replace(/\*$/,"");d&&l.push({from:d,to:String(u[0]).replace(/\*$/,"")})}return l.sort((p,u)=>u.from.length-p.from.length),{baseUrl:a,aliases:l}}c(yn,"readTsconfigPathAliases");function Rn(e,t){if(!t.startsWith("."))return null;let r=m.resolve(m.dirname(e),t);return Nt(r)}c(Rn,"resolveRelativeImport");function Ot(e,t,r){if(!t)return null;if(t.startsWith("."))return Rn(e,t);let n=r||m.dirname(e),{baseUrl:s,aliases:o}=yn(n),i=o.find(l=>t.startsWith(l.from));if(!i)return null;let a=m.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Nt(a)}c(Ot,"resolveImportSpecifier");function se(e){return typeof e?.value=="string"?e.value:void 0}c(se,"stringValue");function Ie(e){return e?.name??se(e)}c(Ie,"propertyName");function xe(e){return e.sourceCode??e.getSourceCode?.()}c(xe,"sourceCodeFor");function Ct(e,t){let r=xe(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}c(Ct,"referenceFor");function B(e,t,r){let n=Ct(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=xe(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}c(B,"isLocallyBound");function hn(e,t){let r=Ct(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}c(hn,"isValueIdentifierReference");function wt(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=wt(e.object),n=Ie(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}c(wt,"memberExpressionPath");function An(e){return Ie(e.callee?.property)}c(An,"calleePropertyName");function vt(e,t){return e?.properties?.find(r=>Ie(r.key)===t)}c(vt,"objectProperty");function ne(e,t){return vt(e,t)!==void 0}c(ne,"objectHasProperty");function kn(e){let t=vt(e,"metadata")?.value;return ne(t,"source")}c(kn,"objectHasMetadataSource");function Tt(e){return An(e)==="publish"}c(Tt,"isPublishCall");function be(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}c(be,"declarationIsTypeOnly");function En(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}c(En,"containingProgram");function bn(e){let t=En(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!be(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(!be(n))return!1;r=!0;continue}return!1}}return r}c(bn,"sourceProgramExportsOnlyTypes");var Sn={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=G(t),n=r?W(r):null,s=r?m.dirname(r):null,o=c(i=>{let a=se(i.source);if(a&&n&&s&&t){let l=m.isAbsolute(t)?t:m.resolve(t),p=m.relative(s,l).split(m.sep).join("/");if(!z(n,p))return;let u=S(p,n.layers);if(!u)return;let d=Ot(l,a,s);if(!d)return;let f=m.relative(s,d).split(m.sep).join("/");if(f.startsWith(".."))return;let g=S(f,n.layers);if(!g)return;let y={fromPath:p,toPath:f,layers:n.layers},h=ie(n.rules,u,g,y),k=h?.rule;if(k){let E=i.type?.startsWith("Export")?"export":"import",q=be(i),D=!!k?.peerIsolation,oe=q&&!D,F=D&&h?De(h.peerIsolationReason??"cross-slice",{fromPath:p,toPath:f,fromSlice:h.fromSlice,toSlice:h.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${u} must not ${E} another slice of ${g} (${p} \u2192 ${f}): ${F}`:`${u} must not ${E} ${g}.`;w(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:p,fromLayer:u,toLayer:g,target:f,edgeKind:E,...D?{peerIsolation:!0}:{},...q?{typeOnly:!0}:{},...oe?{severity:"warning"}:{},...bn(i)?{sourcePureTypeModule:!0}:{},message:oe?`${A} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:A},{fromLayer:u,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},In={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=se(r),s=me({publishCall:Tt(t),rawIntentName:n,objectHasIntent:ne(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");w(e,t,"rawPublish",{...o,file:L(e)})}}}}},xn={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=me({publishCall:Tt(t),rawIntentName:se(r),objectHasIntent:ne(r,"intent"),arkPublishCandidate:!0,hasSource:kn(r)||ne(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&w(e,t,"missingSource",{...o,file:L(e)})}}}},_n={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=G(t),s=n?W(n):null,o=n?m.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let d=m.isAbsolute(t)?t:m.resolve(t),f=m.relative(o,d).split(m.sep).join("/");if(!z(s,f))return{};let g=s.layers?.find(y=>y.name===S(f,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let l=typeof xe(e)?.getScope=="function",p=c((d,f)=>{let g=m.isAbsolute(t)?t:m.resolve(t),y=o?m.relative(o,g).split(m.sep).join("/"):t;w(e,d,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:f,message:`${a} must not use the ambient global "${f}".`},{name:f,layer:a})},"report"),u=c((d,f,g,y)=>{if(g||typeof f!="string")return;let h=le(f,i);if(!h)return;let k=m.isAbsolute(t)?t:m.resolve(t),E=o?m.relative(o,k).split(m.sep).join("/"):t;w(e,d,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:E,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${h}".`},{layer:a,name:h,specifier:f,importKind:y})},"reportModule");return{MemberExpression(d){if(d.parent?.type==="MemberExpression"&&d.parent.object===d)return;let f=wt(d);if(!f||B(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,h;for(let k=y.length;k>=(g?1:2);k-=1){let E=y.slice(0,k).join(".");if(i.has(E)){h=E;break}}h?p(d,h):!l&&i.has(f.segments[0])&&p(d,f.segments[0])},CallExpression(d){let f=d;if(f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!B(e,d,"require")&&u(d,f.arguments[0].value,!1,"require"),l)return;let g=f.callee?.type==="Identifier"?f.callee.name:void 0;g&&i.has(g)&&p(d,g)},ImportDeclaration(d){let f=d,g=(f.specifiers??[]).filter(h=>h.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(h=>h.importKind==="type");u(d,f.source?.value,f.importKind==="type"||y,"import")},ImportExpression(d){let f=d;f.source?.type==="Literal"&&u(d,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let f=d;u(d,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let f=d;if(!f.source)return;let g=f.specifiers??[],y=g.length>0&&g.every(h=>h.exportKind==="type");u(d,f.source.value,f.exportKind==="type"||y,"export")},ExportAllDeclaration(d){let f=d;u(d,f.source?.value,f.exportKind==="type","export")},NewExpression(d){if(l)return;let f=d.callee?.type==="Identifier"?d.callee.name:void 0;f&&i.has(f)&&p(d,f)},Identifier(d){!l||!d.name||!i.has(d.name)||!hn(e,d)||B(e,d,d.name)||p(d,d.name)}}}},Nn={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=G(t),n=r?W(r):null,s=r?m.dirname(r):null;if(!n||!s||!t)return{};let o=m.isAbsolute(t)?t:m.resolve(t),i=m.relative(s,o).split(m.sep).join("/");if(!z(n,i))return{};let a=n.layers?.find(u=>u.name===S(i,n.layers));if(!a)return{};let l=new Set(Me(a));if(l.size===0)return{};let p=c((u,d,f,g)=>{if(f||typeof d!="string"||le(d,a.forbiddenGlobals??[]))return;let y=Ke(d);!y||!l.has(y)||w(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:d,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${d}".`},{layer:a.name,capability:y,specifier:d})},"check");return{ImportDeclaration(u){let d=u,f=(d.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=f.length>0&&f.length===(d.specifiers??[]).length&&f.every(y=>y.importKind==="type");p(u,d.source?.value,d.importKind==="type"||g,"import")},ImportExpression(u){let d=u;d.source?.type==="Literal"&&p(u,d.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let d=u;p(u,d.moduleReference?.expression?.value,d.importKind==="type"||d.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let d=u;if(!d.source)return;let f=d.specifiers??[],g=f.length>0&&f.every(y=>y.exportKind==="type");p(u,d.source.value,d.exportKind==="type"||g,"export")},ExportAllDeclaration(u){let d=u;p(u,d.source?.value,d.exportKind==="type","export")},CallExpression(u){let d=u;d.callee?.type==="Identifier"&&d.callee.name==="require"&&d.arguments?.[0]?.type==="Literal"&&!B(e,u,"require")&&p(u,d.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:On,noArkRunDirectNew:Cn,noArkRunTransportBypass:wn}=mt({findConfigPath:G,loadArkConfig:W,resolveImportSpecifier:Ot,lintedFilename:L,sourceIsInAnalysisScope:z,isLocallyBound:B,reportAdapterDiagnostic:w});function vn(e,t){let r=m.dirname(m.resolve(e));return m.relative(r,m.resolve(t)).split(m.sep).join("/")}c(vn,"toProjectRelative");var{noArkOrderKernelInDomain:Tn,noArkOrderGenericUpdate:Ln}=xt({findConfigPath:G,loadArkConfig:W,lintedFilename:L,sourceIsInAnalysisScope:z,reportAdapterDiagnostic:w,toProjectRelative:vn});var Dn={"no-domain-infra-imports":Sn,"no-raw-event-publish":In,"require-publish-source":xn,"no-forbidden-globals":_n,"no-denied-capabilities":Nn,"no-arkrun-kernel-in-domain":On,"no-arkrun-direct-new":Cn,"no-arkrun-transport-bypass":wn,"no-arkorder-kernel-in-domain":Tn,"no-arkorder-generic-update":Ln},Se={rules:Dn};Se.configs={recommended:{plugins:{ark:Se},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 Js=Se;export{Js as default,G as findConfigPath,N as globToRegExp,Vt as isEdgeDenied,S as layerForRelativePath,W as loadArkConfig,Ln as noArkOrderGenericUpdate,Tn as noArkOrderKernelInDomain,Cn as noArkRunDirectNew,On as noArkRunKernelInDomain,wn as noArkRunTransportBypass,Nn as noDeniedCapabilities,Sn as noDomainInfraImports,_n as noForbiddenGlobals,In as noRawEventPublish,Te as patternSpecificity,Se as plugin,yn as readTsconfigPathAliases,xn as requirePublishSource,Ot as resolveImportSpecifier,Rn as resolveRelativeImport};