arkgate 4.8.15 → 4.8.16

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 (63) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +7 -5
  3. package/bin/ark-shared.mjs +2 -0
  4. package/bin/ark.mjs +17 -8
  5. package/bin/lib/analysis-engine.mjs +5 -5
  6. package/bin/lib/architecture-scan.mjs +17 -0
  7. package/bin/lib/baseline-key.mjs +2 -0
  8. package/bin/lib/config-contract.mjs +1 -1
  9. package/bin/lib/diagnostic-catalog.mjs +2 -0
  10. package/bin/lib/doctor-advisories.mjs +26 -0
  11. package/bin/lib/doctor-green-cite.mjs +139 -0
  12. package/bin/lib/doctor-human.mjs +98 -63
  13. package/bin/lib/doctor-next-actions.mjs +9 -0
  14. package/bin/lib/doctor-plan.mjs +6 -3
  15. package/bin/lib/field-install.mjs +47 -7
  16. package/bin/lib/first-run-help.mjs +1 -0
  17. package/bin/lib/improvement-compass-doctor.mjs +3 -1
  18. package/bin/lib/improvement-compass-map.mjs +3 -1
  19. package/bin/lib/invariant-coverage.mjs +121 -0
  20. package/bin/lib/invariant-tests-path.mjs +212 -0
  21. package/bin/lib/package-manager.mjs +8 -0
  22. package/bin/lib/prototype-shortcuts.mjs +224 -0
  23. package/bin/lib/remediation.mjs +11 -0
  24. package/bin/lib/start-preview.mjs +20 -1
  25. package/dist/{configTypes-Dt3DpVbd.d.ts → configTypes-VD0qcubY.d.ts} +2 -1
  26. package/dist/{diagnosticCatalog-BEg85XlE.d.ts → diagnosticCatalog-KWvGLI1U.d.ts} +24 -3
  27. package/dist/eslint/index.cjs +4 -4
  28. package/dist/eslint/index.d.ts +1 -1
  29. package/dist/eslint/index.js +4 -4
  30. package/dist/index.cjs +31 -31
  31. package/dist/index.d.ts +5 -5
  32. package/dist/index.js +31 -31
  33. package/dist/nestjs/index.cjs +1 -1
  34. package/dist/nestjs/index.d.ts +3 -3
  35. package/dist/nestjs/index.js +1 -1
  36. package/dist/runtime/index.cjs +10 -10
  37. package/dist/runtime/index.d.ts +6 -6
  38. package/dist/runtime/index.js +10 -10
  39. package/dist/{types-TBiv0WHL.d.ts → types-BSzRy2X1.d.ts} +1 -1
  40. package/dist/{types-CN9tVMPz.d.ts → types-D5GT5ZT8.d.ts} +1 -1
  41. package/docs/README.md +1 -1
  42. package/docs/agent-guide.md +2 -0
  43. package/docs/configuration.md +11 -3
  44. package/docs/develop.md +3 -1
  45. package/docs/diagnostics.md +25 -1
  46. package/docs/package-surface.md +1 -1
  47. package/docs/use.md +5 -3
  48. package/package.json +1 -1
  49. package/schemas/ark.config.schema.json +1 -1
  50. package/server.json +2 -2
  51. package/templates/agent-skills/README.md +1 -1
  52. package/templates/agent-skills/ark-adopt/SKILL.md +15 -0
  53. package/templates/agent-skills/ark-autopilot/SKILL.md +6 -1
  54. package/templates/agent-skills/ark-coverage/SKILL.md +1 -1
  55. package/templates/agent-skills/ark-explain/SKILL.md +2 -1
  56. package/templates/agent-skills/ark-explore/SKILL.md +19 -0
  57. package/templates/agent-skills/ark-place/SKILL.md +4 -0
  58. package/templates/skills/ark-adopt.md +15 -0
  59. package/templates/skills/ark-autopilot.md +6 -1
  60. package/templates/skills/ark-coverage.md +1 -1
  61. package/templates/skills/ark-explain.md +2 -1
  62. package/templates/skills/ark-explore.md +19 -0
  63. package/templates/skills/ark-place.md +4 -0
