arkgate 4.8.26 → 4.8.27

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 (61) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -2
  3. package/bin/ark-layer-match.mjs +23 -0
  4. package/bin/ark-mcp-runtime.mjs +45 -4
  5. package/bin/ark-mcp.mjs +9 -3
  6. package/bin/ark.mjs +27 -1
  7. package/bin/lib/analysis-engine.mjs +10 -10
  8. package/bin/lib/arkrules-sensors.mjs +9 -4
  9. package/bin/lib/class-source-scan.mjs +1 -1
  10. package/bin/lib/config-contract.mjs +5 -0
  11. package/bin/lib/prepare-change.mjs +10 -6
  12. package/bin/lib/prepare-write.mjs +7 -0
  13. package/bin/lib/remediation.mjs +84 -0
  14. package/bin/lib/resolved-candidate-facts.mjs +19 -2
  15. package/bin/lib/snippet-analysis.mjs +82 -1
  16. package/dist/chunk-A5EIY3HI.cjs +3 -3
  17. package/dist/chunk-H5I3GARV.js +16 -0
  18. package/dist/chunk-QQ4SJEJ7.cjs +16 -0
  19. package/dist/chunk-SVSQVGFJ.js +3 -3
  20. package/dist/{configTypes-GPvvdleM.d.cts → configTypes-D1oxws6x.d.cts} +6 -0
  21. package/dist/{configTypes-GPvvdleM.d.ts → configTypes-D1oxws6x.d.ts} +6 -0
  22. package/dist/eslint/index.cjs +11 -12
  23. package/dist/eslint/index.d.cts +7 -1
  24. package/dist/eslint/index.d.ts +7 -1
  25. package/dist/eslint/index.js +11 -11
  26. package/dist/index.cjs +32 -32
  27. package/dist/index.d.cts +13 -2
  28. package/dist/index.d.ts +13 -2
  29. package/dist/index.js +32 -32
  30. package/dist/inspectorListen-6DQVJ4DC.js +2 -1
  31. package/dist/inspectorListen-KGMIQ2TF.cjs +2 -1
  32. package/dist/nestjs/index.cjs +1 -1
  33. package/dist/nestjs/index.d.cts +1 -1
  34. package/dist/nestjs/index.d.ts +1 -1
  35. package/dist/nestjs/index.js +1 -1
  36. package/dist/order/index.cjs +1 -1
  37. package/dist/order/index.js +1 -1
  38. package/dist/runtime/index.cjs +10 -10
  39. package/dist/runtime/index.d.cts +4 -3
  40. package/dist/runtime/index.d.ts +4 -3
  41. package/dist/runtime/index.js +10 -10
  42. package/dist/{types-CnauMQQL.d.cts → types-DBiqlOWZ.d.cts} +6 -0
  43. package/dist/{types-CnauMQQL.d.ts → types-DBiqlOWZ.d.ts} +6 -0
  44. package/docs/README.md +2 -1
  45. package/docs/agent-guide.md +3 -2
  46. package/docs/ai-gates.md +1 -1
  47. package/docs/configuration.md +11 -0
  48. package/docs/package-surface.md +2 -1
  49. package/docs/product-voice.md +1 -1
  50. package/package.json +1 -1
  51. package/schemas/ark.config.schema.json +10 -0
  52. package/server.json +2 -2
  53. package/templates/agent-skills/README.md +1 -1
  54. package/templates/agent-skills/ark-adopt/SKILL.md +6 -0
  55. package/templates/agent-skills/ark-autopilot/SKILL.md +1 -1
  56. package/templates/agent-skills/ark-place/SKILL.md +4 -0
  57. package/templates/skills/ark-adopt.md +6 -0
  58. package/templates/skills/ark-autopilot.md +1 -1
  59. package/templates/skills/ark-place.md +4 -0
  60. package/dist/chunk-G3JRBJGH.js +0 -16
  61. package/dist/chunk-R3AJ5RSZ.cjs +0 -16
@@ -1,11 +1,11 @@
1
- var Fs=Object.defineProperty;var a=(e,t)=>Fs(e,"name",{value:t,configurable:!0});import N from"path";function Ps(e){if(e==="deny"||e==="deny-cross-parent")return e;if(e!==null&&typeof e=="object"){let t=e.mode;if(t==="deny-cross-parent")return t}}a(Ps,"sharedImportsSliceMode");var Gt=new Map;function Ht(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Ht,"escapeLiteral");function Fe(e){let t="";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,n+=1;continue}t+="/";continue}t+=r}return t}a(Fe,"normalizeGlobSeparators");function $s(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="\\"){n+=1;continue}if(r==="{")t+=1;else if(r==="}"&&(t-=1,t<0))return!1}return t===0}a($s,"bracesBalanced");function L(e){let t=Gt.get(e);if(t)return t;let n=Fe(e),r=$s(n),s="",o=0;for(let l=0;l<n.length;l+=1){let c=n[l];c==="\\"&&l+1<n.length?(s+=Ht(n[l+1]),l+=1):c==="*"?n[l+1]==="*"?n[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&r?(s+="(?:",o+=1):c==="}"&&r&&o>0?(s+=")",o-=1):c===","&&r&&o>0?s+="|":s+=Ht(c)}let i=new RegExp(`^${s}$`);return Gt.set(e,i),i}a(L,"globToRegExp");function Ms(e){return Fe(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}a(Ms,"concreteGlobSegments");function en(e,t){let n=Fe(String(e)),r=Ms(n),s=n.replace(/\*/g,"").length,o=r.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(r.length===0)return s;let l=0,c=-1;for(let d of r){let u=-1;for(let f=l;f<i.length;f+=1)if(i[f]===d){u=f;break}if(u<0)return o;c=u,l=u+1}return(c+1)*1e6+r.length*1e4+s}a(en,"patternSpecificity");function w(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>L(i).test(n))){for(let i of o.patterns??[])if(L(i).test(n)){let l=en(i,n);l>s&&(s=l,r=o.name)}}return r}a(w,"layerForRelativePath");function Pe(e,t,n){return nn(e,t,n==="stars"?"stars":"path")}a(Pe,"sliceIdForPath");function Bt(e,t){return nn(e,t?[...t]:void 0,tn)}a(Bt,"legacyStarsSliceIdForPath");var tn="stars-4.8.23";function nn(e,t,n){if(!t?.length)return;let r=String(e).split(/[/\\]/).filter(Boolean);if(r.length===0)return;let s=new Set;for(let o of t){if(typeof o!="string"||o.length===0)continue;let i=Ks(o);if(i.anchored){let l=Gs(r,i.anchored,n);if(l)return l;continue}i.bare!==void 0&&s.add(i.bare)}return Bs(r,s)}a(nn,"sliceIdWithBinding");var Ne=new Map;function Ks(e){let t=Ne.get(e);if(t)return t;let n={};return Us(e)?n={anchored:js(e)}:!e.includes("/")&&!e.includes("\\")&&!e.includes("*")&&(n={bare:e.toLowerCase()}),Ne.size>=1024&&Ne.clear(),Ne.set(e,n),n}a(Ks,"parsedSliceFolder");function Us(e){let t=e.split(/[/\\]/).filter(n=>n.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(n=>n==="*")}a(Us,"isAnchoredSliceEntry");function js(e){return e.split(/[/\\]/).filter(t=>t.length>0).map(t=>t.toLowerCase())}a(js,"anchoredSlicePattern");function Gs(e,t,n){let r=sn(e,t[0]??"");for(let s of r){let o=Hs(e,t,s,n);if(o)return o}}a(Gs,"anchoredSliceIdFromPattern");function Hs(e,t,n,r="path"){let s=[],o=[],i=-1,l=n;for(let c=0;c<t.length;c+=1){let d=t[c];if(d==="*"){if(l>=e.length-1){for(let u=c;u<t.length;u+=1)if(t[u]!=="*")return;break}s.push(e[l].toLowerCase()),o.push(!0),l+=1;continue}if(d==="**"||l>=e.length||e[l].toLowerCase()!==d)return;s.push(e[l].toLowerCase()),o.push(!1),i=s.length-1,l+=1}if(s.length!==0)return r===tn?i<0?void 0:s.slice(i).join("/"):r==="stars"?i<0?void 0:s.filter((c,d)=>d>=i||o[d]).join("/"):s.join("/")}a(Hs,"bindAnchoredSlice");function rn(e){let t=-1;for(let r=0;r<e.length;r+=1)e[r]!=="*"&&(t=r);if(t<0)return null;let n=[];for(let r=0;r<e.length;r+=1)(r>=t||e[r]==="*")&&n.push(r);return n}a(rn,"starsKeptSegmentIndexes");function Bs(e,t){if(t.size!==0){for(let n=0;n<e.length-1;n+=1)if(t.has(e[n].toLowerCase())&&!(n+1>=e.length-1))return`${e[n].toLowerCase()}/${e[n+1].toLowerCase()}`}}a(Bs,"bareSliceId");function Vs(e){let t=new Set;for(let n of e??[]){let s=Fe(String(n)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let l=s[o-1];l&&!l.includes("*")&&!l.includes("{")&&!l.includes("}")&&t.add(l)}}}return[...t]}a(Vs,"inferSliceFoldersFromPatterns");function Ws(e,t,n){if(Array.isArray(e.sliceFolders)&&e.sliceFolders.length>0)return e.sliceFolders.filter(s=>typeof s=="string"&&s.length>0);let r=(n??[]).find(s=>s.name===t);return Vs(r?.patterns)}a(Ws,"resolveSliceFolders");function Vt(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(Vt,"normalizeSegments");function ke(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(ke,"trimTrailingSlashes");var zs=["src","app"];function sn(e,t){let n=(e[0]??"").toLowerCase(),r=t.toLowerCase();return zs.includes(n)&&r!==n?[0,1]:[0]}a(sn,"anchorOffsets");function Ys(e){let t=ke(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(Ys,"isBlanketRoot");function Wt(e,t){if(!e||!t?.length)return!1;let n=String(e).split(/[/\\]/).join("/"),r=n.toLowerCase(),s=Vt(n);for(let o of t){if(typeof o!="string"||o.length===0||Ys(o))continue;if(o.includes("*")){let c=ke(o.toLowerCase());if(L(c).test(r)||L(`${c}/**`).test(r))return!0;continue}let i=Vt(o);if(i.length===0)continue;let l=sn(s,i[0]??"");for(let c of l){if(c+i.length>s.length)continue;let d=!0;for(let u=0;u<i.length;u+=1)if(s[c+u]!==i[u]){d=!1;break}if(d)return!0}}return!1}a(Wt,"pathUnderSharedRoot");function zt(e,t){let n=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!n)return!1;let r=t.toLowerCase();return n===r?!0:!n.includes("/")&&r.endsWith(`/${n}`)}a(zt,"sliceMatchesDeclaration");function Yt(e,t,n){return!e?.length||!t||!n?!1:e.some(r=>r&&typeof r.from=="string"&&typeof r.to=="string"&&zt(r.from,t)&&zt(r.to,n))}a(Yt,"crossSliceEdgeAllowed");function qs(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 n=!!e.toSlice||e.toShared===!0;return!t||!n?{denied:!0,reason:"unclassifiable-path"}:e.sharedImportsSlice==="deny"&&e.fromShared===!0&&e.toSlice&&!e.fromSlice?{denied:!0,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}a(qs,"peerIsolationDecision");function on(e){return ke(e.trim().replace(/\\/g,"/")).toLowerCase()}a(on,"aliasGlobPattern");function Zs(e,t){let n=on(e);if(!n||n==="*"||n==="**")return!1;let r=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=De(r),o=L(n),l=(n.split("/").pop()??"").includes("*")?null:L(`${n}/**`),c=a(d=>o.test(d)||l!==null&&l.test(d),"hit");return c(r)||s!==r&&c(s)}a(Zs,"aliasGlobMatches");function an(e){let t=on(e).split("/").filter(Boolean);return t.length<2||t.some(n=>n.includes("*")||n==="."||n==="..")?null:{universeId:t.slice(0,-1).join("/"),childId:t.join("/")}}a(an,"splitAliasTarget");function ln(e,t){for(let n of t.childSlices?.sliceAliases??[])if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&Zs(n.from,e))return n;return null}a(ln,"firstSliceAliasEntry");function Xs(e,t){let n=ln(e,t);return n?an(n.to):null}a(Xs,"firstSliceAlias");function Js(e,t,n){if(!e)return{};let r=n??t.sliceFolders,s=Pe(e,r?[...r]:void 0,t.sliceIdentity),o=Le(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=Xs(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(Js,"resolveGovernedSlice");function Qs(e){let t=[];for(let n of e??[]){if(typeof n!="string"||n.length===0)continue;let r=n.split(/[/\\]/).filter(Boolean).map(l=>l.toLowerCase());if(r.length===1&&r[0]&&!r[0].includes("*")){t.push({literals:[r[0],null],legacy:[r[0],null]});continue}if(r.some(l=>l==="**"||l.includes("*")&&l!=="*"))continue;let s=rn(r);if(!s||!r.includes("*"))continue;let o=a(l=>l==="*"?null:l,"star"),i=s.find(l=>r[l]!=="*")??0;t.push({literals:s.map(l=>o(r[l]??"")),legacy:r.slice(i).map(o)})}return t}a(Qs,"starsUniverseShapes");function qt(e,t){return e.length===t.length&&e.every((n,r)=>n===null||t[r]==="*"||n===t[r])}a(qt,"literalsMatch");function eo(e,t){let n=t.split("/").filter(Boolean).map(o=>o.toLowerCase()),r=Qs(e);if(n.length===0||r.some(o=>qt(o.literals,n)))return[];let s=new Set;for(let o of r)if(o.legacy.length!==o.literals.length&&qt(o.legacy,n)){let i=[...n],l=o.literals.length-o.legacy.length;s.add([...o.literals.slice(0,l).map(()=>"*"),...i].join("/"))}return[...s].sort()}a(eo,"legacyStarsIdTargets");function to(e,t){if(e.sliceIdentity!=="stars")return;let n=an(t);if(n)return eo(e.sliceFolders,n.universeId).length===1?n.universeId:void 0}a(to,"legacyAliasUniverse");function Zt(e,t,n){let r=Js(e,t,n);if(!e||t.sliceIdentity!=="stars")return r;if(r.universeId){let s=ln(e,t);if(!Pe(e,[...n],t.sliceIdentity)&&s&&to(t,s.to)!==void 0)return{...r,legacyAlias:!0,legacyUniverse:r.universeId,legacyChild:r.childId};let i=Bt(e,n),l=t.childSlices,c=l?.sliceIdentity==="stars"?Bt(e,l.sliceFolders):void 0;return{...r,...i?{legacyUniverse:i}:{},...c&&r.childId?{legacyChild:c}:{}}}return r}a(Zt,"placeForPair");function no(e,t,n,r){let s=Zt(n,e,t),o=Zt(r,e,t),i=s.legacyUniverse,l=o.legacyUniverse,c=a((m,R)=>{if(!m.legacyAlias||R.legacyAlias||!R.universeId||R.legacyUniverse?.toLowerCase()!==m.universeId?.toLowerCase())return m;let k=m.childId?.split("/").pop();return{...m,universeId:R.universeId,...k?{childId:`${R.universeId}/${k}`}:{}}},"adopt"),d=c(s,o),u=c(o,s),f=Yt(e.allowedCrossSlice,d.universeId,u.universeId)||e.sliceIdentity==="stars"&&(i!==d.universeId||l!==u.universeId)&&Yt(e.allowedCrossSlice,i,l),p=e.childSlices?.sliceIdentity==="stars"&&s.legacyChild!==void 0&&o.legacyChild!==void 0&&s.legacyChild!==o.legacyChild&&cn(e.childSlices.allowedCrossSlice,s.legacyChild,o.legacyChild),g=a(m=>({...m.universeId?{universeId:m.universeId}:{},...m.childId?{childId:m.childId}:{}}),"strip");return{from:g(d),to:g(u),crossSliceAllowed:f,legacyChildAllowed:p}}a(no,"resolveGovernedSlicePair");function ro(e,t,n){let r=e.split(/[/\\]/).filter(Boolean).map(o=>o.toLowerCase()),s=t.split("/").filter(Boolean).map(o=>o.toLowerCase());if(r.length===0||s.length===0||r.some(o=>o==="**"||o.includes("*")&&o!=="*"))return null;if(n==="stars"){let o=rn(r);if(!o||o.length!==s.length)return null;let i=[...r];for(let l=0;l<o.length;l+=1){let c=o[l]??0;if(r[c]!=="*"&&r[c]!==s[l])return null;i[c]=s[l]??""}return i.join("/")}if(r.length!==s.length)return null;for(let o=0;o<r.length;o+=1)if(r[o]!=="*"&&r[o]!==s[o])return null;return s.join("/")}a(ro,"childPatternDirectory");function so(e,t){let n=De(e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()).split("/"),r=t.split("/"),s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;return s}a(so,"sharedDirectoryPrefix");function oo(e,t){let n=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase();return n.startsWith("src/")&&!t.startsWith("src/")?`src/${t}`:n.startsWith("app/")&&!t.startsWith("app/")?`app/${t}`:t}a(oo,"withSourcePrefix");function io(e,t,n){let r=null;for(let s of n.sliceFolders){if(typeof s!="string")continue;let o=ro(s,t,n.sliceIdentity);if(!o)continue;let i=so(e,o);(!r||i>r.score||i===r.score&&o.length<r.dir.length)&&(r={dir:o,score:i})}return r?oo(e,r.dir):""}a(io,"sliceAliasDestination");var ao="<Layer>";function lo(e,t){let n=ao;if(!e.includes(n)||e.split(n).length!==2||/[*\\/]/.test(e))return null;let r=e.replace(n,t);return!r||r.includes("..")?null:r}a(lo,"sliceRuleFileName");function $e(e){let t=[...new Set(e.layers.filter(s=>typeof s=="string"&&s.length>0))].sort(),n=[],r=new Set;for(let s of e.rules??[]){let o=s?.childSlices,i=o?.arkRulesFile;if(!o||typeof i!="string")continue;let l=new Map;for(let c of e.files){if(typeof c!="string"||c.length===0)continue;let d=s.sliceFolders?.length?Pe(c,s.sliceFolders,s.sliceIdentity):void 0,u=Le(c,d,o);if(!u.childId||l.has(u.childId))continue;let f=io(c,u.childId,o);f&&l.set(u.childId,f)}for(let[c,d]of[...l.entries()].sort((u,f)=>u[0].localeCompare(f[0])))for(let u of t){let f=lo(i,u);if(!f)continue;let p=`${d}/${f}`.replace(/\\/g,"/");r.has(`${u}\0${p}`)||(r.add(`${u}\0${p}`),n.push({path:p,childId:c,layer:u,defaultAppliesTo:[`${d}/**`]}))}}return n}a($e,"resolveSliceRulePlan");function co(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"shared-imports-slice":return`shared root imports slice ${t.toSlice??"?"} (${t.fromPath??"?"} \u2192 ${t.toPath??"?"}). The wall is direct-only.`;case"unclassifiable-path":{let n=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${n.length>0?` (${n.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}a(co,"peerIsolationDenyExplanation");function uo(e,t){return`cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(uo,"crossParentExplanation");function fo(e,t,n){return`cross-sibling slice ${e} \u2192 ${t} inside ${n}.`}a(fo,"crossSiblingExplanation");function po(e){return`universe common imports child ${e}. parentMayImportChild is off.`}a(po,"parentImportsChildExplanation");function Xt(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(Xt,"universePairLabel");function go(e,t){if(!e||!t?.length)return!1;let n=e.toLowerCase();return t.some(r=>typeof r=="string"&&r.length>0&&r.toLowerCase()===n)}a(go,"isCommonFolderName");function Le(e,t,n){if(!e||!n?.sliceFolders?.length)return{};let r=Pe(e,n.sliceFolders,n.sliceIdentity);if(!r||!t)return{};let s=r.toLowerCase(),o=t.toLowerCase();if(s===o)return{};if(!s.startsWith(`${o}/`))return{mismatched:{childId:r,universeId:t}};let i=s.slice(o.length+1).split("/")[0];return go(i,n.commonFolders)?{}:{childId:r}}a(Le,"resolveChildSliceId");function ho(e){return ke(e.trim().replace(/\\/g,"/")).toLowerCase()}a(ho,"siblingEntryKey");function De(e){return e.replace(/^(?:src|app)\//,"")}a(De,"stripSrcOrApp");function mo(e,t){let n=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),r=De(t);if(!r)return!1;let s=De(n);return n===r||n.startsWith(`${r}/`)||s===r||s.startsWith(`${r}/`)}a(mo,"pathUnderSubtree");function yo(e,t,n){if(!t||!n?.length)return!1;let r=t.toLowerCase();for(let s of n){if(typeof s!="string")continue;let o=ho(s);if(!(!o||o.includes("*"))&&(r===o||e&&mo(e,o)))return!0}return!1}a(yo,"importerInEnforcedSubtree");function Ao(e,t,n){return e==null||e==="deny"?!1:e==="advisory"?!0:e.default==="deny"?!1:!yo(t,n,e.enforce)}a(Ao,"siblingCrossingAdvisory");function Jt(e){if(typeof e!="string")return null;let t=ke(e.trim().replace(/\\/g,"/")).toLowerCase();if(!t.includes("/"))return null;let n=t.split("/");for(let r of n)if(r.length===0||r==="."||r===".."||r.includes("*")&&r!=="*")return null;return n}a(Jt,"childSlicePatternSegments");function Qt(e,t){let n=Jt(e),r=Jt(t);if(!n||!r||n.length!==r.length)return!1;for(let s=0;s<n.length;s+=1){let o=n[s];if(o!=="*"&&o!==r[s])return!1}return!0}a(Qt,"childSlicePatternMatches");function cn(e,t,n){if(!e?.length)return!1;for(let r of e)if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&Qt(r.from,t)&&Qt(r.to,n))return!0;return!1}a(cn,"childCrossSliceAllowed");function Ro(e){let t=qs({fromPath:e.fromPath,toPath:e.toPath,folderCount:e.folderCount,fromSlice:e.fromSlice,toSlice:e.toSlice,fromShared:e.fromShared,toShared:e.toShared,crossSliceAllowed:e.crossSliceAllowed,sharedImportsSlice:Ps(e.rule.sharedImportsSlice)});if(t.denied){let i=!!e.rule.childSlices&&t.reason==="cross-slice";return{crossing:t.reason==="cross-slice"?"cross-parent":"fail-closed",decision:"deny",...i?{reasonId:"CROSS_PARENT_SLICE"}:{},explanation:i?uo(e.fromSlice,e.toSlice):co(t.reason??"missing-path",{fromPath:e.fromPath,toPath:e.toPath,fromSlice:e.fromSlice,toSlice:e.toSlice}),peerIsolationReason:t.reason,fromUniverse:e.fromSlice,toUniverse:e.toSlice}}let n=e.rule.childSlices;if(!n||!e.fromSlice||!e.toSlice||e.fromSlice!==e.toSlice||!e.toPath)return{crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};let r=e.fromChild??Le(e.fromPath,e.fromSlice,n).childId,s=e.toChild??Le(e.toPath,e.toSlice,n).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return r&&s&&r!==s?e.legacyChildAllowed||cn(n.allowedCrossSlice,r,s)?o:{crossing:"cross-sibling",decision:Ao(n.siblings,e.fromPath,r)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:fo(r,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!r&&s&&n.parentMayImportChild!==!0?{crossing:"parent-imports-child",decision:"deny",explanation:po(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(Ro,"evaluateNestedSliceWall");function So(e){return e?.crossing==="cross-sibling"||e?.crossing==="parent-imports-child"}a(So,"isChildWallCrossing");function dn(e){let t=e.verdict.explanation,n=So(e.verdict),r=n?e.childMessage:e.ruleMessage;if(e.surface==="intent"){let s=e.defaultMessage??`${e.fromLayer} must not reference ${e.toLayer} intent.`;return n&&t?`${e.childMessage??s} ${t}`:e.verdict.reasonId&&t?`${s} ${t}`:t&&e.verdict.peerIsolationReason!=="cross-slice"?`${s} ${t}`:r?t?`${r} (${t})`:r:s}if(r)return t?`${r} (${t})`:r;if(t){let s=e.kind??"import";return`${e.fromLayer} must not ${s} another slice of ${e.toLayer} (${e.fromPath} \u2192 ${e.toPath}): ${t}`}return`${e.fromLayer} must not ${e.kind??"import"} ${e.toLayer}.`}a(dn,"composeSliceDenialMessage");function un(e){if(!e||e.decision==="allow")return{};let t=Xt(e.fromUniverse),n=Xt(e.toUniverse);return{...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&n?{universeFrom:t,universeTo:n}:{},...e.decision==="advisory"?{failsStrict:!1,severity:"warning"}:{}}}a(un,"sliceFindingExtras");function ko(e,t,n,r){return ct(e,t,n,r)?.rule}a(ko,"findDeniedEdgeRule");function ct(e,t,n,r){for(let s of e??[])if(!(s.from!==t||s.to!==n)&&s.allowed===!1){if(s.peerIsolation){let o=r?.fromPath,i=r?.toPath,l=Ws(s,t,r?.layers),c=no(s,l,o,i),d=c.from,u=c.to,f=d.universeId,p=u.universeId,g=Ro({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:p,fromChild:d.childId,toChild:u.childId,fromShared:!f&&Wt(o,s.sharedRoots),toShared:!p&&Wt(i,s.sharedRoots),crossSliceAllowed:c.crossSliceAllowed,legacyChildAllowed:c.legacyChildAllowed});if(g.decision!=="allow")return{rule:s,peerIsolationReason:g.peerIsolationReason,fromSlice:f,toSlice:p,sliceVerdict:g};continue}if(t!==n)return{rule:s}}}a(ct,"findDeniedEdgeDecision");function bo(e,t,n,r){return ko(e,t,n,r)!==void 0}a(bo,"isEdgeDenied");var Eo=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Io(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(r=>typeof r=="string"):[];return[...e?.excludeGenerated===!1?[]:Eo,...t]}a(Io,"scanExcludePatterns");function dt(e,t){let n=String(e).split(/[/\\]/).join("/");return Io(t).some(r=>L(r).test(n))}a(dt,"isScanExcludedRelative");var fn=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),vo=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Hc=Object.freeze(Object.keys(vo).sort()),ut=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"}),wo=Object.freeze({process:Object.freeze(["process","node:process"])});function pn(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=ut[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=ut[r];if(s)return s;let o=e.indexOf("/",n+1);return o<0?null:ut[e.slice(0,o)]??null}a(pn,"capabilityForModuleSpecifier");function Me(e,t){for(let n of t)if(wo[n]?.includes(e))return n;return null}a(Me,"forbiddenGlobalForModuleSpecifier");function gn(e){if(e?.pure===!0)return[...fn].sort();let n=(e?.capabilities?.deny??[]).filter(r=>fn.includes(r));return[...new Set(n)].sort()}a(gn,"effectiveCapabilityDeny");import nr from"fs";import ee from"path";var hn={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."},xo=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 be(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(be,"looksLikeArkIntent");function ft(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&be(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:hn.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:hn.PUBLISH_MISSING_SOURCE}),t}a(ft,"classifyPublishFacts");var Co=["createArkKernel","createStrictArkKernel","createLenientArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig","createLenientArkKernelFromConfig"],_o="ArkModule",Oo=["forRoot","forRootAsync"],To=["ArkKernel","EventBus","EventPublisher","ArkRunPublisher"],An=new Set(["eventBus"]),No=new Set(["publisher","eventBus"]),Lo=new Set(Oo),Do=new Set(To);var Ke=new Set(Co),Fo=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"]),Rn=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function Q(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")||e==="arkgate/nestjs"||e.startsWith("arkgate/nestjs/")}a(Q,"isArkRunKernelModuleSpecifier");var Po=["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"],pt=new Set(Po);function Sn(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(pt.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let n=e.slice(0,t);if(pt.has(n))return!0;let r=e.indexOf("/",t+1);return r<0?!1:pt.has(e.slice(0,r))}a(Sn,"isArkRunTransportBypassSpecifier");function gt(e){if(Ke.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}a(gt,"arkRunKernelCallKind");function kn(e,t){let n=1;for(let r=0;r<t;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}a(kn,"lineAt");function ht(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,n=>" ".repeat(n.length)))}a(ht,"stripCommentsPreservingLines");function $o(e,t){let n=e.slice(t),r=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(n);if(!r)return;let s=r[2]??"";return s.length>0?s:void 0}a($o,"firstStringLiteralArg");function mn(e,t,n){let r=Math.max(0,t-n.length-8),s=e.slice(r,t);return new RegExp(`\\b${n}\\s+$`).test(s)}a(mn,"keywordBefore");function Ee(e,t){let n=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;)r[1]||t(r[2]??"",r[3]??"")}a(Ee,"parseValueImportClause");function bn(e,t){Ee(ht(e),t)}a(bn,"forEachArkRunValueImportClause");function En(e){let t=/\{([^}]*)\}/.exec(e);if(!t?.[1])return[];let n=[];for(let r of t[1].split(",")){let s=r.trim();if(!s||s.startsWith("type "))continue;let o=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(s),i=o?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(s)?.[1],l=o?.[1]??i;i&&l&&n.push({local:i,original:l})}return n}a(En,"bracedValueImportBindings");function Mo(e){let t=new Map,n=new Set;return Ee(e,(r,s)=>{if(!Q(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(r);o?.[1]&&n.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(r.trim());i?.[1]&&t.set(i[1],i[1]);for(let{local:l,original:c}of En(r))t.set(l,c)}),{named:t,namespaces:n}}a(Mo,"collectKernelImportBindings");function Ko(e,t){let n=new Set(t);return Ee(e,(r,s)=>{for(let{local:o,original:i}of En(r))/^[A-Z]/.test(i)&&(Q(s)||t.has(i)||t.has(o))&&(n.add(o),n.add(i))}),n}a(Ko,"collectImportedConstructors");function Uo(e,t){let n;return Ee(e,(r,s)=>{!n&&new RegExp(`\\b${t}\\b`).test(r)&&(n=s)}),n}a(Uo,"importedFromForName");function jo(e){let t=new Set,n=/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;){if(!Q(r[2]??""))continue;let s=/\{([^}]*)\}/.exec(r[1]??"");if(s?.[1])for(let o of s[1].split(",")){let i=o.trim().replace(/^type\s+/,""),l=/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/.exec(i),c=l?.[1]??i,d=l?.[2]??i;Do.has(c)&&t.add(d)}}return t}a(jo,"collectKernelTypeNames");function Go(e,t){let n=e.split(".");if(n.length===2)return t.namespaces.has(n[0])&&Ke.has(n[1]);if(n.length!==1)return!1;let r=t.named.get(n[0]);return r!==void 0&&Ke.has(r)}a(Go,"isFactoryCalleeExpression");function Ho(e,t,n,r){Ee(e,(s,o)=>{if(!t(o))return;let i=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(s);i?.[1]&&(n.add(i[1]),r?.add(i[1]));let l=/^([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(s.trim());l?.[1]&&n.add(l[1]);let c=/\{([^}]*)\}/.exec(s);for(let d of c?.[1]?.split(",")??[]){let u=d.trim();if(!u||u.startsWith("type "))continue;let f=/([A-Za-z_$][\w$]*)$/.exec(u)?.[1];f&&n.add(f)}})}a(Ho,"addRootModuleImports");function Bo(e,t){let{receivers:n,calleeBindings:r}=t,s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:await\s+)?(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*\.\s*([A-Za-z_$][\w$]*)\b/g,o=/\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*[;\n)]/g,i=/(?:\b(?:const|let|var)\s+|\bthis\s*\.\s*|(?:^|[;{}\n])\s*)([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?(?<![=!<>])=(?![=>])\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*(?:as\s+[A-Za-z_$][\w$.<>]*\s*)?(?=[;\n,)])/g,l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*typeof\s+([A-Za-z_$][\w$]*)\b/g,c;for(let d=!0;d;){d=!1;for(let u of[i,l])for(u.lastIndex=0;(c=u.exec(e))!==null;)!n.has(c[2])||n.has(c[1])||(n.add(c[1]),d=!0);for(s.lastIndex=0;(c=s.exec(e))!==null;)n.has(c[2])&&(!No.has(c[3])&&!t.rootNamespaces.has(c[2])||n.has(c[1])||(n.add(c[1]),d=!0));for(o.lastIndex=0;(c=o.exec(e))!==null;)if(n.has(c[2]))for(let u of c[1].split(",")){let f=/^\s*([A-Za-z_$][\w$]*)\s*(?::\s*([A-Za-z_$][\w$]*))?\s*$/.exec(u);if(!f)continue;let p=f[1],g=f[2]??p;if(An.has(p)){if(n.has(g))continue;n.add(g),d=!0}else gt(p)&&!Ke.has(p)&&r.add(g)}}}a(Bo,"addDerivedReceivers");function Vo(e,t,n){let r={receivers:new Set,calleeBindings:new Set,rootNamespaces:new Set};n&&Ho(e,n,r.receivers,r.rootNamespaces);let s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:await\s+)?((?:[A-Za-z_$][\w$]*\s*\.\s*)?[A-Za-z_$][\w$]*)\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(e))!==null;)Go(o[2].replace(/\s+/g,""),t)&&r.receivers.add(o[1]);let i=jo(e);if(i.size>0){let l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*(?:Readonly\s*<\s*)?([A-Za-z_$][\w$]*)\b/g;for(;(o=l.exec(e))!==null;)i.has(o[2])&&r.receivers.add(o[1])}return Bo(e,r),r}a(Vo,"traceKernelReceivers");function Wo(e,t){let n=0;for(let r=t;r>=0;r-=1){let s=e[r];if(s===")")n+=1;else if(s==="("&&(n-=1,n===0))return r}return-1}a(Wo,"matchingOpenParen");function yn(e){let t=e.split(".").map(n=>n.trim()).filter(n=>n.length>0);return t[0]==="this"?t.slice(1):t}a(yn,"chainParts");function zo(e,t){let n=e.slice(Math.max(0,t-400),t),r=/((?:[A-Za-z_$][\w$]*\s*\??\.\s*)+)$/.exec(n);if(r?.[1]){let d=n.slice(0,n.length-r[1].length);return/[)\]]\s*$/.test(d)||/\.\s*$/.test(d)?{parts:["<expr>"],viaPublisherCall:!1}:{parts:yn(r[1].replace(/\?/g,"")),viaPublisherCall:!1}}let s=/\)\s*\??\.\s*$/.exec(n);if(!s)return;let o=t-n.length+s.index,i=Wo(e,o);if(i<0)return{parts:["<expr>"],viaPublisherCall:!1};let l=e.slice(Math.max(0,i-400),i),c=/((?:[A-Za-z_$][\w$]*\s*\??\.\s*)+)publisher\s*(?:<[^>]*>)?\s*$/.exec(l);return c?.[1]?{parts:yn(c[1].replace(/\?/g,"")),viaPublisherCall:!0}:{parts:["<expr>"],viaPublisherCall:!1}}a(zo,"receiverChainBefore");function Yo(e,t,n){let[r,...s]=e.parts;return r?s.length===0&&t.namespaces.has(r)?!0:Rn.has(r)||!n.receivers.has(r)?!1:(n.rootNamespaces.has(r)?s.slice(1):s).every(i=>An.has(i)):!1}a(Yo,"chainReachesKernel");function qo(e){let t=new Set,n=a((c,d,u)=>{let f=c.get(d);f!==void 0&&f!==u?t.add(d):c.set(d,u)},"bind"),r=new Map,s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(['"])((?:\\.|[^\\])*?)\2\s*(?:as\s+const\s*)?[;\n,)]/g,o;for(;(o=s.exec(e))!==null;)o[3]&&n(r,o[1],o[3]);for(let c of t)r.delete(c);let i=new Map(r),l=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:[A-Za-z_$][\w$]*\s*\.\s*)*(?:define|defineIntent)\s*(?:<[^>]*>)?\s*\(\s*(?:(['"])((?:\\.|[^\\])*?)\2|([A-Za-z_$][\w$]*)\s*[,)])/g;for(;(o=l.exec(e))!==null;){let c=o[3]??(o[4]?r.get(o[4]):void 0);c?n(i,o[1],c):(t.has(o[4]??"")||i.has(o[1]))&&t.add(o[1])}for(let c of t)i.delete(c);return i}a(qo,"collectDefinedIntentNames");function Zo(e,t){return/^\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(e.slice(t))?.[1]}a(Zo,"firstIdentifierArg");function Xo(e,t){return be(e)?!0:(t??[]).some(n=>{let r=n.trim();if(!r)return!1;let s=r.endsWith(".")?r:`${r}.`;return e.startsWith(s)&&/^[A-Za-z0-9_.]+$/.test(e.slice(s.length))})}a(Xo,"carriesIntentPrefix");function Jo(e){if(!e)return;if(e.viaPublisherCall)return"publisher";let t=e.parts[e.parts.length-1];return t==="<expr>"?void 0:t}a(Jo,"receiverName");function Qo(e,t,n){if(!e||t===void 0||!Xo(t,n))return!1;let r=e.parts[0];return r!==void 0&&r!=="<expr>"&&!Rn.has(r)}a(Qo,"untracedKernelNameEvidence");function Ue(e,t,n={}){let r=ht(t),s=Mo(r),o=Vo(r,s,n.isKernelRootSpecifier),i=qo(r),l=[],c=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,d;for(;(d=c.exec(r))!==null;){let u=d[1],f=d.index;if(mn(r,f,"function")||mn(r,f,"class"))continue;let p=zo(r,f),g=Jo(p),m=s.named.get(u)??u,R=gt(m)??gt(u),k=s.named.has(u)||o.calleeBindings.has(u)||p?.parts.length===1&&s.namespaces.has(p.parts[0]);if(!R&&Lo.has(u)&&p?.parts.length===1&&s.named.get(p.parts[0])===_o&&(R="factory",k=!0),!R||R==="factory"&&p!==void 0&&!k)continue;let y=f+d[0].length,A=$o(r,y);if(R!=="factory"&&(p===void 0?!k:!Yo(p,s,o))&&!Qo(p,A,n.intentPrefixes))continue;let S=Zo(r,y),I=A??(S?i.get(S):void 0);l.push({file:e,line:kn(t,f),kind:R,callee:u,viaImport:k,...g?{receiver:g}:{},...I?{nameLiteral:I}:{}})}return l}a(Ue,"extractArkRunKernelCallsFromSource");function mt(e,t,n){let r=ht(t),s=Ko(r,n),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,l;for(;(l=i.exec(r))!==null;){let c=l[1];if(Fo.has(c)||!s.has(c))continue;let d=Uo(r,c);o.push({file:e,line:kn(t,l.index),typeName:c,...d?{importedFrom:d}:{}})}return o}a(mt,"extractArkRunManagedNewsFromSource");var ei=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),ti=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),ni=new Set(["return","typeof","case","do","else","in","of","new","delete","void","throw","instanceof","yield","await"]);function ri(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n-=1;if(n<0)return!0;let r=e[n];if(/[A-Za-z0-9_$]/.test(r)){let s=n;for(;s>=0&&/[A-Za-z0-9_$]/.test(e[s]);)s-=1;return ni.has(e.slice(s+1,n+1))}return r==="/"&&e[n-1]==="*"?!1:ti.has(r)}a(ri,"slashStartsRegex");function si(e,t){if(!ri(e,t))return t;let n=t+1,r=!1;for(;n<e.length;){let s=e[n];if(s===`
2
- `||s==="\r")return t;if(s==="\\"){n+=2;continue}if(r)s==="]"&&(r=!1);else if(s==="[")r=!0;else if(s==="/"){for(n+=1;n<e.length&&/[A-Za-z]/.test(e[n]);)n+=1;return n}n+=1}return t}a(si,"skipRegexLiteral");function ae(e,t){let n=e[t];if(n==="/"&&e[t+1]==="/"){let r=e.indexOf(`
3
- `,t);return r===-1?e.length:r}if(n==="/"&&e[t+1]==="*"){let r=e.indexOf("*/",t+2);return r===-1?e.length:r+2}if(n==="/")return si(e,t);if(n==="'"||n==='"'||n==="`"){let r=t+1;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]===n)return r+1;r+=1}return e.length}return t}a(ae,"skipStringOrComment");function oe(e,t){let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n+=1;continue}if(e[n]==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ae(e,n);continue}break}return n}a(oe,"skipWsAndComments");function In(e,t){let n=e[t];if(!n||!/[A-Za-z_$]/.test(n))return null;let r=t+1;for(;r<e.length&&/[A-Za-z0-9_$]/.test(e[r]);)r+=1;return{ident:e.slice(t,r),end:r}}a(In,"readIdent");function ie(e,t,n,r){if(e[t]!==n)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=ae(e,o);if(i!==o){o=i;continue}let l=e[o];l===n?s+=1:l===r&&!(r===">"&&e[o-1]==="=")&&(s-=1),o+=1}return s===0?o:null}a(ie,"skipBalanced");function vn(e){let t=[],n=0,r;for(;n<e.length&&(n=oe(e,n),!(n>=e.length));){if(e[n]===";"){n+=1;continue}let s=[],o=n;for(;;){let u=In(e,o);if(!u||!ei.has(u.ident))break;s.push(u.ident),o=oe(e,u.end)}if(s.length===1&&s[0]==="static"&&e[o]==="{"){let u=ie(e,o,"{","}");if(u==null){r=e.length;break}n=u;continue}let i=In(e,o);if(!i){n+=1;continue}if(o=oe(e,i.end),e[o]==="<"){let u=ie(e,o,"<",">");if(u==null){r=e.length;break}o=oe(e,u)}if(e[o]==="("){let u=ie(e,o,"(",")");if(u==null){r=e.length;break}if(o=oe(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let f=ae(e,o);if(f!==o){o=f;continue}o+=1}if(e[o]==="{"){let f=ie(e,o,"{","}");if(f==null){r=e.length;break}t.push({name:i.ident,modifiers:s,kind:"method",body:e.slice(o+1,f-1)}),n=f;continue}if(e[o]===";"){n=o+1;continue}n=o+1;continue}let l=0,c=0,d=0;for(;o<e.length;){let u=ae(e,o);if(u!==o){o=u;continue}let f=e[o];if(f==="{")l+=1;else if(f==="}"){if(l===0)break;l-=1}else if(f==="(")c+=1;else if(f===")")c-=1;else if(f==="[")d+=1;else if(f==="]")d-=1;else if(f===";"&&l===0&&c===0&&d===0){o+=1;break}o+=1}o>=e.length&&(l>0||c>0||d>0)&&(r=e.length),t.push({name:i.ident,modifiers:s,kind:"field",body:""}),n=o}return{members:t,truncatedAt:r}}a(vn,"scanClassMembers");function oi(e,t){let n=t;for(;n<e.length;){let r=oe(e,n);if(r!==n){n=r;continue}let s=e[n];if(s==="{")return n;if(s===";")return null;if(s==="<"||s==="("||s==="["){let i=ie(e,n,s,s==="<"?">":s==="("?")":"]");if(i==null)return null;n=i;continue}if(s==='"'||s==="'"||s==="`"){n=ae(e,n);continue}n+=1}return null}a(oi,"findClassBodyBrace");function wn(e,t={}){let n=[],r=t.exportedOnly?/\bexport\s+(?:abstract\s+)?class\s+([A-Za-z_$][A-Za-z0-9_$]*)/g:/(?:\b(export)\s+(?:default\s+)?)?(?:\babstract\s+)?\bclass\s+([A-Za-z_$][A-Za-z0-9_$]*)/g,s=ii(e),o;for(;(o=r.exec(s))!==null;){let i=t.exportedOnly?o[1]:o[2],l=t.exportedOnly===!0||o[1]==="export",c=oi(e,o.index+o[0].length);if(c==null){n.push({name:i,start:o.index,exported:l,bodyStart:null,bodyEnd:null});continue}let d=ie(e,c,"{","}");n.push({name:i,start:o.index,exported:l,bodyStart:c+1,bodyEnd:d==null?null:d-1})}return n}a(wn,"findClassDeclarations");function ii(e){let t="",n=0;for(;n<e.length;){let r=ae(e,n);if(r!==n){t+=e.slice(n,r).replace(/[^\n]/g," "),n=r;continue}t+=e[n],n+=1}return t}a(ii,"maskStringsAndComments");var ai=/\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)/,li=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)/,ci=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]/g,di=["db","tx","client","prisma","prismaClient","drizzle"],ui="(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))",On=/\b(?:INSERT\s+INTO|(?<!\b(?:FOR(?:\s+NO\s+KEY)?|DO)\s)UPDATE(?:\s+ONLY)?(?!\s+(?:OF|SET)\b)|DELETE\s+FROM(?:\s+ONLY)?|MERGE\s+INTO|TRUNCATE(?:\s+TABLE)?(?:\s+ONLY)?)\s+(?:(?:(?:"[^"]*"|[A-Za-z_][\w$]*)\s*\.\s*)?(?:"[^"]*"|[A-Za-z_][\w$]*)|\$\{[^}]+\})/i,fi=/^(?:await|return|throw|yield|new|typeof|void|delete|if|else|case|of|in|instanceof|async|function|class|const|let|var|import|export|from|as|default|type)$/,xn=/(^|[^\w$])([A-Za-z_$][\w$]*)\s*`((?:[^`\\]|\\[\s\S])*)`/g,pi=/\bINSERT\s+INTO\b[\s\S]*?\bON\s+CONFLICT\b[\s\S]*?\bDO\s+UPDATE\s+SET\b[^;`]*/gi,Cn="\\((?:[^()]|\\([^()]*\\))*\\)",gi=`\\bnew\\s+PrismaClient\\s*${Cn}|\\bdrizzle\\s*${Cn}`,hi=/(?<![\w$])([A-Za-z_$][\w$]*)\s*[?!]?\s*(?::[^=;\n]+)?=(?![=>])\s*(?:await\s+)?(?:new\s+(?:PrismaClient|Pool|Client|MongoClient|Sequelize|Kysely|Knex)\b|(?:drizzle|knex|Knex|postgres)\s*\()/g,mi=/(?<![\w$])([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?(?:Prisma\s*\.\s*TransactionClient|PrismaClient|Pool|PoolClient|MongoClient|Sequelize|Kysely|Knex|DataSource|EntityManager|NodePgDatabase|PostgresJsDatabase|BetterSQLite3Database|MySql2Database|LibSQLDatabase)\b/g;function yi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(yi,"escapeRegExp");function Ie(e){return ai.test(e)||li.test(e)}a(Ie,"sourceImportsPersistenceDriverText");function _n(e,t,n){let r=new RegExp(e.source,"g"),s;for(;(s=r.exec(t))!==null;)s[1]&&n.add(s[1])}a(_n,"collectFirstGroup");function Ai(e){let t=new Set;_n(hi,e,t),_n(mi,e,t);let n=new RegExp(ci.source,"g"),r;for(;(r=n.exec(e))!==null;)for(let s of(r[1]??"").split(",")){let o=s.trim().replace(/^type\s+/,"").split(/\s+as\s+/),i=(o[1]??o[0]??"").trim();/^[A-Za-z_$][\w$]*$/.test(i)&&t.add(i)}return[...t].sort()}a(Ai,"persistenceClientBindings");function Tn(e){return e.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|`(?:[^`\\]|\\[\s\S])*`|'(?:[^'\\]|\\[\s\S])*'|"(?:[^"\\]|\\[\s\S])*"/g,t=>t.charCodeAt(0)===47?t.replace(/[^\n]/g," "):t.charCodeAt(0)===96?t.replace(/--[^\n`]*/g,n=>" ".repeat(n.length)):t)}a(Tn,"blankPersistenceComments");function Nn(e){let t=Tn(e);xn.lastIndex=0;let n;for(;(n=xn.exec(t))!==null;)if(!fi.test(n[2]??"")&&On.test((n[3]??"").replace(pi," ")))return!0;return!1}a(Nn,"sourceHasTaggedSqlWrite");function je(e){let t=Tn(e),n=[...di,...Ai(t)].map(yi).join("|");return new RegExp(`(?:\\b(?:${n})(?![\\w$])|${gi})(?:\\s*\\.\\s*[A-Za-z_]\\w*)*\\s*\\.\\s*${ui}\\s*\\(`,"i").test(t)?!0:On.test(t)}a(je,"sourceHasPersistenceWrite");var Ri=["no-anemic-model"],Fn=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Si=new RegExp(`\\b(${Fn.join("|")})\\b`),Pn="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",ki=new RegExp(`\\bthis\\.${Pn}\\.push\\s*\\(`),bi=new RegExp(`^this\\.${Pn}\\s*=\\s*\\[\\s*\\]`),Ei=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,Ii=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g;function vi(){return`${Fn.join(", ")}, or events-array .push(`}a(vi,"expectedDomainInvariantWordsPhrase");function wi(e){return Si.test(e)||ki.test(e)}a(wi,"referencesGuardOrPublish");function xi(e,t,n){let r=e.slice(t);if(bi.test(r))return!0;if(!Ei.test(r))return!1;if(n&&/^pullEvents$/i.test(n))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}a(xi,"isIdiomaticEventsReset");function Ci(e,t){let n=new RegExp(Ii.source,"g"),r;for(;(r=n.exec(t))!==null;)if(!xi(t,r.index,e))return!0;return!1}a(Ci,"methodAssignsThis");function Ln(e,t){return t==null?e:{...e,truncatedUntil:t}}a(Ln,"attachShapeTruncation");function $n(e){return typeof e.truncatedUntil=="number"?e.truncatedUntil:void 0}a($n,"shapeTruncatedUntil");function _i(e){let t=$n(e);return t==null?"":` shape analysed until character ${t}`}a(_i,"shapeTruncationSuffix");function Dn(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Dn,"escapeGlobLiteral");function Oi(e){let t="";for(let r=0;r<e.length;r+=1){let s=e[r];if(s==="\\"&&r+1<e.length){let o=e[r+1];if("*?{}[],".includes(o)||o==="\\"){t+="\\"+o,r+=1;continue}t+="/";continue}t+=s}let n="";for(let r=0;r<t.length;r+=1){let s=t[r];s==="\\"&&r+1<t.length?(n+=Dn(t[r+1]),r+=1):s==="*"?t[r+1]==="*"?t[r+2]==="/"?(n+="(?:.*/)?",r+=2):(n+=".*",r+=1):n+="[^/]*":s==="?"?n+="[^/]":n+=Dn(s)}return new RegExp(`^${n}$`)}a(Oi,"globToRegExp");function Ge(e,t){return!t||t.length===0?!0:t.some(n=>Oi(n).test(e))}a(Ge,"matchesAppliesTo");function Ti(e){return Ri.includes(e)}a(Ti,"isTier2");function Ni(e){return e.mode==="enforced"&&!Ti(e.sensor)?{severity:"error",failsStrict:!0}:{severity:"warning",failsStrict:!1}}a(Ni,"severityFor");function V(e,t,n,r=1){let{severity:s,failsStrict:o}=Ni(e);return{ruleId:"ARKRULE_STRUCTURE",code:e.sensor,message:n,file:t,line:r,fromLayer:e.provenance.layer,arkruleId:e.id,arkruleSource:e.provenance.sourceFile,severity:s,sensor:e.sensor,failsStrict:o}}a(V,"baseViolation");function He(e,t,n){if(!n)return!0;let r=n(e);return r?r===t.provenance.layer:!1}a(He,"isInRuleLayer");function Be(e,t,n){return t.filter(r=>!(!r.exported||!Ge(r.file,e.appliesTo)||!He(r.file,e,n)))}a(Be,"shapesForRule");function yt(e,t,n){let r=$n(t);if(r!=null)return V(e,t.file,`Exported class ${t.className} shape analysed until character ${r}; later ${n} may be invisible (sensor ${e.sensor}).`)}a(yt,"truncatedShapeViolation");function Li(e,t,n){let r=[];for(let s of Be(e,t,n)){let o=yt(e,s,"members");o&&r.push(o),(s.hasPublicSetters||s.hasPublicMutableFields)&&r.push(V(e,s.file,`Exported class ${s.className} exposes public mutable state (sensor aggregate-private-state).`))}return r}a(Li,"evaluateAggregatePrivateState");function Di(e,t,n){let r=[];for(let s of Be(e,t,n)){let o=yt(e,s,"constructors and factories");if(o&&r.push(o),s.hasPublicConstructor&&!s.hasStaticFactory){if(!(s.hasPublicMutableFields||s.hasPublicSetters||(s.mutatingMethods?.length??0)>0))continue;r.push(V(e,s.file,`Exported class ${s.className} exposes a public constructor without a static factory (sensor always-valid-factory).`))}}return r}a(Di,"evaluateAlwaysValidFactory");function Fi(e,t,n){let r=[],s=vi();for(let o of Be(e,t,n)){let i=_i(o),l=yt(e,o,"methods");l&&r.push(l);for(let c of o.mutatingMethods)c.referencesGuardOrPublish||r.push(V(e,o.file,`Mutating method ${o.className}.${c.name} does not reference ${s} (sensor domain-event-on-mutation).${i}`))}return r}a(Fi,"evaluateDomainEventOnMutation");function Pi(e,t){let n=[];for(let r of t.files)Ge(r,e.appliesTo)&&He(r,e,t.layerForFile)&&t.fileHints?.[r]?.orchestrationHeavy&&n.push(V(e,r,"File appears to embed domain branching beyond guard-and-delegate orchestration (sensor orchestration-only)."));return n}a(Pi,"evaluateOrchestrationOnly");function $i(e,t){let n=[];for(let r of t.files)Ge(r,e.appliesTo)&&He(r,e,t.layerForFile)&&t.fileHints?.[r]?.adapterThick&&n.push(V(e,r,"Adapter module mixes domain branching, persistence, and mapping beyond a thin adapter (sensor thin-adapter)."));return n}a($i,"evaluateThinAdapter");function Mi(e,t){let n=[];for(let r of t.files)Ge(r,e.appliesTo)&&He(r,e,t.layerForFile)&&t.fileHints?.[r]?.persistenceWrite&&n.push(V(e,r,"File imports a persistence driver and issues a write; route the write through a Domain aggregate and a persistence adapter (sensor writes-via-aggregate)."));return n}a(Mi,"evaluateWritesViaAggregate");function Ki(e,t,n){let r=[];for(let s of Be(e,t,n))if(s.dataOnly===!0){let o=V(e,s.file,`Exported type ${s.className} looks data-only / anemic (sensor no-anemic-model; advisory only).`);r.push({...o,severity:"warning",failsStrict:!1})}return r}a(Ki,"evaluateNoAnemicModel");function Mn(e){if(!e.arkRules.structure.length)return[];let t=[];for(let n of e.arkRules.structure)switch(n.sensor){case"aggregate-private-state":t.push(...Li(n,e.classShapes,e.layerForFile));break;case"always-valid-factory":t.push(...Di(n,e.classShapes,e.layerForFile));break;case"domain-event-on-mutation":t.push(...Fi(n,e.classShapes,e.layerForFile));break;case"orchestration-only":t.push(...Pi(n,e));break;case"thin-adapter":t.push(...$i(n,e));break;case"writes-via-aggregate":t.push(...Mi(n,e));break;case"no-anemic-model":t.push(...Ki(n,e.classShapes,e.layerForFile));break;case"invariant-coverage":break;default:break}return t.sort((n,r)=>n.file.localeCompare(r.file)||n.arkruleId.localeCompare(r.arkruleId)||n.message.localeCompare(r.message))}a(Mn,"evaluateArkRuleSensors");function Ui(e){return e==="PersistenceAdapters"}a(Ui,"isPersistenceDriverLayer");function ji(e,t){if(Ie(e))return!0;if(!t)return!1;for(let n of t){if(Ui(n.layer))return!0;let r=n.specifier;if(!r)continue;let s=`from '${r}'`;if(Ie(s))return!0}return!1}a(ji,"sourceImportsPersistenceDriver");var Gi=/\b(?:@Controller|@Get|@Post|@Put|@Delete|Router\(\)|createRouter|express\.Router|fastify\.(?:get|post)|export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|DELETE|PATCH)\b|export\s+const\s+(?:GET|POST|PUT|DELETE|PATCH)\s*=)/,Hi=/(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/,Bi=/\b(?:export\s+)?(?:async\s+)?function\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*|\b(?:export\s+)?const\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*\s*=/,Vi=/\bif\s*\(\s*(?:!)?(?:order|invoice|cart|user|account|policy|aggregate|entity|amount|total|balance|status|state)\b/i;function Kn(e,t,n){if(!t)return null;let r=ji(t,n),s=r&&je(t)||Nn(t);if(t.length<40)return s?{persistenceWrite:!0}:null;let o=t.match(new RegExp(Bi.source,"g"))??[],i=t.match(new RegExp(Vi.source,"g"))??[],l=(t.match(/\bif\s*\(/g)??[]).length,c=(t.match(/\bswitch\s*\(/g)??[]).length,d=o.length>=2||o.length>=1&&i.length>=2||i.length>=3&&l+c>=6,u=Gi.test(t)||Hi.test(t),f=o.length>=1||i.length>=2,p=/\b(?:mapTo|toDomain|toDto|fromRow|toEntity|fromPrisma|serialize|deserialize)\w*\s*[(=]/.test(t),g=r&&f||u&&f||r&&p&&(l>=4||o.length>=1)||u&&r;return!d&&!g&&!s?null:{...d?{orchestrationHeavy:!0}:{},...g?{adapterThick:!0}:{},...s?{persistenceWrite:!0}:{}}}a(Kn,"deriveArkRuleFileHints");var Wi=new Set(["if","match","when"]);function ve(e,t){let n=[];for(let r of wn(t,{exportedOnly:!0})){let s=r.name;if(r.bodyStart==null){n.push(Ln({file:e,className:s,exported:!0,hasPublicMutableFields:!1,hasPublicSetters:!1,hasPublicConstructor:!1,hasStaticFactory:!1,mutatingMethods:[]},r.start));continue}let o=r.bodyStart,i=r.bodyEnd==null,l=t.slice(o,r.bodyEnd??t.length),c=vn(l),d=i?t.length:c.truncatedAt==null?void 0:o+c.truncatedAt,u=c.members.filter(S=>!(S.kind!=="field"||S.name==="constructor"||S.modifiers.includes("private")||S.modifiers.includes("protected")||S.modifiers.includes("readonly")||S.modifiers.includes("static")||S.modifiers.includes("get")||S.modifiers.includes("set"))),f=u.length>0,p=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(l),g=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(l),m=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(l)&&!g,R=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(l)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(l),k=[];for(let S of c.members)S.kind==="method"&&S.name!=="constructor"&&(S.modifiers.includes("static")||S.modifiers.includes("get")||S.modifiers.includes("set")||Wi.has(S.name)||Ci(S.name,S.body)&&k.push({name:S.name,referencesGuardOrPublish:wi(S.body)}));let A=c.members.filter(S=>S.kind==="method").length<=1&&u.length>=2&&f;n.push(Ln({file:e,className:s,exported:!0,hasPublicMutableFields:f,hasPublicSetters:p,hasPublicConstructor:m,hasStaticFactory:R,mutatingMethods:[...k],dataOnly:A},d))}return n}a(ve,"extractClassShapesFromSource");function zi(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,n=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return n==null&&typeof e.classifiedFiles=="number"&&(n=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:n}}a(zi,"normalizeExtraMergeTeethClassification");function Ve(e){let t=zi(e),n=typeof t.governedPercent=="number"?t.governedPercent:null,r=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return n==null&&r==null?!0:(n??0)>=50&&(r??0)>=1}a(Ve,"extraMergeTeethAllowed");function h(e,t,n,r,s,o){return{ruleId:e,title:n,why:r,fix:s,docsAnchor:e,category:t,...o?.oftenAdvisory?{oftenAdvisory:!0}:{}}}a(h,"entry");var Un=Object.freeze([h("LAYER_IMPORT_VIOLATION","layer","This import is not allowed","This file imported a folder it may not reach. The write doesn\u2019t land. The same check fails the pull request.","Branch by import kind: constants/types/pure \u2192 adopt into DomainModel or SharedKernel (do not invent a port); kernel/events/bootstrap from Persistence \u2192 inject a port or move the map to SharedTypes (Persistence must not emit); define a port only when the target is a real use-case. Type-only edges use `import type`. Then preflight again. Do not weaken the layer rule without a hash-bound policy acknowledgement."),h("LAYER_INTENT_REFERENCE_VIOLATION","layer","Intent referenced across a blocked layer edge","A string intent (or intent-like reference) names a layer that the file\u2019s layer may not reach under the contract rules \u2014 the same plane as import edges, for event/intent coupling.","Reference that intent from a layer allowed to know about it (usually an adapter or application layer), or relocate the reference \u2014 then preflight again."),h("LAYER_REFERENCE_VIOLATION","layer","Layer reference blocked (snippet / AI gate)","Snippet analysis found an intent or string reference that would couple layers in a direction the architecture profile forbids.","Move the reference to an allowed layer or introduce a port/event boundary, then re-run the snippet gate."),h("SHARED_IMPORTS_SLICE","layer","A shared root imports a slice",'A declared shared root imports a slice directly. That hop is allowed while sharedImportsSlice is unset or "deny-cross-parent", so this is advisory: the universe wall is direct-only.','Move the code the shared root needs into the shared root, or invert the dependency. Set sharedImportsSlice: "deny" to make these edges errors. With "deny-cross-parent", a slice that reaches another universe through a shared root is reported as LAYER_IMPORT_VIOLATION with reasonId CROSS_PARENT_VIA_SHARED. This warning does not fail the check.',{oftenAdvisory:!0}),h("CIRCULAR_DEPENDENCY","layer","Dependency cycle","Two or more modules import each other in a loop. Cycles make ownership unclear and break stable layer direction.","Extract the shared dependency into a third module, invert one edge behind a port, or merge units that are truly one \u2014 then preflight again."),h("CROSS_WALL_DUPLICATE","layer","Code copied across a wall","Near-identical code sits on two sides of a slice wall (or in two layers that may not import each other). The wall would deny the import, so the code was copied instead. Status details (`--doctor --all`) and the report list it from token fingerprints taken at status time; they never enter the check, so the verdict does not change. Same-slice copies are counted, never listed.","Move one copy to a shared home the wall allows \u2014 a declared shared root, the universe common folder, or a layer both sides may import \u2014 then import it from both sides. One move at a time, through the write gate (/ark-place names the destination). Advisory only \u2014 it never fails a run.",{oftenAdvisory:!0}),h("CROSS_LAYER_DUPLICATE","layer","Code copied in two layers","Near-identical code sits in two layers, and at least one of them may import the other. Status details (`--doctor --all`) and the report list it from token fingerprints taken at status time; the verdict does not change.","Keep one copy in the lower layer both sides may import, and import it from the other. One move at a time, through the write gate. Advisory only \u2014 it never fails a run.",{oftenAdvisory:!0}),h("FORBIDDEN_GLOBAL","capability","Forbidden ambient global or dual import","The file\u2019s layer lists this ambient (or its exact import dual, e.g. process / node:process) in forbiddenGlobals. Pure layers must not reach wall-clock, network, process, or similar effects directly.","Inject the capability through a small port (Clock, HttpPort, Config, \u2026), bind the implementation outside the walled layer, then preflight again."),h("CAPABILITY_VIOLATION","capability","Denied effect capability","The layer denies an effect capability (network, filesystem, clock, randomness, environment, process, persistence) and the candidate uses that effect via ambient or import evidence.","Define a capability port in the walled layer, bind the implementation in an adapter layer, then preflight again. Never mechanical-safe \u2014 port shape is a design decision."),h("RAW_EVENT_PUBLISH","publish","Raw event publish","Publish went through a raw string or object instead of a registered intent creator, bypassing Ark intent contracts and tooling.","Publish through a registered intent creator, then run Ark again."),h("PUBLISH_MISSING_SOURCE","publish","Publish missing metadata.source","A strict Ark publish call omitted metadata.source, so the publishing layer cannot be verified.","Add metadata.source to the publish call, then run Ark again."),h("PUBLISH_SOURCE_LAYER_MISMATCH","publish","Publish source layer mismatch","metadata.source resolves to a different layer than the file performing the publish.","Use a source intent owned by the same layer as this file, or move the publish call to the owning layer."),h("UNKNOWN_INTENT","publish","Unknown intent reference","Snippet analysis saw an intent string that is not registered in the intent registry / profile under check.","Register the intent or use a known intent name from the project registry, then re-run the gate."),h("DYNAMIC_IMPORT_NOT_ALLOWLISTED","safety","Non-literal dynamic import","A dynamic import(expr) cannot be resolved statically and the file is not on dynamicImportAllowlist. Unresolved dynamics can hide layer edges.","Rewrite to a static import when possible, or add only reviewed files to dynamicImportAllowlist after human sign-off."),h("DYNAMIC_REQUIRE_NOT_ALLOWLISTED","safety","Non-literal require","A require(expr) cannot be resolved statically and is not allowlisted \u2014 same hide-the-edge risk as dynamic import.","Prefer static import, or allowlist only reviewed files after sign-off."),h("TS_SUPPRESSION_THRESHOLD_EXCEEDED","safety","@ts-ignore / @ts-nocheck threshold","Count of TypeScript suppressions in governed production source exceeds safety.maxTsSuppressions.","Remove suppressions by fixing types, or raise the threshold only with an explicit production exception in ark.config.json."),h("ANY_CAST_THRESHOLD_EXCEEDED","safety","Explicit any cast threshold","Count of explicit any casts exceeds safety.maxAnyCasts.","Replace any with precise types, or raise the threshold only with a documented exception."),h("IN_MEMORY_STORE_IN_PRODUCTION_SOURCE","safety","In-memory store in production source","Governed production source references an Ark InMemory* store without safety.allowInMemory \u2014 durable systems should not ship ephemeral stores by accident.","Provide a durable store implementation, or set safety.allowInMemory only for an explicitly ephemeral service."),h("PEER_ISOLATION_DISABLED","safety","peerIsolation disabled on a rule","A same-layer or peer rule disables peerIsolation (or omits it where required), which allows cross-slice coupling the contract otherwise blocks.","Restore peerIsolation: true, or set safety.allowDisabledPeerIsolation only with a documented production exception."),h("ARKRULE_STRUCTURE","arkrules","ArkRule structure sensor failed","An opt-in ArkRules structure sensor (private state, factory shape, event publish, persistence write outside an aggregate, \u2026) failed on a governed file for a declared arkruleId.","Restore the declared structure for the ArkRule (see arkruleSource), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement."),h("ARKRULE_INVARIANT","arkrules","ArkRule invariant failed","Reserved / remediation-recognized code for invariant-plane failures bound to an ArkRule id (coverage path also emits INVARIANT_UNCOVERED).","Fix the invariant for the ArkRule declared in arkrules/<Layer>.json, then preflight again. Do not demote without acknowledgement."),h("ARKRULE_SCOPE_EMPTY","arkrules","ArkRule appliesTo matched zero files","An ArkRule\u2019s appliesTo globs matched no governed files \u2014 the rule cannot observe what it claims to protect.","Fix appliesTo globs so they match governed files, or remove the rule. Enforced empty scope fails; advisory empty scope warns.",{oftenAdvisory:!0}),h("ARKRULE_HINT_BUDGET_EXHAUSTED","arkrules","Structural-hint budget exhausted","orchestration-only, thin-adapter, and writes-via-aggregate only evaluate files the hint loader preloaded. When eligible governed files exceed that budget (coverage.maxFiles, default 400 \u2014 there is no arkrules.hintBudget), those sensors never saw the rest of their scope. Enforced + unreviewed is not green. The finding names exact hinted/governed counts and per-sensor reviewed N/M of scope.","Raise coverage.maxFiles in ark.config.json (this cap also bounds structural-hint preload; --doctor names the coupling) so hinted/governed counts match, then re-run with --strict-config. An enforced hint sensor that cannot see its scope fails strict."),h("ARKRULE_FILE_UNREFERENCED","arkrules","ArkRules file not referenced","A JSON file under arkrules/, or a slice file named arkrules.<Layer>.json beside governed code, is not in the effective catalog, so none of its rules are enforced. Drift looks like governance until someone notices.","Reference a central file from arkRules, set childSlices.arkRulesFile so a slice file is discovered, or delete it. Advisory only: it never fails the check.",{oftenAdvisory:!0}),h("ARKRULE_DUPLICATE_ID","arkrules","ArkRule id declared more than once","Two ArkRules files in one layer declare the same effective id. Central ids stay bare. A slice file is namespaced as <childId>#<localId>, so the same local id in two slices is not a duplicate.","Rename one id, or split the files onto different slices. Config load fails closed. The catalog is not enforced until the id is unique."),h("ARKRULE_SCOPE_ESCAPES_SLICE","arkrules","Slice ArkRule appliesTo leaves its slice","A file discovered from childSlices.arkRulesFile set appliesTo to a glob that can match outside that child slice. The default, when appliesTo is omitted, is the slice directory.","Narrow appliesTo to the slice directory, or omit it. Config load fails closed. The escaping rule is not enforced."),h("INVARIANT_CATALOG_EMPTY","arkrules","Domain invariant catalog is empty","ArkRules is on and a Domain-role layer has code, but invariants[] has no phrases the code must preserve. Empty looks like \u201Cdone\u201D until someone fills the catalog.","Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json (or the mapped file). Starters show the shape. Advisory unless a domain structure rule is already enforced \u2014 then --strict-merge can refuse. Do not freeze this finding.",{oftenAdvisory:!0}),h("INVARIANT_UNCOVERED","arkrules","Invariant without coverage evidence","An ArkRules invariant is under contract but no covering test title or declared symbol evidence was found (or coverage is partial). Kind is never-had-tests (adopt residual) vs tests-disappeared (suite exists).","Add a test title or declared symbol covering the arkruleId, then preflight again. Treat never-had-tests as adopt residual; treat tests-disappeared as a regression. Missing test globs report partial \u2014 never fake green. When the message reports an exhausted file budget, raise coverage.maxFiles (or narrow coverage.testGlobs) in ark.config.json."),h("INVARIANT_COVERAGE_OUTSIDE_ROOTS","arkrules","Covering test outside the declared coverage roots","The only test naming this invariant sits outside coverage.coverageRoots \u2014 the places the project declares its runner executes. ArkGate matches declared text and never executes tests, so it cannot tell whether that file is ever run: coverage there is a test that exists, not a test that runs.","Move the test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json. Advisory: it never fails strict, but promotion to enforced refuses on it.",{oftenAdvisory:!0}),h("INVARIANT_PROBE_SURVIVED","arkrules","Covering tests do not pin the invariant","The committed invariant probe (.ark/invariant-probe.json, written by arkgate-check --probe-invariants --write) shows, for files that have not changed since, that the covering tests still pass with the invariant's symbol broken on purpose (survived) or never call it (not reached). The test names the rule but does not pin it. A status and inventory line only: it never enters the check, so the verdict does not change.","Add a test case that fails when the rule is broken (the line names the change that went unnoticed), then re-run arkgate-check --probe-invariants --write and commit the file. Promotion to enforced refuses while the fresh artifact says survived or not reached; a stale, killed, inconclusive or missing result changes nothing.",{oftenAdvisory:!0}),h("INVARIANT_TESTS_PATH_MISSING","arkrules","Domain-invariant tests path missing under adopted","The project is adopted (required CI or explicit advisory) and has domain invariants that want test evidence, but ark.config.json does not name where those tests live. Green coverage without a real tests path is an empty checkbox.","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. Not freezable."),h("INVARIANT_COVERAGE_ROOTS_MISSING","arkrules","Coverage roots missing while an invariant is enforced","A catalogued domain invariant is enforced, but ark.config.json does not name coverage.coverageRoots \u2014 the folders where the project says its test runner actually goes. Without that declaration, INVARIANT_COVERAGE_OUTSIDE_ROOTS cannot fire and coverage can certify a test no runner runs.","Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. testGlobs alone is not enough. Fail-closed until that path is present. Not freezable."),h("ARKRUN_MISSING_ROOT","arkrun","No kernel factory in composition roots","The ArkRun extra is on but no kernel factory (createArkKernel / createStrictArkKernel / createLenientArkKernel, their *FromConfig variants, or ArkModule.forRoot / forRootAsync imported from arkgate/nestjs) was found in arkRun.compositionRoots, so agents can skip the kernel while the write gate stays green.","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."),h("ARKRUN_KERNEL_IN_DOMAIN","arkrun","Domain-role layer imports the kernel","A Domain-role layer imports arkgate/runtime, arkgate/nestjs, @arkgate/runtime, or kernel types. Domain stays kernel-free; composition roots and adapters own the factory.","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."),h("ARKRUN_DIRECT_NEW","arkrun","Managed type constructed with new","A managed non-Domain file constructs an admitted type with new outside an ArkRun composition-root factory, skipping kernel resolve/registration.","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."),h("ARKRUN_UNDECLARED_EMIT","arkrun","Emit name not in raises/sends","A publisher / publish / raise / send call on a receiver traced to the kernel names an intent (string literal or same-file define/defineIntent binding) that is not listed in the file\u2019s raises or sends declaration.","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."),h("ARKRUN_UNDECLARED_HANDLE","arkrun","Handle name not in reactsTo","A subscribe / registerHandler call on a receiver traced to the kernel names an intent (string literal or same-file define/defineIntent binding) that is not listed in the file\u2019s reactsTo declaration.","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."),h("ARKRUN_UNDECLARED_DEPEND","arkrun","Depend name not in uses","A resolve / resolveSingleton call on a receiver traced to the kernel names a component that is not listed in the file\u2019s uses declaration.","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."),h("ARKRUN_TRANSPORT_BYPASS","arkrun","Homemade broker or emitter import","A managed layer imports a closed broker/queue/emitter specifier (EventEmitter, queue clients, \u2026) instead of the ArkRun kernel transport.","Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment."),h("ARKORDER_MISSING_PLANE","arkorder","No createOrderPlane in plane roots","The ArkOrder extra is on but no createOrderPlane factory was found in arkOrder.planeRoots, so agents can skip the pattern plane while the write gate stays green.","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."),h("ARKORDER_KERNEL_IN_DOMAIN","arkorder","Domain-role layer imports the order plane","A Domain-role layer imports arkgate/order. Domain stays plane-free; planeRoots own the factory.","Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe."),h("ARKORDER_GENERIC_UPDATE","arkorder","Generic update of a big product choice","A call to update/patch/set rewrites a named product choice (like billing plan) as if it were a seat count.","Don't use a generic update. First freeze with release(). Later, propose the change, then apply it."),h("ARKORDER_TOO_MANY_PARAMS","arkorder","Too many slow keys","\u03BE has more keys than arkOrder.maxXiKeys. Haken requires a few slow modes, not a dump of microstate.","Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe."),h("ARKORDER_INGEST_WRITES_XI","arkorder","ingest assigned into \u03BE","An ingest() result is written into a Release or \u03BE store. ingest may absorb, escalate_up, or hold; it never mints a pattern.","Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe."),h("ARKORDER_XI_FIELD_WRITE","arkorder","Big product choice written like a seat count","A use-case writes a named product choice (like billing plan) through a database update. Invoices and seats can flow. That choice cannot.","Keep invoices and seats as events. Change the choice through the valve (proposeRelease then apply), not a generic update."),h("ARKORDER_INFORMATION_BUDGET","arkorder","Projection observes a forbidden kind","h(\u03BE) allowedKinds includes a kind listed in informationBudget.cannotObserve. A scale may not look at what it was told not to see.","Cut that kind from the projector or from cannotObserve, then preflight again. Never mechanical-safe."),h("ARKORDER_XI_TTL","arkorder","Slow key carries a freshness field","\u03BE named ttl/freshUntil/maxAge. Freshness belongs on \u03C3. A slow parameter that expires per transaction is not slow.","Move freshness onto \u03C3 (freshUntil) and keep \u03BE stable, then preflight again. Never mechanical-safe."),h("ARKORDER_STALE_SIGMA","arkorder","\u03C3 is stale","ingest ran after \u03C3.freshUntil (or sigmaMaxAgeMs). \u03BE does not TTL.","Call refreshSigma and ingest again, or proposeRelease then apply(ProposeResult) if the pattern changed. Never mechanical-safe."),h("ARKORDER_UNVALVED_RELEASE","arkorder","Second freeze without the valve","release() already froze the big choice. A later release() with a different value does not land. First freeze is release(); later change is proposeRelease then apply.","Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe."),h("ARKORDER_STALE_PROPOSAL","arkorder","Proposal is not bound to the current Release","apply() got a ProposeResult computed against another Release (another apply landed first), one missing its base binding, or one whose reviewed blast radius is not the transition that would commit. The binding is data, not a capability: a proposal that states the current base and the exact transition applies whoever built it.","Run proposeRelease again against the current Release, review the new blast radius, then apply that proposal. Never mechanical-safe."),h("INVALID_CHANGE_PATH","preflight","Unsafe change path","A change set entry is not a safe, non-empty project-relative path (absolute, escape, empty, or NUL).","Use canonical project-relative paths only in the atomic change set, then preflight again."),h("DUPLICATE_CHANGE_PATH","preflight","Duplicate path in change set","The atomic change set lists more than one operation for the same path.","Collapse to one create/update/delete per path, then preflight again."),h("DELETE_TARGET_MISSING","preflight","Delete target missing","A delete operation targets a path that is not present in the supplied base tree.","Remove the delete, or include the file in the base tree facts, then preflight again."),h("CHANGE_SET_EMPTY","preflight","Empty change set","Atomic preflight was invoked with no create, update, or delete operations.","Provide at least one change operation, then preflight again."),h("FACTS_IDENTITY_MISMATCH","preflight","Base/candidate facts identity mismatch","Base and candidate resolved facts disagree on resolver, compiler, evidence requirements, or package identity \u2014 verdicts would not be comparable.","Regenerate both fact snapshots with the same resolver/compiler/evidence requirements, then preflight again."),h("CANDIDATE_DELETE_NOT_APPLIED","preflight","Candidate still contains deleted path","Facts claim a delete, but the candidate tree still includes the path.","Ensure the candidate facts apply the delete (path absent), then preflight again."),h("CANDIDATE_CHANGE_MISSING","preflight","Declared change missing from candidate","The change set declares a create/update whose path is missing from candidate facts.","Include the new content in the candidate facts (or drop the operation), then preflight again."),h("CANDIDATE_CONTENT_HASH_MISMATCH","preflight","Candidate content hash mismatch","The candidate file content hash does not match the hash expected for the declared change.","Rebuild candidate facts from the exact proposed content, then preflight again."),h("UNDECLARED_CANDIDATE_CHANGE","preflight","Undeclared candidate change","Candidate facts differ from base for a path that was not listed in the explicit change set.","Declare every path that changes in the atomic change set, then preflight again."),h("ATOMIC_PREFLIGHT_UNAVAILABLE","preflight","Atomic preflight unavailable","The host/MCP path could not run the atomic preflight engine (missing facts, incomplete setup, or unsupported mode).","Use resolved-candidate facts / ark_prepare_change with a complete batch, or fall back to ark-check on disk. Do not treat missing preflight as green."),h("WRITE_GATE_UNAVAILABLE","preflight","Write gate could not run","The write gate could not load its own inputs (ark.config.json missing, unreadable, or invalid; a referenced ArkRules file missing or invalid; or the built library missing), so it cannot judge this governed source write (existing files included), or a write would leave ark.config.json or a referenced ArkRules file unloadable. No checker, no write: the hook blocks instead of letting the write through unchecked.","Fix the reported input (repair ark.config.json or the ArkRules file, or run `npm run build` / reinstall arkgate from npm), then retry the same write. Do not remove the hook to get past it."),h("DESIGN_SMELL_REGRESSION","preflight","Design smell regression on base-relative ratchet","Compared to the base ref, the candidate introduces a created-path domain-logic-in-ui file under --strict-merge, or introduces or worsens a blocking design-smell class under --fail-on-new-smells.","Move the new UI business rule out of the created file (or revert a --fail-on-new-smells regression), then re-run with the same base ref."),h("ANALYSIS_PARSE_INCOMPLETE","analysis","Parse incomplete","Governed source could not be fully parsed; evidence includes the TypeScript diagnostic (line + message). Incremental mid-edit parse is normal for agents. Contract exclude paths skip the write hook.","Finish the source or fix the reported syntax error, then re-run `npx arkgate-check`. The write hook does not deny solely on mid-edit parse. Partial never means pass."),h("LEXICAL_EVIDENCE_INCOMPLETE","analysis","Lexical evidence incomplete","This check only saw one file, so it cannot fully prove how the import resolves. The result is provisional \u2014 `ark-check` on the project is the authority.","For a complete verdict, run `npx arkgate-check --root . --config ark.config.json` (or ark_prepare_change over MCP with the full candidate batch). Read lexicalValid for the one-file result."),h("ANALYSIS_COVERS_NO_FILES","analysis","Analysis covered no files","No file matched the contract include and layer patterns under the analyzed root, so the run had nothing to check. Every rule is vacuously satisfied on an empty set: a green here would read exactly like a green over a governed tree while certifying nothing. Usual causes are a --root that is not the tree the contract describes (including a contract found outside the requested root, whose directory is then adopted as the project root), include / exclude patterns that match nothing, or layer patterns written for a different layout.","Point --root at the tree the contract describes, or keep the contract inside that tree, or fix the include / exclude / layer patterns so they match real files \u2014 then re-run `npx arkgate-check --root . --config ark.config.json`. This is a refusal about ArkGate\u2019s own inputs, not a finding about your code; no baseline or policy acknowledgement can suppress it."),h("ANALYSIS_HOST_UNAVAILABLE","analysis","Analysis host unavailable","No usable TypeScript / analysis host was available for this invocation.","Install a supported TypeScript version visible to the project, then re-run. Unavailable analysis is fail-closed."),h("ADAPTER_NOT_ALLOWED_FOR_PORT","adapter","Adapter not allowed for port","Runtime/port wiring selected an adapter implementation that the architecture profile does not allow for that port.","Bind an allowed adapter for the port, or adjust the profile with an explicit policy decision \u2014 then re-run."),h("FORBIDDEN_PATTERN","snippet-policy","Forbidden regex pattern","Snippet content matched a project or profile forbiddenPatterns rule.","Remove or rewrite the matching code so the pattern no longer matches, then re-run the snippet gate."),h("FORBIDDEN_SUBSTRING","snippet-policy","Forbidden substring","Snippet content contained a forbidden substring from the AI gate options/profile.","Remove the forbidden substring, then re-run the snippet gate."),h("FORBIDDEN_IMPORT","snippet-policy","Forbidden import target","Snippet imported or required a module listed as forbidden for the active profile.","Import an allowed module or inject the dependency behind a port, then re-run."),h("POLICY_VIOLATION","snippet-policy","Policy engine violation","A registered Policy failed on the snippet or generated code under evaluation.","Adjust the code to satisfy the named policy, or change the policy only through an explicit contract decision."),h("EXTENSION_ERROR","snippet-policy","AI gate extension error","A registered AICodeGate extension threw while analyzing the snippet.","Fix or remove the failing extension; do not ignore extension failures as pass."),h("AST_ANALYZER_ERROR","snippet-policy","AST analyzer error","Built-in AST/symbol analysis failed (host error or unexpected analyzer exception).","Ensure TypeScript host and snippet are valid; re-run. If the analyzer crashes on valid input, file a bug with a minimal fixture."),h("CONFIG_INVALID_DYNAMIC_IMPORT_ALLOWLIST","config","Invalid dynamicImportAllowlist","dynamicImportAllowlist is present but not an array of file globs.","Set dynamicImportAllowlist to an array of project-relative globs (or omit it).",{oftenAdvisory:!0}),h("CONFIG_INVALID_SAFETY","config","Invalid safety object","The safety field is present but not an object.","Use a safety object with optional maxTsSuppressions, maxAnyCasts, allowInMemory, allowDisabledPeerIsolation.",{oftenAdvisory:!0}),h("CONFIG_INVALID_SAFETY_THRESHOLD","config","Invalid safety threshold","A safety threshold (maxTsSuppressions / maxAnyCasts) is not a non-negative integer.","Set each threshold to a non-negative integer.",{oftenAdvisory:!0}),h("CONFIG_NO_LAYERS","config","No layers configured","ark.config.json has no file layers, so import-boundary enforcement cannot classify files.","Declare at least one layer with name + patterns (or run ark start / a preset).",{oftenAdvisory:!0}),h("CONFIG_LAYER_WITHOUT_NAME","config","Layer missing name","A configured layer entry has no name.","Give every layer a unique non-empty name.",{oftenAdvisory:!0}),h("CONFIG_INVALID_FORBIDDEN_GLOBALS","config","Invalid forbiddenGlobals","A layer\u2019s forbiddenGlobals is not an array of strings; the entry is ignored.",'Use an array of strings (e.g. ["fetch", "Date.now"]).',{oftenAdvisory:!0}),h("CONFIG_LAYER_WITHOUT_PATTERNS","config","Layer without patterns","A named layer has no file patterns and will never classify files.","Add patterns globs that match the layer\u2019s source tree.",{oftenAdvisory:!0}),h("CONFIG_INVALID_LAYER_PATTERN","config","Invalid layer pattern","A layer pattern is not a valid glob / failed to compile.","Fix the pattern syntax for that layer.",{oftenAdvisory:!0}),h("CONFIG_LAYER_PATTERN_NO_MATCHES","config","Layer pattern matched no files","A layer pattern matched zero included files (often a typo or include mismatch). Reserved/allowEmpty houses do not emit this.","Adjust the pattern or include roots, or mark the layer reserved/allowEmpty if the glob is a future house.",{oftenAdvisory:!0}),h("CONFIG_DUPLICATE_LAYER","config","Duplicate layer name","The same layer name appears more than once in configuration.","Rename or merge duplicate layer entries.",{oftenAdvisory:!0}),h("CONFIG_RULE_UNKNOWN_FROM_LAYER","config","Rule unknown from layer","A dependency rule references a source layer name that is not declared.","Fix the rule\u2019s from field to a declared layer name.",{oftenAdvisory:!0}),h("CONFIG_RULE_UNKNOWN_TO_LAYER","config","Rule unknown to layer","A dependency rule references a target layer name that is not declared.","Fix the rule\u2019s to field to a declared layer name.",{oftenAdvisory:!0}),h("CONFIG_AMBIGUOUS_LAYERS","config","Ambiguous layer classification","Some files match multiple layers at equal specificity; classification falls back to declaration order.","Disambiguate overlapping patterns so each file has one clear layer owner.",{oftenAdvisory:!0}),h("CONFIG_UNCLASSIFIED_FILES","config","Unclassified included files","Included source files match no layer pattern; import rules will not enforce on them.","Extend layer patterns or narrow include so every governed file is classified.",{oftenAdvisory:!0}),h("CONFIG_LAYER_MISSING_OWNER","config","Layer missing owner","requireLayerOwners is on and this layer has no owners. Writes to that house fail closed, like a folder with no name on the door.","Add a GitHub handle or email to that layer\u2019s owners in ark.config.json (/ark-adopt), then re-run. Reserved/allowEmpty houses may stay unnamed. Turn the flag off only if you no longer want owners required."),h("CONFIG_SLICE_IDENTITY_COLLISION","config","Starred slice prefixes share one id","sliceIdentity is stars and two different sliceFolders prefixes bind as the same slice id. Parallel trees of one feature do that on purpose; unrelated trees that share the last folder name merge by accident.","Keep stars when those prefixes are one feature. Otherwise use path, or rename the last literal so the prefixes do not bind as the same id. Doctor names both paths.",{oftenAdvisory:!0}),h("CONFIG_CHILD_SLICES_VERSION","config","Config needs a newer arkgate than a pinned copy",'ark.config.json uses a slice key (childSlices, sharedImportsSlice "deny-cross-parent" or its object form, sliceIdentity, sharedImportsSlice, childSlices.message, siblings.ratchet) that an arkgate pinned in this repo rejects at config load. Emitted only with evidence of that pin: an exact package.json dependency, the installed node_modules/arkgate, package-lock.json, a scripts/*hook* or host hook command, or a CI workflow. Silent otherwise.',"Bump the named file to the version the finding gives (or newer), then run Ark again. This warning does not fail the check.",{oftenAdvisory:!0}),h("CONFIG_CHILD_SLICE_EXTENDS","config","Child slice id does not extend its universe","A path resolved a child id that is not the universe id plus a further segment. The child wall does not treat that id as a child, so the edge is universe common until the folders line up.","Point childSlices.sliceFolders at children under the same universe id the outer sliceFolders already names. Doctor names the path.",{oftenAdvisory:!0}),h("CONFIG_CHILD_SLICE_CROSS_UNIVERSE","config","Child slice allowance cannot cross the universe wall","childSlices.allowedCrossSlice names a pattern that can match two universes. That list clears only a sibling crossing inside one universe. The universe wall still denies the edge.","Narrow the pattern so both sides share one universe prefix (features/projects/* to features/projects/d2d-item), or remove the entry. This warning does not fail the check.",{oftenAdvisory:!0}),h("CONFIG_CHILD_SLICES_INERT","config","childSlices on a rule that cannot run it","A rule sets childSlices without peerIsolation: true and allowed: false. The child wall runs only inside a universe wall, so on this rule childSlices enforces nothing. Config load still accepts it (arkgate 4.8.23 did too).",'Add "peerIsolation": true and "allowed": false to the same rule so the child wall runs, or remove childSlices. This warning does not fail the check.',{oftenAdvisory:!0}),h("CONFIG_SLICE_LEGACY_STARS_ID","config","Slice id written in the 4.8.23 stars form",'Under sliceIdentity "stars", a sliceAliases target or an allowedCrossSlice entry names the 4.8.23 stars id, which dropped a star binding before the last literal (modules/*/api/* bound api/v1). The id now keeps that binding (orders/api/v1). For one release the entry keeps its 4.8.23 meaning, so verdicts do not change.',"Rewrite the entry with the new id the warning names (for example orders/api/v1/x instead of api/v1/x). A sliceAliases target that maps to more than one universe shape is rejected at config load. This warning does not fail the check.",{oftenAdvisory:!0}),h("LITERAL_PATH_DRIFT","drift","Literal path moved by a rename","A repo path written inside a string, a comment or a docstring no longer resolves, and the rename set says where it went. Nothing in the gate sees this class: `tsc` resolves imports, not strings, and ESLint does not either, so the rename compiles green and the reference lies afterwards. It appears in four forms \u2014 the tsconfig alias, a relative literal, a path written without the include-root prefix, and prose \u2014 and a hand sweep reliably covers one of them.","Apply the suggested replacement, or re-run `npx arkgate-check --path-drift --base-ref <ref> --write` to apply every writable anchored replacement at once. The rewrite is mechanical and one-directional: the destination comes from the rename, it must itself resolve and be path-shaped, and the token is rewritten in the form the author wrote it in. A destination that leaves the alias root of the literal is reported with the target only and must be rewritten by hand."),h("LITERAL_PATH_UNRESOLVED","drift","Literal path does not resolve","A literal that looks like a repo path does not resolve under this root, and no rename explains where it went. Unlike LITERAL_PATH_DRIFT this is a candidate, not a verdict: with nothing to anchor it, ArkGate cannot tell a dead reference from an illustrative path in a comment, an example in documentation, or a path belonging to another tree.","Read the candidate and decide: fix the path, or leave it. Advisory only \u2014 it never fails a run and is never rewritten by --write, because there is no destination to propose. Run `--path-drift --all` to list the sweep.",{oftenAdvisory:!0}),h("ORPHAN_MODULE","drift","File nothing imports","No governed file, test or entry point imports this module. It is the leftover an agent leaves when a rewrite lands next to the old file. Status reads it from the import facts the check already resolved, so it never changes the verdict. When a dynamic import, an unresolved import or an unmapped entry could reach the file, the item says so (maybe-dynamic, maybe-unresolved) and the list is partial.","Delete the file through the write gate, one file at a time. If a framework, a script or a runtime loader uses it, add a glob with a reason to .ark/entry-points.json (optional reviewBy) instead. Advisory only \u2014 it never fails a run.",{oftenAdvisory:!0}),h("UNUSED_EXPORT","drift","Export nothing imports by name","An export no governed file or test imports by name. Listed only in status details (`--doctor --all`) and the report. Default, namespace, star, dynamic and require use count as using every export, so those files are skipped.","Drop the export keyword (or the code) if nothing outside the file needs it, or keep it when it is public API an entry point exposes. Advisory only \u2014 it never fails a run.",{oftenAdvisory:!0}),h("ARK_UNKNOWN","meta","Unknown diagnostic","A diagnostic lacked a stable ruleId/code; adapters may emit this fallback so agents never see an empty id.","Resolve the underlying finding without weakening ark.config.json, then run Ark again. Prefer fixing the producer to emit a catalogued ruleId.")]),ld=new Map(Un.map(e=>[e.ruleId,e])),cd=Object.freeze(Un.map(e=>e.ruleId));var Yi=Object.freeze([Object.freeze({reasonId:"CROSS_PARENT_SLICE",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-universe slice",why:"This import crosses two universe slices. The child wall cannot allow another universe.",fix:"Keep the import inside one universe, or move the shared code into a folder both universes may use."}),Object.freeze({reasonId:"CROSS_SIBLING_SLICE",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-sibling slice",why:"This import crosses two feature slices inside one universe.",fix:"Import universe-common code, or move the shared piece into the feature that owns it.",advisoryNote:"This crossing is a warning (siblings advisory). With a baseline in use, a new one fails only when the baseline already records an advisory crossing of this rule and the count grows, or when siblings.ratchet is true; ratchet false measures only."}),Object.freeze({reasonId:"CROSS_PARENT_VIA_SHARED",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-universe through a shared root",why:"A slice reaches another universe only through a shared root. ark-check and CI report this path. The write hook and ESLint see one edge at a time and do not block it.",fix:"Stop the shared root from importing the other universe, or move that import into the universe that owns it. A shared hop that stays inside one universe is allowed. If the shared hop is a composition root (bootstrap, DI registrations), list it in sharedImportsSlice.stopAt; a path through a stop is not a crossing."})]),qi=new Map(Yi.map(e=>[e.reasonId,e]));function jn(e){if(!(typeof e!="string"||e.length===0))return qi.get(e)}a(jn,"sliceReasonHint");var Zi=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Xi=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Ji=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Qi(e,t){let n=String(e??"").replace(/\\/g,"/").trim(),r=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Zi.test(n)?"pure-shared":r==="PersistenceAdapters"&&(Xi.test(n)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${n}`))?"kernel-emit":Ji.test(n)||(r==="DomainModel"||r==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a(Qi,"classifyLayerImportKind");function ea(e,t){return t.failsStrict===!1&&e.advisoryNote?`${e.fix} ${e.advisoryNote}`:e.fix}a(ea,"sliceHintAction");function ta(e){let t=jn(typeof e.reasonId=="string"?e.reasonId:void 0);if(t)return`${ea(t,e)} Then preflight again.`;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 n=Qi(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 n==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":n==="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.":n==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}a(ta,"layerImportNextAction");function na(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a(na,"arkRunCallSiteName");function ra(e){let t=na(e),n=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 ${n??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}a(ra,"arkRunNextAction");function le(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return ta(e);case"CONFIG_CHILD_SLICES_VERSION":return typeof e.nextAction=="string"&&e.nextAction.length>0?e.nextAction:"Bump the pinned arkgate named in the finding to the version it gives, then run Ark again.";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 ra(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}a(le,"deterministicNextAction");var sa=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],oa=new Set(sa);function ia(e){return oa.has(e)}a(ia,"isArkRunEditorSensor");var Gn={"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"},aa="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Vn(e,t=[]){let n=e.trim();return/^domain(?:model)?$/i.test(n)||/^domain(?=[A-Z_\-\s])/i.test(n)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(n)?!0:t.some(r=>{let s=r.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(Vn,"isDomainRoleLayer");function la(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(la,"compareFindings");function K(e,t,n,r,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Gn[t],sensor:t,message:s,file:n,line:r,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:l?"error":"warning",failsStrict:l,nextAction:le({ruleId:Gn[t],fromLayer:o?.fromLayer,target:o?.target})}}a(K,"finding");function ca(e,t){let n=[],r=[],s=[],o=[];for(let i of e)i.file===t&&(n.push(...i.uses),r.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(n),reactsTo:new Set(r),raises:new Set(s),sends:new Set(o)}}a(ca,"bagForFile");function Hn(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Hn,"emitKinds");function Bn(e){return e==="subscribe"||e==="register-handler"}a(Bn,"handleKinds");function da(e){return e==="resolve"||e==="resolve-singleton"}a(da,"dependKinds");function ua(e,t,n){let r=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return r.push(K(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,n)),r;let o=new Map;for(let i of t){let l=o.get(i.matchedRoot)??[];l.push(i),o.set(i.matchedRoot,l)}for(let i of s){let l=[...o.get(i)??[]].sort((d,u)=>d.file.localeCompare(u.file));if(l.length===0){r.push(K(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},n));continue}if(l.some(d=>d.hasKernelFactory))continue;let c=l[0];r.push(K(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no kernel factory (createArkKernel / createStrictArkKernel / createLenientArkKernel / *FromConfig, or ArkModule.forRoot / forRootAsync from arkgate/nestjs).`,{target:i},n))}return r}a(ua,"evaluateMissingRoot");function fa(e,t,n,r,s){let o=new Map(t.map(l=>[l.name,l.intentPrefixes??[]])),i=[];for(let l of n){let c=l.specifier;if(!c||!Q(c))continue;let d=r(l.from);d&&Vn(d,o.get(d)??[])&&i.push(K(e,"arkrun-kernel-in-domain",l.from,l.line,`${d} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:d,target:c},s))}return i}a(fa,"evaluateKernelInDomain");function pa(e,t,n,r,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let l=new Map(t.map(u=>[u.name,u.intentPrefixes??[]])),c=new Set(r.filter(u=>u.hasKernelFactory).map(u=>u.file)),d=[];for(let u of n){if(c.has(u.file))continue;let f=u.typeName;if(e.ignoreDirectNewForErrors!==!1&&(f.endsWith("Error")||f==="Error")||f.endsWith("DTO")||f.endsWith("VO"))continue;let p=s(u.file);!p||!i.has(p)||Vn(p,l.get(p)??[])||d.push(K(e,"arkrun-direct-new",u.file,u.line,`${p} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:p,target:u.typeName},o))}return d}a(pa,"evaluateDirectNew");function ga(e,t,n,r,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let l=new Set(e.managedLayers);if(l.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!Hn(c.kind)&&!Bn(c.kind)&&!da(c.kind))continue;let d=r(c.file);if(!d||!l.has(d))continue;if(!c.nameLiteral){e.mode==="enforced"&&c.kind!=="publisher"&&i.push({code:aa,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name or same-file define/defineIntent binding; enforced extra cannot prove the declaration.`});continue}let u=ca(n,c.file);if(Hn(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:d,target:c.nameLiteral},s));continue}if(Bn(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:d,target:c.nameLiteral},s));continue}u.uses.has(c.nameLiteral)||o.push(K(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:d,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}a(ga,"evaluateUndeclared");function ha(e,t,n,r){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let l=i.specifier;if(!l||!Sn(l))continue;let c=n(i.from);!c||!s.has(c)||o.push(K(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(l)}; use the ArkRun kernel transport.`,{fromLayer:c,target:l},r))}return o}a(ha,"evaluateTransportBypass");function ma(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let n=Ve(e.classification),r=ga(t,e.kernelCalls,e.declarations,e.layerForFile,n),s=[...ua(t,e.compositionRootHits,n),...fa(t,e.layers,e.dependencies,e.layerForFile,n),...pa(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,n),...r.findings,...ha(t,e.dependencies,e.layerForFile,n)].sort(la),o=[...r.completenessReasons].sort((i,l)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,d=`${l.code}\0${l.file??""}\0${l.message}`;return c<d?-1:c>d?1:0});return{findings:s,completenessReasons:o}}a(ma,"evaluateArkRunSensors");function At(e){return{findings:ma(e).findings.filter(n=>ia(n.sensor)),completenessReasons:[]}}a(At,"evaluateArkRunEditorSensors");var Rt="docs/diagnostics.md";function St(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,n=typeof e.file=="string"?e.file:void 0,r=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,n,r??"",s??"",o??""].join("|")}a(St,"adapterFindingTargetKey");function kt(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}a(kt,"adapterFindingRefFromTargetKey");function bt(e){return`${Rt}#${e}`}a(bt,"adapterDocsCodePath");function b(e){return typeof e=="string"&&e.length>0?e:void 0}a(b,"text");function Wn(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(Wn,"positiveInteger");function Ra(e,t,n){return le({ruleId:e,target:b(t.target)??b(n.target)??void 0,fromLayer:b(t.fromLayer)??void 0,toLayer:b(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:b(t.edgeKind)??void 0,capability:b(t.capability)??b(n.capability)??void 0,arkruleId:b(t.arkruleId)??void 0,arkruleSource:b(t.arkruleSource)??void 0,reasonId:b(t.reasonId)??void 0})}a(Ra,"nextActionForDiagnostic");var Sa=new Set(["CROSS_PARENT_SLICE","CROSS_SIBLING_SLICE","CROSS_PARENT_VIA_SHARED"]);function ka(e){let t=e.details,n=t!==null&&typeof t=="object"?t.reasonId:void 0,r=b(e.reasonId)??b(n);return r&&Sa.has(r)?r:void 0}a(ka,"sliceReasonOf");function zn(e,t="error",n){let r=b(e.ruleId)??b(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o=ka(e),i={...b(e.target)?{target:b(e.target)}:{},...b(e.fromLayer)?{fromLayer:b(e.fromLayer)}:{},...b(e.toLayer)?{toLayer:b(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}:{},...b(e.capability)?{capability:b(e.capability)}:{},...b(e.edgeKind)?{edgeKind:b(e.edgeKind)}:{},...b(e.arkruleId)?{arkruleId:b(e.arkruleId)}:{},...b(e.arkruleSource)?{arkruleSource:b(e.arkruleSource)}:{},...o?{reasonId:o}:{},...o&&b(e.universeFrom)?{universeFrom:b(e.universeFrom)}:{},...o&&b(e.universeTo)?{universeTo:b(e.universeTo)}:{}},l=n??St(e),c=kt(l);return{ruleId:r,severity:s,message:b(e.message)??r,location:{file:b(e.file)??"<unknown>",line:Wn(e.line,1),column:Wn(e.column,1)},evidence:i,nextAction:b(e.nextAction)??Ra(r,i,e),findingRef:c,targetKey:l,docsCodePath:bt(r)}}a(zn,"toAdapterDiagnostic");var Et="advisory",qn="{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check]",We="advisoryFallback",Zn='{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check. Enable ark/architecture-advisory (set to "warn" in configs.recommended) to report it as a warning.]',Yn=new WeakMap,Xn=new WeakMap;function ba(e){return Object.prototype.hasOwnProperty.call(e,"sourceCode")||Object.prototype.hasOwnProperty.call(e,"getSourceCode")}a(ba,"ownsSourceCode");function Ea(e){let t=e;for(let n=0;t&&t!==Object.prototype&&n<8;n+=1){if(ba(t))return t===e?null:t;t=Object.getPrototypeOf(t)}return null}a(Ea,"runKey");function Ia(e,t){let n=Object.create(e,{report:{value(r){t.sinks.blocking?.report(r)}}});return Xn.set(n,t),n}a(Ia,"routedContext");function ze(e,t,n){let r=Ea(t),s;if(r){let o=Yn.get(r);o||(o=new Map,Yn.set(r,o)),s=o.get(e),s||(s={sinks:{},created:!1},o.set(e,s))}else s={sinks:{},created:!1};return s.sinks[n]=t,s.created?{}:(s.created=!0,e.create(Ia(t,s)))}a(ze,"createChannelListeners");function Jn(e,t){let n=Xn.get(e),{location:r,diagnostic:s}=t,o={...r,messageId:t.messageId,...t.data?{data:t.data}:{},diagnostic:s};if(!n){e.report(t.nonBlocking?{...r,messageId:We,data:t.advisoryData,diagnostic:s}:o);return}if(!t.nonBlocking){n.sinks.blocking?.report(o);return}if(n.sinks.advisory){n.sinks.advisory.report({...r,messageId:Et,data:t.advisoryData,diagnostic:s});return}n.sinks.blocking?.report({...r,messageId:We,data:t.advisoryData,diagnostic:s})}a(Jn,"deliverReport");function x(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}a(x,"lintedFilename");function W(e){try{return e.sourceCode??e.getSourceCode?.()}catch{return}}a(W,"sourceCodeFor");function ce(e){let t=W(e);if(!t)return null;if(typeof t.getText=="function"){let n=t.getText();if(typeof n=="string")return n}return typeof t.text=="string"?t.text:null}a(ce,"editorSourceText");function va(e,t){let n=e.loc?.start;return typeof n?.line=="number"&&typeof n.column=="number"?{node:e}:{loc:{line:typeof n?.line=="number"?n.line:t,column:0}}}a(va,"reportLocation");function O(e,t,n,r,s){let o=zn({...r,line:r.line??t.loc?.start?.line,column:r.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return Jn(e,{nonBlocking:o.severity==="warning",location:va(t,o.location.line),messageId:n,...s?{data:s}:{},advisoryData:{message:o.message,ruleId:o.ruleId},diagnostic:o}),o}a(O,"reportAdapterDiagnostic");function Qn(e){let t={};for(let r of e)for(let[s,o]of Object.entries(r))(t[s]??=[]).push(o);let n={};for(let[r,s]of Object.entries(t))n[r]=s.length===1?s[0]:o=>{for(let i of s)i(o)};return n}a(Qn,"mergeListeners");function Ye(e){return typeof e?.value=="string"?e.value:void 0}a(Ye,"stringValue");function xe(e){if(e){if(e.type==="TemplateLiteral"){if((e.expressions?.length??0)>0||e.quasis?.length!==1)return;let t=e.quasis[0]?.value?.cooked;return typeof t=="string"?t:void 0}return Ye(e)}}a(xe,"staticStringValue");function qe(e){return e?.name??Ye(e)}a(qe,"propertyName");function It(e,t){return t?xe(e):qe(e)}a(It,"staticKeyName");function er(e,t){let n=W(e)?.getScope?.(t);for(;n;){let r=n.references?.find(s=>s.identifier===t);if(r)return r;n=n.upper??void 0}}a(er,"referenceFor");function z(e,t,n){let r=er(e,t);if(r?.resolved)return(r.resolved.defs?.length??0)>0;let s=W(e)?.getScope?.(t);for(;s;){let o=s.set?.get(n);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}a(z,"isLocallyBound");function tr(e,t){let n=er(e,t);return n?n.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(tr,"isValueIdentifierReference");function we(e){if(e?.type==="Identifier"&&e.name)return{root:e,segments:[e.name]};if(!e)return;if(e.type==="ChainExpression"||e.type==="TSNonNullExpression")return we(e.expression);if(!(e.type==="MemberExpression"||!!(e.object&&e.property)))return;let n=we(e.object),r=It(e.property,e.computed);if(!(!n||!r))return{root:n.root,segments:[...n.segments,r]}}a(we,"memberExpressionPath");function Ze(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(n=>n.type==="ImportSpecifier")?t.every(n=>n.importKind==="type"):t.every(n=>n.exportKind==="type")}a(Ze,"declarationIsTypeOnly");function de(e,t,n=z){return{ImportDeclaration(r){let s=r,o=(s.specifiers??[]).filter(l=>l.type==="ImportSpecifier"),i=o.length>0&&o.length===(s.specifiers??[]).length&&o.every(l=>l.importKind==="type");t(r,s.source?.value,s.importKind==="type"||i,"import")},ImportExpression(r){let s=r;s.source?.type==="Literal"&&t(r,s.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(r){let s=r;t(r,s.moduleReference?.expression?.value,s.importKind==="type"||s.isTypeOnly===!0,"require")},ExportNamedDeclaration(r){let s=r;if(!s.source)return;let o=s.specifiers??[],i=o.length>0&&o.every(l=>l.exportKind==="type");t(r,s.source.value,s.exportKind==="type"||i,"export")},ExportAllDeclaration(r){let s=r;t(r,s.source?.value,s.exportKind==="type","export")},CallExpression(r){let s=r;s.callee?.type==="Identifier"&&s.callee.name==="require"&&s.arguments?.[0]?.type==="Literal"&&!n(e,r,"require")&&t(r,s.arguments[0].value,!1,"require")}}}a(de,"moduleSourceListeners");function sr(e){try{return nr.existsSync(e)?nr.readFileSync(e,"utf8"):null}catch{return null}}a(sr,"readUtf8");function rr(e,t){let n=e.lintedFilename(t),r=e.findConfigPath(n),s=r?e.loadArkConfig(r):null;if(!s?.arkRun||!r||!n)return null;let o=ee.dirname(r),i=ee.isAbsolute(n)?n:ee.resolve(n),l=ee.relative(o,i).split(ee.sep).join("/");if(!e.sourceIsInAnalysisScope(s,l))return null;let c=w(l,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:l,fromLayer:c}:null}a(rr,"loadEditorFile");function wa(e,t,n){let r=Ue(t,n).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!L(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:r})}return s}a(wa,"compositionRootHitsForFile");function xa(e,t,n){let r=new Set(ve(t.relFile,n).map(s=>s.className));return bn(n,(s,o)=>{if(Q(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=ee.relative(t.root,i).split(ee.sep).join("/");if(l.startsWith(".."))return;let c=sr(i);if(c!==null)for(let d of ve(l,c))r.add(d.className)}),r}a(xa,"admittedTypeNamesForEditor");function or(e,t,n,r,s,o){e.reportAdapterDiagnostic(t,n,r,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}a(or,"reportFinding");function Ca(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let n=t?.property?.name;if(n&&/^[A-Z]/.test(n)&&t?.computed!==!0)return n}a(Ca,"constructedTypeName");function _a(e,t,n,r,s){return de(t,a((i,l,c,d)=>{if(typeof l!="string"||l.length===0)return;let u=i.loc?.start?.line??1,f={from:n.relFile,specifier:l,kind:d,typeOnly:c,line:u,resolution:"resolved-external"},{findings:p}=At({arkRun:n.extra,layers:n.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[f],layerForFile:a(g=>g===n.relFile?n.fromLayer:w(g,n.config.layers),"layerForFile")});for(let g of p)g.sensor===r&&or(e,t,i,s,g,{fromLayer:g.fromLayer??n.fromLayer,specifier:l,target:g.target??l})},"check"),e.isLocallyBound)}a(_a,"importListeners");function Oa(e,t,n){let r=ce(t)??sr(n.absFile)??"",s=xa(e,n,r),o=mt(n.relFile,r,s),{findings:i}=At({arkRun:n.extra,layers:n.config.layers,kernelCalls:Ue(n.relFile,r),managedNews:o,compositionRootHits:wa(n.extra,n.relFile,r),declarations:[],dependencies:[],layerForFile:a(c=>c===n.relFile?n.fromLayer:w(c,n.config.layers),"layerForFile")}),l=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let d=Ca(c);if(!d)return;let u=c.loc?.start?.line,f=l.find(p=>p.target===d&&(u===void 0||p.line===u));f&&or(e,t,c,"directNew",f,{fromLayer:f.fromLayer??n.fromLayer,typeName:d,target:f.target??d})}}}a(Oa,"directNewListener");function ir(e){let t=a((n,r,s,o)=>({meta:{type:"problem",docs:{description:r},messages:{[s]:o},schema:[]},create(i){let l=rr(e,i);return l?_a(e,i,l,n,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 (editor-buffer `new` envelope; on-disk import targets)."},messages:{directNew:"{{fromLayer}} must not construct {{typeName}} with new outside an ArkRun composition-root factory."},schema:[]},create(n){let r=rr(e,n);return r?Oa(e,n,r):{}}}}}a(ir,"createArkRunEslintRules");var ar=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var wt="createOrderPlane";function xt(e){return L(e)}a(xt,"arkOrderGlobToRegExp");function Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Xe,"escapeRegExp");function ue(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(ue,"isArkOrderModuleSpecifier");function U(e,t){let n=1;for(let r=0;r<t&&r<e.length;r+=1)e[r]===`
4
- `&&(n+=1);return n}a(U,"lineAt");function $(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,n=>" ".repeat(n.length)))}a($,"stripCommentsPreservingLines");function dr(e,t){let n=$(t),r=[],s=/\b(import|export)(\s+type)?\s+(?:[^;]*?\s+from\s*)?['"]([^'"]+)['"]/g,o;for(;(o=s.exec(n))!==null;){let l=o[3]??"";ue(l)&&r.push({from:e,specifier:l,kind:o[1]==="export"?"export":"import",typeOnly:!!o[2],line:U(t,o.index),resolution:"resolved-external"})}let i=/\b(require|import)\s*\(\s*['"]([^'"]+)['"]\s*\)/g;for(;(o=i.exec(n))!==null;){let l=o[2]??"";ue(l)&&r.push({from:e,specifier:l,kind:o[1]==="import"?"dynamic-import":"require",typeOnly:!1,line:U(t,o.index),resolution:"resolved-external"})}return r}a(dr,"extractArkOrderModuleImportsFromSource");function ur(e,t){let n=$(t),r=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(n))!==null;)r.push({file:e,line:U(t,o.index),callee:wt});return r}a(ur,"extractArkOrderPlaneCallsFromSource");var Ta=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;\n]+)?=\s*createOrderPlane\s*(?:<[^>]*>)?\s*\(/g,vt=/^(?:plane|[A-Za-z_$][\w$]*Plane)$/,Na=/\b([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?OrderPlane\b/g,La=/\bfrom\s+['"]arkgate\/order(?:\/[^'"]*)?['"]|\brequire\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]|\bimport\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]/,Da=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g,lr=["",".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],Fa=/([A-Za-z_$][\w$]*)\s*!?\s*\??\s*$/,Pa=/^\s*(?:<[^<>]*>\s*)?([A-Za-z_$][\w$]*)\s*!?\s*(?:\b(?:as|satisfies)\b[\s\S]*)?$/;function $a(e){let t=$(e),n=new Set,r=new RegExp(Ta.source,"g"),s;for(;(s=r.exec(t))!==null;)s[1]&&n.add(s[1]);return[...n].sort()}a($a,"arkOrderPlaneBindings");function Ma(e){let t=[];for(let n of e)if(!(n===""||n===".")){if(n===".."){if(t.length===0)return"";t.pop();continue}t.push(n)}return t.join("/")}a(Ma,"normalizeRelativePath");function Ka(e,t){if(!t.startsWith("./")&&!t.startsWith("../"))return[];let n=e.replace(/\\/g,"/").split("/").slice(0,-1),r=Ma([...n,...t.split("/")]);if(!r)return[];let s=r.replace(/\.(?:[cm]?js|jsx)$/,""),o=new Set;for(let i of[r,s]){for(let l of lr)o.add(`${i}${l}`);for(let l of lr.slice(1))o.add(`${i}/index${l}`)}return[...o]}a(Ka,"relativeModuleCandidates");function Ua(e,t,n){let r=Ka(e,t);return r.length===0?!1:n.some(s=>{let o;try{o=xt(s)}catch{return!1}return r.some(i=>o.test(i))})}a(Ua,"specifierResolvesToPlaneRoot");function ja(e,t,n={}){let r=$(t),s=new Set($a(t)),o=new RegExp(Na.source,"g"),i;for(;(i=o.exec(r))!==null;)i[1]&&s.add(i[1]);let l=n.planeRoots??[];if(l.length>0){let c=new RegExp(Da.source,"g");for(;(i=c.exec(r))!==null;)if(Ua(e,i[2]??"",l))for(let d of(i[1]??"").split(",")){let u=d.trim().replace(/^type\s+/,"").split(/\s+as\s+/),f=u[0]?.trim()??"",p=(u[1]??u[0]??"").trim();!p||!/^[A-Za-z_$][\w$]*$/.test(p)||(vt.test(f)||vt.test(p))&&s.add(p)}}return s.delete(wt),{names:[...s].sort(),isArkOrderFile:La.test(r)}}a(ja,"arkOrderPlaneReceivers");var Ga=new Set(["return","await","void","typeof","yield","in","of","case","else","do","throw","delete"]);function Ha(e){let t=e.replace(/\s+$/,"");if(/[)\]]$/.test(t))return!0;let n=/([A-Za-z_$][\w$]*)$/.exec(t);return n!==null&&!Ga.has(n[1])}a(Ha,"isCallBefore");function fr(e){let t=e.replace(/\s*!?\s*\??\s*$/,"");if(!t.endsWith(")")){let r=Fa.exec(t);return r?r[1]??null:null}let n=0;for(let r=t.length-1;r>=0;r-=1){let s=t[r];if(s===")")n+=1;else if(s==="("&&(n-=1,n===0)){if(Ha(t.slice(0,r)))return null;let o=t.slice(r+1,t.length-1),i=Pa.exec(o);return i?i[1]??null:null}}return null}a(fr,"receiverBefore");function pr(e,t,n){let r=ja(e,t,n);return{names:new Set(r.names),isArkOrderFile:r.isArkOrderFile}}a(pr,"planeReceiverContext");function gr(e,t){return!e||e===wt?!1:t.names.has(e)?!0:t.isArkOrderFile&&vt.test(e)}a(gr,"isPlaneReceiver");function hr(e,t,n={}){let r=$(t),s=pr(e,t,n),o=[],i=/\.((?:update|patch|set|mutate))\s*\(/g,l;for(;(l=i.exec(r))!==null;){let c=l[1],d=r.slice(Math.max(0,l.index-160),l.index);gr(fr(d),s)&&o.push({file:e,line:U(t,l.index),method:c})}return o}a(hr,"extractArkOrderGenericUpdatesFromSource");function mr(e,t,n){if(n.length===0)return[];let r=$(t);if(!Ie(r)||!je(r))return[];let s=[],o=new Set;for(let i of n){if(!i)continue;let l=new RegExp(`(?:\\b${Xe(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${Xe(i)}['"]\\s*:|[{\\,]\\s*${Xe(i)}\\s*[\\,}]|\\.${Xe(i)}\\s*=)`,"g"),c;for(;(c=l.exec(r))!==null;){let d=`${i}:${c.index}`;if(!o.has(d)){o.add(d),s.push({file:e,line:U(t,c.index),key:i});break}}}return s}a(mr,"extractArkOrderXiFieldWritesFromSource");var Ba="(?:xi(?:[A-Z][\\w$]*)?|release|pattern|house|current|[A-Za-z_$][\\w$]*?(?:Xi|Release|Pattern))(?![\\w$])";function yr(e,t){let n=$(t),r=[],s=new RegExp(`(?:(?<![\\w$])|\\.)${Ba}(?:\\s*:\\s*[A-Za-z_$][\\w$.<>, |[\\]]*?)?\\s*(?:\\[[^\\]\\n]*\\])?\\s*=(?![=>])\\s*[^\\n;]{0,160}?\\bingest\\s*\\(`,"g"),o;for(;(o=s.exec(n))!==null;)r.push({file:e,line:U(t,o.index)});return r}a(yr,"extractArkOrderIngestWritesXiFromSource");function Ar(e,t){let n=$(t),r=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(n))!==null;){let l=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];l.length!==0&&r.push({file:e,line:U(t,o.index),keyCount:l.length})}return r}a(Ar,"extractArkOrderReleaseKeyCountsFromSource");function Va(e){let t=[];for(let n of e.split(",")){let r=/^\s*(['"]?)([A-Za-z_$][\w$]*)\1\s*(?::|$)/.exec(n);r?.[2]&&t.push(r[2])}return t}a(Va,"literalKeys");function Rr(e,t,n={}){let r=$(t),s=pr(e,t,n),o=[],i=/\.(?:release|proposeRelease)\s*\(\s*\{([^}]*)\}/g,l;for(;(l=i.exec(r))!==null;){let c=r.slice(Math.max(0,l.index-160),l.index);if(gr(fr(c),s))for(let d of Va(l[1]??""))ar.test(d)&&o.push({file:e,line:U(t,l.index),key:d})}return o}a(Rr,"extractArkOrderXiTtlKeysFromSource");function cr(e){let t=[],n=/(['"`])([^'"`\n\\]+)\1/g,r;for(;(r=n.exec(e))!==null;)r[2]&&t.push(r[2]);return t}a(cr,"stringLiterals");function Sr(e,t){let n=$(t);if(!/\bcreateOrderPlane\b/.test(n))return[];let r=new Set,s=/\bcannotObserve\s*:\s*\[([^\]]*)\]/g,o;for(;(o=s.exec(n))!==null;)for(let d of cr(o[1]??""))r.add(d);if(r.size===0)return[];let i=[],l=new Set,c=/\ballowedKinds\s*:\s*\[([^\]]*)\]/g;for(;(o=c.exec(n))!==null;){let d=U(t,o.index);for(let u of cr(o[1]??"")){if(!r.has(u))continue;let f=`${d}:${u}`;l.has(f)||(l.add(f),i.push({file:e,line:d,kind:u}))}}return i}a(Sr,"extractArkOrderBudgetLeaksFromSource");var kr={"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 Wa(e,t){return!t||t.length===0?!0:t.some(n=>xt(n).test(e))}a(Wa,"matchesArkOrderAppliesTo");function za(e,t=[]){let n=e.trim();return/^domain(?:model)?$/i.test(n)||/^domain(?=[A-Z_\-\s])/i.test(n)?!0:t.some(r=>{let s=r.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(za,"isDomainRoleLayer");function M(e,t,n,r,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:kr[t],sensor:t,message:s,file:n,line:r,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:l?"error":"warning",failsStrict:l,nextAction:le({ruleId:kr[t],fromLayer:o?.fromLayer,target:o?.target})}}a(M,"finding");function Ct(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let n=Ve(e.classification),r=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)r.push(M(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,n));else{let c=new Map;for(let d of e.planeRootHits){let u=c.get(d.matchedRoot)??[];u.push(d),c.set(d.matchedRoot,u)}for(let d of s){let u=c.get(d)??[];if(u.length===0){r.push(M(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(d)} matched no governed files and has no createOrderPlane factory.`,{target:d},n));continue}u.some(f=>f.hasPlaneFactory)||r.push(M(t,"arkorder-missing-plane",u[0].file,1,`ArkOrder plane root ${JSON.stringify(d)} has no createOrderPlane factory.`,{target:d},n))}}let o=new Map(e.layers.map(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let d=c.specifier;if(!d||!ue(d))continue;let u=e.layerForFile(c.from);u&&za(u,o.get(u)??[])&&r.push(M(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:d},n))}for(let c of e.genericUpdates)r.push(M(t,"arkorder-generic-update",c.file,c.line,`Generic ${c.method}() on the order plane rewrites \u03BE; Haken forbids it.`,{target:c.method},n));let i=t.xiKeys??[];for(let c of e.releaseKeyCounts??[])c.keyCount<=t.maxXiKeys||r.push(M(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)},n));for(let c of e.ingestWritesXi??[])r.push(M(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,n));for(let c of e.xiTtlKeys??[])r.push(M(t,"arkorder-xi-ttl",c.file,c.line,`\u03BE key ${JSON.stringify(c.key)} is a freshness field; freshness belongs on \u03C3 (freshUntil), never on \u03BE.`,{target:c.key},n));for(let c of e.budgetLeaks??[])r.push(M(t,"arkorder-information-budget",c.file,c.line,`Projection allowedKinds lists ${JSON.stringify(c.kind)}, which informationBudget.cannotObserve denies.`,{target:c.kind},n));let l=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let d=e.layerForFile(c.file);!d||!l.has(d)||Wa(c.file,t.appliesTo)&&r.push(M(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:d,target:c.key},n))}return r.sort((c,d)=>c.file.localeCompare(d.file)||c.ruleId.localeCompare(d.ruleId)||c.line-d.line),{findings:r,completenessReasons:[]}}a(Ct,"evaluateArkOrderSensors");function br(e){if(!e.arkOrder)return[];let t=ur(e.file,e.source),n={planeRoots:e.arkOrder.planeRoots??[]},r=hr(e.file,e.source,n),s=e.arkOrder.xiKeys??[],o=e.fromLayer?[{name:e.fromLayer,patterns:[],intentPrefixes:[...e.intentPrefixes??[]]}]:[];return Ct({arkOrder:e.arkOrder,layers:o,planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:mr(e.file,e.source,s),ingestWritesXi:yr(e.file,e.source),releaseKeyCounts:Ar(e.file,e.source),xiTtlKeys:Rr(e.file,e.source,n),budgetLeaks:Sr(e.file,e.source),dependencies:dr(e.file,e.source),layerForFile:a(()=>e.fromLayer,"layerForFile"),...e.classification?{classification:e.classification}:{}}).findings.filter(i=>i.sensor==="arkorder-generic-update"||i.sensor==="arkorder-kernel-in-domain"||i.sensor==="arkorder-xi-field-write"||i.sensor==="arkorder-ingest-writes-xi"||i.sensor==="arkorder-too-many-params"||i.sensor==="arkorder-xi-ttl"||i.sensor==="arkorder-information-budget")}a(br,"evaluateArkOrderEditorSensors");function Er(e){return{ruleId:e.ruleId,file:e.file,line:e.line,fromLayer:e.fromLayer,target:e.target,message:e.message,severity:e.severity,failsStrict:e.failsStrict,nextAction:e.nextAction}}a(Er,"violationFor");function Ya(e,t){let n=e.split(/\r?\n/)[t-1]??"",r=n.length-n.trimStart().length;return{loc:{start:{line:t,column:r},end:{line:t,column:Math.max(r,n.length)}}}}a(Ya,"lineNode");function Ir(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length>0&&t.every(n=>n.importKind==="type"||n.exportKind==="type")}a(Ir,"isTypeOnlyDeclaration");function vr(e){function t(s){let o=e.lintedFilename(s),i=e.findConfigPath(o),l=i?e.loadArkConfig(i):null;if(!l?.arkOrder||!i)return null;let c=e.toProjectRelative(i,o);return e.sourceIsInAnalysisScope(l,c)?{config:l,relative:c,fromLayer:w(c,l.layers)??null}:null}return a(t,"loadOrderFile"),{noArkOrderKernelInDomain:{meta:{type:"problem",docs:{description:"Disallow Domain-role imports of arkgate/order when arkOrder is on (same ARKORDER_KERNEL_IN_DOMAIN sensor as ark-check)."},messages:{denied:"{{message}}"},schema:[]},create(s){let o=t(s);if(!o?.fromLayer)return{};let{config:i,relative:l}=o,c=a((d,u,f,p)=>{if(typeof u!="string"||!ue(u))return;let g=d.loc?.start?.line??1,{findings:m}=Ct({arkOrder:i.arkOrder,layers:i.layers,planeCalls:[],genericUpdates:[],planeRootHits:[],dependencies:[{from:l,specifier:u,kind:p,typeOnly:f,line:g,resolution:"resolved-external"}],layerForFile:a(R=>R===l?o.fromLayer:w(R,i.layers),"layerForFile")});for(let R of m)R.sensor==="arkorder-kernel-in-domain"&&e.reportAdapterDiagnostic(s,d,"denied",Er(R),{message:R.message})},"check");return{ImportDeclaration(d){c(d,d.source?.value,Ir(d),"import")},ExportNamedDeclaration(d){d.source&&c(d,d.source.value,Ir(d),"export")},ExportAllDeclaration(d){c(d,d.source?.value,d.exportKind==="type","export")},ImportExpression(d){d.source?.type==="Literal"&&c(d,d.source.value,!1,"dynamic-import")},CallExpression(d){let u=d.arguments?.[0];d.callee?.type==="Identifier"&&d.callee.name==="require"&&u?.type==="Literal"&&!e.isLocallyBound(s,d,"require")&&c(d,u.value,!1,"require")}}}},noArkOrderGenericUpdate:{meta:{type:"problem",docs:{description:"Disallow file-local \u03BE rewrites on the order plane: generic update(), \u03BE field writes, ingest\u2192\u03BE, and oversized release() (same ARKORDER_* sensors as ark-check)."},messages:{denied:"{{message}}"},schema:[]},create(s){let o=t(s);return o?{Program(){let i=ce(s)??"",l=br({arkOrder:o.config.arkOrder,file:o.relative,source:i,fromLayer:o.fromLayer}).filter(c=>c.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let c of l)e.reportAdapterDiagnostic(s,Ya(i,c.line),"denied",Er(c),{message:c.message})}}:{}}}}}a(vr,"createArkOrderEslintRules");import nc from"fs";import ot from"path";import{createHash as us}from"crypto";import H from"fs";import v from"path";var te={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},wr={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...te,default:[]},kernelRoots:{...te},managedLayers:{...te,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},xr={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...te,default:[]},managedLayers:{...te,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...te,default:[]},appliesTo:{...te,default:[]}}};function Ce(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Ce,"isObject");function qa(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let n of e.layers)Ce(n)&&typeof n.name=="string"&&n.name.length>0&&t.add(n.name);return t}a(qa,"declaredLayerNames");function Cr(e){if(!Ce(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}a(Cr,"defaultedArkRun");function _r(e){if(!Ce(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}a(_r,"defaultedArkOrder");function Or(e,t,n,r){if(!Array.isArray(t))return;let s=qa(e);t.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!s.has(o)&&r.push({path:`$.${n}.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})})}a(Or,"validateManagedLayersDeclared");function Tr(e,t){let n=e.arkRun;if(n===void 0||!Ce(n))return;let r=n.managedLayers;if(Or(e,r,"arkRun",t),n.mode==="enforced"){let s=n.kernelRoots??n.compositionRoots;(!Array.isArray(s)||s.length===0)&&t.push({path:n.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(r)||r.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}a(Tr,"validateArkRunExtra");function Nr(e,t){let n=e.arkOrder;if(n===void 0||!Ce(n))return;let r=n.managedLayers;if(Or(e,r,"arkOrder",t),n.mode==="enforced"){let s=n.planeRoots;(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(r)||r.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}a(Nr,"validateArkOrderExtra");var Qe={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Kr={description:'deny blocks every shared-root import of a slice. deny-cross-parent leaves that hop as a warning and, in ark-check and CI only, reports a slice that reaches another universe through a shared root. The write hook and ESLint see one edge and do not block it. The object form { mode: "deny-cross-parent", stopAt } names composition roots (bootstrap, DI registrations) the whole-graph walk never starts at or passes through; a stop file must still sit under sharedRoots, and stopAt does not silence the direct SHARED_IMPORTS_SLICE warning. arkgate 4.8.22 and older reject deny-cross-parent. arkgate 4.8.23 and older reject the object form (must be one of deny, deny-cross-parent).',oneOf:[{type:"string",enum:["deny","deny-cross-parent"]},{type:"object",additionalProperties:!1,required:["mode","stopAt"],properties:{mode:{type:"string",enum:["deny-cross-parent"]},stopAt:{...Qe,minItems:1}}}]},Ur={type:"object",additionalProperties:!1,required:["sliceFolders"],description:`Optional inner wall under this rule. Runs only on a rule with peerIsolation: true and allowed: false; elsewhere it is inert and ark-check warns CONFIG_CHILD_SLICES_INERT (config load still accepts it, as 4.8.23 did). Absent keeps today's universe wall. sliceFolders names children. Flat files are universe common, and so is a commonFolders directory directly under the universe (a folder of that name inside a child belongs to that child). siblings is "deny" (default), "advisory", or { default, enforce, ratchet }. parentMayImportChild defaults to false. message is the text for inner-wall findings. allowedCrossSlice may use a whole-segment *. It clears only a sibling crossing. Cross-parent has no advisory knob. arkgate 4.8.22 and older reject this key. A build that still rejects unknown childSlices fields rejects allowedCrossSlice at config load. A build that still types siblings as a string enum rejects the object at config load.`,properties:{sliceFolders:{...Qe,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...Qe,minItems:1},siblings:{description:'"deny" or "advisory", or { default, enforce, ratchet } so listed subtrees are errors while the default stays advisory. ratchet absent: a new advisory crossing fails only when the baseline in use already records an advisory crossing of this rule. ratchet true: any unrecorded advisory crossing fails when a baseline is in use. ratchet false: measure only, never fails. A string-enum build rejects the object at config load (must be one of deny, advisory). arkgate 4.8.23 and older reject ratchet (unknown field).',oneOf:[{type:"string",enum:["deny","advisory"]},{type:"object",additionalProperties:!1,required:["default"],properties:{default:{type:"string",enum:["deny","advisory"]},enforce:{...Qe},ratchet:{type:"boolean"}}}]},parentMayImportChild:{type:"boolean"},message:{type:"string",minLength:1,description:"Text for inner-wall findings (CROSS_SIBLING_SLICE and universe common importing a child). The rule message stays the universe-wall text (CROSS_PARENT_SLICE and fail-closed denies). Absent: ArkGate default text, never the rule message. arkgate 4.8.23 and older reject this field (unknown field)."},arkRulesFile:{type:"string",minLength:1,description:"Filename read at each child slice root this wall already resolved. The only token is <Layer>, replaced with a declared layer name (arkrules.<Layer>.json). No slash and no wildcard. A discovered file that omits appliesTo is scoped to that slice directory. Explicit appliesTo outside the slice fails config load (ARKRULE_SCOPE_ESCAPES_SLICE). The effective id is <childId>#<localId>. A build that rejects unknown childSlices fields fails at config load (unknown field)."},sliceAliases:{type:"array",minItems:1,description:"Maps a source path glob onto a child slice id (universe id plus one child segment) so files outside the slice trees take that universe and child for both walls. A path without a wildcard also covers everything under it, as sharedRoots does. A bare name, a universe id alone, a target outside every universe shape, and a wildcard in to are rejected. Under stars identity a target written against the 4.8.23 stars id (star bindings before the last literal dropped, e.g. api/v1/x for modules/*/api/*) still loads when it maps to one universe shape, and ark-check warns CONFIG_SLICE_LEGACY_STARS_ID with the new id; it is rejected only when it maps to more than one shape. Config load checks only the shape; doctor reports a target universe no file belongs to. The glob may not overlap a slice folder, and two aliases may not match the same file. Doctor lists each unpinned alias as an owed move. pinned true lists the alias separately and does not count it as debt. reason is a doctor label and does not pin by itself. A build that rejects unknown childSlices fields fails at config load (unknown field). arkgate 4.8.22 and older reject childSlices.",items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},pinned:{type:"boolean",description:"True when a framework forces the path to stay. The alias is not an owed move and does not clear other honesty debt."},reason:{type:"string",minLength:1,description:"Doctor label, such as framework-route. A label alone does not pin."}}}},allowedCrossSlice:{type:"array",minItems:1,description:"Directed child-slice allowances. * matches one whole path segment (features/projects/*). ** and a partial segment are rejected. A bare name is rejected. This list clears only CROSS_SIBLING_SLICE. It cannot clear CROSS_PARENT_SLICE or CROSS_PARENT_VIA_SHARED. The universe allowedCrossSlice still treats * as a literal. A build that rejects unknown childSlices fields fails at config load (unknown field).",items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}};function C(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(C,"isObject");function et(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(et,"propertyPath");function Y(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Y,"trimTrailingSlashes");function jr(e,t){el(e,t),nl(e,t),il(e,t),kl(e,t),Sl(e,t)}a(jr,"validateSliceContract");var Lr='must be "deny", "deny-cross-parent", or { "mode": "deny-cross-parent", "stopAt": ["<composition root path or glob>"] }',Dr="must not cover the whole tree. Name the composition root itself (bootstrap file, DI registrations folder).";function Za(e){return e==="*"||e==="**"}a(Za,"isWildcardSegment");function Gr(e){let t=e.toLowerCase().split("/").filter(s=>s.length>0&&s!==".");(t[0]==="src"||t[0]==="app")&&(t=t.slice(1));let n=t.length;for(;n>0&&Za(t[n-1]??"");)n-=1;let r=t.slice(0,n);return r.some(s=>s.includes("*"))?null:r}a(Gr,"coveredFolder");function Xa(e,t){return e.length<=t.length&&e.every((n,r)=>t[r]===n)}a(Xa,"isPrefixOf");function Ja(e,t){let n=e.layers;if(!Array.isArray(n))return[];let r=new Set([t.from,t.to].filter(o=>typeof o=="string")),s=[];for(let o of n){if(!C(o)||typeof o.name!="string"||!r.has(o.name))continue;let i=Array.isArray(o.patterns)?o.patterns:[];for(let l of i){if(typeof l!="string")continue;let c=l.replace(/\\/g,"/").split("/"),d=c.findIndex(p=>p.includes("*")),u=d===-1?c:c.slice(0,d),f=Gr(u.join("/"));f&&s.push(f)}}return s}a(Ja,"ruleLayerFolders");function Qa(e,t){let n=Y(e.trim().replace(/\\/g,"/"));if(n.length===0)return"must be a non-empty path or glob";let r=n.replace(/^[./]+/,"");if(r===""||r==="*"||r==="**")return Dr;for(let o of n.split("/"))if(o.length===0||o==="."||o==="..")return"must be a path or glob without empty, . or .. segments";let s=Gr(n);return s===null?null:s.length===0?Dr:t.some(o=>Xa(s,o))?"must not cover a whole layer root of this rule. Name the composition root itself (bootstrap file, DI registrations folder).":null}a(Qa,"stopAtEntryIssue");function el(e,t){let n=e.rules;Array.isArray(n)&&n.forEach((r,s)=>{if(!C(r)||r.sharedImportsSlice===void 0)return;let o=r.sharedImportsSlice,i=`$.rules[${s}].sharedImportsSlice`;if(typeof o=="string"){o!=="deny"&&o!=="deny-cross-parent"&&t.push({path:i,message:Lr});return}if(!C(o)){t.push({path:i,message:Lr});return}for(let u of Object.keys(o))u!=="mode"&&u!=="stopAt"&&t.push({path:et(i,u),message:"unknown field"});o.mode===void 0?t.push({path:`${i}.mode`,message:"is required"}):o.mode!=="deny-cross-parent"&&t.push({path:`${i}.mode`,message:'must be deny-cross-parent. stopAt has no meaning for deny; use the string "deny".'});let l=o.stopAt;if(l===void 0){t.push({path:`${i}.stopAt`,message:"is required"});return}if(!Array.isArray(l)||l.length===0){t.push({path:`${i}.stopAt`,message:"must be a non-empty array of paths or globs"});return}let c=new Set,d=Ja(e,r);l.forEach((u,f)=>{let p=`${i}.stopAt[${f}]`;if(typeof u!="string"){t.push({path:p,message:"must be a non-empty path or glob"});return}let g=Qa(u,d);if(g){t.push({path:p,message:g});return}let m=Y(u.trim().replace(/\\/g,"/")).toLowerCase();if(c.has(m)){t.push({path:p,message:"duplicate stopAt entry"});return}c.add(m)})})}a(el,"validateSharedImportsSlice");var tl=["deny","advisory"],Fr='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"], "ratchet": true | false }';function nl(e,t){let n=e.rules;Array.isArray(n)&&n.forEach((r,s)=>{if(!C(r))return;let o=r.childSlices;if(!C(o)||o.siblings===void 0)return;let i=o.siblings,l=`$.rules[${s}].childSlices.siblings`;if(typeof i=="string"){tl.includes(i)||t.push({path:l,message:Fr});return}if(!C(i)){t.push({path:l,message:Fr});return}for(let d of Object.keys(i))d!=="default"&&d!=="enforce"&&d!=="ratchet"&&t.push({path:et(l,d),message:"unknown field"});if(i.ratchet!==void 0&&typeof i.ratchet!="boolean"&&t.push({path:`${l}.ratchet`,message:"must be a boolean"}),i.default===void 0?t.push({path:`${l}.default`,message:"is required"}):i.default!=="deny"&&i.default!=="advisory"&&t.push({path:`${l}.default`,message:"must be deny or advisory"}),i.enforce===void 0)return;if(!Array.isArray(i.enforce)){t.push({path:`${l}.enforce`,message:"must be an array of child slice ids or subtree paths"});return}let c=new Set;i.enforce.forEach((d,u)=>{let f=`${l}.enforce[${u}]`;if(typeof d!="string"||d.trim().length===0){t.push({path:f,message:"must be a non-empty child slice id or subtree path"});return}let p=Y(d.trim().replace(/\\/g,"/"));if(p.split("/").some(g=>g.length===0||g==="."||g==="..")){t.push({path:f,message:"must be a child slice id or subtree path without . or .."});return}if(p.includes("*")){t.push({path:f,message:"must be a child slice id or subtree path. * is not a wildcard on siblings.enforce"});return}if(c.has(p)){t.push({path:f,message:"duplicate enforce entry"});return}c.add(p)})})}a(nl,"validateChildSliceSiblings");var rl="must be a slice id with a slash. A bare name is ambiguous across universes.",sl="* matches one whole path segment. ** and a partial segment are not wildcards.";function ol(e){let t=Y(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty slice id";if(!t.includes("/"))return rl;let n=t.split("/");for(let r of n){if(r.length===0||r==="."||r==="..")return"must be a slice id without empty, . or .. segments";if(r.includes("*")&&r!=="*")return sl}return null}a(ol,"childCrossSlicePatternIssue");function Pr(e){return Y(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Pr,"childCrossSlicePatternKey");function il(e,t){let n=e.rules;Array.isArray(n)&&n.forEach((r,s)=>{if(!C(r))return;let o=r.childSlices;if(!C(o)||o.allowedCrossSlice===void 0)return;let i=o.allowedCrossSlice,l=`$.rules[${s}].childSlices.allowedCrossSlice`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } child slice ids"});return}let c=new Set;i.forEach((d,u)=>{let f=`${l}[${u}]`;if(!C(d)){t.push({path:f,message:"must be an object with from and to"});return}for(let g of Object.keys(d))g!=="from"&&g!=="to"&&t.push({path:et(f,g),message:"unknown field"});for(let g of["from","to"]){let m=d[g],R=`${f}.${g}`;if(typeof m!="string"||m.trim().length===0){t.push({path:R,message:"must be a non-empty slice id"});continue}let k=ol(m);k&&t.push({path:R,message:k})}if(typeof d.from!="string"||typeof d.to!="string")return;let p=`${Pr(d.from)}\0${Pr(d.to)}`;if(!p.startsWith("\0")&&!p.endsWith("\0")){if(c.has(p)){t.push({path:f,message:"duplicate child slice allowance"});return}c.add(p)}})})}a(il,"validateChildSliceAllowedCrossSlice");var fe="must be a child of a universe shape this rule names (its universe sliceFolders shape plus one child segment). A bare name, a universe id alone, a target outside every universe shape, and a wildcard are rejected. Config load checks the shape only; doctor reports a target universe no file belongs to.",al="is a 4.8.23 stars id (star bindings before the last literal dropped) that maps to more than one universe shape of this rule. Write the new stars id, which keeps every star binding (e.g. orders/api/v1/x for modules/*/api/*).",ll="overlaps a slice folder. An alias covers only files outside the slice trees.",cl="two slice aliases match the same file";function dl(e){return Y(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(dl,"aliasPathSegments");function ul(e){let t=e[e.length-1];return t===void 0||t.includes("*")?[...e]:[...e,"**"]}a(ul,"aliasSegmentsWithSubtree");function Hr(e){let t=[];for(let n of e){if(n.includes("*"))break;t.push(n)}return t}a(Hr,"concreteGlobPrefix");function _e(e,t){if(e.length>t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}a(_e,"segmentsArePrefix");function fl(e){let t=e.split(/[/\\]/).filter(Boolean).map(r=>r.toLowerCase());if(t.length<2||t[0]==="*"||t[0]==="**"||!t.some(r=>r==="*"))return null;let n=[];for(let r of t){if(r==="*"||r==="**")break;if(r.includes("*"))return null;n.push(r)}return n.length>0?n:null}a(fl,"anchoredSlicePrefix");function pl(e,t){let n=Hr(e),r=n.length<e.length,s=n[0]==="src"||n[0]==="app"?n.slice(1):n;return _e(t,n)||_e(t,s)?!0:r?_e(n,t)&&n.length<t.length||_e(n,["src",...t])&&n.length<t.length+1||_e(n,["app",...t])&&n.length<t.length+1:!1}a(pl,"globOverlapsAnchored");function gl(e,t){for(let r=0;r<e.length;r+=1){if(e[r]!==t&&e[r]!=="*")continue;let s=e.slice(r+1);if(s.length>=2||s.some(o=>o==="*"||o==="**"))return!0}let n=Hr(e);return n.length<e.length&&(n.length===0||n.length===1&&(n[0]==="src"||n[0]==="app"))}a(gl,"globOverlapsBare");function hl(e,t){let n=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(n.length===1&&n[0]&&!n[0].includes("*"))return gl(e,n[0]);let r=fl(t);return r?pl(e,r):!1}a(hl,"globOverlapsSliceEntry");function ml(e){let t=Y(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty path glob";if(t==="*"||t==="**")return"must not cover the whole tree";for(let n of t.split("/")){if(n.length===0||n==="."||n==="..")return"must be a path glob without empty, . or .. segments";if(!(n==="*"||n==="**")&&(n.includes("*")||n.includes("?")||n.includes("{")||n.includes("[")))return"* matches one whole path segment. ** is a whole segment. A partial segment is not a wildcard."}return null}a(ml,"aliasGlobIssue");function yl(e,t){let n=[];if(!Array.isArray(e))return n;let r=t==="stars";for(let s of e){if(typeof s!="string"||s.length===0)continue;let o=s.split(/[/\\]/).filter(Boolean).map(i=>i.toLowerCase());if(o.length===1&&o[0]&&!o[0].includes("*")){n.push({literals:[o[0],null]});continue}if(!o.some(i=>i==="**"||i.includes("*")&&i!=="*")&&o.includes("*")){if(r){let i=-1;for(let d=0;d<o.length;d+=1)o[d]!=="*"&&(i=d);if(i<0)continue;let l=o.filter((d,u)=>u>=i||d==="*").map(d=>d==="*"?null:d),c=o.slice(i).map(d=>d==="*"?null:d);n.push(c.length===l.length?{literals:l}:{literals:l,legacy:c});continue}n.push({literals:o.map(i=>i==="*"?null:i)})}}return n}a(yl,"universeShapes");function Je(e,t){return e.literals.length!==t.length?!1:e.literals.every((n,r)=>n===null||n===t[r])}a(Je,"shapeMatches");function Al(e,t){let n=Y(e.trim().replace(/\\/g,"/"));if(n.length===0||n.split("/").some(o=>o.length===0||o==="."||o==="..")||n.includes("*")||!n.includes("/"))return fe;let r=n.split("/").map(o=>o.toLowerCase());if(t.length===0||t.some(o=>Je(o,r)))return fe;if(t.some(o=>Je(o,r.slice(0,-1))))return null;let s=new Set(t.filter(o=>o.legacy!==void 0&&!Je({literals:o.legacy},r)&&Je({literals:o.legacy},r.slice(0,-1))).map(o=>o.literals.map(i=>i??"*").join("/")));return s.size===1?null:s.size>1?al:fe}a(Al,"aliasTargetIssue");function $r(e){let t=e[0];return(t==="src"||t==="app")&&e.length>1?[e,e.slice(1)]:[e]}a($r,"aliasGlobVariants");function Rl(e,t){let n=$r(e),r=$r(t);for(let s of n)if(ne(s,t,0,0,new Map))return!0;for(let s of r)if(ne(e,s,0,0,new Map))return!0;return!1}a(Rl,"aliasesCanMatchSameFile");function ne(e,t,n,r,s){let o=`${n}:${r}`,i=s.get(o);if(i!==void 0)return i;let l=!1;if(n===e.length&&r===t.length)l=!0;else if(n<e.length&&e[n]==="**")l=ne(e,t,n+1,r,s)||r<t.length&&ne(e,t,n,r+1,s);else if(r<t.length&&t[r]==="**")l=ne(e,t,n,r+1,s)||n<e.length&&ne(e,t,n+1,r,s);else if(n<e.length&&r<t.length){let c=e[n],d=t[r];(c===d||c==="*"||d==="*")&&(l=ne(e,t,n+1,r+1,s))}return s.set(o,l),l}a(ne,"globsCanMatchSame");var Mr="must be a filename with exactly one <Layer> token and no slash or wildcard (arkrules.<Layer>.json)";function Sl(e,t){let n=e.rules;Array.isArray(n)&&n.forEach((r,s)=>{if(!C(r))return;let o=r.childSlices;if(!C(o)||o.arkRulesFile===void 0)return;let i=`$.rules[${s}].childSlices.arkRulesFile`,l=o.arkRulesFile;if(typeof l!="string"||l.length===0){t.push({path:i,message:Mr});return}(l.split("<Layer>").length!==2||/[*\\/]/.test(l)||l.includes(".."))&&t.push({path:i,message:Mr})})}a(Sl,"validateChildSliceArkRulesFile");function kl(e,t){let n=e.rules;Array.isArray(n)&&n.forEach((r,s)=>{if(!C(r))return;let o=r.childSlices;if(!C(o)||o.sliceAliases===void 0)return;let i=o.sliceAliases,l=`$.rules[${s}].childSlices.sliceAliases`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } slice aliases"});return}let c=yl(r.sliceFolders,r.sliceIdentity),d=[...Array.isArray(r.sliceFolders)?r.sliceFolders:[],...Array.isArray(o.sliceFolders)?o.sliceFolders:[]].filter(f=>typeof f=="string"&&f.length>0),u=[];i.forEach((f,p)=>{let g=`${l}[${p}]`;if(!C(f)){t.push({path:g,message:"must be an object with from and to"});return}for(let k of Object.keys(f))k!=="from"&&k!=="to"&&k!=="pinned"&&k!=="reason"&&t.push({path:et(g,k),message:"unknown field"});let m=f.from,R=f.to;if(typeof m!="string"||m.trim().length===0)t.push({path:`${g}.from`,message:"must be a non-empty path glob"});else{let k=ml(m);if(k)t.push({path:`${g}.from`,message:k});else{let y=ul(dl(m));d.some(A=>hl(y,A))&&t.push({path:`${g}.from`,message:ll});for(let A of u)if(Rl(A,y)){t.push({path:g,message:cl});break}u.push(y)}}if(typeof R!="string"||R.trim().length===0)t.push({path:`${g}.to`,message:fe});else{let k=Al(R,c);k&&t.push({path:`${g}.to`,message:k})}})})}a(kl,"validateChildSliceAliases");function Z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Z,"isObject");function pe(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(pe,"propertyPath");function j(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(j,"valueType");function bl(e,t){let n="#/$defs/";if(e.startsWith(n))return t.$defs[e.slice(n.length)]}a(bl,"resolveSchemaRef");function q(e,t,n,r,s){if(t.$ref){let o=bl(t.$ref,r);if(!o){s.push({path:n,message:`schema reference ${t.$ref} cannot be resolved`});return}q(e,o,n,r,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:n,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:n,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!Z(e)){s.push({path:n,message:`must be an object; received ${j(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:pe(n,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:pe(n,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||q(e[l],i,pe(n,l),r,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&q(e[i],l,pe(n,i),r,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:n,message:`must be an array; received ${j(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:n,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:n,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>q(o,t.items,`${n}[${i}]`,r,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:n,message:`must be a string; received ${j(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:n,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:n,message:`must be a boolean; received ${j(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:n,message:`must be an integer; received ${j(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:n,message:`must be at least ${t.minimum}`})}}a(q,"validateSchemaNode");function tt(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(tt,"normalizeStewardId");function Br(e){let t=tt(e);return!t||_t(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(Br,"isGitHubHandle");function El(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(!t.includes("@")||t.includes(" ")||_t(t))return!1;let n=t.split("@");if(n.length!==2||!n[0]||/\s/.test(t))return!1;let r=n[1].lastIndexOf(".");return r>0&&r<n[1].length-1}a(El,"isGitHubEmail");function Il(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Br(t[1])?tt(t[1]):null}a(Il,"githubHandleFromEmail");function Vr(e){let t=Il(e);if(t)return t;let n=tt(e);return!n||_t(n)?null:Br(n)||El(n)?n:null}a(Vr,"canonicalStewardId");var vl=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function _t(e){let t=tt(e);return!t||vl.test(t)}a(_t,"isAutomationAuthor");var P="1.3",wl=["public","auth","admin","internal"];var Ot="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",Wr=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],xl=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Cl(){let e=[];for(let t of Wr)for(let n of Wr)t===n||xl.has(`${t}->${n}`)||e.push({from:t,to:n,allowed:!1});return e}a(Cl,"createDefaultRules");var Yr=Cl(),Tt=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],T={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},zr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Ot,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:Ot,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:P,default:P},name:{type:"string",minLength:1},include:{...T,minItems:1,default:["src"]},exclude:{...T,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Yr,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...T,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{description:"A project-relative ArkRules path, or a list of paths merged into one catalog for this layer. A string keeps today's behaviour. An older build that types this value as a string rejects an array at config load.",oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...T,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...T,minItems:1},exclude:T,intentPrefixes:T,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...wl]},owners:{...T,minItems:1},forbiddenGlobals:T,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:{...T,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"],description:"How a starred sliceFolders prefix is named. Absent and path keep today's ids (every literal and star binding). stars keeps the last literal plus every star binding (a star before the last literal is kept too), so parallel trees share one feature id. Bare names are unchanged."},sharedRoots:{...T,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}},sharedImportsSlice:Kr,childSlices:Ur}},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:{...T,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:{...T,minItems:1}}},arkRun:wr,arkOrder:xr}},G=class extends Error{static{a(this,"ArkConfigValidationError")}issues;source;constructor(t,n){super(`Invalid ArkGate config (${t}):
5
- ${n.map(r=>`- ${r.path}: ${r.message}`).join(`
6
- `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=n}};function _l(e,t){let n=e.arkRules;if(!(n===void 0||!Z(n)))for(let[r,s]of Object.entries(n)){let o=pe("$.arkRules",r);if(typeof s=="string"){s.length===0&&t.push({path:o,message:"must be a non-empty relative path string"});continue}if(!Array.isArray(s)||s.length===0){t.push({path:o,message:"must be a non-empty path string or an array of paths"});continue}let i=new Set;s.forEach((l,c)=>{let d=`${o}[${c}]`;if(typeof l!="string"||l.length===0){t.push({path:d,message:"must be a non-empty relative path string"});return}i.has(l)&&t.push({path:d,message:"duplicate path"}),i.add(l)})}}a(_l,"validateArkRulesRefs");function Ol(e,t){let n=e.layers;Array.isArray(n)&&n.forEach((r,s)=>{if(!r||typeof r!="object"||Array.isArray(r)||!("owners"in r))return;let o=r.owners;Array.isArray(o)&&o.forEach((i,l)=>{typeof i=="string"&&(Vr(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}a(Ol,"validateLayerOwners");function Tl(e){let t={...e,$schema:e.$schema===void 0?Ot:e.$schema,schemaVersion:e.schemaVersion===void 0?P:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Yr.map(n=>({...n})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Cr(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=_r(e.arkOrder)),t}a(Tl,"defaultedConfig");function Nl(e){return e===P?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(Nl,"migratedFromOf");function Ll(){let e=new Set([P]);for(let t of Tt)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(Ll,"knownInputVersions");function Dl(e,t="ark.config.json"){if(!Z(e))throw new G(t,[{path:"$",message:`must be an object; received ${j(e)}`}]);let n=Ll(),r=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(r===null)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${P}`}]);if(r!=="unversioned"&&!n.has(r))throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${P}`}]);let s=r,o={...e},i=0;for(;s!==P&&i<Tt.length+1;){i+=1;let l=Tt.find(c=>c.from===s);if(!l)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${P}`}]);s=l.to,o.schemaVersion=s}if(s!==P)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${P}`}]);return{candidate:Tl(o),migratedFrom:Nl(r)}}a(Dl,"migrateArkConfig");function Fl(e,t="ark.config.json"){let{candidate:n,migratedFrom:r}=Dl(e,t),s=[];if(q(n,zr,"$",zr,s),Tr(n,s),Nr(n,s),Ol(n,s),jr(n,s),_l(n,s),s.length>0)throw new G(t,s);return{config:n,migratedFrom:r}}a(Fl,"loadArkConfigContract");function nt(e,t="ark.config.json"){let n;try{n=JSON.parse(e)}catch(r){throw new G(t,[{path:"$",message:`invalid JSON: ${r instanceof Error?r.message:String(r)}`}])}return Fl(n,t)}a(nt,"parseArkConfigJson");var Oe="1.0",Nt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",Pl=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],$l=["no-anemic-model"],qr={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Zr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Nt,title:"ArkGate ArkRules (intra-layer contract)",description:"Per-layer structure sensors and invariant catalog consumed by the ArkGate Effective Contract.",type:"object",additionalProperties:!1,required:["schemaVersion","layer"],properties:{$schema:{type:"string",minLength:1,default:Nt},schemaVersion:{type:"string",const:Oe,default:Oe},layer:{type:"string",minLength:1},structure:{type:"array",default:[],items:{$ref:"#/$defs/structureEntry"}},invariants:{type:"array",default:[],items:{$ref:"#/$defs/invariantEntry"}}},$defs:{structureEntry:{type:"object",additionalProperties:!1,required:["id","sensor"],properties:{id:{type:"string",minLength:1},sensor:{type:"string",enum:[...Pl]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:qr,description:{type:"string",minLength:1}}},invariantEntry:{type:"object",additionalProperties:!1,required:["id","description"],properties:{id:{type:"string",minLength:1},description:{type:"string",minLength:1},aggregate:{type:"string",minLength:1},coverage:{type:"object",additionalProperties:!1,properties:{test:{type:"boolean"},symbol:{type:"string",minLength:1}}},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:qr}}}},ge=class extends Error{static{a(this,"ArkRulesValidationError")}issues;source;constructor(t,n){super(`Invalid ArkRules (${t}):
7
- ${n.map(r=>`- ${r.path}: ${r.message}`).join(`
8
- `)}`),this.name="ArkRulesValidationError",this.source=t,this.issues=n}};function Ml(e){return{...e,$schema:e.$schema===void 0?Nt:e.$schema,schemaVersion:e.schemaVersion===void 0?Oe:e.schemaVersion,structure:e.structure===void 0?[]:e.structure,invariants:e.invariants===void 0?[]:e.invariants}}a(Ml,"defaultedArkRules");function Xr(e){return e==="enforced"?"enforced":"advisory"}a(Xr,"normalizeMode");function Kl(e){return $l.includes(e)}a(Kl,"isTier2Sensor");function Ul(e,t){let n=Array.isArray(e.structure)?e.structure:[],r=Array.isArray(e.invariants)?e.invariants:[],s=new Set;n.forEach((o,i)=>{if(!Z(o))return;let l=typeof o.id=="string"?o.id:"";l&&(s.has(l)&&t.push({path:`$.structure[${i}].id`,message:`duplicate rule id ${JSON.stringify(l)}`}),s.add(l)),typeof o.sensor=="string"&&Kl(o.sensor)&&o.mode==="enforced"&&t.push({path:`$.structure[${i}].mode`,message:`${l?`rule ${JSON.stringify(l)} uses sensor `:"sensor "}${JSON.stringify(o.sensor)}, which is Tier-2 advisory-only and cannot be enforced${l?" (arkgate-check --sensors lists which sensors can)":""}`}),Array.isArray(o.appliesTo)&&o.appliesTo.length===0&&t.push({path:`$.structure[${i}].appliesTo`,message:"must not be an empty array (omit the field to apply to the whole layer)"})}),r.forEach((o,i)=>{if(!Z(o))return;let l=typeof o.id=="string"?o.id:"";l&&(s.has(l)&&t.push({path:`$.invariants[${i}].id`,message:`duplicate rule id ${JSON.stringify(l)}`}),s.add(l)),Array.isArray(o.appliesTo)&&o.appliesTo.length===0&&t.push({path:`$.invariants[${i}].appliesTo`,message:"must not be an empty array (omit the field to apply to the whole layer)"})})}a(Ul,"validateSemantics");function Lt(e,t="arkrules.json",n){if(!Z(e))throw new ge(t,[{path:"$",message:`must be an object; received ${j(e)}`}]);let r=Ml(e),s=[];if(q(r,Zr,"$",Zr,s),Ul(r,s),n!==void 0&&typeof r.layer=="string"&&r.layer!==n&&s.push({path:"$.layer",message:`must match referencing key ${JSON.stringify(n)}; received ${JSON.stringify(r.layer)}`}),s.length>0)throw new ge(t,s);return{config:r}}a(Lt,"loadArkRulesContract");function rt(e,t){return e.childId?`${e.childId}#${t}`:t}a(rt,"effectiveRuleId");function Jr(e,t){if(t&&t.length>0)return[...t];if(e.childId&&e.defaultAppliesTo&&e.defaultAppliesTo.length>0)return[...e.defaultAppliesTo]}a(Jr,"effectiveAppliesTo");function Qr(e,t){return{sourceFile:e.sourceFile,ruleId:rt(e,t),layer:e.layer,...e.childId?{childId:e.childId}:{}}}a(Qr,"provenanceFor");function es(e,t){let n=t.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),r=e.trim().replace(/\\/g,"/").replace(/^\.\//,"").toLowerCase();if(!r||!n||r.includes(".."))return!1;if(r===n||r===`${n}/**`||r===`${n}/*`)return!0;if(r.startsWith(`${n}/`)){let i=r.slice(n.length+1).split("/"),l=i.indexOf("**");return l!==-1&&l!==i.length-1?!1:i.every(c=>c.length>0)}let s=n.replace(/^(?:src|app)\//,""),o=r.replace(/^(?:src|app)\//,"");return s!==n||o!==r?es(o,s):!1}a(es,"appliesToPatternInsideSlice");function ts(e){if(!e.childId||!e.defaultAppliesTo?.length)return[];let t=String(e.defaultAppliesTo[0]).replace(/\/\*\*$/,""),n=[],r=[...e.file.structure??[],...e.file.invariants??[]];for(let s of r)for(let o of s.appliesTo??[])es(o,t)||n.push({id:s.id,pattern:o});return n}a(ts,"sliceScopeEscapes");function ns(e){let t=new Map,n=new Map;for(let r of e){let s=[...(r.file.structure??[]).map(o=>o.id),...(r.file.invariants??[]).map(o=>o.id)];for(let o of s){let i=rt(r,o),l=`${r.layer}\0${i}`,c=t.get(l);if(!c){t.set(l,{id:i,layer:r.layer,sourceFiles:[r.sourceFile]});continue}let d=n.get(l)??{id:i,layer:r.layer,sourceFiles:[...c.sourceFiles]};d.sourceFiles.includes(r.sourceFile)||d.sourceFiles.push(r.sourceFile),n.set(l,d)}}return[...n.values()]}a(ns,"duplicateArkRuleIds");function rs(e){let t={},n=[],r=[],s=[...e].sort((o,i)=>o.layer.localeCompare(i.layer)||o.sourceFile.localeCompare(i.sourceFile));for(let o of s){let i=(o.file.structure??[]).map(d=>{let u=Jr(o,d.appliesTo);return{...d,id:rt(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:Xr(d.mode),provenance:Qr(o,d.id)}}),l=(o.file.invariants??[]).map(d=>{let u=Jr(o,d.appliesTo);return{...d,id:rt(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:Xr(d.mode),provenance:Qr(o,d.id)}}),c=t[o.layer];c?(c.sourceFiles||(c.sourceFiles=[c.sourceFile]),c.sourceFiles.includes(o.sourceFile)||c.sourceFiles.push(o.sourceFile),c.structure.push(...i),c.invariants.push(...l)):t[o.layer]={sourceFile:o.sourceFile,sourceFiles:[o.sourceFile],structure:i,invariants:l},n.push(...i),r.push(...l)}return n.sort((o,i)=>{let l=o.provenance.layer.localeCompare(i.provenance.layer);return l!==0?l:o.id.localeCompare(i.id)}),r.sort((o,i)=>{let l=o.provenance.layer.localeCompare(i.provenance.layer);return l!==0?l:o.id.localeCompare(i.id)}),{schemaVersion:Oe,byLayer:t,structure:n,invariants:r}}a(rs,"buildEffectiveArkRules");function re(){return{schemaVersion:Oe,byLayer:{},structure:[],invariants:[]}}a(re,"emptyEffectiveArkRules");var Dt=class extends Error{static{a(this,"EffectiveContractError")}issues;source;constructor(t,n){super(`Invalid Effective Contract (${t}):
9
- ${n.map(r=>`- ${r.path}: ${r.message}`).join(`
10
- `)}`),this.name="EffectiveContractError",this.source=t,this.issues=n}};function ss(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}a(ss,"normalizeRel");function os(e,t="ark.config.json"){let n=e.config.arkRules??{},r=[],s=Object.keys(n).length>0,o=!!(e.governedFiles&&e.governedFiles.length>0);if(!s&&!o){if(e.discoveredArkRulesFiles&&e.discoveredArkRulesFiles.length>0)for(let f of[...e.discoveredArkRulesFiles].sort())r.push({path:f,message:`ArkRules file ${JSON.stringify(f)} is not referenced by arkRules and will not be enforced`,severity:"advisory"});return{config:e.config,arkRules:re(),warnings:r}}let i=new Set(e.config.layers.map(f=>f.name)),l=[],c=[],d=new Set,u=a((f,p,g)=>{if(g instanceof ge){for(let m of g.issues)l.push({path:`${f}${m.path==="$"?"":m.path.replace(/^\$/,"")}`,message:`${p}: ${m.message}`});return}if(g instanceof SyntaxError){l.push({path:f,message:`referenced ArkRules file ${JSON.stringify(p)} is not valid JSON: ${g.message}`});return}l.push({path:f,message:`referenced ArkRules file ${JSON.stringify(p)} failed to load: ${g instanceof Error?g.message:String(g)}`})},"pushLoadIssue");for(let f of Object.keys(n).sort()){let p=n[f],g=`$.arkRules[${JSON.stringify(f)}]`,m=Array.isArray(p)?p:typeof p=="string"?[p]:null;if(!m||m.length===0||m.some(R=>typeof R!="string"||R.length===0)){l.push({path:g,message:"must be a non-empty path string or an array of paths"});continue}if(!i.has(f)){l.push({path:g,message:`layer ${JSON.stringify(f)} is not declared in layers[]`});continue}m.forEach((R,k)=>{let y=m.length===1&&typeof p=="string"?g:`${g}[${k}]`;if(R.startsWith("/")||/^[A-Za-z]:[\\/]/.test(R)){l.push({path:y,message:"must be a project-relative path (absolute paths are not allowed)"});return}let A=ss(R);d.add(A);let S=e.fileContents[A]??e.fileContents[R];if(S===void 0){l.push({path:y,message:`referenced ArkRules file ${JSON.stringify(A)} is missing`});return}try{let I=Lt(JSON.parse(S),A,f);c.push({layer:f,sourceFile:A,file:I.config})}catch(I){u(y,A,I)}})}if(e.governedFiles&&e.governedFiles.length>0){let f=$e({files:e.governedFiles,rules:e.config.rules,layers:[...i]});for(let p of f){let g=e.fileContents[p.path];if(g!==void 0){d.add(p.path);try{let m=Lt(JSON.parse(g),p.path,p.layer),R={layer:p.layer,sourceFile:p.path,file:m.config,childId:p.childId,defaultAppliesTo:p.defaultAppliesTo},k=ts(R);if(k.length>0){l.push({path:p.path,message:`ARKRULE_SCOPE_ESCAPES_SLICE: ${p.path} appliesTo ${k.map(y=>y.pattern).join(", ")} escapes ${p.childId}`});continue}c.push(R)}catch(m){u(p.path,p.path,m)}}}}for(let f of ns(c))l.push({path:`$.arkRules[${JSON.stringify(f.layer)}]`,message:`ARKRULE_DUPLICATE_ID: ${f.id} is declared in ${f.sourceFiles.join(", ")}`});if(e.discoveredArkRulesFiles)for(let f of[...e.discoveredArkRulesFiles].sort()){let p=ss(f);d.has(p)||r.push({path:p,message:`ArkRules file ${JSON.stringify(p)} is not referenced by arkRules and will not be enforced`,severity:"advisory"})}if(l.length>0)throw new Dt(t,l);return{config:e.config,arkRules:rs(c),warnings:r}}a(os,"resolveEffectiveContract");var jl=2e3,is=new Map;function as(e){try{return H.statSync(e).isFile()}catch{return!1}}a(as,"isFile");function Pt(e){let t=is.get(e);if(t){if(t.found!==null&&as(t.found))return t.found;if(t.found===null&&Date.now()-t.at<jl)return null}let n=v.join(e,"ark.config.json"),r;if(as(n))r=n;else{let s=v.dirname(e);r=s===e?null:Pt(s)}return is.set(e,{found:r,at:Date.now()}),r}a(Pt,"findConfigInDir");function D(e){return!e||e==="<input>"||e.startsWith("stdin")?null:Pt(v.dirname(v.resolve(e)))}a(D,"findConfigPath");var he=new Map,Gl=64;function Hl(e){try{let t=H.statSync(e,{throwIfNoEntry:!1});return t?.isFile()?`${t.mtimeMs}:${t.size}:${t.ino}`:null}catch{return null}}a(Hl,"configFileStamp");function Bl(e,t){if(!he.has(e)&&he.size>=Gl){let n=he.keys().next().value;n!==void 0&&he.delete(n)}he.set(e,t)}a(Bl,"rememberContract");var Vl=/\.[cm]?[tj]sx?$/,Wl=/(^test(?:[-_.]).*|\.(spec|test)(?:-d)?\.)(tsx?|jsx?|mjsx?|cjsx?|mts|cts)$/i,zl=new Set(["node_modules","dist","coverage","bench","benches","benchmark","benchmarks","docs","documentation","example","examples","fixture","fixtures","testdata","playground","scaffold","scaffolds","__tests__","__mocks__","e2e","test","tests"]);function Yl(e){return Vl.test(e)&&!e.endsWith(".d.ts")&&!Wl.test(e)}a(Yl,"isGovernableSourceName");function ql(e){let t=e?.arkRules;if(!t||typeof t!="object")return[];let n=[];for(let r of Object.values(t))if(typeof r=="string"&&r.length>0)n.push(r);else if(Array.isArray(r))for(let s of r)typeof s=="string"&&s.length>0&&n.push(s);return n}a(ql,"arkRulesRefs");function fs(e,t){let n=t.include&&t.include.length>0?t.include:["src"],r=[],s=a(o=>{let i;try{i=H.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of i){if(l.name.startsWith("."))continue;let c=v.join(o,l.name);if(l.isDirectory()){if(zl.has(l.name))continue;s(c);continue}if(!l.isFile()||!Yl(l.name))continue;let d=v.relative(e,c).split(v.sep).join("/");!d||d.startsWith("..")||dt(d,t)||r.push(d)}},"walk");for(let o of n){let i=String(o).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");s(v.resolve(e,i==="."?"":i))}return r}a(fs,"governedRelativeFiles");function Zl(e,t){return $e({files:t,rules:e.rules,layers:e.layers.map(n=>n.name)}).map(n=>n.path)}a(Zl,"plannedSlicePaths");function Xl(e,t){let n=t.replace(/\\/g,"/").replace(/^\.\//,""),r=v.resolve(e,n),s=v.relative(e,r);if(!(s.startsWith("..")||v.isAbsolute(s)))try{return H.readFileSync(r,"utf8")}catch{return}}a(Xl,"readReferencedFile");function ps(e,t){if(!e)return[];let n=new Set,r=[],s=a(o=>{let i=o.replace(/\\/g,"/").replace(/^\.\//,"");!i||n.has(i)||(n.add(i),r.push(i))},"add");for(let o of ql(e))s(o);for(let o of Zl(e,t))s(o);return r}a(ps,"contractSourcePaths");function Ft(e,t){let n=t?fs(e,t):[];return ps(t,n).map(r=>{try{let s=H.statSync(v.resolve(e,r));return`${r}:${s.mtimeMs}:${s.size}`}catch{return`${r}:missing`}}).join("|")}a(Ft,"refStampsFor");function ls(e){return e instanceof Error?e.message:String(e)}a(ls,"errorText");function Jl(e,t){let n=v.dirname(e),r;try{r=nt(t,e).config}catch(c){return{config:null,arkRules:re(),error:ls(c),fingerprint:null}}let s=fs(n,r),o=ps(r,s),i=us("sha256").update(t);if(o.length===0)return{config:r,arkRules:re(),error:null,fingerprint:i.digest("hex")};let l={};for(let c of o){let d=Xl(n,c);if(d===void 0)continue;let u=c.replace(/\\/g,"/").replace(/^\.\//,"");l[u]=d,i.update(`\0${u}\0${d}`)}try{let c=os({config:r,fileContents:l,governedFiles:s},e);return{config:r,arkRules:c.arkRules,error:null,fingerprint:i.digest("hex")}}catch(c){return{config:null,arkRules:re(),error:ls(c),fingerprint:null}}}a(Jl,"resolveContract");function me(e){let t=v.dirname(e),n=Hl(e),r=he.get(e);if(r&&n!==null&&r.stamp===n&&Ft(t,r.refConfig)===r.refStamps)return r.result;let s;try{s=H.readFileSync(e,"utf8")}catch{return{config:null,arkRules:re(),error:null,fingerprint:null}}if(r?.source===s&&Ft(t,r.refConfig)===r.refStamps)return r.stamp=n,r.result;let o=Jl(e,s),i=o.config??Ql(s,e);return Bl(e,{source:s,stamp:n,refConfig:i,refStamps:Ft(t,i),result:o}),o}a(me,"loadArkContract");function Ql(e,t){try{return nt(e,t).config}catch{return null}}a(Ql,"safeConfig");function ec(e){if(!H.existsSync(e))return null;let t=me(e);return t.config?t.config:nt(H.readFileSync(e,"utf8"),e).config}a(ec,"loadArkConfig");function X(e,t){return(e.include??[]).some(r=>{let s=String(r).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!dt(t,e)}a(X,"sourceIsInAnalysisScope");function st(e,t,n){let r=v.isAbsolute(n)?n:v.resolve(n),s=v.relative(t,r).split(v.sep).join("/");if(!X(e,s))return null;let o=e.layers?.find(i=>i.name===w(s,e.layers));return{relFile:s,layer:o}}a(st,"lintedFileInScope");function B(e){return e?me(e).config:null}a(B,"configForRule");var cs="configInvalid",tc="Ark contract is invalid, so no architecture verdict is possible (fix it; ark-check fails closed the same way): {{detail}}",ds=new WeakSet;function $t(e){let t=D(e);return t?me(t).error:null}a($t,"contractErrorForFile");function F(e){return{meta:{...e.meta,messages:{...e.meta.messages,[cs]:tc,[We]:Zn}},create(t){let n=$t(x(t));return n?{Program(r){let s=W(t);if(s&&typeof s=="object"){if(ds.has(s))return;ds.add(s)}t.report({...r?.loc?.start?{node:r}:{loc:{line:1,column:0}},messageId:cs,data:{detail:n.replace(/\s*\n\s*/g," ")}})}}:ze(e,t,"blocking")}}}a(F,"withContractGuard");function gs(e=process.cwd()){let t=Pt(v.resolve(e));if(!t)return null;let n=me(t);if(n.fingerprint)return n.fingerprint;try{return us("sha256").update(H.readFileSync(t,"utf8")).digest("hex")}catch{return null}}a(gs,"contractFingerprint");var rc=256*1024;function sc(e){try{return nc.readFileSync(e,"utf8")}catch{return""}}a(sc,"readUtf8");function oc(e,t){if(!/\.(tsx?|mts|cts)$/i.test(e))return[];try{return ve(e,t)}catch{return[]}}a(oc,"classShapesFor");function ic(e,t){if(!/\.(tsx?|mts|cts|jsx?|mjs|cjs)$/i.test(e)||e.endsWith(".d.ts"))return{};if(t.length>rc)return{};let n=Kn(e,t);return n?{[e]:n}:{}}a(ic,"hintsFor");function hs(e){return{meta:{type:"problem",docs:{description:"Report ArkRules structure-sensor findings for the linted file (same Effective Contract and evaluators as ark-check; file-local sensors only)."},messages:{structure:"ArkRules {{arkruleId}} ({{sensor}}): {{message}}"},schema:[]},create(t){let n=x(t),r=D(n);if(!r||!n)return{};let s=me(r),o=s.config;if(!o||s.arkRules.structure.length===0)return{};let i=ot.dirname(r),l=ot.resolve(n),c=ot.relative(i,l).split(ot.sep).join("/");if(!e(o,c))return{};let d=w(c,o.layers);return{Program(u){let f=ce(t)??sc(l),p=Mn({arkRules:s.arkRules,classShapes:oc(c,f),files:[c],layerForFile:a(g=>g===c?d:w(g,o.layers),"layerForFile"),fileHints:ic(c,f)}).filter(g=>g.file===c);for(let g of p)O(t,{loc:{start:{line:g.line}},parent:u},"structure",{ruleId:g.ruleId,code:g.code,file:c,line:g.line,fromLayer:g.fromLayer,arkruleId:g.arkruleId,arkruleSource:g.arkruleSource,severity:g.severity,failsStrict:g.failsStrict,message:g.message},{arkruleId:g.arkruleId,sensor:g.sensor,message:g.message})}}}}}a(hs,"createArkRulesStructureRule");import Te from"path";function ms(e,t,n){for(let r=t.length;r>=n;r-=1){let s=t.slice(0,r).join(".");if(e.has(s))return s}}a(ms,"longestForbidden");var ys={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=x(e),n=e.options?.[0],r=D(t),s=B(r),o=r?Te.dirname(r):null,i=null,l="this layer";if(s&&o&&t){let y=st(s,o,t);if(!y)return{};let{layer:A}=y;A?.forbiddenGlobals?.length?(i=new Set(A.forbiddenGlobals),l=A.name):i=null}else n?.globals&&(i=new Set(n.globals));if(!i)return{};let c=i,d=typeof W(e)?.getScope=="function",u=Te.isAbsolute(t)?t:Te.resolve(t),f=o?Te.relative(o,u).split(Te.sep).join("/"):t,p=a((y,A)=>{O(e,y,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:A,message:`${l} must not use the ambient global "${A}".`},{name:A,layer:l})},"report"),g=a((y,A,S,I)=>{if(S||typeof A!="string")return;let _=Me(A,c);_&&O(e,y,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:A,edgeKind:I,message:`${l} must not use module "${A}" because it is the import form of forbidden global "${_}".`},{layer:l,name:_,specifier:A,importKind:I})},"reportModule"),m=a((y,A)=>{if(y?.type==="ObjectPattern")for(let S of y.properties??[]){if(S.type==="RestElement")continue;let I=It(S.key,S.computed);if(!I)continue;let _=[...A,I],Se=ms(c,_,A.length+1);if(Se){p(S,Se);continue}let se=S.value,Ds=se?.type==="AssignmentPattern"?se.left:se;m(Ds,_)}},"checkPattern"),R=a((y,A)=>{if(y?.type!=="ObjectPattern")return;let S=we(A);if(!S||z(e,S.root,S.segments[0]))return;let I=S.segments[0]==="globalThis"?S.segments.slice(1):S.segments;m(y,I)},"checkDestructure"),k=de(e,g);return{MemberExpression(y){if(y.parent?.type==="MemberExpression"&&y.parent.object===y)return;let A=we(y);if(!A||z(e,A.root,A.segments[0]))return;let S=A.segments[0]==="globalThis",I=S?A.segments.slice(1):A.segments,_=ms(c,I,S?1:2);_?p(y,_):!d&&c.has(A.segments[0])&&p(y,A.segments[0])},VariableDeclarator(y){R(y.id,y.init)},AssignmentExpression(y){R(y.left,y.right)},CallExpression(y){if(k.CallExpression(y),d)return;let A=y.callee?.type==="Identifier"?y.callee.name:void 0;A&&c.has(A)&&p(y,A)},ImportDeclaration:k.ImportDeclaration,ImportExpression:k.ImportExpression,TSImportEqualsDeclaration:k.TSImportEqualsDeclaration,ExportNamedDeclaration:k.ExportNamedDeclaration,ExportAllDeclaration:k.ExportAllDeclaration,NewExpression(y){if(d)return;let A=y.callee?.type==="Identifier"?y.callee.name:void 0;A&&c.has(A)&&p(y,A)},Identifier(y){!d||!y.name||!c.has(y.name)||!tr(e,y)||z(e,y,y.name)||p(y,y.name)}}}};import it from"path";function As(e,t){if(!(e?.type&&e.type!=="ObjectExpression"))return e?.properties?.find(n=>qe(n.key)===t)}a(As,"objectProperty");function ye(e,t){return As(e,t)!==void 0}a(ye,"objectHasProperty");function ac(e){let t=As(e,"metadata")?.value;return ye(t,"source")}a(ac,"objectHasMetadataSource");function Rs(e){let t=e.callee;return t?.type==="Identifier"?t.name==="publish":t?.computed!==!0&&qe(t?.property)==="publish"}a(Rs,"isPublishCall");function Ss(e){return e?e.type==="Identifier"||e.type===void 0&&e.name?/^[A-Z]/.test(e.name??""):e.type==="MemberExpression"&&e.computed!==!0?Ss(e.property):!1:!1}a(Ss,"looksLikeIntentCreator");function lc(e){let t=xe(e);return t!==void 0&&be(t)||ye(e,"intent")||Ss(e)}a(lc,"isArkPublishCandidate");function cc(e){let[t,n,r]=e;return ac(t)||ye(n,"source")||ye(r,"source")}a(cc,"publishHasSource");function dc(e){let t=x(e),n=D(t),r=B(n);if(!r||!n||!t)return null;let s=it.relative(it.dirname(n),it.resolve(t)).split(it.sep).join("/");return X(r,s)?s:null}a(dc,"scopedFile");var ks={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 n=t.arguments?.[0],s=ft({publishCall:Rs(t),rawIntentName:xe(n),objectHasIntent:ye(n,"intent"),arkPublishCandidate:!1,hasSource:!0}).find(o=>o.ruleId==="RAW_EVENT_PUBLISH");s&&O(e,t,"rawPublish",{...s,file:x(e)})}}}},bs={meta:{type:"problem",docs:{description:"Require Ark publish calls (intent creator / Ark intent first argument) to include source metadata. Silent without an ark.config.json or outside its include scope, like ark-check."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){let t=dc(e);return t?{CallExpression(n){let r=n.arguments??[],s=r[0],i=ft({publishCall:Rs(n),rawIntentName:xe(s),objectHasIntent:ye(s,"intent"),arkPublishCandidate:lc(s),hasSource:cc(r)}).find(l=>l.ruleId==="PUBLISH_MISSING_SOURCE");i&&O(e,n,"missingSource",{...i,file:t})}}:{}}};import at from"fs";import E from"path";function Es(e,t){let n=t,r=e.length;for(;;){for(;n<r&&/\s/.test(e[n]);)n+=1;if(e[n]==="/"&&e[n+1]==="/"){for(;n<r&&e[n]!==`
11
- `;)n+=1;continue}if(e[n]==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2);n=s<0?r:s+2;continue}return n}}a(Es,"skipTrivia");function uc(e){let t=e.replace(/^/,""),n="",r=0,s=t.length;for(;r<s;){let o=t[r];if(o==='"'){let i=r+1;for(;i<s&&t[i]!=='"';)i+=t[i]==="\\"?2:1;n+=t.slice(r,i+1),r=i+1;continue}if(o==="/"&&(t[r+1]==="/"||t[r+1]==="*")){n+=" ",r=Es(t,r);continue}if(o===","){let i=Es(t,r+1);if(t[i]==="}"||t[i]==="]"){r+=1;continue}}n+=o,r+=1}return n}a(uc,"stripJsonc");function Is(e){return JSON.parse(uc(e))}a(Is,"parseJsonc");var vs=new Map,Ae=new Map,fc=64;function Mt(e){try{let t=at.statSync(e);return`${t.mtimeMs}:${t.size}`}catch{return"missing"}}a(Mt,"fileStamp");function J(e){try{return at.statSync(e).isFile()}catch{return!1}}a(J,"isFile");function ws(e){let t=E.resolve(e),n=vs.get(t);if(n!==void 0&&(n===null||J(n)))return n;let r=E.join(t,"tsconfig.json"),s;if(J(r))s=r;else{let o=E.dirname(t);s=o===t?null:ws(o)}return vs.set(t,s),s}a(ws,"findNearestTsconfig");function pc(e,t){let n=e;for(;;){let r=E.join(n,"node_modules",t);for(let i of[r,`${r}.json`])if(J(i))return i;let s=E.join(r,"package.json");if(J(s))try{let i=JSON.parse(at.readFileSync(s,"utf8"));if(typeof i.tsconfig=="string"&&J(E.join(r,i.tsconfig)))return E.join(r,i.tsconfig)}catch{}if(J(E.join(r,"tsconfig.json")))return E.join(r,"tsconfig.json");let o=E.dirname(n);if(o===n)return null;n=o}}a(pc,"resolvePackageExtends");function gc(e,t){let n=E.dirname(e);if(t.startsWith(".")||E.isAbsolute(t)){let r=E.resolve(n,t);for(let s of[r,`${r}.json`])if(J(s))return s;return null}return pc(n,t)}a(gc,"resolveExtends");function Kt(e,t){return e.split("${configDir}").join(t)}a(Kt,"substituteConfigDir");function xs(e,t,n,r,s){if(n>8||r.has(e))return{};r.add(e),s.push({file:e,stamp:Mt(e)});let o;try{o=Is(at.readFileSync(e,"utf8"))??{}}catch{return{}}let i={},l=o.extends,c=typeof l=="string"?[l]:Array.isArray(l)?l:[];for(let f of c){if(typeof f!="string")continue;let p=Kt(f,t),g=gc(e,p);if(!g){if(p.startsWith(".")||E.isAbsolute(p)){let R=E.resolve(E.dirname(e),p);for(let k of[R,`${R}.json`])s.push({file:k,stamp:Mt(k)})}continue}let m=xs(g,t,n+1,r,s);m.baseUrl!==void 0&&(i.baseUrl=m.baseUrl),m.paths!==void 0&&(i.paths=m.paths,i.pathsBase=m.pathsBase)}let d=o.compilerOptions??{},u=E.dirname(e);return typeof d.baseUrl=="string"&&(i.baseUrl=E.resolve(u,Kt(d.baseUrl,t))),d.paths&&typeof d.paths=="object"&&(i.paths=d.paths,i.pathsBase=u),i}a(xs,"loadChain");function hc(e,t){let n=e.baseUrl??e.pathsBase??t,r=[];for(let[s,o]of Object.entries(e.paths??{})){if(!Array.isArray(o)||o.length===0)continue;let i=o.filter(f=>typeof f=="string").map(f=>Kt(f,t));if(i.length===0)continue;let l=s.indexOf("*"),c=l>=0,d=c?s.slice(0,l):s,u=c?s.slice(l+1):"";c&&!d&&!u||r.push({from:d,to:i[0].replace(/\*$/,""),suffix:u,wildcard:c,targets:i})}return r.sort((s,o)=>Number(s.wildcard)-Number(o.wildcard)||o.from.length-s.from.length),{baseUrl:n,aliases:r}}a(hc,"buildAliasSet");function mc(e){let t=Ae.get(e);if(t&&t.chain.every(i=>Mt(i.file)===i.stamp))return t.result;let n=[],r=E.dirname(e),s=xs(e,r,0,new Set,n),o=hc(s,r);if(!Ae.has(e)&&Ae.size>=fc){let i=Ae.keys().next().value;i!==void 0&&Ae.delete(i)}return Ae.set(e,{chain:n,result:o}),o}a(mc,"aliasesForTsconfig");function Cs(e){let t=ws(e);return t?mc(t):{baseUrl:E.resolve(e),aliases:[]}}a(Cs,"readTsconfigPathAliases");function _s(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,E.join(e,"index.ts"),E.join(e,"index.tsx"),E.join(e,"index.js")];for(let n of t)if(J(n))return n;return null}a(_s,"existingSourceFile");function Os(e,t){if(!t.startsWith("."))return null;let n=E.resolve(E.dirname(e),t);return _s(n)}a(Os,"resolveRelativeImport");function yc(e,t){return e.wildcard?!t.startsWith(e.from)||!t.endsWith(e.suffix)||t.length<e.from.length+e.suffix.length?null:t.slice(e.from.length,t.length-e.suffix.length):t===e.from?"":null}a(yc,"matchAlias");function Ut(e,t,n){if(!t)return null;if(t.startsWith("."))return Os(e,t);let r=e?E.dirname(E.resolve(e)):n??".",{baseUrl:s,aliases:o}=Cs(r);for(let i of o){let l=yc(i,t);if(l!==null){for(let c of i.targets){let d=i.wildcard?c.split("*").join(l):c,u=_s(E.resolve(s,d));if(u)return u}return null}}return null}a(Ut,"resolveImportSpecifier");var Ac="4.8.26";function Rc(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(Rc,"containingProgram");function Sc(e){let t=Rc(e)?.body;if(!t)return!1;let n=!1;for(let r of t){if(r.type==="ImportDeclaration"){if(!Ze(r))return!1;continue}if(!(r.type==="TSInterfaceDeclaration"||r.type==="TSTypeAliasDeclaration")){if(r.type==="ExportNamedDeclaration"){if(r.declaration){if(r.declaration.type!=="TSInterfaceDeclaration"&&r.declaration.type!=="TSTypeAliasDeclaration")return!1}else if(!Ze(r))return!1;n=!0;continue}return!1}}return n}a(Sc,"sourceProgramExportsOnlyTypes");var Ts={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{message}} Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=x(e),n=D(t),r=B(n),s=n?N.dirname(n):null,o=a(i=>{let l=Ye(i.source);if(l&&r&&s&&t){let c=N.isAbsolute(t)?t:N.resolve(t),d=N.relative(s,c).split(N.sep).join("/");if(!X(r,d))return;let u=w(d,r.layers);if(!u)return;let f=Ut(c,l,s);if(!f)return;let p=N.relative(s,f).split(N.sep).join("/");if(p.startsWith(".."))return;let g=w(p,r.layers);if(!g)return;let m={fromPath:d,toPath:p,layers:r.layers},R=ct(r.rules,u,g,m),k=R?.rule;if(k){let y=i.type?.startsWith("Export")?"export":"import",A=Ze(i),S=!!k?.peerIsolation,I=A&&!S,_=R?.sliceVerdict,Se=_?dn({surface:"import",verdict:_,fromLayer:u,toLayer:g,kind:y,fromPath:d,toPath:p,ruleMessage:k?.message,childMessage:k?.childSlices?.message}):k?.message??`${u} must not ${y} ${g}.`,se=I?`${Se} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:Se;O(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:g,target:p,edgeKind:y,...S?{peerIsolation:!0}:{},...A?{typeOnly:!0}:{},...un(_),...I?{failsStrict:!1,severity:"warning"}:{},...Sc(i)?{sourcePureTypeModule:!0}:{},message:se},{fromLayer:u,toLayer:g,specifier:l,message:se})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},kc={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=x(e),n=D(t),r=B(n),s=n?N.dirname(n):null;if(!r||!s||!t)return{};let o=st(r,s,t);if(!o?.layer)return{};let{relFile:i,layer:l}=o,c=new Set(gn(l));return c.size===0?{}:de(e,a((u,f,p,g)=>{if(p||typeof f!="string"||Me(f,l.forbiddenGlobals??[]))return;let m=pn(f);!m||!c.has(m)||O(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:l.name,target:f,capability:m,edgeKind:g,message:`${l.name} denies the ${m} capability; found import of "${f}".`},{layer:l.name,capability:m,specifier:f})},"check"))}},Re=ir({findConfigPath:D,loadArkConfig:B,resolveImportSpecifier:Ut,lintedFilename:x,sourceIsInAnalysisScope:X,isLocallyBound:z,reportAdapterDiagnostic:O});function bc(e,t){let n=N.dirname(N.resolve(e));return N.relative(n,N.resolve(t)).split(N.sep).join("/")}a(bc,"toProjectRelative");var lt=vr({findConfigPath:D,loadArkConfig:B,lintedFilename:x,sourceIsInAnalysisScope:X,isLocallyBound:z,reportAdapterDiagnostic:O,toProjectRelative:bc}),Ns=hs(X),Ec=[Ts,Re.noArkRunKernelInDomain,Re.noArkRunDirectNew,Re.noArkRunTransportBypass,lt.noArkOrderKernelInDomain,lt.noArkOrderGenericUpdate,Ns],Ic={meta:{type:"problem",docs:{description:"Report non-blocking Ark findings (type-only placement debt, advisory slice walls, advisory arkRun / arkOrder / ArkRules) as warnings \u2014 the same findings ark-check reports as warnings."},messages:{[Et]:qn},schema:[]},create(e){return $t(x(e))?{}:Qn(Ec.map(t=>ze(t,e,"advisory")))}},vc=F(Ts),wc=F(ks),xc=F(bs),Cc=F(ys),_c=F(kc),Oc=F(Re.noArkRunKernelInDomain),Tc=F(Re.noArkRunDirectNew),Nc=F(Re.noArkRunTransportBypass),Lc=F(lt.noArkOrderKernelInDomain),Dc=F(lt.noArkOrderGenericUpdate),Fc=F(Ns),Pc=Ic,$c={"no-domain-infra-imports":vc,"no-raw-event-publish":wc,"require-publish-source":xc,"no-forbidden-globals":Cc,"no-denied-capabilities":_c,"no-arkrun-kernel-in-domain":Oc,"no-arkrun-direct-new":Tc,"no-arkrun-transport-bypass":Nc,"no-arkorder-kernel-in-domain":Lc,"no-arkorder-generic-update":Dc,"arkrules-structure":Fc,"architecture-advisory":Pc},Mc={"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","ark/arkrules-structure":"error","ark/architecture-advisory":"warn"},jt={meta:{name:"arkgate",version:Ac},rules:$c};function Kc(){let e=gs();return{plugins:{ark:jt},rules:{...Mc},...e?{settings:{ark:{contractHash:e}}}:{}}}a(Kc,"recommendedConfig");var Ls={};Object.defineProperty(Ls,"recommended",{enumerable:!0,configurable:!0,get:Kc});jt.configs=Ls;var Mf=jt;export{Pc as architectureAdvisory,Fc as arkRulesStructureRule,Ls as configs,gs as contractFingerprint,Mf as default,D as findConfigPath,L as globToRegExp,bo as isEdgeDenied,w as layerForRelativePath,ec as loadArkConfig,Dc as noArkOrderGenericUpdate,Lc as noArkOrderKernelInDomain,Tc as noArkRunDirectNew,Oc as noArkRunKernelInDomain,Nc as noArkRunTransportBypass,_c as noDeniedCapabilities,vc as noDomainInfraImports,Cc as noForbiddenGlobals,wc as noRawEventPublish,en as patternSpecificity,jt as plugin,Cs as readTsconfigPathAliases,xc as requirePublishSource,Ut as resolveImportSpecifier,Os as resolveRelativeImport,$c as rules};
1
+ import E from'path';import H from'fs';import {createHash}from'crypto';var Fs=Object.defineProperty;var a=(e,t)=>Fs(e,"name",{value:t,configurable:true});function $s(e){if(e==="deny"||e==="deny-cross-parent")return e;if(e!==null&&typeof e=="object"){let t=e.mode;if(t==="deny-cross-parent")return t}}a($s,"sharedImportsSliceMode");var Ht=new Map;function Bt(e){return /[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Bt,"escapeLiteral");function Pe(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n;}return t}a(Pe,"normalizeGlobSeparators");function Ms(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 false}return t===0}a(Ms,"bracesBalanced");function T(e){let t=Ht.get(e);if(t)return t;let r=Pe(e),n=Ms(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Bt(r[l+1]),l+=1):c==="*"?r[l+1]==="*"?r[l+2]==="/"?(s+="(?:.*/)?",l+=2):(s+=".*",l+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Bt(c);}let i=new RegExp(`^${s}$`);return Ht.set(e,i),i}a(T,"globToRegExp");function Ks(e){return Pe(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}a(Ks,"concreteGlobSegments");function tr(e,t){let r=Pe(String(e)),n=Ks(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let l=0,c=-1;for(let d of n){let u=-1;for(let f=l;f<i.length;f+=1)if(i[f]===d){u=f;break}if(u<0)return o;c=u,l=u+1;}return (c+1)*1e6+n.length*1e4+s}a(tr,"patternSpecificity");function w(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>T(i).test(r))){for(let i of o.patterns??[])if(T(i).test(r)){let l=tr(i,r);l>s&&(s=l,n=o.name);}}return n}a(w,"layerForRelativePath");function Fe(e,t,r){return nr(e,t,r==="stars"?"stars":"path")}a(Fe,"sliceIdForPath");function Vt(e,t){return nr(e,t?[...t]:void 0,rr)}a(Vt,"legacyStarsSliceIdForPath");var rr="stars-4.8.23";function nr(e,t,r){if(!t?.length)return;let n=String(e).split(/[/\\]/).filter(Boolean);if(n.length===0)return;let s=new Set;for(let o of t){if(typeof o!="string"||o.length===0)continue;let i=Us(o);if(i.anchored){let l=Hs(n,i.anchored,r);if(l)return l;continue}i.bare!==void 0&&s.add(i.bare);}return Vs(n,s)}a(nr,"sliceIdWithBinding");var Le=new Map;function Us(e){let t=Le.get(e);if(t)return t;let r={};return js(e)?r={anchored:Gs(e)}:!e.includes("/")&&!e.includes("\\")&&!e.includes("*")&&(r={bare:e.toLowerCase()}),Le.size>=1024&&Le.clear(),Le.set(e,r),r}a(Us,"parsedSliceFolder");function js(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?false:t.some(r=>r==="*")}a(js,"isAnchoredSliceEntry");function Gs(e){return e.split(/[/\\]/).filter(t=>t.length>0).map(t=>t.toLowerCase())}a(Gs,"anchoredSlicePattern");function Hs(e,t,r){let n=or(e,t[0]??"");for(let s of n){let o=Bs(e,t,s,r);if(o)return o}}a(Hs,"anchoredSliceIdFromPattern");function Bs(e,t,r,n="path"){let s=[],o=[],i=-1,l=r;for(let c=0;c<t.length;c+=1){let d=t[c];if(d==="*"){if(l>=e.length-1){for(let u=c;u<t.length;u+=1)if(t[u]!=="*")return;break}s.push(e[l].toLowerCase()),o.push(true),l+=1;continue}if(d==="**"||l>=e.length||e[l].toLowerCase()!==d)return;s.push(e[l].toLowerCase()),o.push(false),i=s.length-1,l+=1;}if(s.length!==0)return n===rr?i<0?void 0:s.slice(i).join("/"):n==="stars"?i<0?void 0:s.filter((c,d)=>d>=i||o[d]).join("/"):s.join("/")}a(Bs,"bindAnchoredSlice");function sr(e){let t=-1;for(let n=0;n<e.length;n+=1)e[n]!=="*"&&(t=n);if(t<0)return null;let r=[];for(let n=0;n<e.length;n+=1)(n>=t||e[n]==="*")&&r.push(n);return r}a(sr,"starsKeptSegmentIndexes");function Vs(e,t){if(t.size!==0){for(let r=0;r<e.length-1;r+=1)if(t.has(e[r].toLowerCase())&&!(r+1>=e.length-1))return `${e[r].toLowerCase()}/${e[r+1].toLowerCase()}`}}a(Vs,"bareSliceId");function Ws(e){let t=new Set;for(let r of e??[]){let s=Pe(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let l=s[o-1];l&&!l.includes("*")&&!l.includes("{")&&!l.includes("}")&&t.add(l);}}}return [...t]}a(Ws,"inferSliceFoldersFromPatterns");function zs(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 Ws(n?.patterns)}a(zs,"resolveSliceFolders");function Wt(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(Wt,"normalizeSegments");function Se(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Se,"trimTrailingSlashes");var Ys=["src","app"];function or(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return Ys.includes(r)&&n!==r?[0,1]:[0]}a(or,"anchorOffsets");function qs(e){let t=Se(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(qs,"isBlanketRoot");function zt(e,t){if(!e||!t?.length)return false;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Wt(r);for(let o of t){if(typeof o!="string"||o.length===0||qs(o))continue;if(o.includes("*")){let c=Se(o.toLowerCase());if(T(c).test(n)||T(`${c}/**`).test(n))return true;continue}let i=Wt(o);if(i.length===0)continue;let l=or(s,i[0]??"");for(let c of l){if(c+i.length>s.length)continue;let d=true;for(let u=0;u<i.length;u+=1)if(s[c+u]!==i[u]){d=false;break}if(d)return true}}return false}a(zt,"pathUnderSharedRoot");function Yt(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return false;let n=t.toLowerCase();return r===n?true:!r.includes("/")&&n.endsWith(`/${r}`)}a(Yt,"sliceMatchesDeclaration");function qt(e,t,r){return !e?.length||!t||!r?false:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Yt(n.from,t)&&Yt(n.to,r))}a(qt,"crossSliceEdgeAllowed");function Zs(e){if(!e.fromPath)return {denied:true,reason:"missing-path"};if(e.folderCount<=0)return {denied:true,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===true;if(!e.toPath)return t?e.fromSlice?{denied:true,reason:"missing-path"}:{denied:false}:{denied:true,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===true;return !t||!r?{denied:true,reason:"unclassifiable-path"}:e.sharedImportsSlice==="deny"&&e.fromShared===true&&e.toSlice&&!e.fromSlice?{denied:true,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:false}:e.fromSlice===e.toSlice?{denied:false}:e.crossSliceAllowed?{denied:false}:{denied:true,reason:"cross-slice"}}a(Zs,"peerIsolationDecision");function ir(e){return Se(e.trim().replace(/\\/g,"/")).toLowerCase()}a(ir,"aliasGlobPattern");function Xs(e,t){let r=ir(e);if(!r||r==="*"||r==="**")return false;let n=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=De(n),o=T(r),l=(r.split("/").pop()??"").includes("*")?null:T(`${r}/**`),c=a(d=>o.test(d)||l!==null&&l.test(d),"hit");return c(n)||s!==n&&c(s)}a(Xs,"aliasGlobMatches");function ar(e){let t=ir(e).split("/").filter(Boolean);return t.length<2||t.some(r=>r.includes("*")||r==="."||r==="..")?null:{universeId:t.slice(0,-1).join("/"),childId:t.join("/")}}a(ar,"splitAliasTarget");function lr(e,t){for(let r of t.childSlices?.sliceAliases??[])if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&Xs(r.from,e))return r;return null}a(lr,"firstSliceAliasEntry");function Js(e,t){let r=lr(e,t);return r?ar(r.to):null}a(Js,"firstSliceAlias");function Qs(e,t,r){if(!e)return {};let n=r??t.sliceFolders,s=Fe(e,n?[...n]:void 0,t.sliceIdentity),o=Ne(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=Js(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(Qs,"resolveGovernedSlice");function eo(e){let t=[];for(let r of e??[]){if(typeof r!="string"||r.length===0)continue;let n=r.split(/[/\\]/).filter(Boolean).map(l=>l.toLowerCase());if(n.length===1&&n[0]&&!n[0].includes("*")){t.push({literals:[n[0],null],legacy:[n[0],null]});continue}if(n.some(l=>l==="**"||l.includes("*")&&l!=="*"))continue;let s=sr(n);if(!s||!n.includes("*"))continue;let o=a(l=>l==="*"?null:l,"star"),i=s.find(l=>n[l]!=="*")??0;t.push({literals:s.map(l=>o(n[l]??"")),legacy:n.slice(i).map(o)});}return t}a(eo,"starsUniverseShapes");function Zt(e,t){return e.length===t.length&&e.every((r,n)=>r===null||t[n]==="*"||r===t[n])}a(Zt,"literalsMatch");function to(e,t){let r=t.split("/").filter(Boolean).map(o=>o.toLowerCase()),n=eo(e);if(r.length===0||n.some(o=>Zt(o.literals,r)))return [];let s=new Set;for(let o of n)if(o.legacy.length!==o.literals.length&&Zt(o.legacy,r)){let i=[...r],l=o.literals.length-o.legacy.length;s.add([...o.literals.slice(0,l).map(()=>"*"),...i].join("/"));}return [...s].sort()}a(to,"legacyStarsIdTargets");function ro(e,t){if(e.sliceIdentity!=="stars")return;let r=ar(t);if(r)return to(e.sliceFolders,r.universeId).length===1?r.universeId:void 0}a(ro,"legacyAliasUniverse");function Xt(e,t,r){let n=Qs(e,t,r);if(!e||t.sliceIdentity!=="stars")return n;if(n.universeId){let s=lr(e,t);if(!Fe(e,[...r],t.sliceIdentity)&&s&&ro(t,s.to)!==void 0)return {...n,legacyAlias:true,legacyUniverse:n.universeId,legacyChild:n.childId};let i=Vt(e,r),l=t.childSlices,c=l?.sliceIdentity==="stars"?Vt(e,l.sliceFolders):void 0;return {...n,...i?{legacyUniverse:i}:{},...c&&n.childId?{legacyChild:c}:{}}}return n}a(Xt,"placeForPair");function no(e,t,r,n){let s=Xt(r,e,t),o=Xt(n,e,t),i=s.legacyUniverse,l=o.legacyUniverse,c=a((m,R)=>{if(!m.legacyAlias||R.legacyAlias||!R.universeId||R.legacyUniverse?.toLowerCase()!==m.universeId?.toLowerCase())return m;let S=m.childId?.split("/").pop();return {...m,universeId:R.universeId,...S?{childId:`${R.universeId}/${S}`}:{}}},"adopt"),d=c(s,o),u=c(o,s),f=qt(e.allowedCrossSlice,d.universeId,u.universeId)||e.sliceIdentity==="stars"&&(i!==d.universeId||l!==u.universeId)&&qt(e.allowedCrossSlice,i,l),p=e.childSlices?.sliceIdentity==="stars"&&s.legacyChild!==void 0&&o.legacyChild!==void 0&&s.legacyChild!==o.legacyChild&&cr(e.childSlices.allowedCrossSlice,s.legacyChild,o.legacyChild),g=a(m=>({...m.universeId?{universeId:m.universeId}:{},...m.childId?{childId:m.childId}:{}}),"strip");return {from:g(d),to:g(u),crossSliceAllowed:f,legacyChildAllowed:p}}a(no,"resolveGovernedSlicePair");function so(e,t,r){let n=e.split(/[/\\]/).filter(Boolean).map(o=>o.toLowerCase()),s=t.split("/").filter(Boolean).map(o=>o.toLowerCase());if(n.length===0||s.length===0||n.some(o=>o==="**"||o.includes("*")&&o!=="*"))return null;if(r==="stars"){let o=sr(n);if(!o||o.length!==s.length)return null;let i=[...n];for(let l=0;l<o.length;l+=1){let c=o[l]??0;if(n[c]!=="*"&&n[c]!==s[l])return null;i[c]=s[l]??"";}return i.join("/")}if(n.length!==s.length)return null;for(let o=0;o<n.length;o+=1)if(n[o]!=="*"&&n[o]!==s[o])return null;return s.join("/")}a(so,"childPatternDirectory");function oo(e,t){let r=De(e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()).split("/"),n=t.split("/"),s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s+=1;return s}a(oo,"sharedDirectoryPrefix");function io(e,t){let r=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase();return r.startsWith("src/")&&!t.startsWith("src/")?`src/${t}`:r.startsWith("app/")&&!t.startsWith("app/")?`app/${t}`:t}a(io,"withSourcePrefix");function ao(e,t,r){let n=null;for(let s of r.sliceFolders){if(typeof s!="string")continue;let o=so(s,t,r.sliceIdentity);if(!o)continue;let i=oo(e,o);(!n||i>n.score||i===n.score&&o.length<n.dir.length)&&(n={dir:o,score:i});}return n?io(e,n.dir):""}a(ao,"sliceAliasDestination");var lo="<Layer>";function co(e,t){let r=lo;if(!e.includes(r)||e.split(r).length!==2||/[*\\/]/.test(e))return null;let n=e.replace(r,t);return !n||n.includes("..")?null:n}a(co,"sliceRuleFileName");function $e(e){let t=[...new Set(e.layers.filter(s=>typeof s=="string"&&s.length>0))].sort(),r=[],n=new Set;for(let s of e.rules??[]){let o=s?.childSlices,i=o?.arkRulesFile;if(!o||typeof i!="string")continue;let l=new Map;for(let c of e.files){if(typeof c!="string"||c.length===0)continue;let d=s.sliceFolders?.length?Fe(c,s.sliceFolders,s.sliceIdentity):void 0,u=Ne(c,d,o);if(!u.childId||l.has(u.childId))continue;let f=ao(c,u.childId,o);f&&l.set(u.childId,f);}for(let[c,d]of [...l.entries()].sort((u,f)=>u[0].localeCompare(f[0])))for(let u of t){let f=co(i,u);if(!f)continue;let p=`${d}/${f}`.replace(/\\/g,"/");n.has(`${u}\0${p}`)||(n.add(`${u}\0${p}`),r.push({path:p,childId:c,layer:u,defaultAppliesTo:[`${d}/**`]}));}}return r}a($e,"resolveSliceRulePlan");function uo(e,t){switch(e){case "cross-slice":return `cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case "shared-imports-slice":return `shared root imports slice ${t.toSlice??"?"} (${t.fromPath??"?"} \u2192 ${t.toPath??"?"}). The wall is direct-only.`;case "unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return `unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case "no-slice-folders":return "no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return "no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}a(uo,"peerIsolationDenyExplanation");function fo(e,t){return `cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(fo,"crossParentExplanation");function po(e,t,r){return `cross-sibling slice ${e} \u2192 ${t} inside ${r}.`}a(po,"crossSiblingExplanation");function go(e){return `universe common imports child ${e}. parentMayImportChild is off.`}a(go,"parentImportsChildExplanation");function Jt(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(Jt,"universePairLabel");function ho(e,t){if(!e||!t?.length)return false;let r=e.toLowerCase();return t.some(n=>typeof n=="string"&&n.length>0&&n.toLowerCase()===r)}a(ho,"isCommonFolderName");function Ne(e,t,r){if(!e||!r?.sliceFolders?.length)return {};let n=Fe(e,r.sliceFolders,r.sliceIdentity);if(!n||!t)return {};let s=n.toLowerCase(),o=t.toLowerCase();if(s===o)return {};if(!s.startsWith(`${o}/`))return {mismatched:{childId:n,universeId:t}};let i=s.slice(o.length+1).split("/")[0];return ho(i,r.commonFolders)?{}:{childId:n}}a(Ne,"resolveChildSliceId");function mo(e){return Se(e.trim().replace(/\\/g,"/")).toLowerCase()}a(mo,"siblingEntryKey");function De(e){return e.replace(/^(?:src|app)\//,"")}a(De,"stripSrcOrApp");function yo(e,t){let r=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),n=De(t);if(!n)return false;let s=De(r);return r===n||r.startsWith(`${n}/`)||s===n||s.startsWith(`${n}/`)}a(yo,"pathUnderSubtree");function Ao(e,t,r){if(!t||!r?.length)return false;let n=t.toLowerCase();for(let s of r){if(typeof s!="string")continue;let o=mo(s);if(!(!o||o.includes("*"))&&(n===o||e&&yo(e,o)))return true}return false}a(Ao,"importerInEnforcedSubtree");function Ro(e,t,r){return e==null||e==="deny"?false:e==="advisory"?true:e.default==="deny"?false:!Ao(t,r,e.enforce)}a(Ro,"siblingCrossingAdvisory");function Qt(e){if(typeof e!="string")return null;let t=Se(e.trim().replace(/\\/g,"/")).toLowerCase();if(!t.includes("/"))return null;let r=t.split("/");for(let n of r)if(n.length===0||n==="."||n===".."||n.includes("*")&&n!=="*")return null;return r}a(Qt,"childSlicePatternSegments");function er(e,t){let r=Qt(e),n=Qt(t);if(!r||!n||r.length!==n.length)return false;for(let s=0;s<r.length;s+=1){let o=r[s];if(o!=="*"&&o!==n[s])return false}return true}a(er,"childSlicePatternMatches");function cr(e,t,r){if(!e?.length)return false;for(let n of e)if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&er(n.from,t)&&er(n.to,r))return true;return false}a(cr,"childCrossSliceAllowed");function ko(e){let t=Zs({fromPath:e.fromPath,toPath:e.toPath,folderCount:e.folderCount,fromSlice:e.fromSlice,toSlice:e.toSlice,fromShared:e.fromShared,toShared:e.toShared,crossSliceAllowed:e.crossSliceAllowed,sharedImportsSlice:$s(e.rule.sharedImportsSlice)});if(t.denied){let i=!!e.rule.childSlices&&t.reason==="cross-slice";return {crossing:t.reason==="cross-slice"?"cross-parent":"fail-closed",decision:"deny",...i?{reasonId:"CROSS_PARENT_SLICE"}:{},explanation:i?fo(e.fromSlice,e.toSlice):uo(t.reason??"missing-path",{fromPath:e.fromPath,toPath:e.toPath,fromSlice:e.fromSlice,toSlice:e.toSlice}),peerIsolationReason:t.reason,fromUniverse:e.fromSlice,toUniverse:e.toSlice}}let r=e.rule.childSlices;if(!r||!e.fromSlice||!e.toSlice||e.fromSlice!==e.toSlice||!e.toPath)return {crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};let n=e.fromChild??Ne(e.fromPath,e.fromSlice,r).childId,s=e.toChild??Ne(e.toPath,e.toSlice,r).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return n&&s&&n!==s?e.legacyChildAllowed||cr(r.allowedCrossSlice,n,s)?o:{crossing:"cross-sibling",decision:Ro(r.siblings,e.fromPath,n)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:po(n,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!n&&s&&r.parentMayImportChild!==true?{crossing:"parent-imports-child",decision:"deny",explanation:go(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(ko,"evaluateNestedSliceWall");function So(e){return e?.crossing==="cross-sibling"||e?.crossing==="parent-imports-child"}a(So,"isChildWallCrossing");function dr(e){let t=e.verdict.explanation,r=So(e.verdict),n=r?e.childMessage:e.ruleMessage;if(e.surface==="intent"){let s=e.defaultMessage??`${e.fromLayer} must not reference ${e.toLayer} intent.`;return r&&t?`${e.childMessage??s} ${t}`:e.verdict.reasonId&&t?`${s} ${t}`:t&&e.verdict.peerIsolationReason!=="cross-slice"?`${s} ${t}`:n?t?`${n} (${t})`:n:s}if(n)return t?`${n} (${t})`:n;if(t){let s=e.kind??"import";return `${e.fromLayer} must not ${s} another slice of ${e.toLayer} (${e.fromPath} \u2192 ${e.toPath}): ${t}`}return `${e.fromLayer} must not ${e.kind??"import"} ${e.toLayer}.`}a(dr,"composeSliceDenialMessage");function ur(e){if(!e||e.decision==="allow")return {};let t=Jt(e.fromUniverse),r=Jt(e.toUniverse);return {...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&r?{universeFrom:t,universeTo:r}:{},...e.decision==="advisory"?{failsStrict:false,severity:"warning"}:{}}}a(ur,"sliceFindingExtras");function bo(e,t,r,n){return dt(e,t,r,n)?.rule}a(bo,"findDeniedEdgeRule");function dt(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===false){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,l=zs(s,t,n?.layers),c=no(s,l,o,i),d=c.from,u=c.to,f=d.universeId,p=u.universeId,g=ko({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:p,fromChild:d.childId,toChild:u.childId,fromShared:!f&&zt(o,s.sharedRoots),toShared:!p&&zt(i,s.sharedRoots),crossSliceAllowed:c.crossSliceAllowed,legacyChildAllowed:c.legacyChildAllowed});if(g.decision!=="allow")return {rule:s,peerIsolationReason:g.peerIsolationReason,fromSlice:f,toSlice:p,sliceVerdict:g};continue}if(t!==r)return {rule:s}}if(t!==r&&typeof n?.toPath=="string"&&n.toPath.length>0&&Array.isArray(n?.layers)){let s=n.layers.find(i=>i.name===r),o=Array.isArray(s?.entrypoints)?s.entrypoints.filter(i=>typeof i=="string"&&i.length>0):[];if(o.length>0){let i=String(n.toPath).split(/[/\\]/).join("/");if(!o.some(c=>T(c).test(i)))return {rule:{from:t,to:r,allowed:false,message:`${t} may only import ${r} via its declared entrypoints (${o.join(", ")}); deep import "${i}" bypasses the public surface.`}}}}}a(dt,"findDeniedEdgeDecision");function Eo(e,t,r,n){return bo(e,t,r,n)!==void 0}a(Eo,"isEdgeDenied");var Io=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function vo(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return [...e?.excludeGenerated===false?[]:Io,...t]}a(vo,"scanExcludePatterns");function ut(e,t){let r=String(e).split(/[/\\]/).join("/");return vo(t).some(n=>T(n).test(r))}a(ut,"isScanExcludedRelative");var fr=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),wo=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"});Object.freeze(Object.keys(wo).sort());var ft=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"}),xo=Object.freeze({process:Object.freeze(["process","node:process"])});function pr(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=ft[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=ft[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:ft[e.slice(0,o)]??null}a(pr,"capabilityForModuleSpecifier");function Me(e,t){for(let r of t)if(xo[r]?.includes(e))return r;return null}a(Me,"forbiddenGlobalForModuleSpecifier");function gr(e){if(e?.pure===true)return [...fr].sort();let r=(e?.capabilities?.deny??[]).filter(n=>fr.includes(n));return [...new Set(r)].sort()}a(gr,"effectiveCapabilityDeny");var hr={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."};function be(e){return /^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(be,"looksLikeArkIntent");function pt(e){if(!e.publishCall)return [];let t=[];return (e.rawIntentName!==void 0&&be(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:hr.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:hr.PUBLISH_MISSING_SOURCE}),t}a(pt,"classifyPublishFacts");var _o=["createArkKernel","createStrictArkKernel","createLenientArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig","createLenientArkKernelFromConfig"],Oo="ArkModule",To=["forRoot","forRootAsync"],Lo=["ArkKernel","EventBus","EventPublisher","ArkRunPublisher"],Ar=new Set(["eventBus"]),No=new Set(["publisher","eventBus"]),Do=new Set(To),Po=new Set(Lo);var Ke=new Set(_o),Fo=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"]),Rr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function Q(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")||e==="arkgate/nestjs"||e.startsWith("arkgate/nestjs/")}a(Q,"isArkRunKernelModuleSpecifier");var $o=["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"],gt=new Set($o);function kr(e){if(!e||e.startsWith(".")||e.startsWith("/"))return false;if(gt.has(e))return true;let t=e.indexOf("/");if(t<0)return false;let r=e.slice(0,t);if(gt.has(r))return true;let n=e.indexOf("/",t+1);return n<0?false:gt.has(e.slice(0,n))}a(kr,"isArkRunTransportBypassSpecifier");function ht(e){if(Ke.has(e))return "factory";switch(e){case "publisher":return "publisher";case "publish":return "publish";case "raise":case "raiseAsync":return "raise";case "send":case "sendTo":return "send";case "subscribe":return "subscribe";case "registerHandler":return "register-handler";case "resolve":return "resolve";case "resolveSingleton":return "resolve-singleton";default:return}}a(ht,"arkRunKernelCallKind");function Sr(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}a(Sr,"lineAt");function mt(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(mt,"stripCommentsPreservingLines");function Mo(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}a(Mo,"firstStringLiteralArg");function mr(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}a(mr,"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]??"");}a(Ee,"parseValueImportClause");function br(e,t){Ee(mt(e),t);}a(br,"forEachArkRunValueImportClause");function Er(e){let t=/\{([^}]*)\}/.exec(e);if(!t?.[1])return [];let r=[];for(let n of t[1].split(",")){let s=n.trim();if(!s||s.startsWith("type "))continue;let o=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(s),i=o?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(s)?.[1],l=o?.[1]??i;i&&l&&r.push({local:i,original:l});}return r}a(Er,"bracedValueImportBindings");function Ko(e){let t=new Map,r=new Set;return Ee(e,(n,s)=>{if(!Q(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]);for(let{local:l,original:c}of Er(n))t.set(l,c);}),{named:t,namespaces:r}}a(Ko,"collectKernelImportBindings");function Uo(e,t){let r=new Set(t);return Ee(e,(n,s)=>{for(let{local:o,original:i}of Er(n))/^[A-Z]/.test(i)&&(Q(s)||t.has(i)||t.has(o))&&(r.add(o),r.add(i));}),r}a(Uo,"collectImportedConstructors");function jo(e,t){let r;return Ee(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s);}),r}a(jo,"importedFromForName");function Go(e){let t=new Set,r=/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;){if(!Q(n[2]??""))continue;let s=/\{([^}]*)\}/.exec(n[1]??"");if(s?.[1])for(let o of s[1].split(",")){let i=o.trim().replace(/^type\s+/,""),l=/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/.exec(i),c=l?.[1]??i,d=l?.[2]??i;Po.has(c)&&t.add(d);}}return t}a(Go,"collectKernelTypeNames");function Ho(e,t){let r=e.split(".");if(r.length===2)return t.namespaces.has(r[0])&&Ke.has(r[1]);if(r.length!==1)return false;let n=t.named.get(r[0]);return n!==void 0&&Ke.has(n)}a(Ho,"isFactoryCalleeExpression");function Bo(e,t,r,n){Ee(e,(s,o)=>{if(!t(o))return;let i=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(s);i?.[1]&&(r.add(i[1]),n?.add(i[1]));let l=/^([A-Za-z_$][\w$]*)\s*(?:,|$)/.exec(s.trim());l?.[1]&&r.add(l[1]);let c=/\{([^}]*)\}/.exec(s);for(let d of c?.[1]?.split(",")??[]){let u=d.trim();if(!u||u.startsWith("type "))continue;let f=/([A-Za-z_$][\w$]*)$/.exec(u)?.[1];f&&r.add(f);}});}a(Bo,"addRootModuleImports");function Vo(e,t){let{receivers:r,calleeBindings:n}=t,s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:await\s+)?(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*\.\s*([A-Za-z_$][\w$]*)\b/g,o=/\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*[;\n)]/g,i=/(?:\b(?:const|let|var)\s+|\bthis\s*\.\s*|(?:^|[;{}\n])\s*)([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?(?<![=!<>])=(?![=>])\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*(?:as\s+[A-Za-z_$][\w$.<>]*\s*)?(?=[;\n,)])/g,l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*typeof\s+([A-Za-z_$][\w$]*)\b/g,c;for(let d=true;d;){d=false;for(let u of [i,l])for(u.lastIndex=0;(c=u.exec(e))!==null;)!r.has(c[2])||r.has(c[1])||(r.add(c[1]),d=true);for(s.lastIndex=0;(c=s.exec(e))!==null;)r.has(c[2])&&(!No.has(c[3])&&!t.rootNamespaces.has(c[2])||r.has(c[1])||(r.add(c[1]),d=true));for(o.lastIndex=0;(c=o.exec(e))!==null;)if(r.has(c[2]))for(let u of c[1].split(",")){let f=/^\s*([A-Za-z_$][\w$]*)\s*(?::\s*([A-Za-z_$][\w$]*))?\s*$/.exec(u);if(!f)continue;let p=f[1],g=f[2]??p;if(Ar.has(p)){if(r.has(g))continue;r.add(g),d=true;}else ht(p)&&!Ke.has(p)&&n.add(g);}}}a(Vo,"addDerivedReceivers");function Wo(e,t,r){let n={receivers:new Set,calleeBindings:new Set,rootNamespaces:new Set};r&&Bo(e,r,n.receivers,n.rootNamespaces);let s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:await\s+)?((?:[A-Za-z_$][\w$]*\s*\.\s*)?[A-Za-z_$][\w$]*)\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(e))!==null;)Ho(o[2].replace(/\s+/g,""),t)&&n.receivers.add(o[1]);let i=Go(e);if(i.size>0){let l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*(?:Readonly\s*<\s*)?([A-Za-z_$][\w$]*)\b/g;for(;(o=l.exec(e))!==null;)i.has(o[2])&&n.receivers.add(o[1]);}return Vo(e,n),n}a(Wo,"traceKernelReceivers");function zo(e,t){let r=0;for(let n=t;n>=0;n-=1){let s=e[n];if(s===")")r+=1;else if(s==="("&&(r-=1,r===0))return n}return -1}a(zo,"matchingOpenParen");function yr(e){let t=e.split(".").map(r=>r.trim()).filter(r=>r.length>0);return t[0]==="this"?t.slice(1):t}a(yr,"chainParts");function Yo(e,t){let r=e.slice(Math.max(0,t-400),t),n=/((?:[A-Za-z_$][\w$]*\s*\??\.\s*)+)$/.exec(r);if(n?.[1]){let d=r.slice(0,r.length-n[1].length);return /[)\]]\s*$/.test(d)||/\.\s*$/.test(d)?{parts:["<expr>"],viaPublisherCall:false}:{parts:yr(n[1].replace(/\?/g,"")),viaPublisherCall:false}}let s=/\)\s*\??\.\s*$/.exec(r);if(!s)return;let o=t-r.length+s.index,i=zo(e,o);if(i<0)return {parts:["<expr>"],viaPublisherCall:false};let l=e.slice(Math.max(0,i-400),i),c=/((?:[A-Za-z_$][\w$]*\s*\??\.\s*)+)publisher\s*(?:<[^>]*>)?\s*$/.exec(l);return c?.[1]?{parts:yr(c[1].replace(/\?/g,"")),viaPublisherCall:true}:{parts:["<expr>"],viaPublisherCall:false}}a(Yo,"receiverChainBefore");function qo(e,t,r){let[n,...s]=e.parts;return n?s.length===0&&t.namespaces.has(n)?true:Rr.has(n)||!r.receivers.has(n)?false:(r.rootNamespaces.has(n)?s.slice(1):s).every(i=>Ar.has(i)):false}a(qo,"chainReachesKernel");function Zo(e){let t=new Set,r=a((c,d,u)=>{let f=c.get(d);f!==void 0&&f!==u?t.add(d):c.set(d,u);},"bind"),n=new Map,s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(['"])((?:\\.|[^\\])*?)\2\s*(?:as\s+const\s*)?[;\n,)]/g,o;for(;(o=s.exec(e))!==null;)o[3]&&r(n,o[1],o[3]);for(let c of t)n.delete(c);let i=new Map(n),l=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:[A-Za-z_$][\w$]*\s*\.\s*)*(?:define|defineIntent)\s*(?:<[^>]*>)?\s*\(\s*(?:(['"])((?:\\.|[^\\])*?)\2|([A-Za-z_$][\w$]*)\s*[,)])/g;for(;(o=l.exec(e))!==null;){let c=o[3]??(o[4]?n.get(o[4]):void 0);c?r(i,o[1],c):(t.has(o[4]??"")||i.has(o[1]))&&t.add(o[1]);}for(let c of t)i.delete(c);return i}a(Zo,"collectDefinedIntentNames");function Xo(e,t){return /^\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(e.slice(t))?.[1]}a(Xo,"firstIdentifierArg");function Jo(e,t){return be(e)?true:(t??[]).some(r=>{let n=r.trim();if(!n)return false;let s=n.endsWith(".")?n:`${n}.`;return e.startsWith(s)&&/^[A-Za-z0-9_.]+$/.test(e.slice(s.length))})}a(Jo,"carriesIntentPrefix");function Qo(e){if(!e)return;if(e.viaPublisherCall)return "publisher";let t=e.parts[e.parts.length-1];return t==="<expr>"?void 0:t}a(Qo,"receiverName");function ei(e,t,r){if(!e||t===void 0||!Jo(t,r))return false;let n=e.parts[0];return n!==void 0&&n!=="<expr>"&&!Rr.has(n)}a(ei,"untracedKernelNameEvidence");function Ue(e,t,r={}){let n=mt(t),s=Ko(n),o=Wo(n,s,r.isKernelRootSpecifier),i=Zo(n),l=[],c=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,d;for(;(d=c.exec(n))!==null;){let u=d[1],f=d.index;if(mr(n,f,"function")||mr(n,f,"class"))continue;let p=Yo(n,f),g=Qo(p),m=s.named.get(u)??u,R=ht(m)??ht(u),S=s.named.has(u)||o.calleeBindings.has(u)||p?.parts.length===1&&s.namespaces.has(p.parts[0]);if(!R&&Do.has(u)&&p?.parts.length===1&&s.named.get(p.parts[0])===Oo&&(R="factory",S=true),!R||R==="factory"&&p!==void 0&&!S)continue;let y=f+d[0].length,A=Mo(n,y);if(R!=="factory"&&(p===void 0?!S:!qo(p,s,o))&&!ei(p,A,r.intentPrefixes))continue;let k=Xo(n,y),I=A??(k?i.get(k):void 0);l.push({file:e,line:Sr(t,f),kind:R,callee:u,viaImport:S,...g?{receiver:g}:{},...I?{nameLiteral:I}:{}});}return l}a(Ue,"extractArkRunKernelCallsFromSource");function yt(e,t,r){let n=mt(t),s=Uo(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,l;for(;(l=i.exec(n))!==null;){let c=l[1];if(Fo.has(c)||!s.has(c))continue;let d=jo(n,c);o.push({file:e,line:Sr(t,l.index),typeName:c,...d?{importedFrom:d}:{}});}return o}a(yt,"extractArkRunManagedNewsFromSource");var ti=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),ri=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),ni=new Set(["return","typeof","case","do","else","in","of","new","delete","void","throw","instanceof","yield","await"]);function si(e,t){let r=t-1;for(;r>=0&&/\s/.test(e[r]);)r-=1;if(r<0)return true;let n=e[r];if(/[A-Za-z0-9_$]/.test(n)){let s=r;for(;s>=0&&/[A-Za-z0-9_$]/.test(e[s]);)s-=1;return ni.has(e.slice(s+1,r+1))}return n==="/"&&e[r-1]==="*"?false:ri.has(n)}a(si,"slashStartsRegex");function oi(e,t){if(!si(e,t))return t;let r=t+1,n=false;for(;r<e.length;){let s=e[r];if(s===`
2
+ `||s==="\r")return t;if(s==="\\"){r+=2;continue}if(n)s==="]"&&(n=false);else if(s==="[")n=true;else if(s==="/"){for(r+=1;r<e.length&&/[A-Za-z]/.test(e[r]);)r+=1;return r}r+=1;}return t}a(oi,"skipRegexLiteral");function ae(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
3
+ `,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==="/")return oi(e,t);if(r==="'"||r==='"'||r==="`"){let n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===r)return n+1;n+=1;}return e.length}return t}a(ae,"skipStringOrComment");function oe(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=ae(e,r);continue}break}return r}a(oe,"skipWsAndComments");function Ir(e,t){let r=e[t];if(!r||!/[A-Za-z_$]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_$]/.test(e[n]);)n+=1;return {ident:e.slice(t,n),end:n}}a(Ir,"readIdent");function ie(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=ae(e,o);if(i!==o){o=i;continue}let l=e[o];l===r?s+=1:l===n&&!(n===">"&&e[o-1]==="=")&&(s-=1),o+=1;}return s===0?o:null}a(ie,"skipBalanced");function vr(e){let t=[],r=0,n;for(;r<e.length&&(r=oe(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=Ir(e,o);if(!u||!ti.has(u.ident))break;s.push(u.ident),o=oe(e,u.end);}if(s.length===1&&s[0]==="static"&&e[o]==="{"){let u=ie(e,o,"{","}");if(u==null){n=e.length;break}r=u;continue}let i=Ir(e,o);if(!i){r+=1;continue}if(o=oe(e,i.end),e[o]==="<"){let u=ie(e,o,"<",">");if(u==null){n=e.length;break}o=oe(e,u);}if(e[o]==="("){let u=ie(e,o,"(",")");if(u==null){n=e.length;break}if(o=oe(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let f=ae(e,o);if(f!==o){o=f;continue}o+=1;}if(e[o]==="{"){let f=ie(e,o,"{","}");if(f==null){n=e.length;break}t.push({name:i.ident,modifiers:s,kind:"method",body:e.slice(o+1,f-1)}),r=f;continue}if(e[o]===";"){r=o+1;continue}r=o+1;continue}let l=0,c=0,d=0;for(;o<e.length;){let u=ae(e,o);if(u!==o){o=u;continue}let f=e[o];if(f==="{")l+=1;else if(f==="}"){if(l===0)break;l-=1;}else if(f==="(")c+=1;else if(f===")")c-=1;else if(f==="[")d+=1;else if(f==="]")d-=1;else if(f===";"&&l===0&&c===0&&d===0){o+=1;break}o+=1;}o>=e.length&&(l>0||c>0||d>0)&&(n=e.length),t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o;}return {members:t,truncatedAt:n}}a(vr,"scanClassMembers");function ii(e,t){let r=t;for(;r<e.length;){let n=oe(e,r);if(n!==r){r=n;continue}let s=e[r];if(s==="{")return r;if(s===";")return null;if(s==="<"||s==="("||s==="["){let i=ie(e,r,s,s==="<"?">":s==="("?")":"]");if(i==null)return null;r=i;continue}if(s==='"'||s==="'"||s==="`"){r=ae(e,r);continue}r+=1;}return null}a(ii,"findClassBodyBrace");function wr(e,t={}){let r=[],n=t.exportedOnly?/\bexport\s+(?:abstract\s+)?class\s+([A-Za-z_$][A-Za-z0-9_$]*)/g:/(?:\b(export)\s+(?:default\s+)?)?(?:\babstract\s+)?\bclass\s+([A-Za-z_$][A-Za-z0-9_$]*)/g,s=je(e),o;for(;(o=n.exec(s))!==null;){let i=t.exportedOnly?o[1]:o[2],l=t.exportedOnly===true||o[1]==="export",c=ii(e,o.index+o[0].length);if(c==null){r.push({name:i,start:o.index,exported:l,bodyStart:null,bodyEnd:null});continue}let d=ie(e,c,"{","}");r.push({name:i,start:o.index,exported:l,bodyStart:c+1,bodyEnd:d==null?null:d-1});}return r}a(wr,"findClassDeclarations");function je(e){let t="",r=0;for(;r<e.length;){let n=ae(e,r);if(n!==r){t+=e.slice(r,n).replace(/[^\n]/g," "),r=n;continue}t+=e[r],r+=1;}return t}a(je,"maskStringsAndComments");var ai=/\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)/,li=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)/,ci=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]/g,di=["db","tx","client","prisma","prismaClient","drizzle"],ui="(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))",Or=/\b(?:INSERT\s+INTO|(?<!\b(?:FOR(?:\s+NO\s+KEY)?|DO)\s)UPDATE(?:\s+ONLY)?(?!\s+(?:OF|SET)\b)|DELETE\s+FROM(?:\s+ONLY)?|MERGE\s+INTO|TRUNCATE(?:\s+TABLE)?(?:\s+ONLY)?)\s+(?:(?:(?:"[^"]*"|[A-Za-z_][\w$]*)\s*\.\s*)?(?:"[^"]*"|[A-Za-z_][\w$]*)|\$\{[^}]+\})/i,fi=/^(?:await|return|throw|yield|new|typeof|void|delete|if|else|case|of|in|instanceof|async|function|class|const|let|var|import|export|from|as|default|type)$/,xr=/(^|[^\w$])([A-Za-z_$][\w$]*)\s*`((?:[^`\\]|\\[\s\S])*)`/g,pi=/\bINSERT\s+INTO\b[\s\S]*?\bON\s+CONFLICT\b[\s\S]*?\bDO\s+UPDATE\s+SET\b[^;`]*/gi,Cr="\\((?:[^()]|\\([^()]*\\))*\\)",gi=`\\bnew\\s+PrismaClient\\s*${Cr}|\\bdrizzle\\s*${Cr}`,hi=/(?<![\w$])([A-Za-z_$][\w$]*)\s*[?!]?\s*(?::[^=;\n]+)?=(?![=>])\s*(?:await\s+)?(?:new\s+(?:PrismaClient|Pool|Client|MongoClient|Sequelize|Kysely|Knex)\b|(?:drizzle|knex|Knex|postgres)\s*\()/g,mi=/(?<![\w$])([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?(?:Prisma\s*\.\s*TransactionClient|PrismaClient|Pool|PoolClient|MongoClient|Sequelize|Kysely|Knex|DataSource|EntityManager|NodePgDatabase|PostgresJsDatabase|BetterSQLite3Database|MySql2Database|LibSQLDatabase)\b/g;function yi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(yi,"escapeRegExp");function Ie(e){return ai.test(e)||li.test(e)}a(Ie,"sourceImportsPersistenceDriverText");function _r(e,t,r){let n=new RegExp(e.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1]);}a(_r,"collectFirstGroup");function Ai(e){let t=new Set;_r(hi,e,t),_r(mi,e,t);let r=new RegExp(ci.source,"g"),n;for(;(n=r.exec(e))!==null;)for(let s of (n[1]??"").split(",")){let o=s.trim().replace(/^type\s+/,"").split(/\s+as\s+/),i=(o[1]??o[0]??"").trim();/^[A-Za-z_$][\w$]*$/.test(i)&&t.add(i);}return [...t].sort()}a(Ai,"persistenceClientBindings");function Tr(e){return e.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|`(?:[^`\\]|\\[\s\S])*`|'(?:[^'\\]|\\[\s\S])*'|"(?:[^"\\]|\\[\s\S])*"/g,t=>t.charCodeAt(0)===47?t.replace(/[^\n]/g," "):t.charCodeAt(0)===96?t.replace(/--[^\n`]*/g,r=>" ".repeat(r.length)):t)}a(Tr,"blankPersistenceComments");function Lr(e){let t=Tr(e);xr.lastIndex=0;let r;for(;(r=xr.exec(t))!==null;)if(!fi.test(r[2]??"")&&Or.test((r[3]??"").replace(pi," ")))return true;return false}a(Lr,"sourceHasTaggedSqlWrite");function Ge(e){let t=Tr(e),r=[...di,...Ai(t)].map(yi).join("|");return new RegExp(`(?:\\b(?:${r})(?![\\w$])|${gi})(?:\\s*\\.\\s*[A-Za-z_]\\w*)*\\s*\\.\\s*${ui}\\s*\\(`,"i").test(t)?true:Or.test(t)}a(Ge,"sourceHasPersistenceWrite");var Ri=["no-anemic-model"],Pr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],ki=new RegExp(`\\b(${Pr.join("|")})\\b`),Fr="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",Si=new RegExp(`\\bthis\\.${Fr}\\.push\\s*\\(`),bi=/\bif\s*\([^)]*\)\s*(?:\{[^}]*\bthrow\b|\bthrow\b)/,Ei=new RegExp(`^this\\.${Fr}\\s*=\\s*\\[\\s*\\]`),Ii=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,vi=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g;function wi(){return `${Pr.join(", ")}, or events-array .push(`}a(wi,"expectedDomainInvariantWordsPhrase");function xi(e){let t=je(e);return ki.test(t)||Si.test(t)||bi.test(t)}a(xi,"referencesGuardOrPublish");function Ci(e,t,r){let n=e.slice(t);if(Ei.test(n))return true;if(!Ii.test(n))return false;if(r&&/^pullEvents$/i.test(r))return true;let s=t>200?t-200:0;return /\bpullEvents\b/.test(e.slice(s,t+200))}a(Ci,"isIdiomaticEventsReset");function _i(e,t){let r=je(t),n=new RegExp(vi.source,"g"),s;for(;(s=n.exec(r))!==null;)if(!Ci(r,s.index,e))return true;return false}a(_i,"methodAssignsThis");function Nr(e,t){return t==null?e:{...e,truncatedUntil:t}}a(Nr,"attachShapeTruncation");function $r(e){return typeof e.truncatedUntil=="number"?e.truncatedUntil:void 0}a($r,"shapeTruncatedUntil");function Oi(e){let t=$r(e);return t==null?"":` shape analysed until character ${t}`}a(Oi,"shapeTruncationSuffix");function Dr(e){return /[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Dr,"escapeGlobLiteral");function Ti(e){let t="";for(let n=0;n<e.length;n+=1){let s=e[n];if(s==="\\"&&n+1<e.length){let o=e[n+1];if("*?{}[],".includes(o)||o==="\\"){t+="\\"+o,n+=1;continue}t+="/";continue}t+=s;}let r="";for(let n=0;n<t.length;n+=1){let s=t[n];s==="\\"&&n+1<t.length?(r+=Dr(t[n+1]),n+=1):s==="*"?t[n+1]==="*"?t[n+2]==="/"?(r+="(?:.*/)?",n+=2):(r+=".*",n+=1):r+="[^/]*":s==="?"?r+="[^/]":r+=Dr(s);}return new RegExp(`^${r}$`)}a(Ti,"globToRegExp");function He(e,t){return !t||t.length===0?true:t.some(r=>Ti(r).test(e))}a(He,"matchesAppliesTo");function Li(e){return Ri.includes(e)}a(Li,"isTier2");function Ni(e){return e.mode==="enforced"&&!Li(e.sensor)?{severity:"error",failsStrict:true}:{severity:"warning",failsStrict:false}}a(Ni,"severityFor");function V(e,t,r,n=1){let{severity:s,failsStrict:o}=Ni(e);return {ruleId:"ARKRULE_STRUCTURE",code:e.sensor,message:r,file:t,line:n,fromLayer:e.provenance.layer,arkruleId:e.id,arkruleSource:e.provenance.sourceFile,severity:s,sensor:e.sensor,failsStrict:o}}a(V,"baseViolation");function Be(e,t,r){if(!r)return true;let n=r(e);return n?n===t.provenance.layer:false}a(Be,"isInRuleLayer");function Ve(e,t,r){return t.filter(n=>!(!n.exported||!He(n.file,e.appliesTo)||!Be(n.file,e,r)))}a(Ve,"shapesForRule");function At(e,t,r){let n=$r(t);if(n!=null)return V(e,t.file,`Exported class ${t.className} shape analysed until character ${n}; later ${r} may be invisible (sensor ${e.sensor}).`)}a(At,"truncatedShapeViolation");function Di(e,t,r){let n=[];for(let s of Ve(e,t,r)){let o=At(e,s,"members");o&&n.push(o),(s.hasPublicSetters||s.hasPublicMutableFields)&&n.push(V(e,s.file,`Exported class ${s.className} exposes public mutable state (sensor aggregate-private-state).`));}return n}a(Di,"evaluateAggregatePrivateState");function Pi(e,t,r){let n=[];for(let s of Ve(e,t,r)){let o=At(e,s,"constructors and factories");if(o&&n.push(o),s.hasPublicConstructor&&!s.hasStaticFactory){if(!(s.hasPublicMutableFields||s.hasPublicSetters||(s.mutatingMethods?.length??0)>0))continue;n.push(V(e,s.file,`Exported class ${s.className} exposes a public constructor without a static factory (sensor always-valid-factory).`));}}return n}a(Pi,"evaluateAlwaysValidFactory");function Fi(e,t,r){let n=[],s=wi();for(let o of Ve(e,t,r)){let i=Oi(o),l=At(e,o,"methods");l&&n.push(l);for(let c of o.mutatingMethods)c.referencesGuardOrPublish||n.push(V(e,o.file,`Mutating method ${o.className}.${c.name} does not reference ${s} (sensor domain-event-on-mutation).${i}`));}return n}a(Fi,"evaluateDomainEventOnMutation");function $i(e,t){let r=[];for(let n of t.files)He(n,e.appliesTo)&&Be(n,e,t.layerForFile)&&t.fileHints?.[n]?.orchestrationHeavy&&r.push(V(e,n,"File appears to embed domain branching beyond guard-and-delegate orchestration (sensor orchestration-only)."));return r}a($i,"evaluateOrchestrationOnly");function Mi(e,t){let r=[];for(let n of t.files)He(n,e.appliesTo)&&Be(n,e,t.layerForFile)&&t.fileHints?.[n]?.adapterThick&&r.push(V(e,n,"Adapter module mixes domain branching, persistence, and mapping beyond a thin adapter (sensor thin-adapter)."));return r}a(Mi,"evaluateThinAdapter");function Ki(e,t){let r=[];for(let n of t.files)He(n,e.appliesTo)&&Be(n,e,t.layerForFile)&&t.fileHints?.[n]?.persistenceWrite&&r.push(V(e,n,"File imports a persistence driver and issues a write; route the write through a Domain aggregate and a persistence adapter (sensor writes-via-aggregate)."));return r}a(Ki,"evaluateWritesViaAggregate");function Ui(e,t,r){let n=[];for(let s of Ve(e,t,r))if(s.dataOnly===true){let o=V(e,s.file,`Exported type ${s.className} looks data-only / anemic (sensor no-anemic-model; advisory only).`);n.push({...o,severity:"warning",failsStrict:false});}return n}a(Ui,"evaluateNoAnemicModel");function Mr(e){if(!e.arkRules.structure.length)return [];let t=[];for(let r of e.arkRules.structure)switch(r.sensor){case "aggregate-private-state":t.push(...Di(r,e.classShapes,e.layerForFile));break;case "always-valid-factory":t.push(...Pi(r,e.classShapes,e.layerForFile));break;case "domain-event-on-mutation":t.push(...Fi(r,e.classShapes,e.layerForFile));break;case "orchestration-only":t.push(...$i(r,e));break;case "thin-adapter":t.push(...Mi(r,e));break;case "writes-via-aggregate":t.push(...Ki(r,e));break;case "no-anemic-model":t.push(...Ui(r,e.classShapes,e.layerForFile));break;}return t.sort((r,n)=>r.file.localeCompare(n.file)||r.arkruleId.localeCompare(n.arkruleId)||r.message.localeCompare(n.message))}a(Mr,"evaluateArkRuleSensors");function ji(e){return e==="PersistenceAdapters"}a(ji,"isPersistenceDriverLayer");function Gi(e,t){if(Ie(e))return true;if(!t)return false;for(let r of t){if(ji(r.layer))return true;let n=r.specifier;if(!n)continue;let s=`from '${n}'`;if(Ie(s))return true}return false}a(Gi,"sourceImportsPersistenceDriver");var Hi=/\b(?:@Controller|@Get|@Post|@Put|@Delete|Router\(\)|createRouter|express\.Router|fastify\.(?:get|post)|export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|DELETE|PATCH)\b|export\s+const\s+(?:GET|POST|PUT|DELETE|PATCH)\s*=)/,Bi=/(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/,Vi=/\b(?:export\s+)?(?:async\s+)?function\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*|\b(?:export\s+)?const\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*\s*=/,Wi=/\bif\s*\(\s*(?:!)?(?:order|invoice|cart|user|account|policy|aggregate|entity|amount|total|balance|status|state)\b/i;function Kr(e,t,r){if(!t)return null;let n=Gi(t,r),s=n&&Ge(t)||Lr(t);if(t.length<40)return s?{persistenceWrite:true}:null;let o=t.match(new RegExp(Vi.source,"g"))??[],i=t.match(new RegExp(Wi.source,"g"))??[],l=(t.match(/\bif\s*\(/g)??[]).length,c=(t.match(/\bswitch\s*\(/g)??[]).length,d=o.length>=2||o.length>=1&&i.length>=2||i.length>=3&&l+c>=6,u=Hi.test(t)||Bi.test(t),f=o.length>=1||i.length>=2,p=/\b(?:mapTo|toDomain|toDto|fromRow|toEntity|fromPrisma|serialize|deserialize)\w*\s*[(=]/.test(t),g=n&&f||u&&f||n&&p&&(l>=4||o.length>=1)||u&&n;return !d&&!g&&!s?null:{...d?{orchestrationHeavy:true}:{},...g?{adapterThick:true}:{},...s?{persistenceWrite:true}:{}}}a(Kr,"deriveArkRuleFileHints");var zi=new Set(["if","match","when"]);function ve(e,t){let r=[];for(let n of wr(t,{exportedOnly:true})){let s=n.name;if(n.bodyStart==null){r.push(Nr({file:e,className:s,exported:true,hasPublicMutableFields:false,hasPublicSetters:false,hasPublicConstructor:false,hasStaticFactory:false,mutatingMethods:[]},n.start));continue}let o=n.bodyStart,i=n.bodyEnd==null,l=t.slice(o,n.bodyEnd??t.length),c=vr(l),d=i?t.length:c.truncatedAt==null?void 0:o+c.truncatedAt,u=c.members.filter(k=>!(k.kind!=="field"||k.name==="constructor"||k.modifiers.includes("private")||k.modifiers.includes("protected")||k.modifiers.includes("readonly")||k.modifiers.includes("static")||k.modifiers.includes("get")||k.modifiers.includes("set"))),f=u.length>0,p=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(l),g=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(l),m=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(l)&&!g,R=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(l)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(l),S=[];for(let k of c.members)k.kind==="method"&&k.name!=="constructor"&&(k.modifiers.includes("static")||k.modifiers.includes("get")||k.modifiers.includes("set")||zi.has(k.name)||_i(k.name,k.body)&&S.push({name:k.name,referencesGuardOrPublish:xi(k.body)}));let A=c.members.filter(k=>k.kind==="method").length<=1&&u.length>=2&&f;r.push(Nr({file:e,className:s,exported:true,hasPublicMutableFields:f,hasPublicSetters:p,hasPublicConstructor:m,hasStaticFactory:R,mutatingMethods:[...S],dataOnly:A},d));}return r}a(ve,"extractClassShapesFromSource");function Yi(e){if(!e)return {};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}a(Yi,"normalizeExtraMergeTeethClassification");function We(e){let t=Yi(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?true:(r??0)>=50&&(n??0)>=1}a(We,"extraMergeTeethAllowed");function h(e,t,r,n,s,o){return {ruleId:e,title:r,why:n,fix:s,docsAnchor:e,category:t,...o?.oftenAdvisory?{oftenAdvisory:true}:{}}}a(h,"entry");var Ur=Object.freeze([h("LAYER_IMPORT_VIOLATION","layer","This import is not allowed","This file imported a folder it may not reach. The write doesn\u2019t land. The same check fails the pull request.","Branch by import kind: constants/types/pure \u2192 adopt into DomainModel or SharedKernel (do not invent a port); kernel/events/bootstrap from Persistence \u2192 inject a port or move the map to SharedTypes (Persistence must not emit); define a port only when the target is a real use-case. Type-only edges use `import type`. Then preflight again. Do not weaken the layer rule without a hash-bound policy acknowledgement."),h("LAYER_INTENT_REFERENCE_VIOLATION","layer","Intent referenced across a blocked layer edge","A string intent (or intent-like reference) names a layer that the file\u2019s layer may not reach under the contract rules \u2014 the same plane as import edges, for event/intent coupling.","Reference that intent from a layer allowed to know about it (usually an adapter or application layer), or relocate the reference \u2014 then preflight again."),h("LAYER_REFERENCE_VIOLATION","layer","Layer reference blocked (snippet / AI gate)","Snippet analysis found an intent or string reference that would couple layers in a direction the architecture profile forbids.","Move the reference to an allowed layer or introduce a port/event boundary, then re-run the snippet gate."),h("SHARED_IMPORTS_SLICE","layer","A shared root imports a slice",'A declared shared root imports a slice directly. That hop is allowed while sharedImportsSlice is unset or "deny-cross-parent", so this is advisory: the universe wall is direct-only.','Move the code the shared root needs into the shared root, or invert the dependency. Set sharedImportsSlice: "deny" to make these edges errors. With "deny-cross-parent", a slice that reaches another universe through a shared root is reported as LAYER_IMPORT_VIOLATION with reasonId CROSS_PARENT_VIA_SHARED. This warning does not fail the check.',{oftenAdvisory:true}),h("CIRCULAR_DEPENDENCY","layer","Dependency cycle","Two or more modules import each other in a loop. Cycles make ownership unclear and break stable layer direction.","Extract the shared dependency into a third module, invert one edge behind a port, or merge units that are truly one \u2014 then preflight again."),h("CROSS_WALL_DUPLICATE","layer","Code copied across a wall","Near-identical code sits on two sides of a slice wall (or in two layers that may not import each other). The wall would deny the import, so the code was copied instead. Status details (`--doctor --all`) and the report list it from token fingerprints taken at status time; they never enter the check, so the verdict does not change. Same-slice copies are counted, never listed.","Move one copy to a shared home the wall allows \u2014 a declared shared root, the universe common folder, or a layer both sides may import \u2014 then import it from both sides. One move at a time, through the write gate (/ark-place names the destination). Advisory only \u2014 it never fails a run.",{oftenAdvisory:true}),h("CROSS_LAYER_DUPLICATE","layer","Code copied in two layers","Near-identical code sits in two layers, and at least one of them may import the other. Status details (`--doctor --all`) and the report list it from token fingerprints taken at status time; the verdict does not change.","Keep one copy in the lower layer both sides may import, and import it from the other. One move at a time, through the write gate. Advisory only \u2014 it never fails a run.",{oftenAdvisory:true}),h("FORBIDDEN_GLOBAL","capability","Forbidden ambient global or dual import","The file\u2019s layer lists this ambient (or its exact import dual, e.g. process / node:process) in forbiddenGlobals. Pure layers must not reach wall-clock, network, process, or similar effects directly.","Inject the capability through a small port (Clock, HttpPort, Config, \u2026), bind the implementation outside the walled layer, then preflight again."),h("CAPABILITY_VIOLATION","capability","Denied effect capability","The layer denies an effect capability (network, filesystem, clock, randomness, environment, process, persistence) and the candidate uses that effect via ambient or import evidence.","Define a capability port in the walled layer, bind the implementation in an adapter layer, then preflight again. Never mechanical-safe \u2014 port shape is a design decision."),h("RAW_EVENT_PUBLISH","publish","Raw event publish","Publish went through a raw string or object instead of a registered intent creator, bypassing Ark intent contracts and tooling.","Publish through a registered intent creator, then run Ark again."),h("PUBLISH_MISSING_SOURCE","publish","Publish missing metadata.source","A strict Ark publish call omitted metadata.source, so the publishing layer cannot be verified.","Add metadata.source to the publish call, then run Ark again."),h("PUBLISH_SOURCE_LAYER_MISMATCH","publish","Publish source layer mismatch","metadata.source resolves to a different layer than the file performing the publish.","Use a source intent owned by the same layer as this file, or move the publish call to the owning layer."),h("UNKNOWN_INTENT","publish","Unknown intent reference","Snippet analysis saw an intent string that is not registered in the intent registry / profile under check.","Register the intent or use a known intent name from the project registry, then re-run the gate."),h("DYNAMIC_IMPORT_NOT_ALLOWLISTED","safety","Non-literal dynamic import","A dynamic import(expr) cannot be resolved statically and the file is not on dynamicImportAllowlist. Unresolved dynamics can hide layer edges.","Rewrite to a static import when possible, or add only reviewed files to dynamicImportAllowlist after human sign-off."),h("DYNAMIC_REQUIRE_NOT_ALLOWLISTED","safety","Non-literal require","A require(expr) cannot be resolved statically and is not allowlisted \u2014 same hide-the-edge risk as dynamic import.","Prefer static import, or allowlist only reviewed files after sign-off."),h("TS_SUPPRESSION_THRESHOLD_EXCEEDED","safety","@ts-ignore / @ts-nocheck threshold","Count of TypeScript suppressions in governed production source exceeds safety.maxTsSuppressions.","Remove suppressions by fixing types, or raise the threshold only with an explicit production exception in ark.config.json."),h("ANY_CAST_THRESHOLD_EXCEEDED","safety","Explicit any cast threshold","Count of explicit any casts exceeds safety.maxAnyCasts.","Replace any with precise types, or raise the threshold only with a documented exception."),h("IN_MEMORY_STORE_IN_PRODUCTION_SOURCE","safety","In-memory store in production source","Governed production source references an Ark InMemory* store without safety.allowInMemory \u2014 durable systems should not ship ephemeral stores by accident.","Provide a durable store implementation, or set safety.allowInMemory only for an explicitly ephemeral service."),h("PEER_ISOLATION_DISABLED","safety","peerIsolation disabled on a rule","A same-layer or peer rule disables peerIsolation (or omits it where required), which allows cross-slice coupling the contract otherwise blocks.","Restore peerIsolation: true, or set safety.allowDisabledPeerIsolation only with a documented production exception."),h("ARKRULE_STRUCTURE","arkrules","ArkRule structure sensor failed","An opt-in ArkRules structure sensor (private state, factory shape, event publish, persistence write outside an aggregate, \u2026) failed on a governed file for a declared arkruleId.","Restore the declared structure for the ArkRule (see arkruleSource), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement."),h("ARKRULE_INVARIANT","arkrules","ArkRule invariant failed","Reserved / remediation-recognized code for invariant-plane failures bound to an ArkRule id (coverage path also emits INVARIANT_UNCOVERED).","Fix the invariant for the ArkRule declared in arkrules/<Layer>.json, then preflight again. Do not demote without acknowledgement."),h("ARKRULE_SCOPE_EMPTY","arkrules","ArkRule appliesTo matched zero files","An ArkRule\u2019s appliesTo globs matched no governed files \u2014 the rule cannot observe what it claims to protect.","Fix appliesTo globs so they match governed files, or remove the rule. Enforced empty scope fails; advisory empty scope warns.",{oftenAdvisory:true}),h("ARKRULE_HINT_BUDGET_EXHAUSTED","arkrules","Structural-hint budget exhausted","orchestration-only, thin-adapter, and writes-via-aggregate only evaluate files the hint loader preloaded. When eligible governed files exceed that budget (coverage.maxFiles, default 400 \u2014 there is no arkrules.hintBudget), those sensors never saw the rest of their scope. Enforced + unreviewed is not green. The finding names exact hinted/governed counts and per-sensor reviewed N/M of scope.","Raise coverage.maxFiles in ark.config.json (this cap also bounds structural-hint preload; --doctor names the coupling) so hinted/governed counts match, then re-run with --strict-config. An enforced hint sensor that cannot see its scope fails strict."),h("ARKRULE_FILE_UNREFERENCED","arkrules","ArkRules file not referenced","A JSON file under arkrules/, or a slice file named arkrules.<Layer>.json beside governed code, is not in the effective catalog, so none of its rules are enforced. Drift looks like governance until someone notices.","Reference a central file from arkRules, set childSlices.arkRulesFile so a slice file is discovered, or delete it. Advisory only: it never fails the check.",{oftenAdvisory:true}),h("ARKRULE_DUPLICATE_ID","arkrules","ArkRule id declared more than once","Two ArkRules files in one layer declare the same effective id. Central ids stay bare. A slice file is namespaced as <childId>#<localId>, so the same local id in two slices is not a duplicate.","Rename one id, or split the files onto different slices. Config load fails closed. The catalog is not enforced until the id is unique."),h("ARKRULE_SCOPE_ESCAPES_SLICE","arkrules","Slice ArkRule appliesTo leaves its slice","A file discovered from childSlices.arkRulesFile set appliesTo to a glob that can match outside that child slice. The default, when appliesTo is omitted, is the slice directory.","Narrow appliesTo to the slice directory, or omit it. Config load fails closed. The escaping rule is not enforced."),h("INVARIANT_CATALOG_EMPTY","arkrules","Domain invariant catalog is empty","ArkRules is on and a Domain-role layer has code, but invariants[] has no phrases the code must preserve. Empty looks like \u201Cdone\u201D until someone fills the catalog.","Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json (or the mapped file). Starters show the shape. Advisory unless a domain structure rule is already enforced \u2014 then --strict-merge can refuse. Do not freeze this finding.",{oftenAdvisory:true}),h("INVARIANT_UNCOVERED","arkrules","Invariant without coverage evidence","An ArkRules invariant is under contract but no covering test title or declared symbol evidence was found (or coverage is partial). Kind is never-had-tests (adopt residual) vs tests-disappeared (suite exists).","Add a test title or declared symbol covering the arkruleId, then preflight again. Treat never-had-tests as adopt residual; treat tests-disappeared as a regression. Missing test globs report partial \u2014 never fake green. When the message reports an exhausted file budget, raise coverage.maxFiles (or narrow coverage.testGlobs) in ark.config.json."),h("INVARIANT_COVERAGE_OUTSIDE_ROOTS","arkrules","Covering test outside the declared coverage roots","The only test naming this invariant sits outside coverage.coverageRoots \u2014 the places the project declares its runner executes. ArkGate matches declared text and never executes tests, so it cannot tell whether that file is ever run: coverage there is a test that exists, not a test that runs.","Move the test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json. Advisory: it never fails strict, but promotion to enforced refuses on it.",{oftenAdvisory:true}),h("INVARIANT_PROBE_SURVIVED","arkrules","Covering tests do not pin the invariant","The committed invariant probe (.ark/invariant-probe.json, written by arkgate-check --probe-invariants --write) shows, for files that have not changed since, that the covering tests still pass with the invariant's symbol broken on purpose (survived) or never call it (not reached). The test names the rule but does not pin it. A status and inventory line only: it never enters the check, so the verdict does not change.","Add a test case that fails when the rule is broken (the line names the change that went unnoticed), then re-run arkgate-check --probe-invariants --write and commit the file. Promotion to enforced refuses while the fresh artifact says survived or not reached; a stale, killed, inconclusive or missing result changes nothing.",{oftenAdvisory:true}),h("INVARIANT_TESTS_PATH_MISSING","arkrules","Domain-invariant tests path missing under adopted","The project is adopted (required CI or explicit advisory) and has domain invariants that want test evidence, but ark.config.json does not name where those tests live. Green coverage without a real tests path is an empty checkbox.","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. Not freezable."),h("INVARIANT_COVERAGE_ROOTS_MISSING","arkrules","Coverage roots missing while an invariant is enforced","A catalogued domain invariant is enforced, but ark.config.json does not name coverage.coverageRoots \u2014 the folders where the project says its test runner actually goes. Without that declaration, INVARIANT_COVERAGE_OUTSIDE_ROOTS cannot fire and coverage can certify a test no runner runs.","Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. testGlobs alone is not enough. Fail-closed until that path is present. Not freezable."),h("ARKRUN_MISSING_ROOT","arkrun","No kernel factory in composition roots","The ArkRun extra is on but no kernel factory (createArkKernel / createStrictArkKernel / createLenientArkKernel, their *FromConfig variants, or ArkModule.forRoot / forRootAsync imported from arkgate/nestjs) was found in arkRun.compositionRoots, so agents can skip the kernel while the write gate stays green.","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."),h("ARKRUN_KERNEL_IN_DOMAIN","arkrun","Domain-role layer imports the kernel","A Domain-role layer imports arkgate/runtime, arkgate/nestjs, @arkgate/runtime, or kernel types. Domain stays kernel-free; composition roots and adapters own the factory.","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."),h("ARKRUN_DIRECT_NEW","arkrun","Managed type constructed with new","A managed non-Domain file constructs an admitted type with new outside an ArkRun composition-root factory, skipping kernel resolve/registration.","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."),h("ARKRUN_UNDECLARED_EMIT","arkrun","Emit name not in raises/sends","A publisher / publish / raise / send call on a receiver traced to the kernel names an intent (string literal or same-file define/defineIntent binding) that is not listed in the file\u2019s raises or sends declaration.","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."),h("ARKRUN_UNDECLARED_HANDLE","arkrun","Handle name not in reactsTo","A subscribe / registerHandler call on a receiver traced to the kernel names an intent (string literal or same-file define/defineIntent binding) that is not listed in the file\u2019s reactsTo declaration.","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."),h("ARKRUN_UNDECLARED_DEPEND","arkrun","Depend name not in uses","A resolve / resolveSingleton call on a receiver traced to the kernel names a component that is not listed in the file\u2019s uses declaration.","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."),h("ARKRUN_TRANSPORT_BYPASS","arkrun","Homemade broker or emitter import","A managed layer imports a closed broker/queue/emitter specifier (EventEmitter, queue clients, \u2026) instead of the ArkRun kernel transport.","Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment."),h("ARKORDER_MISSING_PLANE","arkorder","No createOrderPlane in plane roots","The ArkOrder extra is on but no createOrderPlane factory was found in arkOrder.planeRoots, so agents can skip the pattern plane while the write gate stays green.","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."),h("ARKORDER_KERNEL_IN_DOMAIN","arkorder","Domain-role layer imports the order plane","A Domain-role layer imports arkgate/order. Domain stays plane-free; planeRoots own the factory.","Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe."),h("ARKORDER_GENERIC_UPDATE","arkorder","Generic update of a big product choice","A call to update/patch/set rewrites a named product choice (like billing plan) as if it were a seat count.","Don't use a generic update. First freeze with release(). Later, propose the change, then apply it."),h("ARKORDER_TOO_MANY_PARAMS","arkorder","Too many slow keys","\u03BE has more keys than arkOrder.maxXiKeys. Haken requires a few slow modes, not a dump of microstate.","Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe."),h("ARKORDER_INGEST_WRITES_XI","arkorder","ingest assigned into \u03BE","An ingest() result is written into a Release or \u03BE store. ingest may absorb, escalate_up, or hold; it never mints a pattern.","Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe."),h("ARKORDER_XI_FIELD_WRITE","arkorder","Big product choice written like a seat count","A use-case writes a named product choice (like billing plan) through a database update. Invoices and seats can flow. That choice cannot.","Keep invoices and seats as events. Change the choice through the valve (proposeRelease then apply), not a generic update."),h("ARKORDER_INFORMATION_BUDGET","arkorder","Projection observes a forbidden kind","h(\u03BE) allowedKinds includes a kind listed in informationBudget.cannotObserve. A scale may not look at what it was told not to see.","Cut that kind from the projector or from cannotObserve, then preflight again. Never mechanical-safe."),h("ARKORDER_XI_TTL","arkorder","Slow key carries a freshness field","\u03BE named ttl/freshUntil/maxAge. Freshness belongs on \u03C3. A slow parameter that expires per transaction is not slow.","Move freshness onto \u03C3 (freshUntil) and keep \u03BE stable, then preflight again. Never mechanical-safe."),h("ARKORDER_STALE_SIGMA","arkorder","\u03C3 is stale","ingest ran after \u03C3.freshUntil (or sigmaMaxAgeMs). \u03BE does not TTL.","Call refreshSigma and ingest again, or proposeRelease then apply(ProposeResult) if the pattern changed. Never mechanical-safe."),h("ARKORDER_UNVALVED_RELEASE","arkorder","Second freeze without the valve","release() already froze the big choice. A later release() with a different value does not land. First freeze is release(); later change is proposeRelease then apply.","Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe."),h("ARKORDER_STALE_PROPOSAL","arkorder","Proposal is not bound to the current Release","apply() got a ProposeResult computed against another Release (another apply landed first), one missing its base binding, or one whose reviewed blast radius is not the transition that would commit. The binding is data, not a capability: a proposal that states the current base and the exact transition applies whoever built it.","Run proposeRelease again against the current Release, review the new blast radius, then apply that proposal. Never mechanical-safe."),h("INVALID_CHANGE_PATH","preflight","Unsafe change path","A change set entry is not a safe, non-empty project-relative path (absolute, escape, empty, or NUL).","Use canonical project-relative paths only in the atomic change set, then preflight again."),h("DUPLICATE_CHANGE_PATH","preflight","Duplicate path in change set","The atomic change set lists more than one operation for the same path.","Collapse to one create/update/delete per path, then preflight again."),h("DELETE_TARGET_MISSING","preflight","Delete target missing","A delete operation targets a path that is not present in the supplied base tree.","Remove the delete, or include the file in the base tree facts, then preflight again."),h("CHANGE_SET_EMPTY","preflight","Empty change set","Atomic preflight was invoked with no create, update, or delete operations.","Provide at least one change operation, then preflight again."),h("FACTS_IDENTITY_MISMATCH","preflight","Base/candidate facts identity mismatch","Base and candidate resolved facts disagree on resolver, compiler, evidence requirements, or package identity \u2014 verdicts would not be comparable.","Regenerate both fact snapshots with the same resolver/compiler/evidence requirements, then preflight again."),h("CANDIDATE_DELETE_NOT_APPLIED","preflight","Candidate still contains deleted path","Facts claim a delete, but the candidate tree still includes the path.","Ensure the candidate facts apply the delete (path absent), then preflight again."),h("CANDIDATE_CHANGE_MISSING","preflight","Declared change missing from candidate","The change set declares a create/update whose path is missing from candidate facts.","Include the new content in the candidate facts (or drop the operation), then preflight again."),h("CANDIDATE_CONTENT_HASH_MISMATCH","preflight","Candidate content hash mismatch","The candidate file content hash does not match the hash expected for the declared change.","Rebuild candidate facts from the exact proposed content, then preflight again."),h("UNDECLARED_CANDIDATE_CHANGE","preflight","Undeclared candidate change","Candidate facts differ from base for a path that was not listed in the explicit change set.","Declare every path that changes in the atomic change set, then preflight again."),h("ATOMIC_PREFLIGHT_UNAVAILABLE","preflight","Atomic preflight unavailable","The host/MCP path could not run the atomic preflight engine (missing facts, incomplete setup, or unsupported mode).","Use resolved-candidate facts / ark_prepare_change with a complete batch, or fall back to ark-check on disk. Do not treat missing preflight as green."),h("WRITE_GATE_UNAVAILABLE","preflight","Write gate could not run","The write gate could not load its own inputs (ark.config.json missing, unreadable, or invalid; a referenced ArkRules file missing or invalid; or the built library missing), so it cannot judge this governed source write (existing files included), or a write would leave ark.config.json or a referenced ArkRules file unloadable. No checker, no write: the hook blocks instead of letting the write through unchecked.","Fix the reported input (repair ark.config.json or the ArkRules file, or run `npm run build` / reinstall arkgate from npm), then retry the same write. Do not remove the hook to get past it."),h("DESIGN_SMELL_REGRESSION","preflight","Design smell regression on base-relative ratchet","Compared to the base ref, the candidate introduces a created-path domain-logic-in-ui file under --strict-merge, or introduces or worsens a blocking design-smell class under --fail-on-new-smells.","Move the new UI business rule out of the created file (or revert a --fail-on-new-smells regression), then re-run with the same base ref."),h("ANALYSIS_PARSE_INCOMPLETE","analysis","Parse incomplete","Governed source could not be fully parsed; evidence includes the TypeScript diagnostic (line + message). Incremental mid-edit parse is normal for agents. Contract exclude paths skip the write hook.","Finish the source or fix the reported syntax error, then re-run `npx arkgate-check`. The write hook does not deny solely on mid-edit parse. Partial never means pass."),h("LEXICAL_EVIDENCE_INCOMPLETE","analysis","Lexical evidence incomplete","This check only saw one file, so it cannot fully prove how the import resolves. The result is provisional \u2014 `ark-check` on the project is the authority.","For a complete verdict, run `npx arkgate-check --root . --config ark.config.json` (or ark_prepare_change over MCP with the full candidate batch). Read lexicalValid for the one-file result."),h("ANALYSIS_COVERS_NO_FILES","analysis","Analysis covered no files","No file matched the contract include and layer patterns under the analyzed root, so the run had nothing to check. Every rule is vacuously satisfied on an empty set: a green here would read exactly like a green over a governed tree while certifying nothing. Usual causes are a --root that is not the tree the contract describes (including a contract found outside the requested root, whose directory is then adopted as the project root), include / exclude patterns that match nothing, or layer patterns written for a different layout.","Point --root at the tree the contract describes, or keep the contract inside that tree, or fix the include / exclude / layer patterns so they match real files \u2014 then re-run `npx arkgate-check --root . --config ark.config.json`. This is a refusal about ArkGate\u2019s own inputs, not a finding about your code; no baseline or policy acknowledgement can suppress it."),h("ANALYSIS_HOST_UNAVAILABLE","analysis","Analysis host unavailable","No usable TypeScript / analysis host was available for this invocation.","Install a supported TypeScript version visible to the project, then re-run. Unavailable analysis is fail-closed."),h("ADAPTER_NOT_ALLOWED_FOR_PORT","adapter","Adapter not allowed for port","Runtime/port wiring selected an adapter implementation that the architecture profile does not allow for that port.","Bind an allowed adapter for the port, or adjust the profile with an explicit policy decision \u2014 then re-run."),h("FORBIDDEN_PATTERN","snippet-policy","Forbidden regex pattern","Snippet content matched a project or profile forbiddenPatterns rule.","Remove or rewrite the matching code so the pattern no longer matches, then re-run the snippet gate."),h("FORBIDDEN_SUBSTRING","snippet-policy","Forbidden substring","Snippet content contained a forbidden substring from the AI gate options/profile.","Remove the forbidden substring, then re-run the snippet gate."),h("FORBIDDEN_IMPORT","snippet-policy","Forbidden import target","Snippet imported or required a module listed as forbidden for the active profile.","Import an allowed module or inject the dependency behind a port, then re-run."),h("POLICY_VIOLATION","snippet-policy","Policy engine violation","A registered Policy failed on the snippet or generated code under evaluation.","Adjust the code to satisfy the named policy, or change the policy only through an explicit contract decision."),h("EXTENSION_ERROR","snippet-policy","AI gate extension error","A registered AICodeGate extension threw while analyzing the snippet.","Fix or remove the failing extension; do not ignore extension failures as pass."),h("AST_ANALYZER_ERROR","snippet-policy","AST analyzer error","Built-in AST/symbol analysis failed (host error or unexpected analyzer exception).","Ensure TypeScript host and snippet are valid; re-run. If the analyzer crashes on valid input, file a bug with a minimal fixture."),h("CONFIG_INVALID_DYNAMIC_IMPORT_ALLOWLIST","config","Invalid dynamicImportAllowlist","dynamicImportAllowlist is present but not an array of file globs.","Set dynamicImportAllowlist to an array of project-relative globs (or omit it).",{oftenAdvisory:true}),h("CONFIG_INVALID_SAFETY","config","Invalid safety object","The safety field is present but not an object.","Use a safety object with optional maxTsSuppressions, maxAnyCasts, allowInMemory, allowDisabledPeerIsolation.",{oftenAdvisory:true}),h("CONFIG_INVALID_SAFETY_THRESHOLD","config","Invalid safety threshold","A safety threshold (maxTsSuppressions / maxAnyCasts) is not a non-negative integer.","Set each threshold to a non-negative integer.",{oftenAdvisory:true}),h("CONFIG_NO_LAYERS","config","No layers configured","ark.config.json has no file layers, so import-boundary enforcement cannot classify files.","Declare at least one layer with name + patterns (or run ark start / a preset).",{oftenAdvisory:true}),h("CONFIG_LAYER_WITHOUT_NAME","config","Layer missing name","A configured layer entry has no name.","Give every layer a unique non-empty name.",{oftenAdvisory:true}),h("CONFIG_INVALID_FORBIDDEN_GLOBALS","config","Invalid forbiddenGlobals","A layer\u2019s forbiddenGlobals is not an array of strings; the entry is ignored.",'Use an array of strings (e.g. ["fetch", "Date.now"]).',{oftenAdvisory:true}),h("CONFIG_LAYER_WITHOUT_PATTERNS","config","Layer without patterns","A named layer has no file patterns and will never classify files.","Add patterns globs that match the layer\u2019s source tree.",{oftenAdvisory:true}),h("CONFIG_INVALID_LAYER_PATTERN","config","Invalid layer pattern","A layer pattern is not a valid glob / failed to compile.","Fix the pattern syntax for that layer.",{oftenAdvisory:true}),h("CONFIG_LAYER_PATTERN_NO_MATCHES","config","Layer pattern matched no files","A layer pattern matched zero included files (often a typo or include mismatch). Reserved/allowEmpty houses do not emit this.","Adjust the pattern or include roots, or mark the layer reserved/allowEmpty if the glob is a future house.",{oftenAdvisory:true}),h("CONFIG_DUPLICATE_LAYER","config","Duplicate layer name","The same layer name appears more than once in configuration.","Rename or merge duplicate layer entries.",{oftenAdvisory:true}),h("CONFIG_RULE_UNKNOWN_FROM_LAYER","config","Rule unknown from layer","A dependency rule references a source layer name that is not declared.","Fix the rule\u2019s from field to a declared layer name.",{oftenAdvisory:true}),h("CONFIG_RULE_UNKNOWN_TO_LAYER","config","Rule unknown to layer","A dependency rule references a target layer name that is not declared.","Fix the rule\u2019s to field to a declared layer name.",{oftenAdvisory:true}),h("CONFIG_AMBIGUOUS_LAYERS","config","Ambiguous layer classification","Some files match multiple layers at equal specificity; classification falls back to declaration order.","Disambiguate overlapping patterns so each file has one clear layer owner.",{oftenAdvisory:true}),h("CONFIG_UNCLASSIFIED_FILES","config","Unclassified included files","Included source files match no layer pattern; import rules will not enforce on them.","Extend layer patterns or narrow include so every governed file is classified.",{oftenAdvisory:true}),h("CONFIG_LAYER_MISSING_OWNER","config","Layer missing owner","requireLayerOwners is on and this layer has no owners. Writes to that house fail closed, like a folder with no name on the door.","Add a GitHub handle or email to that layer\u2019s owners in ark.config.json (/ark-adopt), then re-run. Reserved/allowEmpty houses may stay unnamed. Turn the flag off only if you no longer want owners required."),h("CONFIG_SLICE_IDENTITY_COLLISION","config","Starred slice prefixes share one id","sliceIdentity is stars and two different sliceFolders prefixes bind as the same slice id. Parallel trees of one feature do that on purpose; unrelated trees that share the last folder name merge by accident.","Keep stars when those prefixes are one feature. Otherwise use path, or rename the last literal so the prefixes do not bind as the same id. Doctor names both paths.",{oftenAdvisory:true}),h("CONFIG_CHILD_SLICES_VERSION","config","Config needs a newer arkgate than a pinned copy",'ark.config.json uses a slice key (childSlices, sharedImportsSlice "deny-cross-parent" or its object form, sliceIdentity, sharedImportsSlice, childSlices.message, siblings.ratchet) that an arkgate pinned in this repo rejects at config load. Emitted only with evidence of that pin: an exact package.json dependency, the installed node_modules/arkgate, package-lock.json, a scripts/*hook* or host hook command, or a CI workflow. Silent otherwise.',"Bump the named file to the version the finding gives (or newer), then run Ark again. This warning does not fail the check.",{oftenAdvisory:true}),h("CONFIG_CHILD_SLICE_EXTENDS","config","Child slice id does not extend its universe","A path resolved a child id that is not the universe id plus a further segment. The child wall does not treat that id as a child, so the edge is universe common until the folders line up.","Point childSlices.sliceFolders at children under the same universe id the outer sliceFolders already names. Doctor names the path.",{oftenAdvisory:true}),h("CONFIG_CHILD_SLICE_CROSS_UNIVERSE","config","Child slice allowance cannot cross the universe wall","childSlices.allowedCrossSlice names a pattern that can match two universes. That list clears only a sibling crossing inside one universe. The universe wall still denies the edge.","Narrow the pattern so both sides share one universe prefix (features/projects/* to features/projects/d2d-item), or remove the entry. This warning does not fail the check.",{oftenAdvisory:true}),h("CONFIG_CHILD_SLICES_INERT","config","childSlices on a rule that cannot run it","A rule sets childSlices without peerIsolation: true and allowed: false. The child wall runs only inside a universe wall, so on this rule childSlices enforces nothing. Config load still accepts it (arkgate 4.8.23 did too).",'Add "peerIsolation": true and "allowed": false to the same rule so the child wall runs, or remove childSlices. This warning does not fail the check.',{oftenAdvisory:true}),h("CONFIG_SLICE_LEGACY_STARS_ID","config","Slice id written in the 4.8.23 stars form",'Under sliceIdentity "stars", a sliceAliases target or an allowedCrossSlice entry names the 4.8.23 stars id, which dropped a star binding before the last literal (modules/*/api/* bound api/v1). The id now keeps that binding (orders/api/v1). For one release the entry keeps its 4.8.23 meaning, so verdicts do not change.',"Rewrite the entry with the new id the warning names (for example orders/api/v1/x instead of api/v1/x). A sliceAliases target that maps to more than one universe shape is rejected at config load. This warning does not fail the check.",{oftenAdvisory:true}),h("LITERAL_PATH_DRIFT","drift","Literal path moved by a rename","A repo path written inside a string, a comment or a docstring no longer resolves, and the rename set says where it went. Nothing in the gate sees this class: `tsc` resolves imports, not strings, and ESLint does not either, so the rename compiles green and the reference lies afterwards. It appears in four forms \u2014 the tsconfig alias, a relative literal, a path written without the include-root prefix, and prose \u2014 and a hand sweep reliably covers one of them.","Apply the suggested replacement, or re-run `npx arkgate-check --path-drift --base-ref <ref> --write` to apply every writable anchored replacement at once. The rewrite is mechanical and one-directional: the destination comes from the rename, it must itself resolve and be path-shaped, and the token is rewritten in the form the author wrote it in. A destination that leaves the alias root of the literal is reported with the target only and must be rewritten by hand."),h("LITERAL_PATH_UNRESOLVED","drift","Literal path does not resolve","A literal that looks like a repo path does not resolve under this root, and no rename explains where it went. Unlike LITERAL_PATH_DRIFT this is a candidate, not a verdict: with nothing to anchor it, ArkGate cannot tell a dead reference from an illustrative path in a comment, an example in documentation, or a path belonging to another tree.","Read the candidate and decide: fix the path, or leave it. Advisory only \u2014 it never fails a run and is never rewritten by --write, because there is no destination to propose. Run `--path-drift --all` to list the sweep.",{oftenAdvisory:true}),h("ORPHAN_MODULE","drift","File nothing imports","No governed file, test or entry point imports this module. It is the leftover an agent leaves when a rewrite lands next to the old file. Status reads it from the import facts the check already resolved, so it never changes the verdict. When a dynamic import, an unresolved import or an unmapped entry could reach the file, the item says so (maybe-dynamic, maybe-unresolved) and the list is partial.","Delete the file through the write gate, one file at a time. If a framework, a script or a runtime loader uses it, add a glob with a reason to .ark/entry-points.json (optional reviewBy) instead. Advisory only \u2014 it never fails a run.",{oftenAdvisory:true}),h("UNUSED_EXPORT","drift","Export nothing imports by name","An export no governed file or test imports by name. Listed only in status details (`--doctor --all`) and the report. Default, namespace, star, dynamic and require use count as using every export, so those files are skipped.","Drop the export keyword (or the code) if nothing outside the file needs it, or keep it when it is public API an entry point exposes. Advisory only \u2014 it never fails a run.",{oftenAdvisory:true}),h("ARK_UNKNOWN","meta","Unknown diagnostic","A diagnostic lacked a stable ruleId/code; adapters may emit this fallback so agents never see an empty id.","Resolve the underlying finding without weakening ark.config.json, then run Ark again. Prefer fixing the producer to emit a catalogued ruleId.")]);new Map(Ur.map(e=>[e.ruleId,e]));Object.freeze(Ur.map(e=>e.ruleId));var qi=Object.freeze([Object.freeze({reasonId:"CROSS_PARENT_SLICE",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-universe slice",why:"This import crosses two universe slices. The child wall cannot allow another universe.",fix:"Keep the import inside one universe, or move the shared code into a folder both universes may use."}),Object.freeze({reasonId:"CROSS_SIBLING_SLICE",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-sibling slice",why:"This import crosses two feature slices inside one universe.",fix:"Import universe-common code, or move the shared piece into the feature that owns it.",advisoryNote:"This crossing is a warning (siblings advisory). With a baseline in use, a new one fails only when the baseline already records an advisory crossing of this rule and the count grows, or when siblings.ratchet is true; ratchet false measures only."}),Object.freeze({reasonId:"CROSS_PARENT_VIA_SHARED",ruleId:"LAYER_IMPORT_VIOLATION",title:"Cross-universe through a shared root",why:"A slice reaches another universe only through a shared root. ark-check and CI report this path. The write hook and ESLint see one edge at a time and do not block it.",fix:"Stop the shared root from importing the other universe, or move that import into the universe that owns it. A shared hop that stays inside one universe is allowed. If the shared hop is a composition root (bootstrap, DI registrations), list it in sharedImportsSlice.stopAt; a path through a stop is not a crossing."})]),Zi=new Map(qi.map(e=>[e.reasonId,e]));function jr(e){if(!(typeof e!="string"||e.length===0))return Zi.get(e)}a(jr,"sliceReasonHint");var Xi=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Ji=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Qi=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function ea(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Xi.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Ji.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Qi.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a(ea,"classifyLayerImportKind");function ta(e,t){return t.failsStrict===false&&e.advisoryNote?`${e.fix} ${e.advisoryNote}`:e.fix}a(ta,"sliceHintAction");function ra(e){let t=jr(typeof e.reasonId=="string"?e.reasonId:void 0);if(t)return `${ta(t,e)} Then preflight again.`;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 r=ea(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 r==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":r==="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.":r==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}a(ra,"layerImportNextAction");function na(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a(na,"arkRunCallSiteName");function sa(e){let t=na(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case "ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case "ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case "ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case "ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case "ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case "ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case "ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return `Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}a(sa,"arkRunNextAction");function le(e){switch(e.ruleId){case "LAYER_IMPORT_VIOLATION":return ra(e);case "CONFIG_CHILD_SLICES_VERSION":return typeof e.nextAction=="string"&&e.nextAction.length>0?e.nextAction:"Bump the pinned arkgate named in the finding to the version it gives, then run Ark again.";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 sa(e);case "ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case "ARKORDER_KERNEL_IN_DOMAIN":return "Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case "ARKORDER_GENERIC_UPDATE":return "Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case "ARKORDER_TOO_MANY_PARAMS":return "Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case "ARKORDER_INGEST_WRITES_XI":return "Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case "ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case "ARKORDER_UNVALVED_RELEASE":return "Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}a(le,"deterministicNextAction");var oa=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],ia=new Set(oa);function aa(e){return ia.has(e)}a(aa,"isArkRunEditorSensor");var Gr={"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"},la="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Vr(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)?true:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(Vr,"isDomainRoleLayer");function ca(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(ca,"compareFindings");function K(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return {ruleId:Gr[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:l?"error":"warning",failsStrict:l,nextAction:le({ruleId:Gr[t],fromLayer:o?.fromLayer,target:o?.target})}}a(K,"finding");function da(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return {uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}a(da,"bagForFile");function Hr(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Hr,"emitKinds");function Br(e){return e==="subscribe"||e==="register-handler"}a(Br,"handleKinds");function ua(e){return e==="resolve"||e==="resolve-singleton"}a(ua,"dependKinds");function fa(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(K(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let l=o.get(i.matchedRoot)??[];l.push(i),o.set(i.matchedRoot,l);}for(let i of s){let l=[...o.get(i)??[]].sort((d,u)=>d.file.localeCompare(u.file));if(l.length===0){n.push(K(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(l.some(d=>d.hasKernelFactory))continue;let c=l[0];n.push(K(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no kernel factory (createArkKernel / createStrictArkKernel / createLenientArkKernel / *FromConfig, or ArkModule.forRoot / forRootAsync from arkgate/nestjs).`,{target:i},r));}return n}a(fa,"evaluateMissingRoot");function pa(e,t,r,n,s){let o=new Map(t.map(l=>[l.name,l.intentPrefixes??[]])),i=[];for(let l of r){let c=l.specifier;if(!c||!Q(c))continue;let d=n(l.from);d&&Vr(d,o.get(d)??[])&&i.push(K(e,"arkrun-kernel-in-domain",l.from,l.line,`${d} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:d,target:c},s));}return i}a(pa,"evaluateKernelInDomain");function ga(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return [];let l=new Map(t.map(u=>[u.name,u.intentPrefixes??[]])),c=new Set(n.filter(u=>u.hasKernelFactory).map(u=>u.file)),d=[];for(let u of r){if(c.has(u.file))continue;let f=u.typeName;if(e.ignoreDirectNewForErrors!==false&&(f.endsWith("Error")||f==="Error")||f.endsWith("DTO")||f.endsWith("VO"))continue;let p=s(u.file);!p||!i.has(p)||Vr(p,l.get(p)??[])||d.push(K(e,"arkrun-direct-new",u.file,u.line,`${p} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:p,target:u.typeName},o));}return d}a(ga,"evaluateDirectNew");function ha(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==true)return {findings:o,completenessReasons:i};let l=new Set(e.managedLayers);if(l.size===0)return {findings:o,completenessReasons:i};for(let c of t){if(!Hr(c.kind)&&!Br(c.kind)&&!ua(c.kind))continue;let d=n(c.file);if(!d||!l.has(d))continue;if(!c.nameLiteral){e.mode==="enforced"&&c.kind!=="publisher"&&i.push({code:la,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name or same-file define/defineIntent binding; enforced extra cannot prove the declaration.`});continue}let u=da(r,c.file);if(Hr(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:d,target:c.nameLiteral},s));continue}if(Br(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:d,target:c.nameLiteral},s));continue}u.uses.has(c.nameLiteral)||o.push(K(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:d,target:c.nameLiteral},s));}return {findings:o,completenessReasons:i}}a(ha,"evaluateUndeclared");function ma(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return [];let o=[];for(let i of t){if(i.typeOnly)continue;let l=i.specifier;if(!l||!kr(l))continue;let c=r(i.from);!c||!s.has(c)||o.push(K(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(l)}; use the ArkRun kernel transport.`,{fromLayer:c,target:l},n));}return o}a(ma,"evaluateTransportBypass");function ya(e){let t=e.arkRun;if(!t)return {findings:[],completenessReasons:[]};let r=We(e.classification),n=ha(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...fa(t,e.compositionRootHits,r),...pa(t,e.layers,e.dependencies,e.layerForFile,r),...ga(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...ma(t,e.dependencies,e.layerForFile,r)].sort(ca),o=[...n.completenessReasons].sort((i,l)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,d=`${l.code}\0${l.file??""}\0${l.message}`;return c<d?-1:c>d?1:0});return {findings:s,completenessReasons:o}}a(ya,"evaluateArkRunSensors");function Rt(e){return {findings:ya(e).findings.filter(r=>aa(r.sensor)),completenessReasons:[]}}a(Rt,"evaluateArkRunEditorSensors");var kt="docs/diagnostics.md";function St(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return [t,r,n??"",s??"",o??""].join("|")}a(St,"adapterFindingTargetKey");function bt(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return `fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}a(bt,"adapterFindingRefFromTargetKey");function Et(e){return `${kt}#${e}`}a(Et,"adapterDocsCodePath");function b(e){return typeof e=="string"&&e.length>0?e:void 0}a(b,"text");function Wr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(Wr,"positiveInteger");function ka(e,t,r){return le({ruleId:e,target:b(t.target)??b(r.target)??void 0,fromLayer:b(t.fromLayer)??void 0,toLayer:b(t.toLayer)??void 0,typeOnly:t.typeOnly===true,targetTypeOnlyExports:t.targetTypeOnlyExports===true,namedBindingsTypeOnly:t.namedBindingsTypeOnly===true,portProofEligible:t.portProofEligible===true,peerIsolation:t.peerIsolation===true,sourcePureTypeModule:t.sourcePureTypeModule===true,edgeKind:b(t.edgeKind)??void 0,capability:b(t.capability)??b(r.capability)??void 0,arkruleId:b(t.arkruleId)??void 0,arkruleSource:b(t.arkruleSource)??void 0,reasonId:b(t.reasonId)??void 0})}a(ka,"nextActionForDiagnostic");var Sa=new Set(["CROSS_PARENT_SLICE","CROSS_SIBLING_SLICE","CROSS_PARENT_VIA_SHARED"]);function ba(e){let t=e.details,r=t!==null&&typeof t=="object"?t.reasonId:void 0,n=b(e.reasonId)??b(r);return n&&Sa.has(n)?n:void 0}a(ba,"sliceReasonOf");function zr(e,t="error",r){let n=b(e.ruleId)??b(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===false||e.typeOnly===true&&e.peerIsolation!==true?"warning":t,o=ba(e),i={...b(e.target)?{target:b(e.target)}:{},...b(e.fromLayer)?{fromLayer:b(e.fromLayer)}:{},...b(e.toLayer)?{toLayer:b(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}:{},...b(e.capability)?{capability:b(e.capability)}:{},...b(e.edgeKind)?{edgeKind:b(e.edgeKind)}:{},...b(e.arkruleId)?{arkruleId:b(e.arkruleId)}:{},...b(e.arkruleSource)?{arkruleSource:b(e.arkruleSource)}:{},...o?{reasonId:o}:{},...o&&b(e.universeFrom)?{universeFrom:b(e.universeFrom)}:{},...o&&b(e.universeTo)?{universeTo:b(e.universeTo)}:{}},l=r??St(e),c=bt(l);return {ruleId:n,severity:s,message:b(e.message)??n,location:{file:b(e.file)??"<unknown>",line:Wr(e.line,1),column:Wr(e.column,1)},evidence:i,nextAction:b(e.nextAction)??ka(n,i,e),findingRef:c,targetKey:l,docsCodePath:Et(n)}}a(zr,"toAdapterDiagnostic");var It="advisory",qr="{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check]",ze="advisoryFallback",Zr='{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check. Enable ark/architecture-advisory (set to "warn" in configs.recommended) to report it as a warning.]',Yr=new WeakMap,Xr=new WeakMap;function Ea(e){return Object.prototype.hasOwnProperty.call(e,"sourceCode")||Object.prototype.hasOwnProperty.call(e,"getSourceCode")}a(Ea,"ownsSourceCode");function Ia(e){let t=e;for(let r=0;t&&t!==Object.prototype&&r<8;r+=1){if(Ea(t))return t===e?null:t;t=Object.getPrototypeOf(t);}return null}a(Ia,"runKey");function va(e,t){let r=Object.create(e,{report:{value(n){t.sinks.blocking?.report(n);}}});return Xr.set(r,t),r}a(va,"routedContext");function Ye(e,t,r){let n=Ia(t),s;if(n){let o=Yr.get(n);o||(o=new Map,Yr.set(n,o)),s=o.get(e),s||(s={sinks:{},created:false},o.set(e,s));}else s={sinks:{},created:false};return s.sinks[r]=t,s.created?{}:(s.created=true,e.create(va(t,s)))}a(Ye,"createChannelListeners");function Jr(e,t){let r=Xr.get(e),{location:n,diagnostic:s}=t,o={...n,messageId:t.messageId,...t.data?{data:t.data}:{},diagnostic:s};if(!r){e.report(t.nonBlocking?{...n,messageId:ze,data:t.advisoryData,diagnostic:s}:o);return}if(!t.nonBlocking){r.sinks.blocking?.report(o);return}if(r.sinks.advisory){r.sinks.advisory.report({...n,messageId:It,data:t.advisoryData,diagnostic:s});return}r.sinks.blocking?.report({...n,messageId:ze,data:t.advisoryData,diagnostic:s});}a(Jr,"deliverReport");function x(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return ""}a(x,"lintedFilename");function W(e){try{return e.sourceCode??e.getSourceCode?.()}catch{return}}a(W,"sourceCodeFor");function ce(e){let t=W(e);if(!t)return null;if(typeof t.getText=="function"){let r=t.getText();if(typeof r=="string")return r}return typeof t.text=="string"?t.text:null}a(ce,"editorSourceText");function wa(e,t){let r=e.loc?.start;return typeof r?.line=="number"&&typeof r.column=="number"?{node:e}:{loc:{line:typeof r?.line=="number"?r.line:t,column:0}}}a(wa,"reportLocation");function L(e,t,r,n,s){let o=zr({...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 Jr(e,{nonBlocking:o.severity==="warning",location:wa(t,o.location.line),messageId:r,...s?{data:s}:{},advisoryData:{message:o.message,ruleId:o.ruleId},diagnostic:o}),o}a(L,"reportAdapterDiagnostic");function Qr(e){let t={};for(let n of e)for(let[s,o]of Object.entries(n))(t[s]??=[]).push(o);let r={};for(let[n,s]of Object.entries(t))r[n]=s.length===1?s[0]:o=>{for(let i of s)i(o);};return r}a(Qr,"mergeListeners");function qe(e){return typeof e?.value=="string"?e.value:void 0}a(qe,"stringValue");function xe(e){if(e){if(e.type==="TemplateLiteral"){if((e.expressions?.length??0)>0||e.quasis?.length!==1)return;let t=e.quasis[0]?.value?.cooked;return typeof t=="string"?t:void 0}return qe(e)}}a(xe,"staticStringValue");function Ze(e){return e?.name??qe(e)}a(Ze,"propertyName");function vt(e,t){return t?xe(e):Ze(e)}a(vt,"staticKeyName");function en(e,t){let r=W(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0;}}a(en,"referenceFor");function z(e,t,r){let n=en(e,t);if(n?.resolved)return (n.resolved.defs?.length??0)>0;let s=W(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 false}a(z,"isLocallyBound");function tn(e,t){let r=en(e,t);return r?r.isValueReference!==false:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(tn,"isValueIdentifierReference");function we(e){if(e?.type==="Identifier"&&e.name)return {root:e,segments:[e.name]};if(!e)return;if(e.type==="ChainExpression"||e.type==="TSNonNullExpression")return we(e.expression);if(!(e.type==="MemberExpression"||!!(e.object&&e.property)))return;let r=we(e.object),n=vt(e.property,e.computed);if(!(!r||!n))return {root:r.root,segments:[...r.segments,n]}}a(we,"memberExpressionPath");function Xe(e){if(e.importKind==="type"||e.exportKind==="type")return true;let t=e.specifiers??[];return t.length===0?false:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}a(Xe,"declarationIsTypeOnly");function de(e,t,r=z){return {ImportDeclaration(n){let s=n,o=(s.specifiers??[]).filter(l=>l.type==="ImportSpecifier"),i=o.length>0&&o.length===(s.specifiers??[]).length&&o.every(l=>l.importKind==="type");t(n,s.source?.value,s.importKind==="type"||i,"import");},ImportExpression(n){let s=n;s.source?.type==="Literal"&&t(n,s.source.value,false,"dynamic-import");},TSImportEqualsDeclaration(n){let s=n;t(n,s.moduleReference?.expression?.value,s.importKind==="type"||s.isTypeOnly===true,"require");},ExportNamedDeclaration(n){let s=n;if(!s.source)return;let o=s.specifiers??[],i=o.length>0&&o.every(l=>l.exportKind==="type");t(n,s.source.value,s.exportKind==="type"||i,"export");},ExportAllDeclaration(n){let s=n;t(n,s.source?.value,s.exportKind==="type","export");},CallExpression(n){let s=n;s.callee?.type==="Identifier"&&s.callee.name==="require"&&s.arguments?.[0]?.type==="Literal"&&!r(e,n,"require")&&t(n,s.arguments[0].value,false,"require");}}}a(de,"moduleSourceListeners");function sn(e){try{return H.existsSync(e)?H.readFileSync(e,"utf8"):null}catch{return null}}a(sn,"readUtf8");function nn(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=E.dirname(n),i=E.isAbsolute(r)?r:E.resolve(r),l=E.relative(o,i).split(E.sep).join("/");if(!e.sourceIsInAnalysisScope(s,l))return null;let c=w(l,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:l,fromLayer:c}:null}a(nn,"loadEditorFile");function xa(e,t,r){let n=Ue(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!T(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n});}return s}a(xa,"compositionRootHitsForFile");function Ca(e,t,r){let n=new Set(ve(t.relFile,r).map(s=>s.className));return br(r,(s,o)=>{if(Q(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=E.relative(t.root,i).split(E.sep).join("/");if(l.startsWith(".."))return;let c=sn(i);if(c!==null)for(let d of ve(l,c))n.add(d.className);}),n}a(Ca,"admittedTypeNamesForEditor");function on(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o);}a(on,"reportFinding");function _a(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!==true)return r}a(_a,"constructedTypeName");function Oa(e,t,r,n,s){return de(t,a((i,l,c,d)=>{if(typeof l!="string"||l.length===0)return;let u=i.loc?.start?.line??1,f={from:r.relFile,specifier:l,kind:d,typeOnly:c,line:u,resolution:"resolved-external"},{findings:p}=Rt({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[f],layerForFile:a(g=>g===r.relFile?r.fromLayer:w(g,r.config.layers),"layerForFile")});for(let g of p)g.sensor===n&&on(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:l,target:g.target??l});},"check"),e.isLocallyBound)}a(Oa,"importListeners");function Ta(e,t,r){let n=ce(t)??sn(r.absFile)??"",s=Ca(e,r,n),o=yt(r.relFile,n,s),{findings:i}=Rt({arkRun:r.extra,layers:r.config.layers,kernelCalls:Ue(r.relFile,n),managedNews:o,compositionRootHits:xa(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:a(c=>c===r.relFile?r.fromLayer:w(c,r.config.layers),"layerForFile")}),l=i.filter(c=>c.sensor==="arkrun-direct-new");return {NewExpression(c){let d=_a(c);if(!d)return;let u=c.loc?.start?.line,f=l.find(p=>p.target===d&&(u===void 0||p.line===u));f&&on(e,t,c,"directNew",f,{fromLayer:f.fromLayer??r.fromLayer,typeName:d,target:f.target??d});}}}a(Ta,"directNewListener");function an(e){let t=a((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let l=nn(e,i);return l?Oa(e,i,l,r,s):{}}}),"createImportRule");return {noArkRunKernelInDomain:t("arkrun-kernel-in-domain","Disallow Domain-role imports of arkgate/runtime when arkRun is on (same sensor as ark-check).","kernelInDomain",'{{fromLayer}} must not import kernel module "{{specifier}}".'),noArkRunTransportBypass:t("arkrun-transport-bypass","Disallow homemade broker/queue/emitter imports in arkRun managed layers (same sensor as ark-check).","transportBypass",'{{fromLayer}} must not import broker/queue/emitter "{{specifier}}"; use the ArkRun kernel transport.'),noArkRunDirectNew:{meta:{type:"problem",docs:{description:"Disallow `new` of ArkRun-admitted types outside a composition-root factory (editor-buffer `new` envelope; on-disk import targets)."},messages:{directNew:"{{fromLayer}} must not construct {{typeName}} with new outside an ArkRun composition-root factory."},schema:[]},create(r){let n=nn(e,r);return n?Ta(e,r,n):{}}}}}a(an,"createArkRunEslintRules");var ln=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var xt="createOrderPlane";function Ct(e){return T(e)}a(Ct,"arkOrderGlobToRegExp");function Je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Je,"escapeRegExp");function ue(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(ue,"isArkOrderModuleSpecifier");function U(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
4
+ `&&(r+=1);return r}a(U,"lineAt");function $(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a($,"stripCommentsPreservingLines");function un(e,t){let r=$(t),n=[],s=/\b(import|export)(\s+type)?\s+(?:[^;]*?\s+from\s*)?['"]([^'"]+)['"]/g,o;for(;(o=s.exec(r))!==null;){let l=o[3]??"";ue(l)&&n.push({from:e,specifier:l,kind:o[1]==="export"?"export":"import",typeOnly:!!o[2],line:U(t,o.index),resolution:"resolved-external"});}let i=/\b(require|import)\s*\(\s*['"]([^'"]+)['"]\s*\)/g;for(;(o=i.exec(r))!==null;){let l=o[2]??"";ue(l)&&n.push({from:e,specifier:l,kind:o[1]==="import"?"dynamic-import":"require",typeOnly:false,line:U(t,o.index),resolution:"resolved-external"});}return n}a(un,"extractArkOrderModuleImportsFromSource");function fn(e,t){let r=$(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:U(t,o.index),callee:xt});return n}a(fn,"extractArkOrderPlaneCallsFromSource");var La=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;\n]+)?=\s*createOrderPlane\s*(?:<[^>]*>)?\s*\(/g,wt=/^(?:plane|[A-Za-z_$][\w$]*Plane)$/,Na=/\b([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?OrderPlane\b/g,Da=/\bfrom\s+['"]arkgate\/order(?:\/[^'"]*)?['"]|\brequire\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]|\bimport\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]/,Pa=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g,cn=["",".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],Fa=/([A-Za-z_$][\w$]*)\s*!?\s*\??\s*$/,$a=/^\s*(?:<[^<>]*>\s*)?([A-Za-z_$][\w$]*)\s*!?\s*(?:\b(?:as|satisfies)\b[\s\S]*)?$/;function Ma(e){let t=$(e),r=new Set,n=new RegExp(La.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1]);return [...r].sort()}a(Ma,"arkOrderPlaneBindings");function Ka(e){let t=[];for(let r of e)if(!(r===""||r===".")){if(r===".."){if(t.length===0)return "";t.pop();continue}t.push(r);}return t.join("/")}a(Ka,"normalizeRelativePath");function Ua(e,t){if(!t.startsWith("./")&&!t.startsWith("../"))return [];let r=e.replace(/\\/g,"/").split("/").slice(0,-1),n=Ka([...r,...t.split("/")]);if(!n)return [];let s=n.replace(/\.(?:[cm]?js|jsx)$/,""),o=new Set;for(let i of [n,s]){for(let l of cn)o.add(`${i}${l}`);for(let l of cn.slice(1))o.add(`${i}/index${l}`);}return [...o]}a(Ua,"relativeModuleCandidates");function ja(e,t,r){let n=Ua(e,t);return n.length===0?false:r.some(s=>{let o;try{o=Ct(s);}catch{return false}return n.some(i=>o.test(i))})}a(ja,"specifierResolvesToPlaneRoot");function Ga(e,t,r={}){let n=$(t),s=new Set(Ma(t)),o=new RegExp(Na.source,"g"),i;for(;(i=o.exec(n))!==null;)i[1]&&s.add(i[1]);let l=r.planeRoots??[];if(l.length>0){let c=new RegExp(Pa.source,"g");for(;(i=c.exec(n))!==null;)if(ja(e,i[2]??"",l))for(let d of (i[1]??"").split(",")){let u=d.trim().replace(/^type\s+/,"").split(/\s+as\s+/),f=u[0]?.trim()??"",p=(u[1]??u[0]??"").trim();!p||!/^[A-Za-z_$][\w$]*$/.test(p)||(wt.test(f)||wt.test(p))&&s.add(p);}}return s.delete(xt),{names:[...s].sort(),isArkOrderFile:Da.test(n)}}a(Ga,"arkOrderPlaneReceivers");var Ha=new Set(["return","await","void","typeof","yield","in","of","case","else","do","throw","delete"]);function Ba(e){let t=e.replace(/\s+$/,"");if(/[)\]]$/.test(t))return true;let r=/([A-Za-z_$][\w$]*)$/.exec(t);return r!==null&&!Ha.has(r[1])}a(Ba,"isCallBefore");function pn(e){let t=e.replace(/\s*!?\s*\??\s*$/,"");if(!t.endsWith(")")){let n=Fa.exec(t);return n?n[1]??null:null}let r=0;for(let n=t.length-1;n>=0;n-=1){let s=t[n];if(s===")")r+=1;else if(s==="("&&(r-=1,r===0)){if(Ba(t.slice(0,n)))return null;let o=t.slice(n+1,t.length-1),i=$a.exec(o);return i?i[1]??null:null}}return null}a(pn,"receiverBefore");function gn(e,t,r){let n=Ga(e,t,r);return {names:new Set(n.names),isArkOrderFile:n.isArkOrderFile}}a(gn,"planeReceiverContext");function hn(e,t){return !e||e===xt?false:t.names.has(e)?true:t.isArkOrderFile&&wt.test(e)}a(hn,"isPlaneReceiver");function mn(e,t,r={}){let n=$(t),s=gn(e,t,r),o=[],i=/\.((?:update|patch|set|mutate))\s*\(/g,l;for(;(l=i.exec(n))!==null;){let c=l[1],d=n.slice(Math.max(0,l.index-160),l.index);hn(pn(d),s)&&o.push({file:e,line:U(t,l.index),method:c});}return o}a(mn,"extractArkOrderGenericUpdatesFromSource");function yn(e,t,r){if(r.length===0)return [];let n=$(t);if(!Ie(n)||!Ge(n))return [];let s=[],o=new Set;for(let i of r){if(!i)continue;let l=new RegExp(`(?:\\b${Je(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${Je(i)}['"]\\s*:|[{\\,]\\s*${Je(i)}\\s*[\\,}]|\\.${Je(i)}\\s*=)`,"g"),c;for(;(c=l.exec(n))!==null;){let d=`${i}:${c.index}`;if(!o.has(d)){o.add(d),s.push({file:e,line:U(t,c.index),key:i});break}}}return s}a(yn,"extractArkOrderXiFieldWritesFromSource");var Va="(?:xi(?:[A-Z][\\w$]*)?|release|pattern|house|current|[A-Za-z_$][\\w$]*?(?:Xi|Release|Pattern))(?![\\w$])";function An(e,t){let r=$(t),n=[],s=new RegExp(`(?:(?<![\\w$])|\\.)${Va}(?:\\s*:\\s*[A-Za-z_$][\\w$.<>, |[\\]]*?)?\\s*(?:\\[[^\\]\\n]*\\])?\\s*=(?![=>])\\s*[^\\n;]{0,160}?\\bingest\\s*\\(`,"g"),o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:U(t,o.index)});return n}a(An,"extractArkOrderIngestWritesXiFromSource");function Rn(e,t){let r=$(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let l=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];l.length!==0&&n.push({file:e,line:U(t,o.index),keyCount:l.length});}return n}a(Rn,"extractArkOrderReleaseKeyCountsFromSource");function Wa(e){let t=[];for(let r of e.split(",")){let n=/^\s*(['"]?)([A-Za-z_$][\w$]*)\1\s*(?::|$)/.exec(r);n?.[2]&&t.push(n[2]);}return t}a(Wa,"literalKeys");function kn(e,t,r={}){let n=$(t),s=gn(e,t,r),o=[],i=/\.(?:release|proposeRelease)\s*\(\s*\{([^}]*)\}/g,l;for(;(l=i.exec(n))!==null;){let c=n.slice(Math.max(0,l.index-160),l.index);if(hn(pn(c),s))for(let d of Wa(l[1]??""))ln.test(d)&&o.push({file:e,line:U(t,l.index),key:d});}return o}a(kn,"extractArkOrderXiTtlKeysFromSource");function dn(e){let t=[],r=/(['"`])([^'"`\n\\]+)\1/g,n;for(;(n=r.exec(e))!==null;)n[2]&&t.push(n[2]);return t}a(dn,"stringLiterals");function Sn(e,t){let r=$(t);if(!/\bcreateOrderPlane\b/.test(r))return [];let n=new Set,s=/\bcannotObserve\s*:\s*\[([^\]]*)\]/g,o;for(;(o=s.exec(r))!==null;)for(let d of dn(o[1]??""))n.add(d);if(n.size===0)return [];let i=[],l=new Set,c=/\ballowedKinds\s*:\s*\[([^\]]*)\]/g;for(;(o=c.exec(r))!==null;){let d=U(t,o.index);for(let u of dn(o[1]??"")){if(!n.has(u))continue;let f=`${d}:${u}`;l.has(f)||(l.add(f),i.push({file:e,line:d,kind:u}));}}return i}a(Sn,"extractArkOrderBudgetLeaksFromSource");var bn={"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 za(e,t){return !t||t.length===0?true:t.some(r=>Ct(r).test(e))}a(za,"matchesArkOrderAppliesTo");function Ya(e,t=[]){let r=e.trim();return /^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?true:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(Ya,"isDomainRoleLayer");function M(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return {ruleId:bn[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:l?"error":"warning",failsStrict:l,nextAction:le({ruleId:bn[t],fromLayer:o?.fromLayer,target:o?.target})}}a(M,"finding");function _t(e){let t=e.arkOrder;if(!t)return {findings:[],completenessReasons:[]};let r=We(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(M(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 d of e.planeRootHits){let u=c.get(d.matchedRoot)??[];u.push(d),c.set(d.matchedRoot,u);}for(let d of s){let u=c.get(d)??[];if(u.length===0){n.push(M(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(d)} matched no governed files and has no createOrderPlane factory.`,{target:d},r));continue}u.some(f=>f.hasPlaneFactory)||n.push(M(t,"arkorder-missing-plane",u[0].file,1,`ArkOrder plane root ${JSON.stringify(d)} has no createOrderPlane factory.`,{target:d},r));}}let o=new Map(e.layers.map(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let d=c.specifier;if(!d||!ue(d))continue;let u=e.layerForFile(c.from);u&&Ya(u,o.get(u)??[])&&n.push(M(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:u,target:d},r));}for(let c of e.genericUpdates)n.push(M(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(M(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(M(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));for(let c of e.xiTtlKeys??[])n.push(M(t,"arkorder-xi-ttl",c.file,c.line,`\u03BE key ${JSON.stringify(c.key)} is a freshness field; freshness belongs on \u03C3 (freshUntil), never on \u03BE.`,{target:c.key},r));for(let c of e.budgetLeaks??[])n.push(M(t,"arkorder-information-budget",c.file,c.line,`Projection allowedKinds lists ${JSON.stringify(c.kind)}, which informationBudget.cannotObserve denies.`,{target:c.kind},r));let l=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let d=e.layerForFile(c.file);!d||!l.has(d)||za(c.file,t.appliesTo)&&n.push(M(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:d,target:c.key},r));}return n.sort((c,d)=>c.file.localeCompare(d.file)||c.ruleId.localeCompare(d.ruleId)||c.line-d.line),{findings:n,completenessReasons:[]}}a(_t,"evaluateArkOrderSensors");function En(e){if(!e.arkOrder)return [];let t=fn(e.file,e.source),r={planeRoots:e.arkOrder.planeRoots??[]},n=mn(e.file,e.source,r),s=e.arkOrder.xiKeys??[],o=e.fromLayer?[{name:e.fromLayer,patterns:[],intentPrefixes:[...e.intentPrefixes??[]]}]:[];return _t({arkOrder:e.arkOrder,layers:o,planeCalls:t,genericUpdates:n,planeRootHits:[],xiFieldWrites:yn(e.file,e.source,s),ingestWritesXi:An(e.file,e.source),releaseKeyCounts:Rn(e.file,e.source),xiTtlKeys:kn(e.file,e.source,r),budgetLeaks:Sn(e.file,e.source),dependencies:un(e.file,e.source),layerForFile:a(()=>e.fromLayer,"layerForFile"),...e.classification?{classification:e.classification}:{}}).findings.filter(i=>i.sensor==="arkorder-generic-update"||i.sensor==="arkorder-kernel-in-domain"||i.sensor==="arkorder-xi-field-write"||i.sensor==="arkorder-ingest-writes-xi"||i.sensor==="arkorder-too-many-params"||i.sensor==="arkorder-xi-ttl"||i.sensor==="arkorder-information-budget")}a(En,"evaluateArkOrderEditorSensors");function In(e){return {ruleId:e.ruleId,file:e.file,line:e.line,fromLayer:e.fromLayer,target:e.target,message:e.message,severity:e.severity,failsStrict:e.failsStrict,nextAction:e.nextAction}}a(In,"violationFor");function qa(e,t){let r=e.split(/\r?\n/)[t-1]??"",n=r.length-r.trimStart().length;return {loc:{start:{line:t,column:n},end:{line:t,column:Math.max(n,r.length)}}}}a(qa,"lineNode");function vn(e){if(e.importKind==="type"||e.exportKind==="type")return true;let t=e.specifiers??[];return t.length>0&&t.every(r=>r.importKind==="type"||r.exportKind==="type")}a(vn,"isTypeOnlyDeclaration");function wn(e){function t(s){let o=e.lintedFilename(s),i=e.findConfigPath(o),l=i?e.loadArkConfig(i):null;if(!l?.arkOrder||!i)return null;let c=e.toProjectRelative(i,o);return e.sourceIsInAnalysisScope(l,c)?{config:l,relative:c,fromLayer:w(c,l.layers)??null}:null}return a(t,"loadOrderFile"),{noArkOrderKernelInDomain:{meta:{type:"problem",docs:{description:"Disallow Domain-role imports of arkgate/order when arkOrder is on (same ARKORDER_KERNEL_IN_DOMAIN sensor as ark-check)."},messages:{denied:"{{message}}"},schema:[]},create(s){let o=t(s);if(!o?.fromLayer)return {};let{config:i,relative:l}=o,c=a((d,u,f,p)=>{if(typeof u!="string"||!ue(u))return;let g=d.loc?.start?.line??1,{findings:m}=_t({arkOrder:i.arkOrder,layers:i.layers,planeCalls:[],genericUpdates:[],planeRootHits:[],dependencies:[{from:l,specifier:u,kind:p,typeOnly:f,line:g,resolution:"resolved-external"}],layerForFile:a(R=>R===l?o.fromLayer:w(R,i.layers),"layerForFile")});for(let R of m)R.sensor==="arkorder-kernel-in-domain"&&e.reportAdapterDiagnostic(s,d,"denied",In(R),{message:R.message});},"check");return {ImportDeclaration(d){c(d,d.source?.value,vn(d),"import");},ExportNamedDeclaration(d){d.source&&c(d,d.source.value,vn(d),"export");},ExportAllDeclaration(d){c(d,d.source?.value,d.exportKind==="type","export");},ImportExpression(d){d.source?.type==="Literal"&&c(d,d.source.value,false,"dynamic-import");},CallExpression(d){let u=d.arguments?.[0];d.callee?.type==="Identifier"&&d.callee.name==="require"&&u?.type==="Literal"&&!e.isLocallyBound(s,d,"require")&&c(d,u.value,false,"require");}}}},noArkOrderGenericUpdate:{meta:{type:"problem",docs:{description:"Disallow file-local \u03BE rewrites on the order plane: generic update(), \u03BE field writes, ingest\u2192\u03BE, and oversized release() (same ARKORDER_* sensors as ark-check)."},messages:{denied:"{{message}}"},schema:[]},create(s){let o=t(s);return o?{Program(){let i=ce(s)??"",l=En({arkOrder:o.config.arkOrder,file:o.relative,source:i,fromLayer:o.fromLayer}).filter(c=>c.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let c of l)e.reportAdapterDiagnostic(s,qa(i,c.line),"denied",In(c),{message:c.message});}}:{}}}}}a(wn,"createArkOrderEslintRules");var te={type:"array",items:{type:"string",minLength:1},uniqueItems:true},xn={type:"object",additionalProperties:false,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...te,default:[]},kernelRoots:{...te},managedLayers:{...te,default:[]},requireDeclarations:{type:"boolean",default:true},ignoreDirectNewForErrors:{type:"boolean",default:true}}},Cn={type:"object",additionalProperties:false,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...te,default:[]},managedLayers:{...te,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...te,default:[]},appliesTo:{...te,default:[]}}};function Ce(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Ce,"isObject");function Za(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)Ce(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}a(Za,"declaredLayerNames");function _n(e){if(!Ce(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?true:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}a(_n,"defaultedArkRun");function On(e){if(!Ce(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return {...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}a(On,"defaultedArkOrder");function Tn(e,t,r,n){if(!Array.isArray(t))return;let s=Za(e);t.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!s.has(o)&&n.push({path:`$.${r}.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`});});}a(Tn,"validateManagedLayersDeclared");function Ln(e,t){let r=e.arkRun;if(r===void 0||!Ce(r))return;let n=r.managedLayers;if(Tn(e,n,"arkRun",t),r.mode==="enforced"){let s=r.kernelRoots??r.compositionRoots;(!Array.isArray(s)||s.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(n)||n.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"});}}a(Ln,"validateArkRunExtra");function Nn(e,t){let r=e.arkOrder;if(r===void 0||!Ce(r))return;let n=r.managedLayers;if(Tn(e,n,"arkOrder",t),r.mode==="enforced"){let s=r.planeRoots;(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(n)||n.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"});}}a(Nn,"validateArkOrderExtra");var et={type:"array",items:{type:"string",minLength:1},uniqueItems:true},Un={description:'deny blocks every shared-root import of a slice. deny-cross-parent leaves that hop as a warning and, in ark-check and CI only, reports a slice that reaches another universe through a shared root. The write hook and ESLint see one edge and do not block it. The object form { mode: "deny-cross-parent", stopAt } names composition roots (bootstrap, DI registrations) the whole-graph walk never starts at or passes through; a stop file must still sit under sharedRoots, and stopAt does not silence the direct SHARED_IMPORTS_SLICE warning. arkgate 4.8.22 and older reject deny-cross-parent. arkgate 4.8.23 and older reject the object form (must be one of deny, deny-cross-parent).',oneOf:[{type:"string",enum:["deny","deny-cross-parent"]},{type:"object",additionalProperties:false,required:["mode","stopAt"],properties:{mode:{type:"string",enum:["deny-cross-parent"]},stopAt:{...et,minItems:1}}}]},jn={type:"object",additionalProperties:false,required:["sliceFolders"],description:`Optional inner wall under this rule. Runs only on a rule with peerIsolation: true and allowed: false; elsewhere it is inert and ark-check warns CONFIG_CHILD_SLICES_INERT (config load still accepts it, as 4.8.23 did). Absent keeps today's universe wall. sliceFolders names children. Flat files are universe common, and so is a commonFolders directory directly under the universe (a folder of that name inside a child belongs to that child). siblings is "deny" (default), "advisory", or { default, enforce, ratchet }. parentMayImportChild defaults to false. message is the text for inner-wall findings. allowedCrossSlice may use a whole-segment *. It clears only a sibling crossing. Cross-parent has no advisory knob. arkgate 4.8.22 and older reject this key. A build that still rejects unknown childSlices fields rejects allowedCrossSlice at config load. A build that still types siblings as a string enum rejects the object at config load.`,properties:{sliceFolders:{...et,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...et,minItems:1},siblings:{description:'"deny" or "advisory", or { default, enforce, ratchet } so listed subtrees are errors while the default stays advisory. ratchet absent: a new advisory crossing fails only when the baseline in use already records an advisory crossing of this rule. ratchet true: any unrecorded advisory crossing fails when a baseline is in use. ratchet false: measure only, never fails. A string-enum build rejects the object at config load (must be one of deny, advisory). arkgate 4.8.23 and older reject ratchet (unknown field).',oneOf:[{type:"string",enum:["deny","advisory"]},{type:"object",additionalProperties:false,required:["default"],properties:{default:{type:"string",enum:["deny","advisory"]},enforce:{...et},ratchet:{type:"boolean"}}}]},parentMayImportChild:{type:"boolean"},message:{type:"string",minLength:1,description:"Text for inner-wall findings (CROSS_SIBLING_SLICE and universe common importing a child). The rule message stays the universe-wall text (CROSS_PARENT_SLICE and fail-closed denies). Absent: ArkGate default text, never the rule message. arkgate 4.8.23 and older reject this field (unknown field)."},arkRulesFile:{type:"string",minLength:1,description:"Filename read at each child slice root this wall already resolved. The only token is <Layer>, replaced with a declared layer name (arkrules.<Layer>.json). No slash and no wildcard. A discovered file that omits appliesTo is scoped to that slice directory. Explicit appliesTo outside the slice fails config load (ARKRULE_SCOPE_ESCAPES_SLICE). The effective id is <childId>#<localId>. A build that rejects unknown childSlices fields fails at config load (unknown field)."},sliceAliases:{type:"array",minItems:1,description:"Maps a source path glob onto a child slice id (universe id plus one child segment) so files outside the slice trees take that universe and child for both walls. A path without a wildcard also covers everything under it, as sharedRoots does. A bare name, a universe id alone, a target outside every universe shape, and a wildcard in to are rejected. Under stars identity a target written against the 4.8.23 stars id (star bindings before the last literal dropped, e.g. api/v1/x for modules/*/api/*) still loads when it maps to one universe shape, and ark-check warns CONFIG_SLICE_LEGACY_STARS_ID with the new id; it is rejected only when it maps to more than one shape. Config load checks only the shape; doctor reports a target universe no file belongs to. The glob may not overlap a slice folder, and two aliases may not match the same file. Doctor lists each unpinned alias as an owed move. pinned true lists the alias separately and does not count it as debt. reason is a doctor label and does not pin by itself. A build that rejects unknown childSlices fields fails at config load (unknown field). arkgate 4.8.22 and older reject childSlices.",items:{type:"object",additionalProperties:false,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},pinned:{type:"boolean",description:"True when a framework forces the path to stay. The alias is not an owed move and does not clear other honesty debt."},reason:{type:"string",minLength:1,description:"Doctor label, such as framework-route. A label alone does not pin."}}}},allowedCrossSlice:{type:"array",minItems:1,description:"Directed child-slice allowances. * matches one whole path segment (features/projects/*). ** and a partial segment are rejected. A bare name is rejected. This list clears only CROSS_SIBLING_SLICE. It cannot clear CROSS_PARENT_SLICE or CROSS_PARENT_VIA_SHARED. The universe allowedCrossSlice still treats * as a literal. A build that rejects unknown childSlices fields fails at config load (unknown field).",items:{type:"object",additionalProperties:false,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}};function C(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(C,"isObject");function tt(e,t){return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(tt,"propertyPath");function Y(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Y,"trimTrailingSlashes");function Gn(e,t){tl(e,t),nl(e,t),al(e,t),bl(e,t),Sl(e,t);}a(Gn,"validateSliceContract");var Dn='must be "deny", "deny-cross-parent", or { "mode": "deny-cross-parent", "stopAt": ["<composition root path or glob>"] }',Pn="must not cover the whole tree. Name the composition root itself (bootstrap file, DI registrations folder).";function Xa(e){return e==="*"||e==="**"}a(Xa,"isWildcardSegment");function Hn(e){let t=e.toLowerCase().split("/").filter(s=>s.length>0&&s!==".");(t[0]==="src"||t[0]==="app")&&(t=t.slice(1));let r=t.length;for(;r>0&&Xa(t[r-1]??"");)r-=1;let n=t.slice(0,r);return n.some(s=>s.includes("*"))?null:n}a(Hn,"coveredFolder");function Ja(e,t){return e.length<=t.length&&e.every((r,n)=>t[n]===r)}a(Ja,"isPrefixOf");function Qa(e,t){let r=e.layers;if(!Array.isArray(r))return [];let n=new Set([t.from,t.to].filter(o=>typeof o=="string")),s=[];for(let o of r){if(!C(o)||typeof o.name!="string"||!n.has(o.name))continue;let i=Array.isArray(o.patterns)?o.patterns:[];for(let l of i){if(typeof l!="string")continue;let c=l.replace(/\\/g,"/").split("/"),d=c.findIndex(p=>p.includes("*")),u=d===-1?c:c.slice(0,d),f=Hn(u.join("/"));f&&s.push(f);}}return s}a(Qa,"ruleLayerFolders");function el(e,t){let r=Y(e.trim().replace(/\\/g,"/"));if(r.length===0)return "must be a non-empty path or glob";let n=r.replace(/^[./]+/,"");if(n===""||n==="*"||n==="**")return Pn;for(let o of r.split("/"))if(o.length===0||o==="."||o==="..")return "must be a path or glob without empty, . or .. segments";let s=Hn(r);return s===null?null:s.length===0?Pn:t.some(o=>Ja(s,o))?"must not cover a whole layer root of this rule. Name the composition root itself (bootstrap file, DI registrations folder).":null}a(el,"stopAtEntryIssue");function tl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!C(n)||n.sharedImportsSlice===void 0)return;let o=n.sharedImportsSlice,i=`$.rules[${s}].sharedImportsSlice`;if(typeof o=="string"){o!=="deny"&&o!=="deny-cross-parent"&&t.push({path:i,message:Dn});return}if(!C(o)){t.push({path:i,message:Dn});return}for(let u of Object.keys(o))u!=="mode"&&u!=="stopAt"&&t.push({path:tt(i,u),message:"unknown field"});o.mode===void 0?t.push({path:`${i}.mode`,message:"is required"}):o.mode!=="deny-cross-parent"&&t.push({path:`${i}.mode`,message:'must be deny-cross-parent. stopAt has no meaning for deny; use the string "deny".'});let l=o.stopAt;if(l===void 0){t.push({path:`${i}.stopAt`,message:"is required"});return}if(!Array.isArray(l)||l.length===0){t.push({path:`${i}.stopAt`,message:"must be a non-empty array of paths or globs"});return}let c=new Set,d=Qa(e,n);l.forEach((u,f)=>{let p=`${i}.stopAt[${f}]`;if(typeof u!="string"){t.push({path:p,message:"must be a non-empty path or glob"});return}let g=el(u,d);if(g){t.push({path:p,message:g});return}let m=Y(u.trim().replace(/\\/g,"/")).toLowerCase();if(c.has(m)){t.push({path:p,message:"duplicate stopAt entry"});return}c.add(m);});});}a(tl,"validateSharedImportsSlice");var rl=["deny","advisory"],Fn='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"], "ratchet": true | false }';function nl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!C(n))return;let o=n.childSlices;if(!C(o)||o.siblings===void 0)return;let i=o.siblings,l=`$.rules[${s}].childSlices.siblings`;if(typeof i=="string"){rl.includes(i)||t.push({path:l,message:Fn});return}if(!C(i)){t.push({path:l,message:Fn});return}for(let d of Object.keys(i))d!=="default"&&d!=="enforce"&&d!=="ratchet"&&t.push({path:tt(l,d),message:"unknown field"});if(i.ratchet!==void 0&&typeof i.ratchet!="boolean"&&t.push({path:`${l}.ratchet`,message:"must be a boolean"}),i.default===void 0?t.push({path:`${l}.default`,message:"is required"}):i.default!=="deny"&&i.default!=="advisory"&&t.push({path:`${l}.default`,message:"must be deny or advisory"}),i.enforce===void 0)return;if(!Array.isArray(i.enforce)){t.push({path:`${l}.enforce`,message:"must be an array of child slice ids or subtree paths"});return}let c=new Set;i.enforce.forEach((d,u)=>{let f=`${l}.enforce[${u}]`;if(typeof d!="string"||d.trim().length===0){t.push({path:f,message:"must be a non-empty child slice id or subtree path"});return}let p=Y(d.trim().replace(/\\/g,"/"));if(p.split("/").some(g=>g.length===0||g==="."||g==="..")){t.push({path:f,message:"must be a child slice id or subtree path without . or .."});return}if(p.includes("*")){t.push({path:f,message:"must be a child slice id or subtree path. * is not a wildcard on siblings.enforce"});return}if(c.has(p)){t.push({path:f,message:"duplicate enforce entry"});return}c.add(p);});});}a(nl,"validateChildSliceSiblings");var sl="must be a slice id with a slash. A bare name is ambiguous across universes.",ol="* matches one whole path segment. ** and a partial segment are not wildcards.";function il(e){let t=Y(e.trim().replace(/\\/g,"/"));if(t.length===0)return "must be a non-empty slice id";if(!t.includes("/"))return sl;let r=t.split("/");for(let n of r){if(n.length===0||n==="."||n==="..")return "must be a slice id without empty, . or .. segments";if(n.includes("*")&&n!=="*")return ol}return null}a(il,"childCrossSlicePatternIssue");function $n(e){return Y(e.trim().replace(/\\/g,"/")).toLowerCase()}a($n,"childCrossSlicePatternKey");function al(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!C(n))return;let o=n.childSlices;if(!C(o)||o.allowedCrossSlice===void 0)return;let i=o.allowedCrossSlice,l=`$.rules[${s}].childSlices.allowedCrossSlice`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } child slice ids"});return}let c=new Set;i.forEach((d,u)=>{let f=`${l}[${u}]`;if(!C(d)){t.push({path:f,message:"must be an object with from and to"});return}for(let g of Object.keys(d))g!=="from"&&g!=="to"&&t.push({path:tt(f,g),message:"unknown field"});for(let g of ["from","to"]){let m=d[g],R=`${f}.${g}`;if(typeof m!="string"||m.trim().length===0){t.push({path:R,message:"must be a non-empty slice id"});continue}let S=il(m);S&&t.push({path:R,message:S});}if(typeof d.from!="string"||typeof d.to!="string")return;let p=`${$n(d.from)}\0${$n(d.to)}`;if(!p.startsWith("\0")&&!p.endsWith("\0")){if(c.has(p)){t.push({path:f,message:"duplicate child slice allowance"});return}c.add(p);}});});}a(al,"validateChildSliceAllowedCrossSlice");var fe="must be a child of a universe shape this rule names (its universe sliceFolders shape plus one child segment). A bare name, a universe id alone, a target outside every universe shape, and a wildcard are rejected. Config load checks the shape only; doctor reports a target universe no file belongs to.",ll="is a 4.8.23 stars id (star bindings before the last literal dropped) that maps to more than one universe shape of this rule. Write the new stars id, which keeps every star binding (e.g. orders/api/v1/x for modules/*/api/*).",cl="overlaps a slice folder. An alias covers only files outside the slice trees.",dl="two slice aliases match the same file";function ul(e){return Y(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(ul,"aliasPathSegments");function fl(e){let t=e[e.length-1];return t===void 0||t.includes("*")?[...e]:[...e,"**"]}a(fl,"aliasSegmentsWithSubtree");function Bn(e){let t=[];for(let r of e){if(r.includes("*"))break;t.push(r);}return t}a(Bn,"concreteGlobPrefix");function _e(e,t){if(e.length>t.length)return false;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return false;return true}a(_e,"segmentsArePrefix");function pl(e){let t=e.split(/[/\\]/).filter(Boolean).map(n=>n.toLowerCase());if(t.length<2||t[0]==="*"||t[0]==="**"||!t.some(n=>n==="*"))return null;let r=[];for(let n of t){if(n==="*"||n==="**")break;if(n.includes("*"))return null;r.push(n);}return r.length>0?r:null}a(pl,"anchoredSlicePrefix");function gl(e,t){let r=Bn(e),n=r.length<e.length,s=r[0]==="src"||r[0]==="app"?r.slice(1):r;return _e(t,r)||_e(t,s)?true:n?_e(r,t)&&r.length<t.length||_e(r,["src",...t])&&r.length<t.length+1||_e(r,["app",...t])&&r.length<t.length+1:false}a(gl,"globOverlapsAnchored");function hl(e,t){for(let n=0;n<e.length;n+=1){if(e[n]!==t&&e[n]!=="*")continue;let s=e.slice(n+1);if(s.length>=2||s.some(o=>o==="*"||o==="**"))return true}let r=Bn(e);return r.length<e.length&&(r.length===0||r.length===1&&(r[0]==="src"||r[0]==="app"))}a(hl,"globOverlapsBare");function ml(e,t){let r=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(r.length===1&&r[0]&&!r[0].includes("*"))return hl(e,r[0]);let n=pl(t);return n?gl(e,n):false}a(ml,"globOverlapsSliceEntry");function yl(e){let t=Y(e.trim().replace(/\\/g,"/"));if(t.length===0)return "must be a non-empty path glob";if(t==="*"||t==="**")return "must not cover the whole tree";for(let r of t.split("/")){if(r.length===0||r==="."||r==="..")return "must be a path glob without empty, . or .. segments";if(!(r==="*"||r==="**")&&(r.includes("*")||r.includes("?")||r.includes("{")||r.includes("[")))return "* matches one whole path segment. ** is a whole segment. A partial segment is not a wildcard."}return null}a(yl,"aliasGlobIssue");function Al(e,t){let r=[];if(!Array.isArray(e))return r;let n=t==="stars";for(let s of e){if(typeof s!="string"||s.length===0)continue;let o=s.split(/[/\\]/).filter(Boolean).map(i=>i.toLowerCase());if(o.length===1&&o[0]&&!o[0].includes("*")){r.push({literals:[o[0],null]});continue}if(!o.some(i=>i==="**"||i.includes("*")&&i!=="*")&&o.includes("*")){if(n){let i=-1;for(let d=0;d<o.length;d+=1)o[d]!=="*"&&(i=d);if(i<0)continue;let l=o.filter((d,u)=>u>=i||d==="*").map(d=>d==="*"?null:d),c=o.slice(i).map(d=>d==="*"?null:d);r.push(c.length===l.length?{literals:l}:{literals:l,legacy:c});continue}r.push({literals:o.map(i=>i==="*"?null:i)});}}return r}a(Al,"universeShapes");function Qe(e,t){return e.literals.length!==t.length?false:e.literals.every((r,n)=>r===null||r===t[n])}a(Qe,"shapeMatches");function Rl(e,t){let r=Y(e.trim().replace(/\\/g,"/"));if(r.length===0||r.split("/").some(o=>o.length===0||o==="."||o==="..")||r.includes("*")||!r.includes("/"))return fe;let n=r.split("/").map(o=>o.toLowerCase());if(t.length===0||t.some(o=>Qe(o,n)))return fe;if(t.some(o=>Qe(o,n.slice(0,-1))))return null;let s=new Set(t.filter(o=>o.legacy!==void 0&&!Qe({literals:o.legacy},n)&&Qe({literals:o.legacy},n.slice(0,-1))).map(o=>o.literals.map(i=>i??"*").join("/")));return s.size===1?null:s.size>1?ll:fe}a(Rl,"aliasTargetIssue");function Mn(e){let t=e[0];return (t==="src"||t==="app")&&e.length>1?[e,e.slice(1)]:[e]}a(Mn,"aliasGlobVariants");function kl(e,t){let r=Mn(e),n=Mn(t);for(let s of r)if(re(s,t,0,0,new Map))return true;for(let s of n)if(re(e,s,0,0,new Map))return true;return false}a(kl,"aliasesCanMatchSameFile");function re(e,t,r,n,s){let o=`${r}:${n}`,i=s.get(o);if(i!==void 0)return i;let l=false;if(r===e.length&&n===t.length)l=true;else if(r<e.length&&e[r]==="**")l=re(e,t,r+1,n,s)||n<t.length&&re(e,t,r,n+1,s);else if(n<t.length&&t[n]==="**")l=re(e,t,r,n+1,s)||r<e.length&&re(e,t,r+1,n,s);else if(r<e.length&&n<t.length){let c=e[r],d=t[n];(c===d||c==="*"||d==="*")&&(l=re(e,t,r+1,n+1,s));}return s.set(o,l),l}a(re,"globsCanMatchSame");var Kn="must be a filename with exactly one <Layer> token and no slash or wildcard (arkrules.<Layer>.json)";function Sl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!C(n))return;let o=n.childSlices;if(!C(o)||o.arkRulesFile===void 0)return;let i=`$.rules[${s}].childSlices.arkRulesFile`,l=o.arkRulesFile;if(typeof l!="string"||l.length===0){t.push({path:i,message:Kn});return}(l.split("<Layer>").length!==2||/[*\\/]/.test(l)||l.includes(".."))&&t.push({path:i,message:Kn});});}a(Sl,"validateChildSliceArkRulesFile");function bl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!C(n))return;let o=n.childSlices;if(!C(o)||o.sliceAliases===void 0)return;let i=o.sliceAliases,l=`$.rules[${s}].childSlices.sliceAliases`;if(!Array.isArray(i)){t.push({path:l,message:"must be an array of { from, to } slice aliases"});return}let c=Al(n.sliceFolders,n.sliceIdentity),d=[...Array.isArray(n.sliceFolders)?n.sliceFolders:[],...Array.isArray(o.sliceFolders)?o.sliceFolders:[]].filter(f=>typeof f=="string"&&f.length>0),u=[];i.forEach((f,p)=>{let g=`${l}[${p}]`;if(!C(f)){t.push({path:g,message:"must be an object with from and to"});return}for(let S of Object.keys(f))S!=="from"&&S!=="to"&&S!=="pinned"&&S!=="reason"&&t.push({path:tt(g,S),message:"unknown field"});let m=f.from,R=f.to;if(typeof m!="string"||m.trim().length===0)t.push({path:`${g}.from`,message:"must be a non-empty path glob"});else {let S=yl(m);if(S)t.push({path:`${g}.from`,message:S});else {let y=fl(ul(m));d.some(A=>ml(y,A))&&t.push({path:`${g}.from`,message:cl});for(let A of u)if(kl(A,y)){t.push({path:g,message:dl});break}u.push(y);}}if(typeof R!="string"||R.trim().length===0)t.push({path:`${g}.to`,message:fe});else {let S=Rl(R,c);S&&t.push({path:`${g}.to`,message:S});}});});}a(bl,"validateChildSliceAliases");function Z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Z,"isObject");function pe(e,t){return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(pe,"propertyPath");function j(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(j,"valueType");function El(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(El,"resolveSchemaRef");function q(e,t,r,n,s){if(t.$ref){let o=El(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}q(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(!Z(e)){s.push({path:r,message:`must be an object; received ${j(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:pe(r,i),message:"is required"});if(t.additionalProperties===false)for(let i of Object.keys(e))i in o||s.push({path:pe(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==true&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||q(e[l],i,pe(r,l),n,s);}for(let[i,l]of Object.entries(o))e[i]!==void 0&&q(e[i],l,pe(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${j(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)=>q(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 ${j(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 ${j(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${j(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`});}}a(q,"validateSchemaNode");function rt(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(rt,"normalizeStewardId");function Vn(e){let t=rt(e);return !t||Ot(t)||t.includes(" ")||t.includes("@")?false:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(Vn,"isGitHubHandle");function Il(e){if(typeof e!="string")return false;let t=e.trim().toLowerCase();if(!t.includes("@")||t.includes(" ")||Ot(t))return false;let r=t.split("@");if(r.length!==2||!r[0]||/\s/.test(t))return false;let n=r[1].lastIndexOf(".");return n>0&&n<r[1].length-1}a(Il,"isGitHubEmail");function vl(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Vn(t[1])?rt(t[1]):null}a(vl,"githubHandleFromEmail");function Wn(e){let t=vl(e);if(t)return t;let r=rt(e);return !r||Ot(r)?null:Vn(r)||Il(r)?r:null}a(Wn,"canonicalStewardId");var wl=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function Ot(e){let t=rt(e);return !t||wl.test(t)}a(Ot,"isAutomationAuthor");var F="1.3",xl=["public","auth","admin","internal"];var Tt="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",zn=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Cl=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function _l(){let e=[];for(let t of zn)for(let r of zn)t===r||Cl.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:false});return e}a(_l,"createDefaultRules");var qn=_l(),Lt=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],_={type:"array",items:{type:"string",minLength:1},uniqueItems:true},Yn={type:"object",additionalProperties:false,required:["$schema","schemaVersion","include","layers","rules"],properties:{$schema:{type:"string",minLength:1,default:Tt,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:F,default:F},name:{type:"string",minLength:1},include:{..._,minItems:1,default:["src"]},exclude:{..._,default:[]},excludeGenerated:{type:"boolean",default:true},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:qn,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{..._,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:false,allowDisabledPeerIsolation:false}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{description:"A project-relative ArkRules path, or a list of paths merged into one catalog for this layer. A string keeps today's behaviour. An older build that types this value as a string rejects an array at config load.",oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:true,items:{type:"string",minLength:1}}]},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{..._,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:false,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{..._,minItems:1},exclude:_,entrypoints:{..._,minItems:1,description:"Optional public surface globs for this layer. When non-empty, cross-layer imports into this layer must target a file matching one of these globs; deep imports into internal layer files are denied."},intentPrefixes:_,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...xl]},owners:{..._,minItems:1},forbiddenGlobals:_,capabilities:{type:"object",additionalProperties:false,properties:{deny:{type:"array",uniqueItems:true,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:false,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:{..._,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"],description:"How a starred sliceFolders prefix is named. Absent and path keep today's ids (every literal and star binding). stars keeps the last literal plus every star binding (a star before the last literal is kept too), so parallel trees share one feature id. Bare names are unchanged."},sharedRoots:{..._,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:false,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}},sharedImportsSlice:Un,childSlices:jn}},safety:{type:"object",additionalProperties:false,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:false},allowDisabledPeerIsolation:{type:"boolean",default:false}}},coverage:{type:"object",additionalProperties:false,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:{..._,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:{..._,minItems:1}}},arkRun:xn,arkOrder:Cn}},G=class extends Error{static{a(this,"ArkConfigValidationError");}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
5
+ ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
6
+ `)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r;}};function Ol(e,t){let r=e.arkRules;if(!(r===void 0||!Z(r)))for(let[n,s]of Object.entries(r)){let o=pe("$.arkRules",n);if(typeof s=="string"){s.length===0&&t.push({path:o,message:"must be a non-empty relative path string"});continue}if(!Array.isArray(s)||s.length===0){t.push({path:o,message:"must be a non-empty path string or an array of paths"});continue}let i=new Set;s.forEach((l,c)=>{let d=`${o}[${c}]`;if(typeof l!="string"||l.length===0){t.push({path:d,message:"must be a non-empty relative path string"});return}i.has(l)&&t.push({path:d,message:"duplicate path"}),i.add(l);});}}a(Ol,"validateArkRulesRefs");function Tl(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,l)=>{typeof i=="string"&&(Wn(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}));});});}a(Tl,"validateLayerOwners");function Ll(e){let t={...e,$schema:e.$schema===void 0?Tt:e.$schema,schemaVersion:e.schemaVersion===void 0?F:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?qn.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=_n(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=On(e.arkOrder)),t}a(Ll,"defaultedConfig");function Nl(e){return e===F?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(Nl,"migratedFromOf");function Dl(){let e=new Set([F]);for(let t of Lt)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(Dl,"knownInputVersions");function Pl(e,t="ark.config.json"){if(!Z(e))throw new G(t,[{path:"$",message:`must be an object; received ${j(e)}`}]);let r=Dl(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${F}`}]);if(n!=="unversioned"&&!r.has(n))throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${F}`}]);let s=n,o={...e},i=0;for(;s!==F&&i<Lt.length+1;){i+=1;let l=Lt.find(c=>c.from===s);if(!l)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${F}`}]);s=l.to,o.schemaVersion=s;}if(s!==F)throw new G(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${F}`}]);return {candidate:Ll(o),migratedFrom:Nl(n)}}a(Pl,"migrateArkConfig");function Fl(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=Pl(e,t),s=[];if(q(r,Yn,"$",Yn,s),Ln(r,s),Nn(r,s),Tl(r,s),Gn(r,s),Ol(r,s),s.length>0)throw new G(t,s);return {config:r,migratedFrom:n}}a(Fl,"loadArkConfigContract");function nt(e,t="ark.config.json"){let r;try{r=JSON.parse(e);}catch(n){throw new G(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Fl(r,t)}a(nt,"parseArkConfigJson");var Oe="1.0",Nt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",$l=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],Ml=["no-anemic-model"],Zn={type:"array",items:{type:"string",minLength:1},uniqueItems:true},Xn={type:"object",additionalProperties:false,required:["schemaVersion","layer"],properties:{$schema:{type:"string",minLength:1,default:Nt},schemaVersion:{type:"string",const:Oe,default:Oe},layer:{type:"string",minLength:1},structure:{type:"array",default:[],items:{$ref:"#/$defs/structureEntry"}},invariants:{type:"array",default:[],items:{$ref:"#/$defs/invariantEntry"}}},$defs:{structureEntry:{type:"object",additionalProperties:false,required:["id","sensor"],properties:{id:{type:"string",minLength:1},sensor:{type:"string",enum:[...$l]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:Zn,description:{type:"string",minLength:1}}},invariantEntry:{type:"object",additionalProperties:false,required:["id","description"],properties:{id:{type:"string",minLength:1},description:{type:"string",minLength:1},aggregate:{type:"string",minLength:1},coverage:{type:"object",additionalProperties:false,properties:{test:{type:"boolean"},symbol:{type:"string",minLength:1}}},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:Zn}}}},ge=class extends Error{static{a(this,"ArkRulesValidationError");}issues;source;constructor(t,r){super(`Invalid ArkRules (${t}):
7
+ ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
8
+ `)}`),this.name="ArkRulesValidationError",this.source=t,this.issues=r;}};function Kl(e){return {...e,$schema:e.$schema===void 0?Nt:e.$schema,schemaVersion:e.schemaVersion===void 0?Oe:e.schemaVersion,structure:e.structure===void 0?[]:e.structure,invariants:e.invariants===void 0?[]:e.invariants}}a(Kl,"defaultedArkRules");function Jn(e){return e==="enforced"?"enforced":"advisory"}a(Jn,"normalizeMode");function Ul(e){return Ml.includes(e)}a(Ul,"isTier2Sensor");function jl(e,t){let r=Array.isArray(e.structure)?e.structure:[],n=Array.isArray(e.invariants)?e.invariants:[],s=new Set;r.forEach((o,i)=>{if(!Z(o))return;let l=typeof o.id=="string"?o.id:"";l&&(s.has(l)&&t.push({path:`$.structure[${i}].id`,message:`duplicate rule id ${JSON.stringify(l)}`}),s.add(l)),typeof o.sensor=="string"&&Ul(o.sensor)&&o.mode==="enforced"&&t.push({path:`$.structure[${i}].mode`,message:`${l?`rule ${JSON.stringify(l)} uses sensor `:"sensor "}${JSON.stringify(o.sensor)}, which is Tier-2 advisory-only and cannot be enforced${l?" (arkgate-check --sensors lists which sensors can)":""}`}),Array.isArray(o.appliesTo)&&o.appliesTo.length===0&&t.push({path:`$.structure[${i}].appliesTo`,message:"must not be an empty array (omit the field to apply to the whole layer)"});}),n.forEach((o,i)=>{if(!Z(o))return;let l=typeof o.id=="string"?o.id:"";l&&(s.has(l)&&t.push({path:`$.invariants[${i}].id`,message:`duplicate rule id ${JSON.stringify(l)}`}),s.add(l)),Array.isArray(o.appliesTo)&&o.appliesTo.length===0&&t.push({path:`$.invariants[${i}].appliesTo`,message:"must not be an empty array (omit the field to apply to the whole layer)"});});}a(jl,"validateSemantics");function Dt(e,t="arkrules.json",r){if(!Z(e))throw new ge(t,[{path:"$",message:`must be an object; received ${j(e)}`}]);let n=Kl(e),s=[];if(q(n,Xn,"$",Xn,s),jl(n,s),r!==void 0&&typeof n.layer=="string"&&n.layer!==r&&s.push({path:"$.layer",message:`must match referencing key ${JSON.stringify(r)}; received ${JSON.stringify(n.layer)}`}),s.length>0)throw new ge(t,s);return {config:n}}a(Dt,"loadArkRulesContract");function st(e,t){return e.childId?`${e.childId}#${t}`:t}a(st,"effectiveRuleId");function Qn(e,t){if(t&&t.length>0)return [...t];if(e.childId&&e.defaultAppliesTo&&e.defaultAppliesTo.length>0)return [...e.defaultAppliesTo]}a(Qn,"effectiveAppliesTo");function es(e,t){return {sourceFile:e.sourceFile,ruleId:st(e,t),layer:e.layer,...e.childId?{childId:e.childId}:{}}}a(es,"provenanceFor");function ts(e,t){let r=t.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),n=e.trim().replace(/\\/g,"/").replace(/^\.\//,"").toLowerCase();if(!n||!r||n.includes(".."))return false;if(n===r||n===`${r}/**`||n===`${r}/*`)return true;if(n.startsWith(`${r}/`)){let i=n.slice(r.length+1).split("/"),l=i.indexOf("**");return l!==-1&&l!==i.length-1?false:i.every(c=>c.length>0)}let s=r.replace(/^(?:src|app)\//,""),o=n.replace(/^(?:src|app)\//,"");return s!==r||o!==n?ts(o,s):false}a(ts,"appliesToPatternInsideSlice");function rs(e){if(!e.childId||!e.defaultAppliesTo?.length)return [];let t=String(e.defaultAppliesTo[0]).replace(/\/\*\*$/,""),r=[],n=[...e.file.structure??[],...e.file.invariants??[]];for(let s of n)for(let o of s.appliesTo??[])ts(o,t)||r.push({id:s.id,pattern:o});return r}a(rs,"sliceScopeEscapes");function ns(e){let t=new Map,r=new Map;for(let n of e){let s=[...(n.file.structure??[]).map(o=>o.id),...(n.file.invariants??[]).map(o=>o.id)];for(let o of s){let i=st(n,o),l=`${n.layer}\0${i}`,c=t.get(l);if(!c){t.set(l,{id:i,layer:n.layer,sourceFiles:[n.sourceFile]});continue}let d=r.get(l)??{id:i,layer:n.layer,sourceFiles:[...c.sourceFiles]};d.sourceFiles.includes(n.sourceFile)||d.sourceFiles.push(n.sourceFile),r.set(l,d);}}return [...r.values()]}a(ns,"duplicateArkRuleIds");function ss(e){let t={},r=[],n=[],s=[...e].sort((o,i)=>o.layer.localeCompare(i.layer)||o.sourceFile.localeCompare(i.sourceFile));for(let o of s){let i=(o.file.structure??[]).map(d=>{let u=Qn(o,d.appliesTo);return {...d,id:st(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:Jn(d.mode),provenance:es(o,d.id)}}),l=(o.file.invariants??[]).map(d=>{let u=Qn(o,d.appliesTo);return {...d,id:st(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:Jn(d.mode),provenance:es(o,d.id)}}),c=t[o.layer];c?(c.sourceFiles||(c.sourceFiles=[c.sourceFile]),c.sourceFiles.includes(o.sourceFile)||c.sourceFiles.push(o.sourceFile),c.structure.push(...i),c.invariants.push(...l)):t[o.layer]={sourceFile:o.sourceFile,sourceFiles:[o.sourceFile],structure:i,invariants:l},r.push(...i),n.push(...l);}return r.sort((o,i)=>{let l=o.provenance.layer.localeCompare(i.provenance.layer);return l!==0?l:o.id.localeCompare(i.id)}),n.sort((o,i)=>{let l=o.provenance.layer.localeCompare(i.provenance.layer);return l!==0?l:o.id.localeCompare(i.id)}),{schemaVersion:Oe,byLayer:t,structure:r,invariants:n}}a(ss,"buildEffectiveArkRules");function ne(){return {schemaVersion:Oe,byLayer:{},structure:[],invariants:[]}}a(ne,"emptyEffectiveArkRules");var Pt=class extends Error{static{a(this,"EffectiveContractError");}issues;source;constructor(t,r){super(`Invalid Effective Contract (${t}):
9
+ ${r.map(n=>`- ${n.path}: ${n.message}`).join(`
10
+ `)}`),this.name="EffectiveContractError",this.source=t,this.issues=r;}};function os(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}a(os,"normalizeRel");function is(e,t="ark.config.json"){let r=e.config.arkRules??{},n=[],s=Object.keys(r).length>0,o=!!(e.governedFiles&&e.governedFiles.length>0);if(!s&&!o){if(e.discoveredArkRulesFiles&&e.discoveredArkRulesFiles.length>0)for(let f of [...e.discoveredArkRulesFiles].sort())n.push({path:f,message:`ArkRules file ${JSON.stringify(f)} is not referenced by arkRules and will not be enforced`,severity:"advisory"});return {config:e.config,arkRules:ne(),warnings:n}}let i=new Set(e.config.layers.map(f=>f.name)),l=[],c=[],d=new Set,u=a((f,p,g)=>{if(g instanceof ge){for(let m of g.issues)l.push({path:`${f}${m.path==="$"?"":m.path.replace(/^\$/,"")}`,message:`${p}: ${m.message}`});return}if(g instanceof SyntaxError){l.push({path:f,message:`referenced ArkRules file ${JSON.stringify(p)} is not valid JSON: ${g.message}`});return}l.push({path:f,message:`referenced ArkRules file ${JSON.stringify(p)} failed to load: ${g instanceof Error?g.message:String(g)}`});},"pushLoadIssue");for(let f of Object.keys(r).sort()){let p=r[f],g=`$.arkRules[${JSON.stringify(f)}]`,m=Array.isArray(p)?p:typeof p=="string"?[p]:null;if(!m||m.length===0||m.some(R=>typeof R!="string"||R.length===0)){l.push({path:g,message:"must be a non-empty path string or an array of paths"});continue}if(!i.has(f)){l.push({path:g,message:`layer ${JSON.stringify(f)} is not declared in layers[]`});continue}m.forEach((R,S)=>{let y=m.length===1&&typeof p=="string"?g:`${g}[${S}]`;if(R.startsWith("/")||/^[A-Za-z]:[\\/]/.test(R)){l.push({path:y,message:"must be a project-relative path (absolute paths are not allowed)"});return}let A=os(R);d.add(A);let k=e.fileContents[A]??e.fileContents[R];if(k===void 0){l.push({path:y,message:`referenced ArkRules file ${JSON.stringify(A)} is missing`});return}try{let I=Dt(JSON.parse(k),A,f);c.push({layer:f,sourceFile:A,file:I.config});}catch(I){u(y,A,I);}});}if(e.governedFiles&&e.governedFiles.length>0){let f=$e({files:e.governedFiles,rules:e.config.rules,layers:[...i]});for(let p of f){let g=e.fileContents[p.path];if(g!==void 0){d.add(p.path);try{let m=Dt(JSON.parse(g),p.path,p.layer),R={layer:p.layer,sourceFile:p.path,file:m.config,childId:p.childId,defaultAppliesTo:p.defaultAppliesTo},S=rs(R);if(S.length>0){l.push({path:p.path,message:`ARKRULE_SCOPE_ESCAPES_SLICE: ${p.path} appliesTo ${S.map(y=>y.pattern).join(", ")} escapes ${p.childId}`});continue}c.push(R);}catch(m){u(p.path,p.path,m);}}}}for(let f of ns(c))l.push({path:`$.arkRules[${JSON.stringify(f.layer)}]`,message:`ARKRULE_DUPLICATE_ID: ${f.id} is declared in ${f.sourceFiles.join(", ")}`});if(e.discoveredArkRulesFiles)for(let f of [...e.discoveredArkRulesFiles].sort()){let p=os(f);d.has(p)||n.push({path:p,message:`ArkRules file ${JSON.stringify(p)} is not referenced by arkRules and will not be enforced`,severity:"advisory"});}if(l.length>0)throw new Pt(t,l);return {config:e.config,arkRules:ss(c),warnings:n}}a(is,"resolveEffectiveContract");var Gl=2e3,as=new Map;function ls(e){try{return H.statSync(e).isFile()}catch{return false}}a(ls,"isFile");function $t(e){let t=as.get(e);if(t){if(t.found!==null&&ls(t.found))return t.found;if(t.found===null&&Date.now()-t.at<Gl)return null}let r=E.join(e,"ark.config.json"),n;if(ls(r))n=r;else {let s=E.dirname(e);n=s===e?null:$t(s);}return as.set(e,{found:n,at:Date.now()}),n}a($t,"findConfigInDir");function D(e){return !e||e==="<input>"||e.startsWith("stdin")?null:$t(E.dirname(E.resolve(e)))}a(D,"findConfigPath");var he=new Map,Hl=64;function Bl(e){try{let t=H.statSync(e,{throwIfNoEntry:!1});return t?.isFile()?`${t.mtimeMs}:${t.size}:${t.ino}`:null}catch{return null}}a(Bl,"configFileStamp");function Vl(e,t){if(!he.has(e)&&he.size>=Hl){let r=he.keys().next().value;r!==void 0&&he.delete(r);}he.set(e,t);}a(Vl,"rememberContract");var Wl=/\.[cm]?[tj]sx?$/,zl=/(^test(?:[-_.]).*|\.(spec|test)(?:-d)?\.)(tsx?|jsx?|mjsx?|cjsx?|mts|cts)$/i,Yl=new Set(["node_modules","dist","coverage","bench","benches","benchmark","benchmarks","docs","documentation","example","examples","fixture","fixtures","testdata","playground","scaffold","scaffolds","__tests__","__mocks__","e2e","test","tests"]);function ql(e){return Wl.test(e)&&!e.endsWith(".d.ts")&&!zl.test(e)}a(ql,"isGovernableSourceName");function Zl(e){let t=e?.arkRules;if(!t||typeof t!="object")return [];let r=[];for(let n of Object.values(t))if(typeof n=="string"&&n.length>0)r.push(n);else if(Array.isArray(n))for(let s of n)typeof s=="string"&&s.length>0&&r.push(s);return r}a(Zl,"arkRulesRefs");function ps(e,t){let r=t.include&&t.include.length>0?t.include:["src"],n=[],s=a(o=>{let i;try{i=H.readdirSync(o,{withFileTypes:!0});}catch{return}for(let l of i){if(l.name.startsWith("."))continue;let c=E.join(o,l.name);if(l.isDirectory()){if(Yl.has(l.name))continue;s(c);continue}if(!l.isFile()||!ql(l.name))continue;let d=E.relative(e,c).split(E.sep).join("/");!d||d.startsWith("..")||ut(d,t)||n.push(d);}},"walk");for(let o of r){let i=String(o).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");s(E.resolve(e,i==="."?"":i));}return n}a(ps,"governedRelativeFiles");function Xl(e,t){return $e({files:t,rules:e.rules,layers:e.layers.map(r=>r.name)}).map(r=>r.path)}a(Xl,"plannedSlicePaths");function Jl(e,t){let r=t.replace(/\\/g,"/").replace(/^\.\//,""),n=E.resolve(e,r),s=E.relative(e,n);if(!(s.startsWith("..")||E.isAbsolute(s)))try{return H.readFileSync(n,"utf8")}catch{return}}a(Jl,"readReferencedFile");function gs(e,t){if(!e)return [];let r=new Set,n=[],s=a(o=>{let i=o.replace(/\\/g,"/").replace(/^\.\//,"");!i||r.has(i)||(r.add(i),n.push(i));},"add");for(let o of Zl(e))s(o);for(let o of Xl(e,t))s(o);return n}a(gs,"contractSourcePaths");function Ft(e,t){let r=t?ps(e,t):[];return gs(t,r).map(n=>{try{let s=H.statSync(E.resolve(e,n));return `${n}:${s.mtimeMs}:${s.size}`}catch{return `${n}:missing`}}).join("|")}a(Ft,"refStampsFor");function cs(e){return e instanceof Error?e.message:String(e)}a(cs,"errorText");function Ql(e,t){let r=E.dirname(e),n;try{n=nt(t,e).config;}catch(c){return {config:null,arkRules:ne(),error:cs(c),fingerprint:null}}let s=ps(r,n),o=gs(n,s),i=createHash("sha256").update(t);if(o.length===0)return {config:n,arkRules:ne(),error:null,fingerprint:i.digest("hex")};let l={};for(let c of o){let d=Jl(r,c);if(d===void 0)continue;let u=c.replace(/\\/g,"/").replace(/^\.\//,"");l[u]=d,i.update(`\0${u}\0${d}`);}try{let c=is({config:n,fileContents:l,governedFiles:s},e);return {config:n,arkRules:c.arkRules,error:null,fingerprint:i.digest("hex")}}catch(c){return {config:null,arkRules:ne(),error:cs(c),fingerprint:null}}}a(Ql,"resolveContract");function me(e){let t=E.dirname(e),r=Bl(e),n=he.get(e);if(n&&r!==null&&n.stamp===r&&Ft(t,n.refConfig)===n.refStamps)return n.result;let s;try{s=H.readFileSync(e,"utf8");}catch{return {config:null,arkRules:ne(),error:null,fingerprint:null}}if(n?.source===s&&Ft(t,n.refConfig)===n.refStamps)return n.stamp=r,n.result;let o=Ql(e,s),i=o.config??ec(s,e);return Vl(e,{source:s,stamp:r,refConfig:i,refStamps:Ft(t,i),result:o}),o}a(me,"loadArkContract");function ec(e,t){try{return nt(e,t).config}catch{return null}}a(ec,"safeConfig");function tc(e){if(!H.existsSync(e))return null;let t=me(e);return t.config?t.config:nt(H.readFileSync(e,"utf8"),e).config}a(tc,"loadArkConfig");function X(e,t){return (e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!ut(t,e)}a(X,"sourceIsInAnalysisScope");function ot(e,t,r){let n=E.isAbsolute(r)?r:E.resolve(r),s=E.relative(t,n).split(E.sep).join("/");if(!X(e,s))return null;let o=e.layers?.find(i=>i.name===w(s,e.layers));return {relFile:s,layer:o}}a(ot,"lintedFileInScope");function B(e){return e?me(e).config:null}a(B,"configForRule");var ds="configInvalid",rc="Ark contract is invalid, so no architecture verdict is possible (fix it; ark-check fails closed the same way): {{detail}}",us=new WeakSet;function Mt(e){let t=D(e);return t?me(t).error:null}a(Mt,"contractErrorForFile");function P(e){return {meta:{...e.meta,messages:{...e.meta.messages,[ds]:rc,[ze]:Zr}},create(t){let r=Mt(x(t));return r?{Program(n){let s=W(t);if(s&&typeof s=="object"){if(us.has(s))return;us.add(s);}t.report({...n?.loc?.start?{node:n}:{loc:{line:1,column:0}},messageId:ds,data:{detail:r.replace(/\s*\n\s*/g," ")}});}}:Ye(e,t,"blocking")}}}a(P,"withContractGuard");function hs(e=process.cwd()){let t=$t(E.resolve(e));if(!t)return null;let r=me(t);if(r.fingerprint)return r.fingerprint;try{return createHash("sha256").update(H.readFileSync(t,"utf8")).digest("hex")}catch{return null}}a(hs,"contractFingerprint");var sc=256*1024;function oc(e){try{return H.readFileSync(e,"utf8")}catch{return ""}}a(oc,"readUtf8");function ic(e,t){if(!/\.(tsx?|mts|cts)$/i.test(e))return [];try{return ve(e,t)}catch{return []}}a(ic,"classShapesFor");function ac(e,t){if(!/\.(tsx?|mts|cts|jsx?|mjs|cjs)$/i.test(e)||e.endsWith(".d.ts"))return {};if(t.length>sc)return {};let r=Kr(e,t);return r?{[e]:r}:{}}a(ac,"hintsFor");function ms(e){return {meta:{type:"problem",docs:{description:"Report ArkRules structure-sensor findings for the linted file (same Effective Contract and evaluators as ark-check; file-local sensors only)."},messages:{structure:"ArkRules {{arkruleId}} ({{sensor}}): {{message}}"},schema:[]},create(t){let r=x(t),n=D(r);if(!n||!r)return {};let s=me(n),o=s.config;if(!o||s.arkRules.structure.length===0)return {};let i=E.dirname(n),l=E.resolve(r),c=E.relative(i,l).split(E.sep).join("/");if(!e(o,c))return {};let d=w(c,o.layers);return {Program(u){let f=ce(t)??oc(l),p=Mr({arkRules:s.arkRules,classShapes:ic(c,f),files:[c],layerForFile:a(g=>g===c?d:w(g,o.layers),"layerForFile"),fileHints:ac(c,f)}).filter(g=>g.file===c);for(let g of p)L(t,{loc:{start:{line:g.line}},parent:u},"structure",{ruleId:g.ruleId,code:g.code,file:c,line:g.line,fromLayer:g.fromLayer,arkruleId:g.arkruleId,arkruleSource:g.arkruleSource,severity:g.severity,failsStrict:g.failsStrict,message:g.message},{arkruleId:g.arkruleId,sensor:g.sensor,message:g.message});}}}}}a(ms,"createArkRulesStructureRule");function ys(e,t,r){for(let n=t.length;n>=r;n-=1){let s=t.slice(0,n).join(".");if(e.has(s))return s}}a(ys,"longestForbidden");var As={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:false}]},create(e){let t=x(e),r=e.options?.[0],n=D(t),s=B(n),o=n?E.dirname(n):null,i=null,l="this layer";if(s&&o&&t){let y=ot(s,o,t);if(!y)return {};let{layer:A}=y;A?.forbiddenGlobals?.length?(i=new Set(A.forbiddenGlobals),l=A.name):i=null;}else r?.globals&&(i=new Set(r.globals));if(!i)return {};let c=i,d=typeof W(e)?.getScope=="function",u=E.isAbsolute(t)?t:E.resolve(t),f=o?E.relative(o,u).split(E.sep).join("/"):t,p=a((y,A)=>{L(e,y,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:A,message:`${l} must not use the ambient global "${A}".`},{name:A,layer:l});},"report"),g=a((y,A,k,I)=>{if(k||typeof A!="string")return;let O=Me(A,c);O&&L(e,y,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:A,edgeKind:I,message:`${l} must not use module "${A}" because it is the import form of forbidden global "${O}".`},{layer:l,name:O,specifier:A,importKind:I});},"reportModule"),m=a((y,A)=>{if(y?.type==="ObjectPattern")for(let k of y.properties??[]){if(k.type==="RestElement")continue;let I=vt(k.key,k.computed);if(!I)continue;let O=[...A,I],ke=ys(c,O,A.length+1);if(ke){p(k,ke);continue}let se=k.value,Ps=se?.type==="AssignmentPattern"?se.left:se;m(Ps,O);}},"checkPattern"),R=a((y,A)=>{if(y?.type!=="ObjectPattern")return;let k=we(A);if(!k||z(e,k.root,k.segments[0]))return;let I=k.segments[0]==="globalThis"?k.segments.slice(1):k.segments;m(y,I);},"checkDestructure"),S=de(e,g);return {MemberExpression(y){if(y.parent?.type==="MemberExpression"&&y.parent.object===y)return;let A=we(y);if(!A||z(e,A.root,A.segments[0]))return;let k=A.segments[0]==="globalThis",I=k?A.segments.slice(1):A.segments,O=ys(c,I,k?1:2);O?p(y,O):!d&&c.has(A.segments[0])&&p(y,A.segments[0]);},VariableDeclarator(y){R(y.id,y.init);},AssignmentExpression(y){R(y.left,y.right);},CallExpression(y){if(S.CallExpression(y),d)return;let A=y.callee?.type==="Identifier"?y.callee.name:void 0;A&&c.has(A)&&p(y,A);},ImportDeclaration:S.ImportDeclaration,ImportExpression:S.ImportExpression,TSImportEqualsDeclaration:S.TSImportEqualsDeclaration,ExportNamedDeclaration:S.ExportNamedDeclaration,ExportAllDeclaration:S.ExportAllDeclaration,NewExpression(y){if(d)return;let A=y.callee?.type==="Identifier"?y.callee.name:void 0;A&&c.has(A)&&p(y,A);},Identifier(y){!d||!y.name||!c.has(y.name)||!tn(e,y)||z(e,y,y.name)||p(y,y.name);}}}};function Rs(e,t){if(!(e?.type&&e.type!=="ObjectExpression"))return e?.properties?.find(r=>Ze(r.key)===t)}a(Rs,"objectProperty");function ye(e,t){return Rs(e,t)!==void 0}a(ye,"objectHasProperty");function lc(e){let t=Rs(e,"metadata")?.value;return ye(t,"source")}a(lc,"objectHasMetadataSource");function ks(e){let t=e.callee;return t?.type==="Identifier"?t.name==="publish":t?.computed!==true&&Ze(t?.property)==="publish"}a(ks,"isPublishCall");function Ss(e){return e?e.type==="Identifier"||e.type===void 0&&e.name?/^[A-Z]/.test(e.name??""):e.type==="MemberExpression"&&e.computed!==true?Ss(e.property):false:false}a(Ss,"looksLikeIntentCreator");function cc(e){let t=xe(e);return t!==void 0&&be(t)||ye(e,"intent")||Ss(e)}a(cc,"isArkPublishCandidate");function dc(e){let[t,r,n]=e;return lc(t)||ye(r,"source")||ye(n,"source")}a(dc,"publishHasSource");function uc(e){let t=x(e),r=D(t),n=B(r);if(!n||!r||!t)return null;let s=E.relative(E.dirname(r),E.resolve(t)).split(E.sep).join("/");return X(n,s)?s:null}a(uc,"scopedFile");var bs={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],s=pt({publishCall:ks(t),rawIntentName:xe(r),objectHasIntent:ye(r,"intent"),arkPublishCandidate:false,hasSource:true}).find(o=>o.ruleId==="RAW_EVENT_PUBLISH");s&&L(e,t,"rawPublish",{...s,file:x(e)});}}}},Es={meta:{type:"problem",docs:{description:"Require Ark publish calls (intent creator / Ark intent first argument) to include source metadata. Silent without an ark.config.json or outside its include scope, like ark-check."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){let t=uc(e);return t?{CallExpression(r){let n=r.arguments??[],s=n[0],i=pt({publishCall:ks(r),rawIntentName:xe(s),objectHasIntent:ye(s,"intent"),arkPublishCandidate:cc(s),hasSource:dc(n)}).find(l=>l.ruleId==="PUBLISH_MISSING_SOURCE");i&&L(e,r,"missingSource",{...i,file:t});}}:{}}};function Is(e,t){let r=t,n=e.length;for(;;){for(;r<n&&/\s/.test(e[r]);)r+=1;if(e[r]==="/"&&e[r+1]==="/"){for(;r<n&&e[r]!==`
11
+ `;)r+=1;continue}if(e[r]==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2);r=s<0?n:s+2;continue}return r}}a(Is,"skipTrivia");function fc(e){let t=e.replace(/^/,""),r="",n=0,s=t.length;for(;n<s;){let o=t[n];if(o==='"'){let i=n+1;for(;i<s&&t[i]!=='"';)i+=t[i]==="\\"?2:1;r+=t.slice(n,i+1),n=i+1;continue}if(o==="/"&&(t[n+1]==="/"||t[n+1]==="*")){r+=" ",n=Is(t,n);continue}if(o===","){let i=Is(t,n+1);if(t[i]==="}"||t[i]==="]"){n+=1;continue}}r+=o,n+=1;}return r}a(fc,"stripJsonc");function vs(e){return JSON.parse(fc(e))}a(vs,"parseJsonc");var ws=new Map,Ae=new Map,pc=64;function Kt(e){try{let t=H.statSync(e);return `${t.mtimeMs}:${t.size}`}catch{return "missing"}}a(Kt,"fileStamp");function J(e){try{return H.statSync(e).isFile()}catch{return false}}a(J,"isFile");function xs(e){let t=E.resolve(e),r=ws.get(t);if(r!==void 0&&(r===null||J(r)))return r;let n=E.join(t,"tsconfig.json"),s;if(J(n))s=n;else {let o=E.dirname(t);s=o===t?null:xs(o);}return ws.set(t,s),s}a(xs,"findNearestTsconfig");function gc(e,t){let r=e;for(;;){let n=E.join(r,"node_modules",t);for(let i of [n,`${n}.json`])if(J(i))return i;let s=E.join(n,"package.json");if(J(s))try{let i=JSON.parse(H.readFileSync(s,"utf8"));if(typeof i.tsconfig=="string"&&J(E.join(n,i.tsconfig)))return E.join(n,i.tsconfig)}catch{}if(J(E.join(n,"tsconfig.json")))return E.join(n,"tsconfig.json");let o=E.dirname(r);if(o===r)return null;r=o;}}a(gc,"resolvePackageExtends");function hc(e,t){let r=E.dirname(e);if(t.startsWith(".")||E.isAbsolute(t)){let n=E.resolve(r,t);for(let s of [n,`${n}.json`])if(J(s))return s;return null}return gc(r,t)}a(hc,"resolveExtends");function Ut(e,t){return e.split("${configDir}").join(t)}a(Ut,"substituteConfigDir");function Cs(e,t,r,n,s){if(r>8||n.has(e))return {};n.add(e),s.push({file:e,stamp:Kt(e)});let o;try{o=vs(H.readFileSync(e,"utf8"))??{};}catch{return {}}let i={},l=o.extends,c=typeof l=="string"?[l]:Array.isArray(l)?l:[];for(let f of c){if(typeof f!="string")continue;let p=Ut(f,t),g=hc(e,p);if(!g){if(p.startsWith(".")||E.isAbsolute(p)){let R=E.resolve(E.dirname(e),p);for(let S of [R,`${R}.json`])s.push({file:S,stamp:Kt(S)});}continue}let m=Cs(g,t,r+1,n,s);m.baseUrl!==void 0&&(i.baseUrl=m.baseUrl),m.paths!==void 0&&(i.paths=m.paths,i.pathsBase=m.pathsBase);}let d=o.compilerOptions??{},u=E.dirname(e);return typeof d.baseUrl=="string"&&(i.baseUrl=E.resolve(u,Ut(d.baseUrl,t))),d.paths&&typeof d.paths=="object"&&(i.paths=d.paths,i.pathsBase=u),i}a(Cs,"loadChain");function mc(e,t){let r=e.baseUrl??e.pathsBase??t,n=[];for(let[s,o]of Object.entries(e.paths??{})){if(!Array.isArray(o)||o.length===0)continue;let i=o.filter(f=>typeof f=="string").map(f=>Ut(f,t));if(i.length===0)continue;let l=s.indexOf("*"),c=l>=0,d=c?s.slice(0,l):s,u=c?s.slice(l+1):"";c&&!d&&!u||n.push({from:d,to:i[0].replace(/\*$/,""),suffix:u,wildcard:c,targets:i});}return n.sort((s,o)=>Number(s.wildcard)-Number(o.wildcard)||o.from.length-s.from.length),{baseUrl:r,aliases:n}}a(mc,"buildAliasSet");function yc(e){let t=Ae.get(e);if(t&&t.chain.every(i=>Kt(i.file)===i.stamp))return t.result;let r=[],n=E.dirname(e),s=Cs(e,n,0,new Set,r),o=mc(s,n);if(!Ae.has(e)&&Ae.size>=pc){let i=Ae.keys().next().value;i!==void 0&&Ae.delete(i);}return Ae.set(e,{chain:r,result:o}),o}a(yc,"aliasesForTsconfig");function _s(e){let t=xs(e);return t?yc(t):{baseUrl:E.resolve(e),aliases:[]}}a(_s,"readTsconfigPathAliases");function Os(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,E.join(e,"index.ts"),E.join(e,"index.tsx"),E.join(e,"index.js")];for(let r of t)if(J(r))return r;return null}a(Os,"existingSourceFile");function Ts(e,t){if(!t.startsWith("."))return null;let r=E.resolve(E.dirname(e),t);return Os(r)}a(Ts,"resolveRelativeImport");function Ac(e,t){return e.wildcard?!t.startsWith(e.from)||!t.endsWith(e.suffix)||t.length<e.from.length+e.suffix.length?null:t.slice(e.from.length,t.length-e.suffix.length):t===e.from?"":null}a(Ac,"matchAlias");function jt(e,t,r){if(!t)return null;if(t.startsWith("."))return Ts(e,t);let n=e?E.dirname(E.resolve(e)):r??".",{baseUrl:s,aliases:o}=_s(n);for(let i of o){let l=Ac(i,t);if(l!==null){for(let c of i.targets){let d=i.wildcard?c.split("*").join(l):c,u=Os(E.resolve(s,d));if(u)return u}return null}}return null}a(jt,"resolveImportSpecifier");var Rc="4.8.27";function kc(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(kc,"containingProgram");function Sc(e){let t=kc(e)?.body;if(!t)return false;let r=false;for(let n of t){if(n.type==="ImportDeclaration"){if(!Xe(n))return false;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 false}else if(!Xe(n))return false;r=true;continue}return false}}return r}a(Sc,"sourceProgramExportsOnlyTypes");var Ls={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{message}} Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=x(e),r=D(t),n=B(r),s=r?E.dirname(r):null,o=a(i=>{let l=qe(i.source);if(l&&n&&s&&t){let c=E.isAbsolute(t)?t:E.resolve(t),d=E.relative(s,c).split(E.sep).join("/");if(!X(n,d))return;let u=w(d,n.layers);if(!u)return;let f=jt(c,l,s);if(!f)return;let p=E.relative(s,f).split(E.sep).join("/");if(p.startsWith(".."))return;let g=w(p,n.layers);if(!g)return;let m={fromPath:d,toPath:p,layers:n.layers},R=dt(n.rules,u,g,m),S=R?.rule;if(S){let y=i.type?.startsWith("Export")?"export":"import",A=Xe(i),k=!!S?.peerIsolation,I=A&&!k,O=R?.sliceVerdict,ke=O?dr({surface:"import",verdict:O,fromLayer:u,toLayer:g,kind:y,fromPath:d,toPath:p,ruleMessage:S?.message,childMessage:S?.childSlices?.message}):S?.message??`${u} must not ${y} ${g}.`,se=I?`${ke} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:ke;L(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:g,target:p,edgeKind:y,...k?{peerIsolation:true}:{},...A?{typeOnly:true}:{},...ur(O),...I?{failsStrict:false,severity:"warning"}:{},...Sc(i)?{sourcePureTypeModule:true}:{},message:se},{fromLayer:u,toLayer:g,specifier:l,message:se});}return}},"check");return {ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},bc={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=x(e),r=D(t),n=B(r),s=r?E.dirname(r):null;if(!n||!s||!t)return {};let o=ot(n,s,t);if(!o?.layer)return {};let{relFile:i,layer:l}=o,c=new Set(gr(l));return c.size===0?{}:de(e,a((u,f,p,g)=>{if(p||typeof f!="string"||Me(f,l.forbiddenGlobals??[]))return;let m=pr(f);!m||!c.has(m)||L(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:l.name,target:f,capability:m,edgeKind:g,message:`${l.name} denies the ${m} capability; found import of "${f}".`},{layer:l.name,capability:m,specifier:f});},"check"))}},Re=an({findConfigPath:D,loadArkConfig:B,resolveImportSpecifier:jt,lintedFilename:x,sourceIsInAnalysisScope:X,isLocallyBound:z,reportAdapterDiagnostic:L});function Ec(e,t){let r=E.dirname(E.resolve(e));return E.relative(r,E.resolve(t)).split(E.sep).join("/")}a(Ec,"toProjectRelative");var ct=wn({findConfigPath:D,loadArkConfig:B,lintedFilename:x,sourceIsInAnalysisScope:X,isLocallyBound:z,reportAdapterDiagnostic:L,toProjectRelative:Ec}),Ns=ms(X),Ic=[Ls,Re.noArkRunKernelInDomain,Re.noArkRunDirectNew,Re.noArkRunTransportBypass,ct.noArkOrderKernelInDomain,ct.noArkOrderGenericUpdate,Ns],vc={meta:{type:"problem",docs:{description:"Report non-blocking Ark findings (type-only placement debt, advisory slice walls, advisory arkRun / arkOrder / ArkRules) as warnings \u2014 the same findings ark-check reports as warnings."},messages:{[It]:qr},schema:[]},create(e){return Mt(x(e))?{}:Qr(Ic.map(t=>Ye(t,e,"advisory")))}},wc=P(Ls),xc=P(bs),Cc=P(Es),_c=P(As),Oc=P(bc),Tc=P(Re.noArkRunKernelInDomain),Lc=P(Re.noArkRunDirectNew),Nc=P(Re.noArkRunTransportBypass),Dc=P(ct.noArkOrderKernelInDomain),Pc=P(ct.noArkOrderGenericUpdate),Fc=P(Ns),$c=vc,Mc={"no-domain-infra-imports":wc,"no-raw-event-publish":xc,"require-publish-source":Cc,"no-forbidden-globals":_c,"no-denied-capabilities":Oc,"no-arkrun-kernel-in-domain":Tc,"no-arkrun-direct-new":Lc,"no-arkrun-transport-bypass":Nc,"no-arkorder-kernel-in-domain":Dc,"no-arkorder-generic-update":Pc,"arkrules-structure":Fc,"architecture-advisory":$c},Kc={"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","ark/arkrules-structure":"error","ark/architecture-advisory":"warn"},Gt={meta:{name:"arkgate",version:Rc},rules:Mc};function Uc(){let e=hs();return {plugins:{ark:Gt},rules:{...Kc},...e?{settings:{ark:{contractHash:e}}}:{}}}a(Uc,"recommendedConfig");var Ds={};Object.defineProperty(Ds,"recommended",{enumerable:true,configurable:true,get:Uc});Gt.configs=Ds;var Kf=Gt;export{$c as architectureAdvisory,Fc as arkRulesStructureRule,Ds as configs,hs as contractFingerprint,Kf as default,D as findConfigPath,T as globToRegExp,Eo as isEdgeDenied,w as layerForRelativePath,tc as loadArkConfig,Pc as noArkOrderGenericUpdate,Dc as noArkOrderKernelInDomain,Lc as noArkRunDirectNew,Tc as noArkRunKernelInDomain,Nc as noArkRunTransportBypass,Oc as noDeniedCapabilities,wc as noDomainInfraImports,_c as noForbiddenGlobals,xc as noRawEventPublish,tr as patternSpecificity,Gt as plugin,_s as readTsconfigPathAliases,Cc as requirePublishSource,jt as resolveImportSpecifier,Ts as resolveRelativeImport,Mc as rules};