@@ -1,5 +1,5 @@
1
- "use strict";var Qt=Object.create;var H=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var l=(e,t)=>H(e,"name",{value:t,configurable:!0});var sr=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tr(t))!nr.call(e,s)&&s!==r&&H(e,s,{get:()=>t[s],enumerable:!(n=er(t,s))||n.enumerable});return e};var Y=(e,t,r)=>(r=e!=null?Qt(rr(e)):{},Le(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),or=e=>Le(H({},"__esModule",{value:!0}),e);var es={};sr(es,{default:()=>Qn,findConfigPath:()=>$,globToRegExp:()=>x,isEdgeDenied:()=>je,layerForRelativePath:()=>S,loadArkConfig:()=>U,noArkOrderGenericUpdate:()=>Jt,noArkOrderKernelInDomain:()=>Xt,noArkRunDirectNew:()=>Zt,noArkRunKernelInDomain:()=>qt,noArkRunTransportBypass:()=>Yt,noDeniedCapabilities:()=>zt,noDomainInfraImports:()=>Vt,noForbiddenGlobals:()=>Wt,noRawEventPublish:()=>Bt,patternSpecificity:()=>ue,plugin:()=>ae,readTsconfigPathAliases:()=>Kt,requirePublishSource:()=>Gt,resolveImportSpecifier:()=>Oe,resolveRelativeImport:()=>Mt});module.exports=or(es);var N=Y(require("fs"),1),m=Y(require("path"),1);var De=new Map;function Fe(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(Fe,"escapeLiteral");function X(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l(X,"normalizeGlobSeparators");function ir(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}l(ir,"bracesBalanced");function x(e){let t=De.get(e);if(t)return t;let r=X(e),n=ir(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=Fe(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Fe(c)}let i=new RegExp(`^${s}$`);return De.set(e,i),i}l(x,"globToRegExp");function ar(e){return X(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}l(ar,"concreteGlobSegments");function ue(e,t){let r=X(String(e)),n=ar(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,c=-1;for(let 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;c=u,a=u+1}return(c+1)*1e6+n.length*1e4+s}l(ue,"patternSpecificity");function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>x(i).test(r))){for(let i of o.patterns??[])if(x(i).test(r)){let a=ue(i,r);a>s&&(s=a,n=o.name)}}return n}l(S,"layerForRelativePath");function Pe(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()}`}l(Pe,"sliceIdForPath");function lr(e){let t=new Set;for(let r of e??[]){let s=X(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}l(lr,"inferSliceFoldersFromPatterns");function cr(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 lr(n?.patterns)}l(cr,"resolveSliceFolders");function Ke(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}l(Ke,"normalizeSegments");function Ue(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}l(Ue,"trimTrailingSlashes");var ur=["src","app"];function dr(e){let t=Ue(e.replace(/^[./]+/,""));return t==="*"||t==="**"}l(dr,"isBlanketRoot");function Me(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ke(r);for(let o of t){if(typeof o!="string"||o.length===0||dr(o))continue;if(o.includes("*")){let c=Ue(o.toLowerCase());if(x(c).test(n)||x(`${c}/**`).test(n))return!0;continue}let i=Ke(o);if(i.length===0)continue;let a=ur.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let c of a){if(c+i.length>s.length)continue;let p=!0;for(let u=0;u<i.length;u+=1)if(s[c+u]!==i[u]){p=!1;break}if(p)return!0}}return!1}l(Me,"pathUnderSharedRoot");function $e(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}l($e,"sliceMatchesDeclaration");function pr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&$e(n.from,t)&&$e(n.to,r))}l(pr,"crossSliceEdgeAllowed");function fr(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}l(fr,"peerIsolationDecision");function He(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}l(He,"peerIsolationDenyExplanation");function gr(e,t,r,n){return de(e,t,r,n)?.rule}l(gr,"findDeniedEdgeRule");function de(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=cr(s,t,n?.layers),c=o?Pe(o,a):void 0,p=i?Pe(i,a):void 0,u=fr({fromPath:o,toPath:i,folderCount:a.length,fromSlice:c,toSlice:p,fromShared:!c&&Me(o,s.sharedRoots),toShared:!p&&Me(i,s.sharedRoots),crossSliceAllowed:pr(s.allowedCrossSlice,c,p)});if(u.denied)return{rule:s,peerIsolationReason:u.reason,fromSlice:c,toSlice:p};continue}if(t!==r)return{rule:s}}}l(de,"findDeniedEdgeDecision");function je(e,t,r,n){return gr(e,t,r,n)!==void 0}l(je,"isEdgeDenied");var mr=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function yr(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:mr,...t]}l(yr,"scanExcludePatterns");function Ve(e,t){let r=String(e).split(/[/\\]/).join("/");return yr(t).some(n=>x(n).test(r))}l(Ve,"isScanExcludedRelative");var Be=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),hr=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),ss=Object.freeze(Object.keys(hr).sort()),pe=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"}),Rr=Object.freeze({process:Object.freeze(["process","node:process"])});function Ge(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pe[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=pe[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:pe[e.slice(0,o)]??null}l(Ge,"capabilityForModuleSpecifier");function fe(e,t){for(let r of t)if(Rr[r]?.includes(e))return r;return null}l(fe,"forbiddenGlobalForModuleSpecifier");function We(e){if(e?.pure===!0)return[...Be].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Be.includes(n));return[...new Set(r)].sort()}l(We,"effectiveCapabilityDeny");var T={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ze={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...T,default:[]},kernelRoots:{...T},managedLayers:{...T,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},qe={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...T,default:[]},managedLayers:{...T,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...T,default:[]},appliesTo:{...T,default:[]}}};function j(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(j,"isObject");function Ze(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)j(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}l(Ze,"declaredLayerNames");function Ye(e){if(!j(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}l(Ye,"defaultedArkRun");function Xe(e){if(!j(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}l(Xe,"defaultedArkOrder");function Je(e,t){let r=e.arkRun;if(r===void 0||!j(r))return;let n=Ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(Je,"validateArkRunExtra");function Qe(e,t){let r=e.arkOrder;if(r===void 0||!j(r))return;let n=Ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(Qe,"validateArkOrderExtra");function J(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}l(J,"normalizeStewardId");function et(e){let t=J(e);return!t||ge(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}l(et,"isGitHubHandle");function Ar(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return!t.includes("@")||t.includes(" ")||ge(t)?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}l(Ar,"isGitHubEmail");function kr(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&et(t[1])?J(t[1]):null}l(kr,"githubHandleFromEmail");function tt(e){let t=kr(e);if(t)return t;let r=J(e);return!r||ge(r)?null:et(r)||Ar(r)?r:null}l(tt,"canonicalStewardId");var br=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function ge(e){let t=J(e);return!t||br.test(t)}l(ge,"isAutomationAuthor");var I="1.3",Er=["public","auth","admin","internal"];var me="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",rt=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Sr=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Ir(){let e=[];for(let t of rt)for(let r of rt)t===r||Sr.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}l(Ir,"createDefaultRules");var st=Ir(),ye=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],E={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:me,title:"ArkGate architecture contract",description:"Versioned contract consumed identically by ArkGate CLI, MCP, and ESLint surfaces.",type:"object",additionalProperties:!1,required:["$schema","schemaVersion","include","layers","rules"],properties:{$schema:{type:"string",minLength:1,default:me,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...E,minItems:1,default:["src"]},exclude:{...E,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:st,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...E,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...E,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...E,minItems:1},exclude:E,intentPrefixes:E,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...Er]},owners:{...E,minItems:1},forbiddenGlobals:E,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...E,minItems:1},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 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:{...E,minItems:1},maxFiles:{type:"integer",minimum:1,description:"Evidence file budget (default 400) and structural-hint preload cap for orchestration-only, thin-adapter, and writes-via-aggregate. Raise this when hinted/governed counts show truncated sensors. There is no separate arkrules.hintBudget."},coverageRoots:{...E,minItems:1}}},arkRun:ze,arkOrder:qe}},w=class extends Error{static{l(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
1
+ "use strict";var Qt=Object.create;var j=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var l=(e,t)=>j(e,"name",{value:t,configurable:!0});var sr=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tr(t))!nr.call(e,s)&&s!==r&&j(e,s,{get:()=>t[s],enumerable:!(n=er(t,s))||n.enumerable});return e};var Y=(e,t,r)=>(r=e!=null?Qt(rr(e)):{},Le(t||!e||!e.__esModule?j(r,"default",{value:e,enumerable:!0}):r,e)),or=e=>Le(j({},"__esModule",{value:!0}),e);var es={};sr(es,{default:()=>Qn,findConfigPath:()=>$,globToRegExp:()=>x,isEdgeDenied:()=>He,layerForRelativePath:()=>S,loadArkConfig:()=>U,noArkOrderGenericUpdate:()=>Jt,noArkOrderKernelInDomain:()=>Xt,noArkRunDirectNew:()=>Zt,noArkRunKernelInDomain:()=>qt,noArkRunTransportBypass:()=>Yt,noDeniedCapabilities:()=>zt,noDomainInfraImports:()=>Vt,noForbiddenGlobals:()=>Wt,noRawEventPublish:()=>Gt,patternSpecificity:()=>ue,plugin:()=>ae,readTsconfigPathAliases:()=>Kt,requirePublishSource:()=>Bt,resolveImportSpecifier:()=>Ce,resolveRelativeImport:()=>Mt});module.exports=or(es);var N=Y(require("fs"),1),m=Y(require("path"),1);var De=new Map;function Fe(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(Fe,"escapeLiteral");function X(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l(X,"normalizeGlobSeparators");function ir(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}l(ir,"bracesBalanced");function x(e){let t=De.get(e);if(t)return t;let r=X(e),n=ir(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=Fe(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Fe(c)}let i=new RegExp(`^${s}$`);return De.set(e,i),i}l(x,"globToRegExp");function ar(e){return X(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}l(ar,"concreteGlobSegments");function ue(e,t){let r=X(String(e)),n=ar(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,c=-1;for(let 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;c=u,a=u+1}return(c+1)*1e6+n.length*1e4+s}l(ue,"patternSpecificity");function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>x(i).test(r))){for(let i of o.patterns??[])if(x(i).test(r)){let a=ue(i,r);a>s&&(s=a,n=o.name)}}return n}l(S,"layerForRelativePath");function Pe(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()}`}l(Pe,"sliceIdForPath");function lr(e){let t=new Set;for(let r of e??[]){let s=X(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}l(lr,"inferSliceFoldersFromPatterns");function cr(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 lr(n?.patterns)}l(cr,"resolveSliceFolders");function Ke(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}l(Ke,"normalizeSegments");function Ue(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}l(Ue,"trimTrailingSlashes");var ur=["src","app"];function dr(e){let t=Ue(e.replace(/^[./]+/,""));return t==="*"||t==="**"}l(dr,"isBlanketRoot");function Me(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ke(r);for(let o of t){if(typeof o!="string"||o.length===0||dr(o))continue;if(o.includes("*")){let c=Ue(o.toLowerCase());if(x(c).test(n)||x(`${c}/**`).test(n))return!0;continue}let i=Ke(o);if(i.length===0)continue;let a=ur.includes(s[0])&&i[0]!==s[0]?[0,1]:[0];for(let c of a){if(c+i.length>s.length)continue;let p=!0;for(let u=0;u<i.length;u+=1)if(s[c+u]!==i[u]){p=!1;break}if(p)return!0}}return!1}l(Me,"pathUnderSharedRoot");function $e(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}l($e,"sliceMatchesDeclaration");function pr(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&$e(n.from,t)&&$e(n.to,r))}l(pr,"crossSliceEdgeAllowed");function fr(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}l(fr,"peerIsolationDecision");function je(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."}}l(je,"peerIsolationDenyExplanation");function gr(e,t,r,n){return de(e,t,r,n)?.rule}l(gr,"findDeniedEdgeRule");function de(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=cr(s,t,n?.layers),c=o?Pe(o,a):void 0,p=i?Pe(i,a):void 0,u=fr({fromPath:o,toPath:i,folderCount:a.length,fromSlice:c,toSlice:p,fromShared:!c&&Me(o,s.sharedRoots),toShared:!p&&Me(i,s.sharedRoots),crossSliceAllowed:pr(s.allowedCrossSlice,c,p)});if(u.denied)return{rule:s,peerIsolationReason:u.reason,fromSlice:c,toSlice:p};continue}if(t!==r)return{rule:s}}}l(de,"findDeniedEdgeDecision");function He(e,t,r,n){return gr(e,t,r,n)!==void 0}l(He,"isEdgeDenied");var mr=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function yr(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:mr,...t]}l(yr,"scanExcludePatterns");function Ve(e,t){let r=String(e).split(/[/\\]/).join("/");return yr(t).some(n=>x(n).test(r))}l(Ve,"isScanExcludedRelative");var Ge=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),hr=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),ss=Object.freeze(Object.keys(hr).sort()),pe=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"}),Rr=Object.freeze({process:Object.freeze(["process","node:process"])});function Be(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pe[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=pe[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:pe[e.slice(0,o)]??null}l(Be,"capabilityForModuleSpecifier");function fe(e,t){for(let r of t)if(Rr[r]?.includes(e))return r;return null}l(fe,"forbiddenGlobalForModuleSpecifier");function We(e){if(e?.pure===!0)return[...Ge].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Ge.includes(n));return[...new Set(r)].sort()}l(We,"effectiveCapabilityDeny");var T={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ze={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...T,default:[]},kernelRoots:{...T},managedLayers:{...T,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},qe={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...T,default:[]},managedLayers:{...T,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...T,default:[]},appliesTo:{...T,default:[]}}};function H(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(H,"isObject");function Ze(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)H(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}l(Ze,"declaredLayerNames");function Ye(e){if(!H(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}l(Ye,"defaultedArkRun");function Xe(e){if(!H(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}l(Xe,"defaultedArkOrder");function Je(e,t){let r=e.arkRun;if(r===void 0||!H(r))return;let n=Ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(Je,"validateArkRunExtra");function Qe(e,t){let r=e.arkOrder;if(r===void 0||!H(r))return;let n=Ze(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(Qe,"validateArkOrderExtra");function J(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}l(J,"normalizeStewardId");function et(e){let t=J(e);return!t||ge(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}l(et,"isGitHubHandle");function Ar(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return!t.includes("@")||t.includes(" ")||ge(t)?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}l(Ar,"isGitHubEmail");function kr(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&et(t[1])?J(t[1]):null}l(kr,"githubHandleFromEmail");function tt(e){let t=kr(e);if(t)return t;let r=J(e);return!r||ge(r)?null:et(r)||Ar(r)?r:null}l(tt,"canonicalStewardId");var br=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function ge(e){let t=J(e);return!t||br.test(t)}l(ge,"isAutomationAuthor");var I="1.3",Er=["public","auth","admin","internal"];var me="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",rt=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Sr=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Ir(){let e=[];for(let t of rt)for(let r of rt)t===r||Sr.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}l(Ir,"createDefaultRules");var st=Ir(),ye=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],E={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:me,title:"ArkGate architecture contract",description:"Versioned contract consumed identically by ArkGate CLI, MCP, and ESLint surfaces.",type:"object",additionalProperties:!1,required:["$schema","schemaVersion","include","layers","rules"],properties:{$schema:{type:"string",minLength:1,default:me,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...E,minItems:1,default:["src"]},exclude:{...E,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:st,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...E,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...E,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...E,minItems:1},exclude:E,intentPrefixes:E,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...Er]},owners:{...E,minItems:1},forbiddenGlobals:E,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...E,minItems:1},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 and also bounds structural-hint preload for orchestration-only, thin-adapter, and writes-via-aggregate (default 400; there is no arkrules.hintBudget); coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant. When any invariant is enforced, missing coverageRoots fails closed.",properties:{testGlobs:{...E,minItems:1},maxFiles:{type:"integer",minimum:1,description:"Evidence file budget (default 400) and structural-hint preload cap for orchestration-only, thin-adapter, and writes-via-aggregate. Raise this when hinted/governed counts show truncated sensors. There is no separate arkrules.hintBudget."},coverageRoots:{...E,minItems:1}}},arkRun:ze,arkOrder:qe}},w=class extends Error{static{l(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 ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(ot,"isObject");function Q(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}l(Q,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}l(P,"valueType");function xr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}l(xr,"resolveSchemaRef");function V(e,t,r,n,s){if(t.$ref){let o=xr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}V(e,o,r,n,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:r,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!ot(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:Q(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Q(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||V(e[a],i,Q(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,Q(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>V(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}l(V,"validateNode");function wr(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,a)=>{typeof i=="string"&&(tt(i)||t.push({path:`$.layers[${s}].owners[${a}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}l(wr,"validateLayerOwners");function _r(e){let t={...e,$schema:e.$schema===void 0?me:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?st.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Ye(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Xe(e.arkOrder)),t}l(_r,"defaultedConfig");function Nr(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}l(Nr,"migratedFromOf");function Cr(){let e=new Set([I]);for(let t of ye)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}l(Cr,"knownInputVersions");function Or(e,t="ark.config.json"){if(!ot(e))throw new w(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=Cr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ye.length+1;){i+=1;let a=ye.find(c=>c.from===s);if(!a)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:_r(o),migratedFrom:Nr(n)}}l(Or,"migrateArkConfig");function vr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Or(e,t),s=[];if(V(r,nt,"$",nt,s),Je(r,s),Qe(r,s),wr(r,s),s.length>0)throw new w(t,s);return{config:r,migratedFrom:n}}l(vr,"loadArkConfigContract");function it(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new w(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return vr(r,t)}l(it,"parseArkConfigJson");var Tr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Lr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Dr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Fr(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Tr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Lr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Dr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}l(Fr,"classifyLayerImportKind");function Pr(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=Fr(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}l(Pr,"layerImportNextAction");function Kr(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}l(Kr,"arkRunCallSiteName");function Mr(e){let t=Kr(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(Mr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Pr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"INVARIANT_CATALOG_EMPTY":return typeof e.file=="string"&&e.file.length>0?`Add 1\u20132 short phrases to invariants[] in ${e.file}, then run ark-check --doctor. Starters show the shape.`:"Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json, then run ark-check --doctor. Starters show the shape.";case"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 Mr(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(K,"deterministicNextAction");var he="docs/diagnostics.md";function Re(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}l(Re,"adapterFindingTargetKey");function Ae(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}l(Ae,"adapterFindingRefFromTargetKey");function ke(e){return`${he}#${e}`}l(ke,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}l(h,"text");function at(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}l(at,"positiveInteger");function Hr(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}l(Hr,"nextActionForDiagnostic");function lt(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??Re(e),a=Ae(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:at(e.line,1),column:at(e.column,1)},evidence:o,nextAction:h(e.nextAction)??Hr(n,o,e),findingRef:a,targetKey:i,docsCodePath:ke(n)}}l(lt,"toAdapterDiagnostic");var ct={RAW_EVENT_PUBLISH:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts and tooling.",PUBLISH_MISSING_SOURCE:"Strict Ark publish calls must include metadata.source."},Cs=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 jr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}l(jr,"looksLikeArkIntent");function be(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&jr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:ct.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:ct.PUBLISH_MISSING_SOURCE}),t}l(be,"classifyPublishFacts");var Ne=Y(require("fs"),1),C=Y(require("path"),1);var Vr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Br=new Set(Vr),Gr=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"]),Wr=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/")}l(M,"isArkRunKernelModuleSpecifier");var zr=["events","node:events","eventemitter2","eventemitter3","emittery","kafkajs","kafka-node","amqplib","amqp","bull","bullmq","mqtt","nats","@aws-sdk/client-sqs","@aws-sdk/client-sns","@aws-sdk/client-eventbridge","@google-cloud/pubsub","@azure/service-bus"],Ee=new Set(zr);function pt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(Ee.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(Ee.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:Ee.has(e.slice(0,n))}l(pt,"isArkRunTransportBypassSpecifier");function ut(e){if(Br.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}l(ut,"arkRunKernelCallKind");function ft(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}l(ft,"lineAt");function Se(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(Se,"stripCommentsPreservingLines");function qr(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}l(qr,"firstStringLiteralArg");function dt(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}l(dt,"keywordBefore");function ee(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}l(ee,"parseValueImportClause");function gt(e,t){ee(Se(e),t)}l(gt,"forEachArkRunValueImportClause");function Zr(e){let t=new Map,r=new Set;return ee(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 c of a[1].split(",")){let p=c.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}}l(Zr,"collectKernelImportBindings");function Yr(e,t){let r=new Set(t);return ee(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),p=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],u=c?.[1]??p;!p||!u||!/^[A-Z]/.test(u)||(M(s)||t.has(u)||t.has(p))&&(r.add(p),r.add(u))}}),r}l(Yr,"collectImportedConstructors");function Xr(e,t){let r;return ee(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}l(Xr,"importedFromForName");function te(e,t){let r=Se(t),n=Zr(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],c=i.index;if(dt(r,c,"function")||dt(r,c,"class"))continue;let u=r.slice(0,c).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],d=n.named.get(a)??a,f=ut(d)??ut(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&&Wr.has(u)&&!g))continue;let y=qr(r,c+i[0].length);s.push({file:e,line:ft(t,c),kind:f,callee:a,viaImport:g,...u?{receiver:u}:{},...y?{nameLiteral:y}:{}})}return s}l(te,"extractArkRunKernelCallsFromSource");function Ie(e,t,r){let n=Se(t),s=Yr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let c=a[1];if(Gr.has(c)||!s.has(c))continue;let p=Xr(n,c);o.push({file:e,line:ft(t,a.index),typeName:c,...p?{importedFrom:p}:{}})}return o}l(Ie,"extractArkRunManagedNewsFromSource");var Jr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Qr=new RegExp(`\\b(${Jr.join("|")})\\b`),yt="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",en=new RegExp(`\\bthis\\.${yt}\\.push\\s*\\(`),tn=new RegExp(`^this\\.${yt}\\s*=\\s*\\[\\s*\\]`),rn=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,nn=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,sn="truncatedUntil";function on(e){return Qr.test(e)||en.test(e)}l(on,"referencesGuardOrPublish");function an(e,t,r){let n=e.slice(t);if(tn.test(n))return!0;if(!rn.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}l(an,"isIdiomaticEventsReset");function ln(e,t){let r=new RegExp(nn.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!an(t,n.index,e))return!0;return!1}l(ln,"methodAssignsThis");function cn(e,t){return t==null||Object.defineProperty(e,sn,{value:t,enumerable:!1,configurable:!0}),e}l(cn,"attachShapeTruncation");var un=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),dn=new Set(["if","match","when"]);function re(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
4
- `,t);return n===-1?e.length:n}if(r==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2}if(r==="'"||r==='"'||r==="`"){let n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===r)return n+1;n+=1}return e.length}return t}l(re,"skipStringOrComment");function B(e,t){let r=t;for(;r<e.length;){if(/\s/.test(e[r])){r+=1;continue}if(e[r]==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=re(e,r);continue}break}return r}l(B,"skipWsAndComments");function mt(e,t){let r=e[t];if(!r||!/[A-Za-z_]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_]/.test(e[n]);)n+=1;return{ident:e.slice(t,n),end:n}}l(mt,"readIdent");function xe(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=re(e,o);if(i!==o){o=i;continue}let a=e[o];a===r?s+=1:a===n&&(s-=1),o+=1}return s===0?o:null}l(xe,"skipBalanced");function pn(e){let t=[],r=0,n;for(;r<e.length&&(r=B(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=mt(e,o);if(!u||!un.has(u.ident))break;s.push(u.ident),o=B(e,u.end)}let i=mt(e,o);if(!i){r+=1;continue}if(o=B(e,i.end),e[o]==="<"){let u=xe(e,o,"<",">");if(u==null){n=e.length;break}o=B(e,u)}if(e[o]==="("){let u=xe(e,o,"(",")");if(u==null){n=e.length;break}if(o=B(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let d=re(e,o);if(d!==o){o=d;continue}o+=1}if(e[o]==="{"){let d=xe(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,c=0,p=0;for(;o<e.length;){let u=re(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==="(")c+=1;else if(d===")")c-=1;else if(d==="[")p+=1;else if(d==="]")p-=1;else if(d===";"&&a===0&&c===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}}l(pn,"scanClassMembers");function we(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,c=i;for(;c<t.length&&a>0;){let A=t[c];A==="{"?a+=1:A==="}"&&(a-=1),c+=1}let p=t.slice(i,c-1),u=a>0,d=pn(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,R=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(p),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(p),b=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(p)&&!k,Z=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(p)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(p),D=[];for(let A of d.members)A.kind==="method"&&A.name!=="constructor"&&(A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set")||dn.has(A.name)||ln(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:on(A.body)}));let F=d.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(cn({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:R,hasPublicConstructor:b,hasStaticFactory:Z,mutatingMethods:[...D],dataOnly:F},f))}return r}l(we,"extractClassShapesFromSource");function fn(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}l(fn,"normalizeExtraMergeTeethClassification");function ne(e){let t=fn(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}l(ne,"extraMergeTeethAllowed");var gn=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],mn=new Set(gn);function yn(e){return mn.has(e)}l(yn,"isArkRunEditorSensor");var ht={"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"},hn="ARKRUN_INTERACTION_NAME_INCOMPLETE";function kt(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(kt,"isDomainRoleLayer");function Rn(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}l(Rn,"compareFindings");function _(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:ht[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:ht[t],fromLayer:o?.fromLayer,target:o?.target})}}l(_,"finding");function An(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}l(An,"bagForFile");function Rt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}l(Rt,"emitKinds");function At(e){return e==="subscribe"||e==="register-handler"}l(At,"handleKinds");function kn(e){return e==="resolve"||e==="resolve-singleton"}l(kn,"dependKinds");function bn(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 c=a[0];n.push(_(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}l(bn,"evaluateMissingRoot");function En(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let c=a.specifier;if(!c||!M(c))continue;let p=n(a.from);p&&kt(p,o.get(p)??[])&&i.push(_(e,"arkrun-kernel-in-domain",a.from,a.line,`${p} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:p,target:c},s))}return i}l(En,"evaluateKernelInDomain");function Sn(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??[]])),c=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),p=[];for(let u of r){if(c.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)||kt(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}l(Sn,"evaluateDirectNew");function In(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!Rt(c.kind)&&!At(c.kind)&&!kn(c.kind))continue;let p=n(c.file);if(!p||!a.has(p))continue;if(!c.nameLiteral){e.mode==="enforced"&&i.push({code:hn,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let u=An(r,c.file);if(Rt(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:p,target:c.nameLiteral},s));continue}if(At(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:p,target:c.nameLiteral},s));continue}u.uses.has(c.nameLiteral)||o.push(_(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:p,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}l(In,"evaluateUndeclared");function xn(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let a=i.specifier;if(!a||!pt(a))continue;let c=r(i.from);!c||!s.has(c)||o.push(_(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:c,target:a},n))}return o}l(xn,"evaluateTransportBypass");function wn(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=In(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...bn(t,e.compositionRootHits,r),...En(t,e.layers,e.dependencies,e.layerForFile,r),...Sn(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...xn(t,e.dependencies,e.layerForFile,r)].sort(Rn),o=[...n.completenessReasons].sort((i,a)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,p=`${a.code}\0${a.file??""}\0${a.message}`;return c<p?-1:c>p?1:0});return{findings:s,completenessReasons:o}}l(wn,"evaluateArkRunSensors");function _e(e){return{findings:wn(e).findings.filter(r=>yn(r.sensor)),completenessReasons:[]}}l(_e,"evaluateArkRunEditorSensors");function _n(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(_n,"declarationIsTypeOnly");function Et(e){try{return Ne.default.existsSync(e)?Ne.default.readFileSync(e,"utf8"):null}catch{return null}}l(Et,"readUtf8");function bt(e,t){let r=e.lintedFilename(t),n=e.findConfigPath(r),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!r)return null;let o=C.default.dirname(n),i=C.default.isAbsolute(r)?r:C.default.resolve(r),a=C.default.relative(o,i).split(C.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let c=S(a,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:c}:null}l(bt,"loadEditorFile");function Nn(e,t,r){let n=te(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!x(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}l(Nn,"compositionRootHitsForFile");function Cn(e,t,r){let n=new Set(we(t.relFile,r).map(s=>s.className));return gt(r,(s,o)=>{if(M(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=C.default.relative(t.root,i).split(C.default.sep).join("/");if(a.startsWith(".."))return;let c=Et(i);if(c!==null)for(let p of we(a,c))n.add(p.className)}),n}l(Cn,"admittedTypeNamesForEditor");function St(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}l(St,"reportFinding");function On(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}l(On,"constructedTypeName");function vn(e,t){return e.type?.startsWith("Export")?"export":t}l(vn,"specifierEdgeKind");function Tn(e,t,r,n,s){let o=l((i,a,c,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:c,line:u,resolution:"resolved-external"},{findings:f}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[d],layerForFile:l(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&St(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,c=(a.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),p=c.length>0&&c.length===(a.specifiers??[]).length&&c.every(u=>u.importKind==="type");o(i,a.source?.value,a.importKind==="type"||p||_n(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let c=a.specifiers??[],p=c.length>0&&c.every(u=>u.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||p,vn(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}l(Tn,"importListeners");function Ln(e,t,r){let n=Et(r.absFile)??"",s=Cn(e,r,n),o=Ie(r.relFile,n,s),{findings:i}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:te(r.relFile,n),managedNews:o,compositionRootHits:Nn(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:l(c=>c===r.relFile?r.fromLayer:S(c,r.config.layers),"layerForFile")}),a=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let p=On(c);if(!p)return;let u=c.loc?.start?.line,d=a.find(f=>f.target===p&&(u===void 0||f.line===u))??a.find(f=>f.target===p);d&&St(e,t,c,"directNew",d,{fromLayer:d.fromLayer??r.fromLayer,typeName:p,target:d.target??p})}}}l(Ln,"directNewListener");function It(e){let t=l((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=bt(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=bt(e,r);return n?Ln(e,r,n):{}}}}}l(It,"createArkRunEslintRules");var Dn="createOrderPlane";var Fn=/\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)/,Pn=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,Kn=/\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 Mn(e){return Fn.test(e)||Pn.test(e)}l(Mn,"sourceImportsPersistenceDriver");function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(se,"escapeRegExp");function oe(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}l(oe,"isArkOrderModuleSpecifier");function G(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
5
- `&&(r+=1);return r}l(G,"lineAt");function W(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(W,"stripCommentsPreservingLines");function xt(e,t){let r=W(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:G(t,o.index),callee:Dn});return n}l(xt,"extractArkOrderPlaneCallsFromSource");function wt(e,t){let r=W(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],a=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane)\s*(?:\?|!)?$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:G(t,o.index),method:i})}return n}l(wt,"extractArkOrderGenericUpdatesFromSource");function _t(e,t,r){if(r.length===0)return[];let n=W(t);if(!Mn(n)||!Kn.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${se(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${se(i)}['"]\\s*:|[{\\,]\\s*${se(i)}\\s*[\\,}]|\\.${se(i)}\\s*=)`,"g"),c;for(;(c=a.exec(n))!==null;){let p=`${i}:${c.index}`;if(!o.has(p)){o.add(p),s.push({file:e,line:G(t,c.index),key:i});break}}}return s}l(_t,"extractArkOrderXiFieldWritesFromSource");function Nt(e,t){let r=W(t),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:G(t,o.index)});return n}l(Nt,"extractArkOrderIngestWritesXiFromSource");function Ct(e,t){let r=W(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:G(t,o.index),keyCount:a.length})}return n}l(Ct,"extractArkOrderReleaseKeyCountsFromSource");var Ot=new Map;function vt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(vt,"escapeAppliesToLiteral");function $n(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l($n,"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}l(Un,"appliesToBracesBalanced");function Hn(e){let t=Ot.get(e);if(t)return t;let r=$n(e),n=Un(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=vt(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=vt(c)}let i=new RegExp(`^${s}$`);return Ot.set(e,i),i}l(Hn,"globToRegExp");var Tt={"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 jn(e,t){return!t||t.length===0?!0:t.some(r=>Hn(r).test(e))}l(jn,"matchesArkOrderAppliesTo");function Vn(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(Vn,"isDomainRoleLayer");function O(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Tt[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:Tt[t],fromLayer:o?.fromLayer,target:o?.target})}}l(O,"finding");function Bn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(O(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let c=new Map;for(let p of e.planeRootHits){let u=c.get(p.matchedRoot)??[];u.push(p),c.set(p.matchedRoot,u)}for(let p of s){let u=c.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(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let p=c.specifier;if(!p||!oe(p))continue;let u=e.layerForFile(c.from);u&&Vn(u,o.get(u)??[])&&n.push(O(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:p},r))}for(let c of e.genericUpdates)n.push(O(t,"arkorder-generic-update",c.file,c.line,`Generic ${c.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:c.method},r));let i=t.xiKeys??[];for(let c of e.releaseKeyCounts??[])c.keyCount<=t.maxXiKeys||n.push(O(t,"arkorder-too-many-params",c.file,c.line,`release() freezes ${c.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(c.keyCount)},r));for(let c of e.ingestWritesXi??[])n.push(O(t,"arkorder-ingest-writes-xi",c.file,c.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let p=e.layerForFile(c.file);!p||!a.has(p)||jn(c.file,t.appliesTo)&&n.push(O(t,"arkorder-xi-field-write",c.file,c.line,`This file writes ${JSON.stringify(c.key)} the same way it would write a seat count. Take the event in, or change that choice through the valve (propose, then apply).`,{fromLayer:p,target:c.key},r))}return n.sort((c,p)=>c.file.localeCompare(p.file)||c.ruleId.localeCompare(p.ruleId)||c.line-p.line),{findings:n,completenessReasons:[]}}l(Bn,"evaluateArkOrderSensors");function Lt(e){if(!e.arkOrder)return[];let t=xt(e.file,e.source),r=wt(e.file,e.source),n=e.arkOrder.xiKeys??[];return Bn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:_t(e.file,e.source,n),ingestWritesXi:Nt(e.file,e.source),releaseKeyCounts:Ct(e.file,e.source),dependencies:[],layerForFile:l(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}l(Lt,"evaluateArkOrderEditorSensors");function Gn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}l(Gn,"eslintSourceText");function Dt(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let c=S(a,i.layers);return{ImportDeclaration(p){let u=typeof p.source?.value=="string"?p.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!oe(u)||c!=="DomainModel"&&!/^domain/i.test(c??""))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=Gn(n),u=Lt({arkOrder:i.arkOrder,file:a,source:p,fromLayer:c}).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 l(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}l(Dt,"createArkOrderEslintRules");function L(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}l(L,"lintedFilename");function v(e,t,r,n,s){let o=lt({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}l(v,"reportAdapterDiagnostic");function $(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.default.dirname(m.default.resolve(e));for(;;){let r=m.default.join(t,"ark.config.json");if(N.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}l($,"findConfigPath");var Ft=new Map;function U(e){if(!N.default.existsSync(e))return null;let t=N.default.readFileSync(e,"utf8"),r=Ft.get(e);if(r?.source===t)return r.config;let n=it(t,e).config;return Ft.set(e,{source:t,config:n}),n}l(U,"loadArkConfig");function q(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!Ve(t,e)}l(q,"sourceIsInAnalysisScope");function Pt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.default.join(e,"index.ts"),m.default.join(e,"index.tsx"),m.default.join(e,"index.js")];for(let r of t)try{if(N.default.existsSync(r)&&N.default.statSync(r).isFile())return r}catch{}return null}l(Pt,"existingSourceFile");function Kt(e){let t=m.default.resolve(e),r=null;for(;;){let p=m.default.join(t,"tsconfig.json");if(N.default.existsSync(p)){r=p;break}let u=m.default.dirname(t);if(u===t)break;t=u}if(!r)return{baseUrl:e,aliases:[]};let n=l(p=>{try{let u=N.default.readFileSync(p,"utf8");return u=u.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(u)}catch{return null}},"loadJsonc"),s=l((p,u)=>{if(u>4)return{};let d=n(p);if(!d)return{};let f=d.compilerOptions??{},g=f.baseUrl,y=f.paths,R=d.extends;if(typeof R=="string"&&!R.startsWith("@")){let k=m.default.resolve(m.default.dirname(p),R.endsWith(".json")?R:`${R}.json`);if(N.default.existsSync(k)){let b=s(k,u+1);g=g??b.baseUrl,y={...b.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),a=m.default.resolve(i,o.baseUrl||"."),c=[];for(let[p,u]of Object.entries(o.paths||{})){if(!Array.isArray(u)||u.length===0)continue;let d=p.replace(/\*$/,"");d&&c.push({from:d,to:String(u[0]).replace(/\*$/,"")})}return c.sort((p,u)=>u.from.length-p.from.length),{baseUrl:a,aliases:c}}l(Kt,"readTsconfigPathAliases");function Mt(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return Pt(r)}l(Mt,"resolveRelativeImport");function Oe(e,t,r){if(!t)return null;if(t.startsWith("."))return Mt(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=Kt(n),i=o.find(c=>t.startsWith(c.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Pt(a)}l(Oe,"resolveImportSpecifier");function le(e){return typeof e?.value=="string"?e.value:void 0}l(le,"stringValue");function ve(e){return e?.name??le(e)}l(ve,"propertyName");function Te(e){return e.sourceCode??e.getSourceCode?.()}l(Te,"sourceCodeFor");function $t(e,t){let r=Te(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}l($t,"referenceFor");function z(e,t,r){let n=$t(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Te(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}l(z,"isLocallyBound");function Wn(e,t){let r=$t(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}l(Wn,"isValueIdentifierReference");function Ut(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=Ut(e.object),n=ve(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}l(Ut,"memberExpressionPath");function zn(e){return ve(e.callee?.property)}l(zn,"calleePropertyName");function Ht(e,t){return e?.properties?.find(r=>ve(r.key)===t)}l(Ht,"objectProperty");function ie(e,t){return Ht(e,t)!==void 0}l(ie,"objectHasProperty");function qn(e){let t=Ht(e,"metadata")?.value;return ie(t,"source")}l(qn,"objectHasMetadataSource");function jt(e){return zn(e)==="publish"}l(jt,"isPublishCall");function Ce(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(Ce,"declarationIsTypeOnly");function Zn(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}l(Zn,"containingProgram");function Yn(e){let t=Zn(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Ce(n))return!1;continue}if(!(n.type==="TSInterfaceDeclaration"||n.type==="TSTypeAliasDeclaration")){if(n.type==="ExportNamedDeclaration"){if(n.declaration){if(n.declaration.type!=="TSInterfaceDeclaration"&&n.declaration.type!=="TSTypeAliasDeclaration")return!1}else if(!Ce(n))return!1;r=!0;continue}return!1}}return r}l(Yn,"sourceProgramExportsOnlyTypes");var Vt={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null,o=l(i=>{let a=le(i.source);if(a&&n&&s&&t){let c=m.default.isAbsolute(t)?t:m.default.resolve(t),p=m.default.relative(s,c).split(m.default.sep).join("/");if(!q(n,p))return;let u=S(p,n.layers);if(!u)return;let d=Oe(c,a,s);if(!d)return;let f=m.default.relative(s,d).split(m.default.sep).join("/");if(f.startsWith(".."))return;let g=S(f,n.layers);if(!g)return;let y={fromPath:p,toPath:f,layers:n.layers},R=de(n.rules,u,g,y),k=R?.rule;if(k){let b=i.type?.startsWith("Export")?"export":"import",Z=Ce(i),D=!!k?.peerIsolation,ce=Z&&!D,F=D&&R?He(R.peerIsolationReason??"cross-slice",{fromPath:p,toPath:f,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${u} must not ${b} another slice of ${g} (${p} \u2192 ${f}): ${F}`:`${u} must not ${b} ${g}.`;v(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:p,fromLayer:u,toLayer:g,target:f,edgeKind:b,...D?{peerIsolation:!0}:{},...Z?{typeOnly:!0}:{},...ce?{severity:"warning"}:{},...Yn(i)?{sourcePureTypeModule:!0}:{},message:ce?`${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}}},Bt={meta:{type:"problem",docs:{description:"Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."},messages:{rawPublish:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=le(r),s=be({publishCall:jt(t),rawIntentName:n,objectHasIntent:ie(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");v(e,t,"rawPublish",{...o,file:L(e)})}}}}},Gt={meta:{type:"problem",docs:{description:"Require event bus publish calls to include source metadata."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=t.arguments?.[2],o=be({publishCall:jt(t),rawIntentName:le(r),objectHasIntent:ie(r,"intent"),arkPublishCandidate:!0,hasSource:qn(r)||ie(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&v(e,t,"missingSource",{...o,file:L(e)})}}}},Wt={meta:{type:"problem",docs:{description:"Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as ark-check). Option `globals` is a standalone fallback when no project config applies."},messages:{forbiddenGlobal:'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',forbiddenGlobalDefault:'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.',forbiddenModule:'{{layer}} must not use module "{{specifier}}" because it is the import form of forbidden global "{{name}}".'},schema:[{type:"object",properties:{globals:{type:"array",items:{type:"string"}}},additionalProperties:!1}]},create(e){let t=L(e),r=e.options?.[0],n=$(t),s=n?U(n):null,o=n?m.default.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let d=m.default.isAbsolute(t)?t:m.default.resolve(t),f=m.default.relative(o,d).split(m.default.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 c=typeof Te(e)?.getScope=="function",p=l((d,f)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;v(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=l((d,f,g,y)=>{if(g||typeof f!="string")return;let R=fe(f,i);if(!R)return;let k=m.default.isAbsolute(t)?t:m.default.resolve(t),b=o?m.default.relative(o,k).split(m.default.sep).join("/"):t;v(e,d,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:b,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:f,importKind:y})},"reportModule");return{MemberExpression(d){if(d.parent?.type==="MemberExpression"&&d.parent.object===d)return;let f=Ut(d);if(!f||z(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,R;for(let k=y.length;k>=(g?1:2);k-=1){let b=y.slice(0,k).join(".");if(i.has(b)){R=b;break}}R?p(d,R):!c&&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"&&!z(e,d,"require")&&u(d,f.arguments[0].value,!1,"require"),c)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(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(R=>R.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(R=>R.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(c)return;let f=d.callee?.type==="Identifier"?d.callee.name:void 0;f&&i.has(f)&&p(d,f)},Identifier(d){!c||!d.name||!i.has(d.name)||!Wn(e,d)||z(e,d,d.name)||p(d,d.name)}}}},zt={meta:{type:"problem",docs:{description:"Disallow importing modules whose effect capability the layer denies (ark.config.json capabilities.deny / pure \u2014 same wall surface as ark-check). Import dimension only: ambient globals stay with no-forbidden-globals and the CLI/hook symbol path."},messages:{deniedCapability:'{{layer}} denies the {{capability}} capability (ark.config.json); "{{specifier}}" imports it. Define a port and bind the implementation in an adapter layer.'},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null;if(!n||!s||!t)return{};let o=m.default.isAbsolute(t)?t:m.default.resolve(t),i=m.default.relative(s,o).split(m.default.sep).join("/");if(!q(n,i))return{};let a=n.layers?.find(u=>u.name===S(i,n.layers));if(!a)return{};let c=new Set(We(a));if(c.size===0)return{};let p=l((u,d,f,g)=>{if(f||typeof d!="string"||fe(d,a.forbiddenGlobals??[]))return;let y=Ge(d);!y||!c.has(y)||v(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"&&!z(e,u,"require")&&p(u,d.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:qt,noArkRunDirectNew:Zt,noArkRunTransportBypass:Yt}=It({findConfigPath:$,loadArkConfig:U,resolveImportSpecifier:Oe,lintedFilename:L,sourceIsInAnalysisScope:q,isLocallyBound:z,reportAdapterDiagnostic:v});function Xn(e,t){let r=m.default.dirname(m.default.resolve(e));return m.default.relative(r,m.default.resolve(t)).split(m.default.sep).join("/")}l(Xn,"toProjectRelative");var{noArkOrderKernelInDomain:Xt,noArkOrderGenericUpdate:Jt}=Dt({findConfigPath:$,loadArkConfig:U,lintedFilename:L,sourceIsInAnalysisScope:q,reportAdapterDiagnostic:v,toProjectRelative:Xn});var Jn={"no-domain-infra-imports":Vt,"no-raw-event-publish":Bt,"require-publish-source":Gt,"no-forbidden-globals":Wt,"no-denied-capabilities":zt,"no-arkrun-kernel-in-domain":qt,"no-arkrun-direct-new":Zt,"no-arkrun-transport-bypass":Yt,"no-arkorder-kernel-in-domain":Xt,"no-arkorder-generic-update":Jt},ae={rules:Jn};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 Qn=ae;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
3
+ `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(ot,"isObject");function Q(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}l(Q,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}l(P,"valueType");function xr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}l(xr,"resolveSchemaRef");function V(e,t,r,n,s){if(t.$ref){let o=xr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}V(e,o,r,n,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:r,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!ot(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:Q(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Q(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||V(e[a],i,Q(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&V(e[i],a,Q(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>V(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}l(V,"validateNode");function wr(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,a)=>{typeof i=="string"&&(tt(i)||t.push({path:`$.layers[${s}].owners[${a}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}l(wr,"validateLayerOwners");function _r(e){let t={...e,$schema:e.$schema===void 0?me:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?st.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Ye(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Xe(e.arkOrder)),t}l(_r,"defaultedConfig");function Nr(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}l(Nr,"migratedFromOf");function Or(){let e=new Set([I]);for(let t of ye)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}l(Or,"knownInputVersions");function Cr(e,t="ark.config.json"){if(!ot(e))throw new w(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=Or(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<ye.length+1;){i+=1;let a=ye.find(c=>c.from===s);if(!a)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new w(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:_r(o),migratedFrom:Nr(n)}}l(Cr,"migrateArkConfig");function vr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Cr(e,t),s=[];if(V(r,nt,"$",nt,s),Je(r,s),Qe(r,s),wr(r,s),s.length>0)throw new w(t,s);return{config:r,migratedFrom:n}}l(vr,"loadArkConfigContract");function it(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new w(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return vr(r,t)}l(it,"parseArkConfigJson");var Tr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Lr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Dr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Fr(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Tr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Lr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Dr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}l(Fr,"classifyLayerImportKind");function Pr(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=Fr(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}l(Pr,"layerImportNextAction");function Kr(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}l(Kr,"arkRunCallSiteName");function Mr(e){let t=Kr(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(Mr,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Pr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"INVARIANT_CATALOG_EMPTY":return typeof e.file=="string"&&e.file.length>0?`Add 1\u20132 short phrases to invariants[] in ${e.file}, then run ark-check --doctor. Starters show the shape.`:"Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json, then run ark-check --doctor. Starters show the shape.";case"INVARIANT_TESTS_PATH_MISSING":return"Add coverage.testGlobs or coverage.coverageRoots in ark.config.json pointing at a real tests folder, then re-run. Adopted mode fails closed until that path is present.";case"INVARIANT_COVERAGE_ROOTS_MISSING":return"Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. An enforced invariant fails closed until that path is present.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return Mr(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(K,"deterministicNextAction");var he="docs/diagnostics.md";function Re(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}l(Re,"adapterFindingTargetKey");function Ae(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}l(Ae,"adapterFindingRefFromTargetKey");function ke(e){return`${he}#${e}`}l(ke,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}l(h,"text");function at(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}l(at,"positiveInteger");function jr(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}l(jr,"nextActionForDiagnostic");function lt(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??Re(e),a=Ae(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:at(e.line,1),column:at(e.column,1)},evidence:o,nextAction:h(e.nextAction)??jr(n,o,e),findingRef:a,targetKey:i,docsCodePath:ke(n)}}l(lt,"toAdapterDiagnostic");var ct={RAW_EVENT_PUBLISH:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts and tooling.",PUBLISH_MISSING_SOURCE:"Strict Ark publish calls must include metadata.source."},Os=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 Hr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}l(Hr,"looksLikeArkIntent");function be(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Hr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:ct.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:ct.PUBLISH_MISSING_SOURCE}),t}l(be,"classifyPublishFacts");var Ne=Y(require("fs"),1),O=Y(require("path"),1);var Vr=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Gr=new Set(Vr),Br=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"]),Wr=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/")}l(M,"isArkRunKernelModuleSpecifier");var zr=["events","node:events","eventemitter2","eventemitter3","emittery","kafkajs","kafka-node","amqplib","amqp","bull","bullmq","mqtt","nats","@aws-sdk/client-sqs","@aws-sdk/client-sns","@aws-sdk/client-eventbridge","@google-cloud/pubsub","@azure/service-bus"],Ee=new Set(zr);function pt(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(Ee.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(Ee.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:Ee.has(e.slice(0,n))}l(pt,"isArkRunTransportBypassSpecifier");function ut(e){if(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}}l(ut,"arkRunKernelCallKind");function ft(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}l(ft,"lineAt");function Se(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(Se,"stripCommentsPreservingLines");function qr(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}l(qr,"firstStringLiteralArg");function dt(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}l(dt,"keywordBefore");function ee(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}l(ee,"parseValueImportClause");function gt(e,t){ee(Se(e),t)}l(gt,"forEachArkRunValueImportClause");function Zr(e){let t=new Map,r=new Set;return ee(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 c of a[1].split(",")){let p=c.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}}l(Zr,"collectKernelImportBindings");function Yr(e,t){let r=new Set(t);return ee(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),p=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],u=c?.[1]??p;!p||!u||!/^[A-Z]/.test(u)||(M(s)||t.has(u)||t.has(p))&&(r.add(p),r.add(u))}}),r}l(Yr,"collectImportedConstructors");function Xr(e,t){let r;return ee(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}l(Xr,"importedFromForName");function te(e,t){let r=Se(t),n=Zr(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],c=i.index;if(dt(r,c,"function")||dt(r,c,"class"))continue;let u=r.slice(0,c).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],d=n.named.get(a)??a,f=ut(d)??ut(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&&Wr.has(u)&&!g))continue;let y=qr(r,c+i[0].length);s.push({file:e,line:ft(t,c),kind:f,callee:a,viaImport:g,...u?{receiver:u}:{},...y?{nameLiteral:y}:{}})}return s}l(te,"extractArkRunKernelCallsFromSource");function Ie(e,t,r){let n=Se(t),s=Yr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let c=a[1];if(Br.has(c)||!s.has(c))continue;let p=Xr(n,c);o.push({file:e,line:ft(t,a.index),typeName:c,...p?{importedFrom:p}:{}})}return o}l(Ie,"extractArkRunManagedNewsFromSource");var Jr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Qr=new RegExp(`\\b(${Jr.join("|")})\\b`),yt="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",en=new RegExp(`\\bthis\\.${yt}\\.push\\s*\\(`),tn=new RegExp(`^this\\.${yt}\\s*=\\s*\\[\\s*\\]`),rn=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,nn=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,sn="truncatedUntil";function on(e){return Qr.test(e)||en.test(e)}l(on,"referencesGuardOrPublish");function an(e,t,r){let n=e.slice(t);if(tn.test(n))return!0;if(!rn.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}l(an,"isIdiomaticEventsReset");function ln(e,t){let r=new RegExp(nn.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!an(t,n.index,e))return!0;return!1}l(ln,"methodAssignsThis");function cn(e,t){return t==null||Object.defineProperty(e,sn,{value:t,enumerable:!1,configurable:!0}),e}l(cn,"attachShapeTruncation");var un=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),dn=new Set(["if","match","when"]);function re(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
4
+ `,t);return n===-1?e.length:n}if(r==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2}if(r==="'"||r==='"'||r==="`"){let n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===r)return n+1;n+=1}return e.length}return t}l(re,"skipStringOrComment");function G(e,t){let r=t;for(;r<e.length;){if(/\s/.test(e[r])){r+=1;continue}if(e[r]==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=re(e,r);continue}break}return r}l(G,"skipWsAndComments");function mt(e,t){let r=e[t];if(!r||!/[A-Za-z_]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_]/.test(e[n]);)n+=1;return{ident:e.slice(t,n),end:n}}l(mt,"readIdent");function xe(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=re(e,o);if(i!==o){o=i;continue}let a=e[o];a===r?s+=1:a===n&&(s-=1),o+=1}return s===0?o:null}l(xe,"skipBalanced");function pn(e){let t=[],r=0,n;for(;r<e.length&&(r=G(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=mt(e,o);if(!u||!un.has(u.ident))break;s.push(u.ident),o=G(e,u.end)}let i=mt(e,o);if(!i){r+=1;continue}if(o=G(e,i.end),e[o]==="<"){let u=xe(e,o,"<",">");if(u==null){n=e.length;break}o=G(e,u)}if(e[o]==="("){let u=xe(e,o,"(",")");if(u==null){n=e.length;break}if(o=G(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let d=re(e,o);if(d!==o){o=d;continue}o+=1}if(e[o]==="{"){let d=xe(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,c=0,p=0;for(;o<e.length;){let u=re(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==="(")c+=1;else if(d===")")c-=1;else if(d==="[")p+=1;else if(d==="]")p-=1;else if(d===";"&&a===0&&c===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}}l(pn,"scanClassMembers");function we(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,c=i;for(;c<t.length&&a>0;){let A=t[c];A==="{"?a+=1:A==="}"&&(a-=1),c+=1}let p=t.slice(i,c-1),u=a>0,d=pn(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,R=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(p),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(p),b=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(p)&&!k,Z=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(p)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(p),D=[];for(let A of d.members)A.kind==="method"&&A.name!=="constructor"&&(A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set")||dn.has(A.name)||ln(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:on(A.body)}));let F=d.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(cn({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:R,hasPublicConstructor:b,hasStaticFactory:Z,mutatingMethods:[...D],dataOnly:F},f))}return r}l(we,"extractClassShapesFromSource");function fn(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}l(fn,"normalizeExtraMergeTeethClassification");function ne(e){let t=fn(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}l(ne,"extraMergeTeethAllowed");var gn=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],mn=new Set(gn);function yn(e){return mn.has(e)}l(yn,"isArkRunEditorSensor");var ht={"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"},hn="ARKRUN_INTERACTION_NAME_INCOMPLETE";function kt(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(kt,"isDomainRoleLayer");function Rn(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}l(Rn,"compareFindings");function _(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:ht[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:ht[t],fromLayer:o?.fromLayer,target:o?.target})}}l(_,"finding");function An(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}l(An,"bagForFile");function Rt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}l(Rt,"emitKinds");function At(e){return e==="subscribe"||e==="register-handler"}l(At,"handleKinds");function kn(e){return e==="resolve"||e==="resolve-singleton"}l(kn,"dependKinds");function bn(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 c=a[0];n.push(_(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}l(bn,"evaluateMissingRoot");function En(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let c=a.specifier;if(!c||!M(c))continue;let p=n(a.from);p&&kt(p,o.get(p)??[])&&i.push(_(e,"arkrun-kernel-in-domain",a.from,a.line,`${p} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:p,target:c},s))}return i}l(En,"evaluateKernelInDomain");function Sn(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??[]])),c=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),p=[];for(let u of r){if(c.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)||kt(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}l(Sn,"evaluateDirectNew");function In(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!Rt(c.kind)&&!At(c.kind)&&!kn(c.kind))continue;let p=n(c.file);if(!p||!a.has(p))continue;if(!c.nameLiteral){e.mode==="enforced"&&i.push({code:hn,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let u=An(r,c.file);if(Rt(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:p,target:c.nameLiteral},s));continue}if(At(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(_(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:p,target:c.nameLiteral},s));continue}u.uses.has(c.nameLiteral)||o.push(_(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:p,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}l(In,"evaluateUndeclared");function xn(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let a=i.specifier;if(!a||!pt(a))continue;let c=r(i.from);!c||!s.has(c)||o.push(_(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:c,target:a},n))}return o}l(xn,"evaluateTransportBypass");function wn(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=In(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...bn(t,e.compositionRootHits,r),...En(t,e.layers,e.dependencies,e.layerForFile,r),...Sn(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...xn(t,e.dependencies,e.layerForFile,r)].sort(Rn),o=[...n.completenessReasons].sort((i,a)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,p=`${a.code}\0${a.file??""}\0${a.message}`;return c<p?-1:c>p?1:0});return{findings:s,completenessReasons:o}}l(wn,"evaluateArkRunSensors");function _e(e){return{findings:wn(e).findings.filter(r=>yn(r.sensor)),completenessReasons:[]}}l(_e,"evaluateArkRunEditorSensors");function _n(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(_n,"declarationIsTypeOnly");function Et(e){try{return Ne.default.existsSync(e)?Ne.default.readFileSync(e,"utf8"):null}catch{return null}}l(Et,"readUtf8");function bt(e,t){let r=e.lintedFilename(t),n=e.findConfigPath(r),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!r)return null;let o=O.default.dirname(n),i=O.default.isAbsolute(r)?r:O.default.resolve(r),a=O.default.relative(o,i).split(O.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let c=S(a,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:c}:null}l(bt,"loadEditorFile");function Nn(e,t,r){let n=te(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!x(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}l(Nn,"compositionRootHitsForFile");function On(e,t,r){let n=new Set(we(t.relFile,r).map(s=>s.className));return gt(r,(s,o)=>{if(M(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=O.default.relative(t.root,i).split(O.default.sep).join("/");if(a.startsWith(".."))return;let c=Et(i);if(c!==null)for(let p of we(a,c))n.add(p.className)}),n}l(On,"admittedTypeNamesForEditor");function St(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}l(St,"reportFinding");function Cn(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}l(Cn,"constructedTypeName");function vn(e,t){return e.type?.startsWith("Export")?"export":t}l(vn,"specifierEdgeKind");function Tn(e,t,r,n,s){let o=l((i,a,c,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:c,line:u,resolution:"resolved-external"},{findings:f}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[d],layerForFile:l(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of f)g.sensor===n&&St(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,c=(a.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),p=c.length>0&&c.length===(a.specifiers??[]).length&&c.every(u=>u.importKind==="type");o(i,a.source?.value,a.importKind==="type"||p||_n(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let c=a.specifiers??[],p=c.length>0&&c.every(u=>u.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||p,vn(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}l(Tn,"importListeners");function Ln(e,t,r){let n=Et(r.absFile)??"",s=On(e,r,n),o=Ie(r.relFile,n,s),{findings:i}=_e({arkRun:r.extra,layers:r.config.layers,kernelCalls:te(r.relFile,n),managedNews:o,compositionRootHits:Nn(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:l(c=>c===r.relFile?r.fromLayer:S(c,r.config.layers),"layerForFile")}),a=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let p=Cn(c);if(!p)return;let u=c.loc?.start?.line,d=a.find(f=>f.target===p&&(u===void 0||f.line===u))??a.find(f=>f.target===p);d&&St(e,t,c,"directNew",d,{fromLayer:d.fromLayer??r.fromLayer,typeName:p,target:d.target??p})}}}l(Ln,"directNewListener");function It(e){let t=l((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=bt(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=bt(e,r);return n?Ln(e,r,n):{}}}}}l(It,"createArkRunEslintRules");var Dn="createOrderPlane";var Fn=/\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)/,Pn=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,Kn=/\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 Mn(e){return Fn.test(e)||Pn.test(e)}l(Mn,"sourceImportsPersistenceDriver");function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(se,"escapeRegExp");function oe(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}l(oe,"isArkOrderModuleSpecifier");function B(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
5
+ `&&(r+=1);return r}l(B,"lineAt");function W(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(W,"stripCommentsPreservingLines");function xt(e,t){let r=W(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:B(t,o.index),callee:Dn});return n}l(xt,"extractArkOrderPlaneCallsFromSource");function wt(e,t){let r=W(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],a=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane)\s*(?:\?|!)?$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:B(t,o.index),method:i})}return n}l(wt,"extractArkOrderGenericUpdatesFromSource");function _t(e,t,r){if(r.length===0)return[];let n=W(t);if(!Mn(n)||!Kn.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${se(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${se(i)}['"]\\s*:|[{\\,]\\s*${se(i)}\\s*[\\,}]|\\.${se(i)}\\s*=)`,"g"),c;for(;(c=a.exec(n))!==null;){let p=`${i}:${c.index}`;if(!o.has(p)){o.add(p),s.push({file:e,line:B(t,c.index),key:i});break}}}return s}l(_t,"extractArkOrderXiFieldWritesFromSource");function Nt(e,t){let r=W(t),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:B(t,o.index)});return n}l(Nt,"extractArkOrderIngestWritesXiFromSource");function Ot(e,t){let r=W(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:B(t,o.index),keyCount:a.length})}return n}l(Ot,"extractArkOrderReleaseKeyCountsFromSource");var Ct=new Map;function vt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(vt,"escapeAppliesToLiteral");function $n(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l($n,"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}l(Un,"appliesToBracesBalanced");function jn(e){let t=Ct.get(e);if(t)return t;let r=$n(e),n=Un(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=vt(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=vt(c)}let i=new RegExp(`^${s}$`);return Ct.set(e,i),i}l(jn,"globToRegExp");var Tt={"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 Hn(e,t){return!t||t.length===0?!0:t.some(r=>jn(r).test(e))}l(Hn,"matchesArkOrderAppliesTo");function Vn(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(Vn,"isDomainRoleLayer");function C(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Tt[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:Tt[t],fromLayer:o?.fromLayer,target:o?.target})}}l(C,"finding");function Gn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=ne(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(C(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let c=new Map;for(let p of e.planeRootHits){let u=c.get(p.matchedRoot)??[];u.push(p),c.set(p.matchedRoot,u)}for(let p of s){let u=c.get(p)??[];if(u.length===0){n.push(C(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(p)} matched no governed files and has no createOrderPlane factory.`,{target:p},r));continue}u.some(d=>d.hasPlaneFactory)||n.push(C(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(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let p=c.specifier;if(!p||!oe(p))continue;let u=e.layerForFile(c.from);u&&Vn(u,o.get(u)??[])&&n.push(C(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:p},r))}for(let c of e.genericUpdates)n.push(C(t,"arkorder-generic-update",c.file,c.line,`Generic ${c.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:c.method},r));let i=t.xiKeys??[];for(let c of e.releaseKeyCounts??[])c.keyCount<=t.maxXiKeys||n.push(C(t,"arkorder-too-many-params",c.file,c.line,`release() freezes ${c.keyCount} keys; maxXiKeys is ${t.maxXiKeys} (few slow modes).`,{target:String(c.keyCount)},r));for(let c of e.ingestWritesXi??[])n.push(C(t,"arkorder-ingest-writes-xi",c.file,c.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let p=e.layerForFile(c.file);!p||!a.has(p)||Hn(c.file,t.appliesTo)&&n.push(C(t,"arkorder-xi-field-write",c.file,c.line,`This file writes ${JSON.stringify(c.key)} the same way it would write a seat count. Take the event in, or change that choice through the valve (propose, then apply).`,{fromLayer:p,target:c.key},r))}return n.sort((c,p)=>c.file.localeCompare(p.file)||c.ruleId.localeCompare(p.ruleId)||c.line-p.line),{findings:n,completenessReasons:[]}}l(Gn,"evaluateArkOrderSensors");function Lt(e){if(!e.arkOrder)return[];let t=xt(e.file,e.source),r=wt(e.file,e.source),n=e.arkOrder.xiKeys??[];return Gn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:_t(e.file,e.source,n),ingestWritesXi:Nt(e.file,e.source),releaseKeyCounts:Ot(e.file,e.source),dependencies:[],layerForFile:l(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}l(Lt,"evaluateArkOrderEditorSensors");function Bn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}l(Bn,"eslintSourceText");function Dt(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let c=S(a,i.layers);return{ImportDeclaration(p){let u=typeof p.source?.value=="string"?p.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!oe(u)||c!=="DomainModel"&&!/^domain/i.test(c??""))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=Bn(n),u=Lt({arkOrder:i.arkOrder,file:a,source:p,fromLayer:c}).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 l(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}l(Dt,"createArkOrderEslintRules");function L(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}l(L,"lintedFilename");function v(e,t,r,n,s){let o=lt({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}l(v,"reportAdapterDiagnostic");function $(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.default.dirname(m.default.resolve(e));for(;;){let r=m.default.join(t,"ark.config.json");if(N.default.existsSync(r))return r;let n=m.default.dirname(t);if(n===t)return null;t=n}}l($,"findConfigPath");var Ft=new Map;function U(e){if(!N.default.existsSync(e))return null;let t=N.default.readFileSync(e,"utf8"),r=Ft.get(e);if(r?.source===t)return r.config;let n=it(t,e).config;return Ft.set(e,{source:t,config:n}),n}l(U,"loadArkConfig");function q(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!Ve(t,e)}l(q,"sourceIsInAnalysisScope");function Pt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.default.join(e,"index.ts"),m.default.join(e,"index.tsx"),m.default.join(e,"index.js")];for(let r of t)try{if(N.default.existsSync(r)&&N.default.statSync(r).isFile())return r}catch{}return null}l(Pt,"existingSourceFile");function Kt(e){let t=m.default.resolve(e),r=null;for(;;){let p=m.default.join(t,"tsconfig.json");if(N.default.existsSync(p)){r=p;break}let u=m.default.dirname(t);if(u===t)break;t=u}if(!r)return{baseUrl:e,aliases:[]};let n=l(p=>{try{let u=N.default.readFileSync(p,"utf8");return u=u.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(u)}catch{return null}},"loadJsonc"),s=l((p,u)=>{if(u>4)return{};let d=n(p);if(!d)return{};let f=d.compilerOptions??{},g=f.baseUrl,y=f.paths,R=d.extends;if(typeof R=="string"&&!R.startsWith("@")){let k=m.default.resolve(m.default.dirname(p),R.endsWith(".json")?R:`${R}.json`);if(N.default.existsSync(k)){let b=s(k,u+1);g=g??b.baseUrl,y={...b.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.default.dirname(r),a=m.default.resolve(i,o.baseUrl||"."),c=[];for(let[p,u]of Object.entries(o.paths||{})){if(!Array.isArray(u)||u.length===0)continue;let d=p.replace(/\*$/,"");d&&c.push({from:d,to:String(u[0]).replace(/\*$/,"")})}return c.sort((p,u)=>u.from.length-p.from.length),{baseUrl:a,aliases:c}}l(Kt,"readTsconfigPathAliases");function Mt(e,t){if(!t.startsWith("."))return null;let r=m.default.resolve(m.default.dirname(e),t);return Pt(r)}l(Mt,"resolveRelativeImport");function Ce(e,t,r){if(!t)return null;if(t.startsWith("."))return Mt(e,t);let n=r||m.default.dirname(e),{baseUrl:s,aliases:o}=Kt(n),i=o.find(c=>t.startsWith(c.from));if(!i)return null;let a=m.default.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Pt(a)}l(Ce,"resolveImportSpecifier");function le(e){return typeof e?.value=="string"?e.value:void 0}l(le,"stringValue");function ve(e){return e?.name??le(e)}l(ve,"propertyName");function Te(e){return e.sourceCode??e.getSourceCode?.()}l(Te,"sourceCodeFor");function $t(e,t){let r=Te(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}l($t,"referenceFor");function z(e,t,r){let n=$t(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=Te(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}l(z,"isLocallyBound");function Wn(e,t){let r=$t(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}l(Wn,"isValueIdentifierReference");function Ut(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=Ut(e.object),n=ve(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}l(Ut,"memberExpressionPath");function zn(e){return ve(e.callee?.property)}l(zn,"calleePropertyName");function jt(e,t){return e?.properties?.find(r=>ve(r.key)===t)}l(jt,"objectProperty");function ie(e,t){return jt(e,t)!==void 0}l(ie,"objectHasProperty");function qn(e){let t=jt(e,"metadata")?.value;return ie(t,"source")}l(qn,"objectHasMetadataSource");function Ht(e){return zn(e)==="publish"}l(Ht,"isPublishCall");function Oe(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(Oe,"declarationIsTypeOnly");function Zn(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}l(Zn,"containingProgram");function Yn(e){let t=Zn(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Oe(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(!Oe(n))return!1;r=!0;continue}return!1}}return r}l(Yn,"sourceProgramExportsOnlyTypes");var Vt={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null,o=l(i=>{let a=le(i.source);if(a&&n&&s&&t){let c=m.default.isAbsolute(t)?t:m.default.resolve(t),p=m.default.relative(s,c).split(m.default.sep).join("/");if(!q(n,p))return;let u=S(p,n.layers);if(!u)return;let d=Ce(c,a,s);if(!d)return;let f=m.default.relative(s,d).split(m.default.sep).join("/");if(f.startsWith(".."))return;let g=S(f,n.layers);if(!g)return;let y={fromPath:p,toPath:f,layers:n.layers},R=de(n.rules,u,g,y),k=R?.rule;if(k){let b=i.type?.startsWith("Export")?"export":"import",Z=Oe(i),D=!!k?.peerIsolation,ce=Z&&!D,F=D&&R?je(R.peerIsolationReason??"cross-slice",{fromPath:p,toPath:f,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${u} must not ${b} another slice of ${g} (${p} \u2192 ${f}): ${F}`:`${u} must not ${b} ${g}.`;v(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:p,fromLayer:u,toLayer:g,target:f,edgeKind:b,...D?{peerIsolation:!0}:{},...Z?{typeOnly:!0}:{},...ce?{severity:"warning"}:{},...Yn(i)?{sourcePureTypeModule:!0}:{},message:ce?`${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}}},Gt={meta:{type:"problem",docs:{description:"Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."},messages:{rawPublish:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=le(r),s=be({publishCall:Ht(t),rawIntentName:n,objectHasIntent:ie(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");v(e,t,"rawPublish",{...o,file:L(e)})}}}}},Bt={meta:{type:"problem",docs:{description:"Require event bus publish calls to include source metadata."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=t.arguments?.[2],o=be({publishCall:Ht(t),rawIntentName:le(r),objectHasIntent:ie(r,"intent"),arkPublishCandidate:!0,hasSource:qn(r)||ie(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&v(e,t,"missingSource",{...o,file:L(e)})}}}},Wt={meta:{type:"problem",docs:{description:"Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as ark-check). Option `globals` is a standalone fallback when no project config applies."},messages:{forbiddenGlobal:'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',forbiddenGlobalDefault:'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.',forbiddenModule:'{{layer}} must not use module "{{specifier}}" because it is the import form of forbidden global "{{name}}".'},schema:[{type:"object",properties:{globals:{type:"array",items:{type:"string"}}},additionalProperties:!1}]},create(e){let t=L(e),r=e.options?.[0],n=$(t),s=n?U(n):null,o=n?m.default.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let d=m.default.isAbsolute(t)?t:m.default.resolve(t),f=m.default.relative(o,d).split(m.default.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 c=typeof Te(e)?.getScope=="function",p=l((d,f)=>{let g=m.default.isAbsolute(t)?t:m.default.resolve(t),y=o?m.default.relative(o,g).split(m.default.sep).join("/"):t;v(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=l((d,f,g,y)=>{if(g||typeof f!="string")return;let R=fe(f,i);if(!R)return;let k=m.default.isAbsolute(t)?t:m.default.resolve(t),b=o?m.default.relative(o,k).split(m.default.sep).join("/"):t;v(e,d,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:b,fromLayer:a,target:f,edgeKind:y,message:`${a} must not use module "${f}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:f,importKind:y})},"reportModule");return{MemberExpression(d){if(d.parent?.type==="MemberExpression"&&d.parent.object===d)return;let f=Ut(d);if(!f||z(e,f.root,f.segments[0]))return;let g=f.segments[0]==="globalThis",y=g?f.segments.slice(1):f.segments,R;for(let k=y.length;k>=(g?1:2);k-=1){let b=y.slice(0,k).join(".");if(i.has(b)){R=b;break}}R?p(d,R):!c&&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"&&!z(e,d,"require")&&u(d,f.arguments[0].value,!1,"require"),c)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(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(R=>R.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(R=>R.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(c)return;let f=d.callee?.type==="Identifier"?d.callee.name:void 0;f&&i.has(f)&&p(d,f)},Identifier(d){!c||!d.name||!i.has(d.name)||!Wn(e,d)||z(e,d,d.name)||p(d,d.name)}}}},zt={meta:{type:"problem",docs:{description:"Disallow importing modules whose effect capability the layer denies (ark.config.json capabilities.deny / pure \u2014 same wall surface as ark-check). Import dimension only: ambient globals stay with no-forbidden-globals and the CLI/hook symbol path."},messages:{deniedCapability:'{{layer}} denies the {{capability}} capability (ark.config.json); "{{specifier}}" imports it. Define a port and bind the implementation in an adapter layer.'},schema:[]},create(e){let t=L(e),r=$(t),n=r?U(r):null,s=r?m.default.dirname(r):null;if(!n||!s||!t)return{};let o=m.default.isAbsolute(t)?t:m.default.resolve(t),i=m.default.relative(s,o).split(m.default.sep).join("/");if(!q(n,i))return{};let a=n.layers?.find(u=>u.name===S(i,n.layers));if(!a)return{};let c=new Set(We(a));if(c.size===0)return{};let p=l((u,d,f,g)=>{if(f||typeof d!="string"||fe(d,a.forbiddenGlobals??[]))return;let y=Be(d);!y||!c.has(y)||v(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"&&!z(e,u,"require")&&p(u,d.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:qt,noArkRunDirectNew:Zt,noArkRunTransportBypass:Yt}=It({findConfigPath:$,loadArkConfig:U,resolveImportSpecifier:Ce,lintedFilename:L,sourceIsInAnalysisScope:q,isLocallyBound:z,reportAdapterDiagnostic:v});function Xn(e,t){let r=m.default.dirname(m.default.resolve(e));return m.default.relative(r,m.default.resolve(t)).split(m.default.sep).join("/")}l(Xn,"toProjectRelative");var{noArkOrderKernelInDomain:Xt,noArkOrderGenericUpdate:Jt}=Dt({findConfigPath:$,loadArkConfig:U,lintedFilename:L,sourceIsInAnalysisScope:q,reportAdapterDiagnostic:v,toProjectRelative:Xn});var Jn={"no-domain-infra-imports":Vt,"no-raw-event-publish":Gt,"require-publish-source":Bt,"no-forbidden-globals":Wt,"no-denied-capabilities":zt,"no-arkrun-kernel-in-domain":qt,"no-arkrun-direct-new":Zt,"no-arkrun-transport-bypass":Yt,"no-arkorder-kernel-in-domain":Xt,"no-arkorder-generic-update":Jt},ae={rules:Jn};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 Qn=ae;0&&(module.exports={findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport});
@@ -1,4 +1,4 @@
1
- import { A as ArkConfig } from '../configTypes-Dt3DpVbd.js';
1
+ import { A as ArkConfig } from '../configTypes-VD0qcubY.js';
2
2
 
3
3
  type RuleContext$1 = {
4
4
  report(descriptor: Record<string, unknown>): void;