arkgate 4.8.24 → 4.8.25

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 (166) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +2 -2
  3. package/bin/ark-check-runtime.mjs +17 -14
  4. package/bin/ark-layer-match.mjs +115 -13
  5. package/bin/ark-mcp-runtime.mjs +36 -31
  6. package/bin/ark-shared.mjs +4 -23
  7. package/bin/lib/adoption-stance.mjs +2 -2
  8. package/bin/lib/adr-path.mjs +3 -3
  9. package/bin/lib/agent-gates.mjs +0 -61
  10. package/bin/lib/agent-homes.mjs +12 -21
  11. package/bin/lib/agent-projection-command.mjs +4 -4
  12. package/bin/lib/ambient-state.mjs +9 -30
  13. package/bin/lib/analysis-engine.mjs +14 -14
  14. package/bin/lib/architecture-scan.mjs +11 -9
  15. package/bin/lib/ark-order-doctor.mjs +3 -28
  16. package/bin/lib/ark-order-facts.mjs +6 -99
  17. package/bin/lib/ark-order-types.mjs +1 -2
  18. package/bin/lib/ark-run-doctor.mjs +3 -28
  19. package/bin/lib/ark-run-facts.mjs +30 -40
  20. package/bin/lib/ark-run-sensors.mjs +1 -1
  21. package/bin/lib/arkrule-file-hints.mjs +2 -47
  22. package/bin/lib/arkrules-contract.mjs +124 -133
  23. package/bin/lib/arkrules-sensors.mjs +7 -5
  24. package/bin/lib/check-args.mjs +63 -1
  25. package/bin/lib/ci-and-commands.mjs +8 -72
  26. package/bin/lib/ci-merge-boundary.mjs +1 -1
  27. package/bin/lib/class-source-scan.mjs +5 -5
  28. package/bin/lib/clone-detection.mjs +474 -0
  29. package/bin/lib/codex-home.mjs +1 -1
  30. package/bin/lib/config-contract-slices.mjs +44 -6
  31. package/bin/lib/config-contract.mjs +40 -117
  32. package/bin/lib/config-extras.mjs +16 -22
  33. package/bin/lib/contract-smells.mjs +33 -15
  34. package/bin/lib/core-ratchet.mjs +0 -2
  35. package/bin/lib/dashboard-cli.mjs +2 -2
  36. package/bin/lib/deep-module-coach.mjs +2 -4
  37. package/bin/lib/deploy-path.mjs +13 -38
  38. package/bin/lib/design-smells.mjs +2 -2
  39. package/bin/lib/diagnostic-catalog.mjs +8 -1
  40. package/bin/lib/doctor-advisories.mjs +55 -9
  41. package/bin/lib/doctor-green-cite.mjs +1 -1
  42. package/bin/lib/doctor-human.mjs +1 -1
  43. package/bin/lib/doctor-next-actions.mjs +2 -2
  44. package/bin/lib/doctor-plan.mjs +4 -6
  45. package/bin/lib/duplication-io.mjs +572 -0
  46. package/bin/lib/effective-contract-load.mjs +181 -44
  47. package/bin/lib/entry-points-io.mjs +424 -0
  48. package/bin/lib/extra-merge-teeth.mjs +36 -0
  49. package/bin/lib/field-install.mjs +38 -14
  50. package/bin/lib/first-run-help.mjs +7 -3
  51. package/bin/lib/flat-parent-importers.mjs +5 -3
  52. package/bin/lib/gate-files.mjs +30 -89
  53. package/bin/lib/github-enforcement.mjs +165 -28
  54. package/bin/lib/golden-pattern.mjs +1 -1
  55. package/bin/lib/hook-templates.mjs +16 -16
  56. package/bin/lib/html-report-advisories.mjs +4 -0
  57. package/bin/lib/html-report-depth.mjs +2 -2
  58. package/bin/lib/html-report.mjs +2 -2
  59. package/bin/lib/import-graph-projection.mjs +112 -0
  60. package/bin/lib/improvement-compass-doctor.mjs +1 -24
  61. package/bin/lib/invariant-coverage-io.mjs +4 -3
  62. package/bin/lib/invariant-coverage.mjs +26 -0
  63. package/bin/lib/invariant-probe-cli.mjs +347 -0
  64. package/bin/lib/invariant-probe-io.mjs +165 -0
  65. package/bin/lib/invariant-probe-runner.mjs +268 -0
  66. package/bin/lib/invariant-probe-sites.mjs +174 -0
  67. package/bin/lib/invariant-probe-workspace.mjs +183 -0
  68. package/bin/lib/invariant-probe.mjs +461 -0
  69. package/bin/lib/invariant-tests-path.mjs +16 -22
  70. package/bin/lib/literal-path-drift.mjs +4 -2
  71. package/bin/lib/managed-upgrade.mjs +2 -8
  72. package/bin/lib/mcp-adoption.mjs +4 -5
  73. package/bin/lib/mcp-hook-payload.mjs +4 -4
  74. package/bin/lib/orphan-modules-io.mjs +458 -0
  75. package/bin/lib/orphan-modules.mjs +251 -0
  76. package/bin/lib/outside-importers.mjs +197 -0
  77. package/bin/lib/package-manager.mjs +3 -3
  78. package/bin/lib/parse-health.mjs +1 -1
  79. package/bin/lib/persistence-write-hint.mjs +33 -8
  80. package/bin/lib/pin-dependent-gates.mjs +2 -2
  81. package/bin/lib/policy-delta-io.mjs +55 -8
  82. package/bin/lib/post-green-path.mjs +1 -1
  83. package/bin/lib/prepare-change.mjs +3 -9
  84. package/bin/lib/prepare-write.mjs +1 -2
  85. package/bin/lib/presets.mjs +56 -68
  86. package/bin/lib/product-copy.mjs +1 -6
  87. package/bin/lib/project-root.mjs +31 -62
  88. package/bin/lib/resolved-candidate-facts.mjs +90 -62
  89. package/bin/lib/rules-under-contract.mjs +72 -8
  90. package/bin/lib/scan-files.mjs +4 -4
  91. package/bin/lib/schema-validation.mjs +130 -0
  92. package/bin/lib/sensor-promote-cli.mjs +2 -11
  93. package/bin/lib/sensor-promote-io.mjs +33 -22
  94. package/bin/lib/sensor-promotion.mjs +1 -1
  95. package/bin/lib/skill-catalog-apply.mjs +1 -1
  96. package/bin/lib/skill-install.mjs +42 -38
  97. package/bin/lib/snippet-analysis.mjs +1 -1
  98. package/bin/lib/start-install-recovery.mjs +1 -1
  99. package/bin/lib/start-preview.mjs +1 -1
  100. package/bin/lib/states-transitions-presence.mjs +3 -3
  101. package/bin/lib/status-command.mjs +2 -18
  102. package/bin/lib/status-manifest.mjs +18 -26
  103. package/bin/lib/status-transition-catalog.mjs +0 -6
  104. package/bin/lib/suggestions.mjs +3 -3
  105. package/bin/lib/team-parliament-io.mjs +3 -17
  106. package/bin/lib/team-parliament.mjs +15 -9
  107. package/bin/lib/upgrade-behavior-changes.mjs +2 -2
  108. package/bin/lib/upgrade-command.mjs +2 -24
  109. package/bin/lib/upgrade-outcome.mjs +1 -1
  110. package/bin/lib/upstream-report.mjs +21 -10
  111. package/bin/lib/violations.mjs +10 -9
  112. package/bin/lib/weakest-link.mjs +13 -0
  113. package/bin/lib/write-path-capabilities.mjs +2 -2
  114. package/dist/chunk-AHACEKSV.js +16 -0
  115. package/dist/chunk-UN5EH4QV.cjs +16 -0
  116. package/dist/{configTypes-BJbaeoj4.d.cts → configTypes-GPvvdleM.d.cts} +12 -1
  117. package/dist/{configTypes-BJbaeoj4.d.ts → configTypes-GPvvdleM.d.ts} +12 -1
  118. package/dist/eslint/index.cjs +11 -11
  119. package/dist/eslint/index.d.cts +10 -1
  120. package/dist/eslint/index.d.ts +10 -1
  121. package/dist/eslint/index.js +11 -11
  122. package/dist/index.cjs +34 -34
  123. package/dist/index.d.cts +587 -515
  124. package/dist/index.d.ts +587 -515
  125. package/dist/index.js +34 -34
  126. package/dist/nestjs/index.cjs +1 -1
  127. package/dist/nestjs/index.d.cts +1 -1
  128. package/dist/nestjs/index.d.ts +1 -1
  129. package/dist/nestjs/index.js +1 -1
  130. package/dist/order/index.cjs +1 -1
  131. package/dist/order/index.js +1 -1
  132. package/dist/runtime/index.cjs +12 -12
  133. package/dist/runtime/index.d.cts +174 -136
  134. package/dist/runtime/index.d.ts +174 -136
  135. package/dist/runtime/index.js +12 -12
  136. package/dist/{types-DRinG-vT.d.cts → types-CnauMQQL.d.cts} +33 -25
  137. package/dist/{types-DRinG-vT.d.ts → types-CnauMQQL.d.ts} +33 -25
  138. package/docs/README.md +2 -1
  139. package/docs/agent-guide.md +134 -2
  140. package/docs/ai-gates.md +15 -1
  141. package/docs/configuration.md +40 -11
  142. package/docs/diagnostics.md +118 -2
  143. package/docs/package-surface.md +4 -1
  144. package/docs/product-voice.md +7 -1
  145. package/package.json +11 -2
  146. package/schemas/ark.config.schema.json +31 -3
  147. package/schemas/ark.invariant-probe.schema.json +368 -0
  148. package/server.json +2 -2
  149. package/templates/agent-skills/README.md +1 -1
  150. package/templates/agent-skills/ark-adopt/SKILL.md +1 -0
  151. package/templates/agent-skills/ark-contract/SKILL.md +17 -0
  152. package/templates/agent-skills/ark-coverage/SKILL.md +2 -0
  153. package/templates/agent-skills/ark-explore/SKILL.md +7 -0
  154. package/templates/agent-skills/ark-fix/SKILL.md +20 -0
  155. package/templates/agent-skills/ark-place/SKILL.md +8 -0
  156. package/templates/skills/ark-adopt.md +1 -0
  157. package/templates/skills/ark-contract.md +17 -0
  158. package/templates/skills/ark-coverage.md +2 -0
  159. package/templates/skills/ark-explore.md +7 -0
  160. package/templates/skills/ark-fix.md +20 -0
  161. package/templates/skills/ark-place.md +8 -0
  162. package/bin/lib/ark-order-error.mjs +0 -18
  163. package/bin/lib/ark-order-invariants.mjs +0 -388
  164. package/bin/lib/stable-hash.mjs +0 -90
  165. package/dist/chunk-MBXCFLO4.js +0 -16
  166. package/dist/chunk-RNQHRDCQ.cjs +0 -16
@@ -1,14 +1,14 @@
1
- "use strict";var Us=Object.create;var Ae=Object.defineProperty;var Gs=Object.getOwnPropertyDescriptor;var Hs=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,Bs=Object.prototype.hasOwnProperty;var a=(e,t)=>Ae(e,"name",{value:t,configurable:!0});var zs=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},Wt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Hs(t))!Bs.call(e,s)&&s!==r&&Ae(e,s,{get:()=>t[s],enumerable:!(n=Gs(t,s))||n.enumerable});return e};var D=(e,t,r)=>(r=e!=null?Us(Vs(e)):{},Wt(t||!e||!e.__esModule?Ae(r,"default",{value:e,enumerable:!0}):r,e)),Ws=e=>Wt(Ae({},"__esModule",{value:!0}),e);var xc={};zs(xc,{architectureAdvisory:()=>Ks,arkRulesStructureRule:()=>Ms,configs:()=>zt,contractFingerprint:()=>jt,default:()=>vc,findConfigPath:()=>O,globToRegExp:()=>F,isEdgeDenied:()=>hr,layerForRelativePath:()=>v,loadArkConfig:()=>ls,noArkOrderGenericUpdate:()=>$s,noArkOrderKernelInDomain:()=>Ps,noArkRunDirectNew:()=>Ds,noArkRunKernelInDomain:()=>Ls,noArkRunTransportBypass:()=>Fs,noDeniedCapabilities:()=>Ts,noDomainInfraImports:()=>_s,noForbiddenGlobals:()=>Ns,noRawEventPublish:()=>Cs,patternSpecificity:()=>dt,plugin:()=>at,readTsconfigPathAliases:()=>Vt,requirePublishSource:()=>Os,resolveImportSpecifier:()=>ot,resolveRelativeImport:()=>Bt,rules:()=>js});module.exports=Ws(xc);var w=D(require("path"),1);function qs(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(qs,"sharedImportsSliceMode");var qt=new Map;function Yt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Yt,"escapeLiteral");function $e(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($e,"normalizeGlobSeparators");function Ys(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}a(Ys,"bracesBalanced");function F(e){let t=qt.get(e);if(t)return t;let r=$e(e),n=Ys(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Yt(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+=Yt(c)}let i=new RegExp(`^${s}$`);return qt.set(e,i),i}a(F,"globToRegExp");function Zs(e){return $e(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}a(Zs,"concreteGlobSegments");function dt(e,t){let r=$e(String(e)),n=Zs(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(dt,"patternSpecificity");function v(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>F(i).test(r))){for(let i of o.patterns??[])if(F(i).test(r)){let l=dt(i,r);l>s&&(s=l,n=o.name)}}return n}a(v,"layerForRelativePath");function ut(e,t,r){return ar(e,t,r==="stars"?"stars":"path")}a(ut,"sliceIdForPath");function Zt(e,t){return ar(e,t?[...t]:void 0,ir)}a(Zt,"legacyStarsSliceIdForPath");var ir="stars-4.8.23";function ar(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=Xs(o);if(i.anchored){let l=eo(n,i.anchored,r);if(l)return l;continue}i.bare!==void 0&&s.add(i.bare)}return no(n,s)}a(ar,"sliceIdWithBinding");var Pe=new Map;function Xs(e){let t=Pe.get(e);if(t)return t;let r={};return Js(e)?r={anchored:Qs(e)}:!e.includes("/")&&!e.includes("\\")&&!e.includes("*")&&(r={bare:e.toLowerCase()}),Pe.size>=1024&&Pe.clear(),Pe.set(e,r),r}a(Xs,"parsedSliceFolder");function Js(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(r=>r==="*")}a(Js,"isAnchoredSliceEntry");function Qs(e){return e.split(/[/\\]/).filter(t=>t.length>0).map(t=>t.toLowerCase())}a(Qs,"anchoredSlicePattern");function eo(e,t,r){let n=lr(e,t[0]??"");for(let s of n){let o=to(e,t,s,r);if(o)return o}}a(eo,"anchoredSliceIdFromPattern");function to(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(!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 n===ir?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(to,"bindAnchoredSlice");function ro(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(ro,"starsKeptSegmentIndexes");function no(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(no,"bareSliceId");function so(e){let t=new Set;for(let r of e??[]){let s=$e(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(so,"inferSliceFoldersFromPatterns");function oo(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 so(n?.patterns)}a(oo,"resolveSliceFolders");function Xt(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(Xt,"normalizeSegments");function Re(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Re,"trimTrailingSlashes");var io=["src","app"];function lr(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return io.includes(r)&&n!==r?[0,1]:[0]}a(lr,"anchorOffsets");function ao(e){let t=Re(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(ao,"isBlanketRoot");function Jt(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Xt(r);for(let o of t){if(typeof o!="string"||o.length===0||ao(o))continue;if(o.includes("*")){let c=Re(o.toLowerCase());if(F(c).test(n)||F(`${c}/**`).test(n))return!0;continue}let i=Xt(o);if(i.length===0)continue;let l=lr(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(Jt,"pathUnderSharedRoot");function Qt(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}a(Qt,"sliceMatchesDeclaration");function er(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Qt(n.from,t)&&Qt(n.to,r))}a(er,"crossSliceEdgeAllowed");function lo(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:e.sharedImportsSlice==="deny"&&e.fromShared===!0&&e.toSlice&&!e.fromSlice?{denied:!0,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}a(lo,"peerIsolationDecision");function cr(e){return Re(e.trim().replace(/\\/g,"/")).toLowerCase()}a(cr,"aliasGlobPattern");function co(e,t){let r=cr(e);if(!r||r==="*"||r==="**")return!1;let n=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=ct(n),o=F(r),l=(r.split("/").pop()??"").includes("*")?null:F(`${r}/**`),c=a(d=>o.test(d)||l!==null&&l.test(d),"hit");return c(n)||s!==n&&c(s)}a(co,"aliasGlobMatches");function dr(e){let t=cr(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(dr,"splitAliasTarget");function ur(e,t){for(let r of t.childSlices?.sliceAliases??[])if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&co(r.from,e))return r;return null}a(ur,"firstSliceAliasEntry");function uo(e,t){let r=ur(e,t);return r?dr(r.to):null}a(uo,"firstSliceAlias");function fo(e,t,r){if(!e)return{};let n=r??t.sliceFolders,s=ut(e,n?[...n]:void 0,t.sliceIdentity),o=lt(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=uo(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(fo,"resolveGovernedSlice");function po(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=ro(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(po,"starsUniverseShapes");function tr(e,t){return e.length===t.length&&e.every((r,n)=>r===null||t[n]==="*"||r===t[n])}a(tr,"literalsMatch");function go(e,t){let r=t.split("/").filter(Boolean).map(o=>o.toLowerCase()),n=po(e);if(r.length===0||n.some(o=>tr(o.literals,r)))return[];let s=new Set;for(let o of n)if(o.legacy.length!==o.literals.length&&tr(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(go,"legacyStarsIdTargets");function ho(e,t){if(e.sliceIdentity!=="stars")return;let r=dr(t);if(r)return go(e.sliceFolders,r.universeId).length===1?r.universeId:void 0}a(ho,"legacyAliasUniverse");function rr(e,t,r){let n=fo(e,t,r);if(!e||t.sliceIdentity!=="stars")return n;if(n.universeId){let s=ur(e,t);if(!ut(e,[...r],t.sliceIdentity)&&s&&ho(t,s.to)!==void 0)return{...n,legacyAlias:!0,legacyUniverse:n.universeId,legacyChild:n.childId};let i=Zt(e,r),l=t.childSlices,c=l?.sliceIdentity==="stars"?Zt(e,l.sliceFolders):void 0;return{...n,...i?{legacyUniverse:i}:{},...c&&n.childId?{legacyChild:c}:{}}}return n}a(rr,"placeForPair");function mo(e,t,r,n){let s=rr(r,e,t),o=rr(n,e,t),i=s.legacyUniverse,l=o.legacyUniverse,c=a((A,S)=>{if(!A.legacyAlias||S.legacyAlias||!S.universeId||S.legacyUniverse?.toLowerCase()!==A.universeId?.toLowerCase())return A;let m=A.childId?.split("/").pop();return{...A,universeId:S.universeId,...m?{childId:`${S.universeId}/${m}`}:{}}},"adopt"),d=c(s,o),u=c(o,s),f=er(e.allowedCrossSlice,d.universeId,u.universeId)||e.sliceIdentity==="stars"&&(i!==d.universeId||l!==u.universeId)&&er(e.allowedCrossSlice,i,l),g=e.childSlices?.sliceIdentity==="stars"&&s.legacyChild!==void 0&&o.legacyChild!==void 0&&s.legacyChild!==o.legacyChild&&fr(e.childSlices.allowedCrossSlice,s.legacyChild,o.legacyChild),p=a(A=>({...A.universeId?{universeId:A.universeId}:{},...A.childId?{childId:A.childId}:{}}),"strip");return{from:p(d),to:p(u),crossSliceAllowed:f,legacyChildAllowed:g}}a(mo,"resolveGovernedSlicePair");function yo(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(yo,"peerIsolationDenyExplanation");function Ao(e,t){return`cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(Ao,"crossParentExplanation");function Ro(e,t,r){return`cross-sibling slice ${e} \u2192 ${t} inside ${r}.`}a(Ro,"crossSiblingExplanation");function ko(e){return`universe common imports child ${e}. parentMayImportChild is off.`}a(ko,"parentImportsChildExplanation");function nr(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(nr,"universePairLabel");function So(e,t){if(!e||!t?.length)return!1;let r=e.toLowerCase();return t.some(n=>typeof n=="string"&&n.length>0&&n.toLowerCase()===r)}a(So,"isCommonFolderName");function lt(e,t,r){if(!e||!r?.sliceFolders?.length)return{};let n=ut(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 So(i,r.commonFolders)?{}:{childId:n}}a(lt,"resolveChildSliceId");function bo(e){return Re(e.trim().replace(/\\/g,"/")).toLowerCase()}a(bo,"siblingEntryKey");function ct(e){return e.replace(/^(?:src|app)\//,"")}a(ct,"stripSrcOrApp");function Eo(e,t){let r=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),n=ct(t);if(!n)return!1;let s=ct(r);return r===n||r.startsWith(`${n}/`)||s===n||s.startsWith(`${n}/`)}a(Eo,"pathUnderSubtree");function Io(e,t,r){if(!t||!r?.length)return!1;let n=t.toLowerCase();for(let s of r){if(typeof s!="string")continue;let o=bo(s);if(!(!o||o.includes("*"))&&(n===o||e&&Eo(e,o)))return!0}return!1}a(Io,"importerInEnforcedSubtree");function wo(e,t,r){return e==null||e==="deny"?!1:e==="advisory"?!0:e.default==="deny"?!1:!Io(t,r,e.enforce)}a(wo,"siblingCrossingAdvisory");function sr(e){if(typeof e!="string")return null;let t=Re(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(sr,"childSlicePatternSegments");function or(e,t){let r=sr(e),n=sr(t);if(!r||!n||r.length!==n.length)return!1;for(let s=0;s<r.length;s+=1){let o=r[s];if(o!=="*"&&o!==n[s])return!1}return!0}a(or,"childSlicePatternMatches");function fr(e,t,r){if(!e?.length)return!1;for(let n of e)if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&or(n.from,t)&&or(n.to,r))return!0;return!1}a(fr,"childCrossSliceAllowed");function vo(e){let t=lo({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:qs(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?Ao(e.fromSlice,e.toSlice):yo(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??lt(e.fromPath,e.fromSlice,r).childId,s=e.toChild??lt(e.toPath,e.toSlice,r).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return n&&s&&n!==s?e.legacyChildAllowed||fr(r.allowedCrossSlice,n,s)?o:{crossing:"cross-sibling",decision:wo(r.siblings,e.fromPath,n)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:Ro(n,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!n&&s&&r.parentMayImportChild!==!0?{crossing:"parent-imports-child",decision:"deny",explanation:ko(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(vo,"evaluateNestedSliceWall");function xo(e){return e?.crossing==="cross-sibling"||e?.crossing==="parent-imports-child"}a(xo,"isChildWallCrossing");function pr(e){let t=e.verdict.explanation,r=xo(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(pr,"composeSliceDenialMessage");function gr(e){if(!e||e.decision==="allow")return{};let t=nr(e.fromUniverse),r=nr(e.toUniverse);return{...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&r?{universeFrom:t,universeTo:r}:{},...e.decision==="advisory"?{failsStrict:!1,severity:"warning"}:{}}}a(gr,"sliceFindingExtras");function _o(e,t,r,n){return ft(e,t,r,n)?.rule}a(_o,"findDeniedEdgeRule");function ft(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,l=oo(s,t,n?.layers),c=mo(s,l,o,i),d=c.from,u=c.to,f=d.universeId,g=u.universeId,p=vo({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:g,fromChild:d.childId,toChild:u.childId,fromShared:!f&&Jt(o,s.sharedRoots),toShared:!g&&Jt(i,s.sharedRoots),crossSliceAllowed:c.crossSliceAllowed,legacyChildAllowed:c.legacyChildAllowed});if(p.decision!=="allow")return{rule:s,peerIsolationReason:p.peerIsolationReason,fromSlice:f,toSlice:g,sliceVerdict:p};continue}if(t!==r)return{rule:s}}}a(ft,"findDeniedEdgeDecision");function hr(e,t,r,n){return _o(e,t,r,n)!==void 0}a(hr,"isEdgeDenied");var Co=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Oo(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Co,...t]}a(Oo,"scanExcludePatterns");function mr(e,t){let r=String(e).split(/[/\\]/).join("/");return Oo(t).some(n=>F(n).test(r))}a(mr,"isScanExcludedRelative");var yr=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),No=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Nc=Object.freeze(Object.keys(No).sort()),pt=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"}),To=Object.freeze({process:Object.freeze(["process","node:process"])});function Ar(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=pt[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=pt[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:pt[e.slice(0,o)]??null}a(Ar,"capabilityForModuleSpecifier");function Me(e,t){for(let r of t)if(To[r]?.includes(e))return r;return null}a(Me,"forbiddenGlobalForModuleSpecifier");function Rr(e){if(e?.pure===!0)return[...yr].sort();let r=(e?.capabilities?.deny??[]).filter(n=>yr.includes(n));return[...new Set(r)].sort()}a(Rr,"effectiveCapabilityDeny");var vt=D(require("fs"),1),Y=D(require("path"),1);var kr={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."},Lo=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 ke(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(ke,"looksLikeArkIntent");function gt(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ke(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:kr.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:kr.PUBLISH_MISSING_SOURCE}),t}a(gt,"classifyPublishFacts");var Do=["createArkKernel","createStrictArkKernel","createLenientArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig","createLenientArkKernelFromConfig"],Fo="ArkModule",Po=["forRoot","forRootAsync"],$o=["ArkKernel","EventBus","EventPublisher","ArkRunPublisher"],Er=new Set(["eventBus"]),Mo=new Set(["publisher","eventBus"]),Ko=new Set(Po),jo=new Set($o);var Ke=new Set(Do),Uo=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"]),Ir=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function J(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")||e==="arkgate/nestjs"||e.startsWith("arkgate/nestjs/")}a(J,"isArkRunKernelModuleSpecifier");var Go=["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"],ht=new Set(Go);function wr(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(ht.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(ht.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:ht.has(e.slice(0,n))}a(wr,"isArkRunTransportBypassSpecifier");function mt(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(mt,"arkRunKernelCallKind");function vr(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}a(vr,"lineAt");function yt(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(yt,"stripCommentsPreservingLines");function Ho(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(Ho,"firstStringLiteralArg");function Sr(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(Sr,"keywordBefore");function Se(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(Se,"parseValueImportClause");function xr(e,t){Se(yt(e),t)}a(xr,"forEachArkRunValueImportClause");function Vo(e){let t=new Map,r=new Set;return Se(e,(n,s)=>{if(!J(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let l=/\{([^}]*)\}/.exec(n);if(l?.[1])for(let c of l[1].split(",")){let d=c.trim();if(!d||d.startsWith("type "))continue;let u=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(d);if(u){t.set(u[2],u[1]);continue}let f=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(d);f?.[1]&&t.set(f[1],f[1])}}),{named:t,namespaces:r}}a(Vo,"collectKernelImportBindings");function Bo(e,t){let r=new Set(t);return Se(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let l=i.trim();if(!l||l.startsWith("type "))continue;let c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(l),d=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(l)?.[1],u=c?.[1]??d;!d||!u||!/^[A-Z]/.test(u)||(J(s)||t.has(u)||t.has(d))&&(r.add(d),r.add(u))}}),r}a(Bo,"collectImportedConstructors");function zo(e,t){let r;return Se(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}a(zo,"importedFromForName");function Wo(e){let t=new Set,r=/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;){if(!J(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;jo.has(c)&&t.add(d)}}return t}a(Wo,"collectKernelTypeNames");function qo(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!1;let n=t.named.get(r[0]);return n!==void 0&&Ke.has(n)}a(qo,"isFactoryCalleeExpression");function Yo(e,t,r,n){Se(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(Yo,"addRootModuleImports");function Zo(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=!0;d;){d=!1;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=!0);for(s.lastIndex=0;(c=s.exec(e))!==null;)r.has(c[2])&&(!Mo.has(c[3])&&!t.rootNamespaces.has(c[2])||r.has(c[1])||(r.add(c[1]),d=!0));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 g=f[1],p=f[2]??g;if(Er.has(g)){if(r.has(p))continue;r.add(p),d=!0}else mt(g)&&!Ke.has(g)&&n.add(p)}}}a(Zo,"addDerivedReceivers");function Xo(e,t,r){let n={receivers:new Set,calleeBindings:new Set,rootNamespaces:new Set};r&&Yo(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;)qo(o[2].replace(/\s+/g,""),t)&&n.receivers.add(o[1]);let i=Wo(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 Zo(e,n),n}a(Xo,"traceKernelReceivers");function Jo(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(Jo,"matchingOpenParen");function br(e){let t=e.split(".").map(r=>r.trim()).filter(r=>r.length>0);return t[0]==="this"?t.slice(1):t}a(br,"chainParts");function Qo(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:!1}:{parts:br(n[1].replace(/\?/g,"")),viaPublisherCall:!1}}let s=/\)\s*\??\.\s*$/.exec(r);if(!s)return;let o=t-r.length+s.index,i=Jo(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:br(c[1].replace(/\?/g,"")),viaPublisherCall:!0}:{parts:["<expr>"],viaPublisherCall:!1}}a(Qo,"receiverChainBefore");function ei(e,t,r){let[n,...s]=e.parts;return n?s.length===0&&t.namespaces.has(n)?!0:Ir.has(n)||!r.receivers.has(n)?!1:(r.rootNamespaces.has(n)?s.slice(1):s).every(i=>Er.has(i)):!1}a(ei,"chainReachesKernel");function ti(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(ti,"collectDefinedIntentNames");function ri(e,t){return/^\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(e.slice(t))?.[1]}a(ri,"firstIdentifierArg");function ni(e,t){return ke(e)?!0:(t??[]).some(r=>{let n=r.trim();if(!n)return!1;let s=n.endsWith(".")?n:`${n}.`;return e.startsWith(s)&&/^[A-Za-z0-9_.]+$/.test(e.slice(s.length))})}a(ni,"carriesIntentPrefix");function si(e){if(!e)return;if(e.viaPublisherCall)return"publisher";let t=e.parts[e.parts.length-1];return t==="<expr>"?void 0:t}a(si,"receiverName");function oi(e,t,r){if(!e||t===void 0||!ni(t,r))return!1;let n=e.parts[0];return n!==void 0&&n!=="<expr>"&&!Ir.has(n)}a(oi,"untracedKernelNameEvidence");function je(e,t,r={}){let n=yt(t),s=Vo(n),o=Xo(n,s,r.isKernelRootSpecifier),i=ti(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(Sr(n,f,"function")||Sr(n,f,"class"))continue;let g=Qo(n,f),p=si(g),A=s.named.get(u)??u,S=mt(A)??mt(u),m=s.named.has(u)||o.calleeBindings.has(u)||g?.parts.length===1&&s.namespaces.has(g.parts[0]);if(!S&&Ko.has(u)&&g?.parts.length===1&&s.named.get(g.parts[0])===Fo&&(S="factory",m=!0),!S||S==="factory"&&g!==void 0&&!m)continue;let y=f+d[0].length,R=Ho(n,y);if(S!=="factory"&&(g===void 0?!m:!ei(g,s,o))&&!oi(g,R,r.intentPrefixes))continue;let k=ri(n,y),I=R??(k?i.get(k):void 0);l.push({file:e,line:vr(t,f),kind:S,callee:u,viaImport:m,...p?{receiver:p}:{},...I?{nameLiteral:I}:{}})}return l}a(je,"extractArkRunKernelCallsFromSource");function At(e,t,r){let n=yt(t),s=Bo(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(Uo.has(c)||!s.has(c))continue;let d=zo(n,c);o.push({file:e,line:vr(t,l.index),typeName:c,...d?{importedFrom:d}:{}})}return o}a(At,"extractArkRunManagedNewsFromSource");var ii=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),ai=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),li=new Set(["return","typeof","case","do","else","in","of","new","delete","void","throw","instanceof","yield","await"]);function ci(e,t){let r=t-1;for(;r>=0&&/\s/.test(e[r]);)r-=1;if(r<0)return!0;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 li.has(e.slice(s+1,r+1))}return n==="/"&&e[r-1]==="*"?!1:ai.has(n)}a(ci,"slashStartsRegex");function di(e,t){if(!ci(e,t))return t;let r=t+1,n=!1;for(;r<e.length;){let s=e[r];if(s===`
2
- `||s==="\r")return t;if(s==="\\"){r+=2;continue}if(n)s==="]"&&(n=!1);else if(s==="[")n=!0;else if(s==="/"){for(r+=1;r<e.length&&/[A-Za-z]/.test(e[r]);)r+=1;return r}r+=1}return t}a(di,"skipRegexLiteral");function ie(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 di(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(ie,"skipStringOrComment");function se(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=ie(e,r);continue}break}return r}a(se,"skipWsAndComments");function _r(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(_r,"readIdent");function oe(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=ie(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(oe,"skipBalanced");function Cr(e){let t=[],r=0,n;for(;r<e.length&&(r=se(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=_r(e,o);if(!u||!ii.has(u.ident))break;s.push(u.ident),o=se(e,u.end)}if(s.length===1&&s[0]==="static"&&e[o]==="{"){let u=oe(e,o,"{","}");if(u==null){n=e.length;break}r=u;continue}let i=_r(e,o);if(!i){r+=1;continue}if(o=se(e,i.end),e[o]==="<"){let u=oe(e,o,"<",">");if(u==null){n=e.length;break}o=se(e,u)}if(e[o]==="("){let u=oe(e,o,"(",")");if(u==null){n=e.length;break}if(o=se(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let f=ie(e,o);if(f!==o){o=f;continue}o+=1}if(e[o]==="{"){let f=oe(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=ie(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(Cr,"scanClassMembers");function ui(e,t){let r=t;for(;r<e.length;){let n=se(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=oe(e,r,s,s==="<"?">":s==="("?")":"]");if(i==null)return null;r=i;continue}if(s==='"'||s==="'"||s==="`"){r=ie(e,r);continue}r+=1}return null}a(ui,"findClassBodyBrace");function Or(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=fi(e),o;for(;(o=n.exec(s))!==null;){let i=t.exportedOnly?o[1]:o[2],l=t.exportedOnly===!0||o[1]==="export",c=ui(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=oe(e,c,"{","}");r.push({name:i,start:o.index,exported:l,bodyStart:c+1,bodyEnd:d==null?null:d-1})}return r}a(Or,"findClassDeclarations");function fi(e){let t="",r=0;for(;r<e.length;){let n=ie(e,r);if(n!==r){t+=e.slice(r,n).replace(/[^\n]/g," "),r=n;continue}t+=e[r],r+=1}return t}a(fi,"maskStringsAndComments");var pi=/\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)/,gi=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)/,hi=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]/g,mi=["db","tx","client","prisma","prismaClient","drizzle"],yi="(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))",Ai="\\bINSERT\\s+INTO\\b|\\bUPDATE\\s+[A-Za-z_][\\w.]*\\s+SET\\b|\\bDELETE\\s+FROM\\b",Nr="\\((?:[^()]|\\([^()]*\\))*\\)",Ri=`\\bnew\\s+PrismaClient\\s*${Nr}|\\bdrizzle\\s*${Nr}`,ki=/(?<![\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,Si=/(?<![\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 bi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(bi,"escapeRegExp");function be(e){return pi.test(e)||gi.test(e)}a(be,"sourceImportsPersistenceDriverText");function Tr(e,t,r){let n=new RegExp(e.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1])}a(Tr,"collectFirstGroup");function Ei(e){let t=new Set;Tr(ki,e,t),Tr(Si,e,t);let r=new RegExp(hi.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(Ei,"persistenceClientBindings");function Ue(e){let t=[...mi,...Ei(e)].map(bi).join("|");return new RegExp(`(?:\\b(?:${t})(?![\\w$])|${Ri})(?:\\s*\\.\\s*[A-Za-z_]\\w*)*\\s*\\.\\s*${yi}\\s*\\(|${Ai}`,"i").test(e)}a(Ue,"sourceHasPersistenceWrite");var Ii=["no-anemic-model"],Fr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],wi=new RegExp(`\\b(${Fr.join("|")})\\b`),Pr="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",vi=new RegExp(`\\bthis\\.${Pr}\\.push\\s*\\(`),xi=new RegExp(`^this\\.${Pr}\\s*=\\s*\\[\\s*\\]`),_i=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,Ci=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g;function Oi(){return`${Fr.join(", ")}, or events-array .push(`}a(Oi,"expectedDomainInvariantWordsPhrase");function Ni(e){return wi.test(e)||vi.test(e)}a(Ni,"referencesGuardOrPublish");function Ti(e,t,r){let n=e.slice(t);if(xi.test(n))return!0;if(!_i.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}a(Ti,"isIdiomaticEventsReset");function Li(e,t){let r=new RegExp(Ci.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!Ti(t,n.index,e))return!0;return!1}a(Li,"methodAssignsThis");function Lr(e,t){return t==null?e:{...e,truncatedUntil:t}}a(Lr,"attachShapeTruncation");function $r(e){return typeof e.truncatedUntil=="number"?e.truncatedUntil:void 0}a($r,"shapeTruncatedUntil");function Di(e){let t=$r(e);return t==null?"":` shape analysed until character ${t}`}a(Di,"shapeTruncationSuffix");function Dr(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Dr,"escapeGlobLiteral");function Fi(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(Fi,"globToRegExp");function Ge(e,t){return!t||t.length===0?!0:t.some(r=>Fi(r).test(e))}a(Ge,"matchesAppliesTo");function Pi(e){return Ii.includes(e)}a(Pi,"isTier2");function $i(e){return e.mode==="enforced"&&!Pi(e.sensor)?{severity:"error",failsStrict:!0}:{severity:"warning",failsStrict:!1}}a($i,"severityFor");function W(e,t,r,n=1){let{severity:s,failsStrict:o}=$i(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(W,"baseViolation");function He(e,t,r){if(!r)return!0;let n=r(e);return n?n===t.provenance.layer:!1}a(He,"isInRuleLayer");function Ve(e,t,r){return t.filter(n=>!(!n.exported||!Ge(n.file,e.appliesTo)||!He(n.file,e,r)))}a(Ve,"shapesForRule");function Rt(e,t,r){let n=$r(t);if(n!=null)return W(e,t.file,`Exported class ${t.className} shape analysed until character ${n}; later ${r} may be invisible (sensor ${e.sensor}).`)}a(Rt,"truncatedShapeViolation");function Mi(e,t,r){let n=[];for(let s of Ve(e,t,r)){let o=Rt(e,s,"members");o&&n.push(o),(s.hasPublicSetters||s.hasPublicMutableFields)&&n.push(W(e,s.file,`Exported class ${s.className} exposes public mutable state (sensor aggregate-private-state).`))}return n}a(Mi,"evaluateAggregatePrivateState");function Ki(e,t,r){let n=[];for(let s of Ve(e,t,r)){let o=Rt(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(W(e,s.file,`Exported class ${s.className} exposes a public constructor without a static factory (sensor always-valid-factory).`))}}return n}a(Ki,"evaluateAlwaysValidFactory");function ji(e,t,r){let n=[],s=Oi();for(let o of Ve(e,t,r)){let i=Di(o),l=Rt(e,o,"methods");l&&n.push(l);for(let c of o.mutatingMethods)c.referencesGuardOrPublish||n.push(W(e,o.file,`Mutating method ${o.className}.${c.name} does not reference ${s} (sensor domain-event-on-mutation).${i}`))}return n}a(ji,"evaluateDomainEventOnMutation");function Ui(e,t){let r=[];for(let n of t.files)Ge(n,e.appliesTo)&&He(n,e,t.layerForFile)&&t.fileHints?.[n]?.orchestrationHeavy&&r.push(W(e,n,"File appears to embed domain branching beyond guard-and-delegate orchestration (sensor orchestration-only)."));return r}a(Ui,"evaluateOrchestrationOnly");function Gi(e,t){let r=[];for(let n of t.files)Ge(n,e.appliesTo)&&He(n,e,t.layerForFile)&&t.fileHints?.[n]?.adapterThick&&r.push(W(e,n,"Adapter module mixes domain branching, persistence, and mapping beyond a thin adapter (sensor thin-adapter)."));return r}a(Gi,"evaluateThinAdapter");function Hi(e,t){let r=[];for(let n of t.files)Ge(n,e.appliesTo)&&He(n,e,t.layerForFile)&&t.fileHints?.[n]?.persistenceWrite&&r.push(W(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(Hi,"evaluateWritesViaAggregate");function Vi(e,t,r){let n=[];for(let s of Ve(e,t,r))if(s.dataOnly===!0){let o=W(e,s.file,`Exported type ${s.className} looks data-only / anemic (sensor no-anemic-model; advisory only).`);n.push({...o,severity:"warning",failsStrict:!1})}return n}a(Vi,"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(...Mi(r,e.classShapes,e.layerForFile));break;case"always-valid-factory":t.push(...Ki(r,e.classShapes,e.layerForFile));break;case"domain-event-on-mutation":t.push(...ji(r,e.classShapes,e.layerForFile));break;case"orchestration-only":t.push(...Ui(r,e));break;case"thin-adapter":t.push(...Gi(r,e));break;case"writes-via-aggregate":t.push(...Hi(r,e));break;case"no-anemic-model":t.push(...Vi(r,e.classShapes,e.layerForFile));break;case"invariant-coverage":break;default: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 Bi(e){return e==="PersistenceAdapters"}a(Bi,"isPersistenceDriverLayer");function zi(e,t){if(be(e))return!0;if(!t)return!1;for(let r of t){if(Bi(r.layer))return!0;let n=r.specifier;if(!n)continue;let s=`from '${n}'`;if(be(s))return!0}return!1}a(zi,"sourceImportsPersistenceDriver");var Wi=/\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*=)/,qi=/(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/,Yi=/\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*=/,Zi=/\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=zi(t,r),s=n&&Ue(t);if(t.length<40)return s?{persistenceWrite:!0}:null;let o=t.match(new RegExp(Yi.source,"g"))??[],i=t.match(new RegExp(Zi.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=Wi.test(t)||qi.test(t),f=o.length>=1||i.length>=2,g=/\b(?:mapTo|toDomain|toDto|fromRow|toEntity|fromPrisma|serialize|deserialize)\w*\s*[(=]/.test(t),p=n&&f||u&&f||n&&g&&(l>=4||o.length>=1)||u&&n;return!d&&!p&&!s?null:{...d?{orchestrationHeavy:!0}:{},...p?{adapterThick:!0}:{},...s?{persistenceWrite:!0}:{}}}a(Kr,"deriveArkRuleFileHints");var Xi=new Set(["if","match","when"]);function Ee(e,t){let r=[];for(let n of Or(t,{exportedOnly:!0})){let s=n.name;if(n.bodyStart==null){r.push(Lr({file:e,className:s,exported:!0,hasPublicMutableFields:!1,hasPublicSetters:!1,hasPublicConstructor:!1,hasStaticFactory:!1,mutatingMethods:[]},n.start));continue}let o=n.bodyStart,i=n.bodyEnd==null,l=t.slice(o,n.bodyEnd??t.length),c=Cr(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,g=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(l),p=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(l),A=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(l)&&!p,S=/(?:^|[\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),m=[];for(let k of c.members)k.kind==="method"&&k.name!=="constructor"&&(k.modifiers.includes("static")||k.modifiers.includes("get")||k.modifiers.includes("set")||Xi.has(k.name)||Li(k.name,k.body)&&m.push({name:k.name,referencesGuardOrPublish:Ni(k.body)}));let R=c.members.filter(k=>k.kind==="method").length<=1&&u.length>=2&&f;r.push(Lr({file:e,className:s,exported:!0,hasPublicMutableFields:f,hasPublicSetters:g,hasPublicConstructor:A,hasStaticFactory:S,mutatingMethods:[...m],dataOnly:R},d))}return r}a(Ee,"extractClassShapesFromSource");function Ji(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(Ji,"normalizeExtraMergeTeethClassification");function Be(e){let t=Ji(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}a(Be,"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:!0}:{}}}a(h,"entry");var jr=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("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/ is not referenced by the arkRules map in ark.config.json (or no map exists), so none of its rules are enforced or reported. Drift looks like governance until someone notices.",'Reference the file from arkRules ("<Layer>": "arkrules/<file>.json"), or delete it. Advisory only: it never fails the check.',{oftenAdvisory:!0}),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_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("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.")]),Zc=new Map(jr.map(e=>[e.ruleId,e])),Xc=Object.freeze(jr.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."})]),ea=new Map(Qi.map(e=>[e.reasonId,e]));function Ur(e){if(!(typeof e!="string"||e.length===0))return ea.get(e)}a(Ur,"sliceReasonHint");var ta=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,ra=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,na=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function sa(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return ta.test(r)?"pure-shared":n==="PersistenceAdapters"&&(ra.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":na.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a(sa,"classifyLayerImportKind");function oa(e,t){return t.failsStrict===!1&&e.advisoryNote?`${e.fix} ${e.advisoryNote}`:e.fix}a(oa,"sliceHintAction");function ia(e){let t=Ur(typeof e.reasonId=="string"?e.reasonId:void 0);if(t)return`${oa(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=sa(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(ia,"layerImportNextAction");function aa(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a(aa,"arkRunCallSiteName");function la(e){let t=aa(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(la,"arkRunNextAction");function ae(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return ia(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 la(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(ae,"deterministicNextAction");var ca=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],da=new Set(ca);function ua(e){return da.has(e)}a(ua,"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"},fa="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Br(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(Br,"isDomainRoleLayer");function pa(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(pa,"compareFindings");function U(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:ae({ruleId:Gr[t],fromLayer:o?.fromLayer,target:o?.target})}}a(U,"finding");function ga(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(ga,"bagForFile");function Hr(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Hr,"emitKinds");function Vr(e){return e==="subscribe"||e==="register-handler"}a(Vr,"handleKinds");function ha(e){return e==="resolve"||e==="resolve-singleton"}a(ha,"dependKinds");function ma(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(U(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(U(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(U(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(ma,"evaluateMissingRoot");function ya(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||!J(c))continue;let d=n(l.from);d&&Br(d,o.get(d)??[])&&i.push(U(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(ya,"evaluateKernelInDomain");function Aa(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!==!1&&(f.endsWith("Error")||f==="Error")||f.endsWith("DTO")||f.endsWith("VO"))continue;let g=s(u.file);!g||!i.has(g)||Br(g,l.get(g)??[])||d.push(U(e,"arkrun-direct-new",u.file,u.line,`${g} must not construct ${u.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:g,target:u.typeName},o))}return d}a(Aa,"evaluateDirectNew");function Ra(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let l=new Set(e.managedLayers);if(l.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!Hr(c.kind)&&!Vr(c.kind)&&!ha(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:fa,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=ga(r,c.file);if(Hr(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(U(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(Vr(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(U(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(U(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(Ra,"evaluateUndeclared");function ka(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||!wr(l))continue;let c=r(i.from);!c||!s.has(c)||o.push(U(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(ka,"evaluateTransportBypass");function Sa(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=Be(e.classification),n=Ra(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...ma(t,e.compositionRootHits,r),...ya(t,e.layers,e.dependencies,e.layerForFile,r),...Aa(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...ka(t,e.dependencies,e.layerForFile,r)].sort(pa),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(Sa,"evaluateArkRunSensors");function kt(e){return{findings:Sa(e).findings.filter(r=>ua(r.sensor)),completenessReasons:[]}}a(kt,"evaluateArkRunEditorSensors");var St="docs/diagnostics.md";function bt(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(bt,"adapterFindingTargetKey");function Et(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(Et,"adapterFindingRefFromTargetKey");function It(e){return`${St}#${e}`}a(It,"adapterDocsCodePath");function b(e){return typeof e=="string"&&e.length>0?e:void 0}a(b,"text");function zr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(zr,"positiveInteger");function Ia(e,t,r){return ae({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===!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(r.capability)??void 0,arkruleId:b(t.arkruleId)??void 0,arkruleSource:b(t.arkruleSource)??void 0,reasonId:b(t.reasonId)??void 0})}a(Ia,"nextActionForDiagnostic");var wa=new Set(["CROSS_PARENT_SLICE","CROSS_SIBLING_SLICE","CROSS_PARENT_VIA_SHARED"]);function va(e){let t=e.details,r=t!==null&&typeof t=="object"?t.reasonId:void 0,n=b(e.reasonId)??b(r);return n&&wa.has(n)?n:void 0}a(va,"sliceReasonOf");function Wr(e,t="error",r){let n=b(e.ruleId)??b(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o=va(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??bt(e),c=Et(l);return{ruleId:n,severity:s,message:b(e.message)??n,location:{file:b(e.file)??"<unknown>",line:zr(e.line,1),column:zr(e.column,1)},evidence:i,nextAction:b(e.nextAction)??Ia(n,i,e),findingRef:c,targetKey:l,docsCodePath:It(n)}}a(Wr,"toAdapterDiagnostic");var wt="advisory",Yr="{{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.]',qr=new WeakMap,Xr=new WeakMap;function xa(e){return Object.prototype.hasOwnProperty.call(e,"sourceCode")||Object.prototype.hasOwnProperty.call(e,"getSourceCode")}a(xa,"ownsSourceCode");function _a(e){let t=e;for(let r=0;t&&t!==Object.prototype&&r<8;r+=1){if(xa(t))return t===e?null:t;t=Object.getPrototypeOf(t)}return null}a(_a,"runKey");function Ca(e,t){let r=Object.create(e,{report:{value(n){t.sinks.blocking?.report(n)}}});return Xr.set(r,t),r}a(Ca,"routedContext");function We(e,t,r){let n=_a(t),s;if(n){let o=qr.get(n);o||(o=new Map,qr.set(n,o)),s=o.get(e),s||(s={sinks:{},created:!1},o.set(e,s))}else s={sinks:{},created:!1};return s.sinks[r]=t,s.created?{}:(s.created=!0,e.create(Ca(t,s)))}a(We,"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:wt,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 q(e){try{return e.sourceCode??e.getSourceCode?.()}catch{return}}a(q,"sourceCodeFor");function le(e){let t=q(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(le,"editorSourceText");function Oa(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(Oa,"reportLocation");function _(e,t,r,n,s){let o=Wr({...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:Oa(t,o.location.line),messageId:r,...s?{data:s}:{},advisoryData:{message:o.message,ruleId:o.ruleId},diagnostic:o}),o}a(_,"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 Na(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}a(Na,"declarationIsTypeOnly");function tn(e){try{return vt.default.existsSync(e)?vt.default.readFileSync(e,"utf8"):null}catch{return null}}a(tn,"readUtf8");function en(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=Y.default.dirname(n),i=Y.default.isAbsolute(r)?r:Y.default.resolve(r),l=Y.default.relative(o,i).split(Y.default.sep).join("/");if(!e.sourceIsInAnalysisScope(s,l))return null;let c=v(l,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:l,fromLayer:c}:null}a(en,"loadEditorFile");function Ta(e,t,r){let n=je(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!F(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}a(Ta,"compositionRootHitsForFile");function La(e,t,r){let n=new Set(Ee(t.relFile,r).map(s=>s.className));return xr(r,(s,o)=>{if(J(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=Y.default.relative(t.root,i).split(Y.default.sep).join("/");if(l.startsWith(".."))return;let c=tn(i);if(c!==null)for(let d of Ee(l,c))n.add(d.className)}),n}a(La,"admittedTypeNamesForEditor");function rn(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(rn,"reportFinding");function Da(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}a(Da,"constructedTypeName");function Fa(e,t){return e.type?.startsWith("Export")?"export":t}a(Fa,"specifierEdgeKind");function Pa(e,t,r,n,s){let o=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:g}=kt({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[f],layerForFile:a(p=>p===r.relFile?r.fromLayer:v(p,r.config.layers),"layerForFile")});for(let p of g)p.sensor===n&&rn(e,t,i,s,p,{fromLayer:p.fromLayer??r.fromLayer,specifier:l,target:p.target??l})},"check");return{ImportDeclaration(i){let l=i,c=(l.specifiers??[]).filter(u=>u.type==="ImportSpecifier"),d=c.length>0&&c.length===(l.specifiers??[]).length&&c.every(u=>u.importKind==="type");o(i,l.source?.value,l.importKind==="type"||d||Na(i),"import")},ImportExpression(i){let l=i;l.source?.type==="Literal"&&o(i,l.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let l=i;o(i,l.moduleReference?.expression?.value,l.importKind==="type"||l.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let l=i;if(!l.source)return;let c=l.specifiers??[],d=c.length>0&&c.every(u=>u.exportKind==="type");o(i,l.source.value,l.exportKind==="type"||d,Fa(i,"export"))},ExportAllDeclaration(i){let l=i;o(i,l.source?.value,l.exportKind==="type","export")},CallExpression(i){let l=i;l.callee?.type==="Identifier"&&l.callee.name==="require"&&l.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,l.arguments[0].value,!1,"require")}}}a(Pa,"importListeners");function $a(e,t,r){let n=le(t)??tn(r.absFile)??"",s=La(e,r,n),o=At(r.relFile,n,s),{findings:i}=kt({arkRun:r.extra,layers:r.config.layers,kernelCalls:je(r.relFile,n),managedNews:o,compositionRootHits:Ta(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:a(c=>c===r.relFile?r.fromLayer:v(c,r.config.layers),"layerForFile")}),l=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let d=Da(c);if(!d)return;let u=c.loc?.start?.line,f=l.find(g=>g.target===d&&(u===void 0||g.line===u));f&&rn(e,t,c,"directNew",f,{fromLayer:f.fromLayer??r.fromLayer,typeName:d,target:f.target??d})}}}a($a,"directNewListener");function nn(e){let t=a((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let l=en(e,i);return l?Pa(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=en(e,r);return n?$a(e,r,n):{}}}}}a(nn,"createArkRunEslintRules");var sn=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var _t="createOrderPlane";var on=new Map;function an(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(an,"escapeAppliesToLiteral");function Ma(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(Ma,"normalizeAppliesToGlob");function Ka(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}a(Ka,"appliesToBracesBalanced");function Ct(e){let t=on.get(e);if(t)return t;let r=Ma(e),n=Ka(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=an(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+=an(c)}let i=new RegExp(`^${s}$`);return on.set(e,i),i}a(Ct,"arkOrderGlobToRegExp");function qe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(qe,"escapeRegExp");function ce(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(ce,"isArkOrderModuleSpecifier");function G(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
4
- `&&(r+=1);return r}a(G,"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 dn(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]??"";ce(l)&&n.push({from:e,specifier:l,kind:o[1]==="export"?"export":"import",typeOnly:!!o[2],line:G(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]??"";ce(l)&&n.push({from:e,specifier:l,kind:o[1]==="import"?"dynamic-import":"require",typeOnly:!1,line:G(t,o.index),resolution:"resolved-external"})}return n}a(dn,"extractArkOrderModuleImportsFromSource");function un(e,t){let r=$(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:G(t,o.index),callee:_t});return n}a(un,"extractArkOrderPlaneCallsFromSource");var ja=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;\n]+)?=\s*createOrderPlane\s*(?:<[^>]*>)?\s*\(/g,xt=/^(?:plane|[A-Za-z_$][\w$]*Plane)$/,Ua=/\b([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?OrderPlane\b/g,Ga=/\bfrom\s+['"]arkgate\/order(?:\/[^'"]*)?['"]|\brequire\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]|\bimport\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]/,Ha=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g,ln=["",".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],Va=/([A-Za-z_$][\w$]*)\s*!?\s*\??\s*$/,Ba=/^\s*(?:<[^<>]*>\s*)?([A-Za-z_$][\w$]*)\s*!?\s*(?:\b(?:as|satisfies)\b[\s\S]*)?$/;function za(e){let t=$(e),r=new Set,n=new RegExp(ja.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1]);return[...r].sort()}a(za,"arkOrderPlaneBindings");function Wa(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(Wa,"normalizeRelativePath");function qa(e,t){if(!t.startsWith("./")&&!t.startsWith("../"))return[];let r=e.replace(/\\/g,"/").split("/").slice(0,-1),n=Wa([...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 ln)o.add(`${i}${l}`);for(let l of ln.slice(1))o.add(`${i}/index${l}`)}return[...o]}a(qa,"relativeModuleCandidates");function Ya(e,t,r){let n=qa(e,t);return n.length===0?!1:r.some(s=>{let o;try{o=Ct(s)}catch{return!1}return n.some(i=>o.test(i))})}a(Ya,"specifierResolvesToPlaneRoot");function Za(e,t,r={}){let n=$(t),s=new Set(za(t)),o=new RegExp(Ua.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(Ha.source,"g");for(;(i=c.exec(n))!==null;)if(Ya(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()??"",g=(u[1]??u[0]??"").trim();!g||!/^[A-Za-z_$][\w$]*$/.test(g)||(xt.test(f)||xt.test(g))&&s.add(g)}}return s.delete(_t),{names:[...s].sort(),isArkOrderFile:Ga.test(n)}}a(Za,"arkOrderPlaneReceivers");var Xa=new Set(["return","await","void","typeof","yield","in","of","case","else","do","throw","delete"]);function Ja(e){let t=e.replace(/\s+$/,"");if(/[)\]]$/.test(t))return!0;let r=/([A-Za-z_$][\w$]*)$/.exec(t);return r!==null&&!Xa.has(r[1])}a(Ja,"isCallBefore");function fn(e){let t=e.replace(/\s*!?\s*\??\s*$/,"");if(!t.endsWith(")")){let n=Va.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(Ja(t.slice(0,n)))return null;let o=t.slice(n+1,t.length-1),i=Ba.exec(o);return i?i[1]??null:null}}return null}a(fn,"receiverBefore");function pn(e,t,r){let n=Za(e,t,r);return{names:new Set(n.names),isArkOrderFile:n.isArkOrderFile}}a(pn,"planeReceiverContext");function gn(e,t){return!e||e===_t?!1:t.names.has(e)?!0:t.isArkOrderFile&&xt.test(e)}a(gn,"isPlaneReceiver");function hn(e,t,r={}){let n=$(t),s=pn(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);gn(fn(d),s)&&o.push({file:e,line:G(t,l.index),method:c})}return o}a(hn,"extractArkOrderGenericUpdatesFromSource");function mn(e,t,r){if(r.length===0)return[];let n=$(t);if(!be(n)||!Ue(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let l=new RegExp(`(?:\\b${qe(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${qe(i)}['"]\\s*:|[{\\,]\\s*${qe(i)}\\s*[\\,}]|\\.${qe(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:G(t,c.index),key:i});break}}}return s}a(mn,"extractArkOrderXiFieldWritesFromSource");var Qa="(?:xi(?:[A-Z][\\w$]*)?|release|pattern|house|current|[A-Za-z_$][\\w$]*?(?:Xi|Release|Pattern))(?![\\w$])";function yn(e,t){let r=$(t),n=[],s=new RegExp(`(?:(?<![\\w$])|\\.)${Qa}(?:\\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:G(t,o.index)});return n}a(yn,"extractArkOrderIngestWritesXiFromSource");function An(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:G(t,o.index),keyCount:l.length})}return n}a(An,"extractArkOrderReleaseKeyCountsFromSource");function el(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(el,"literalKeys");function Rn(e,t,r={}){let n=$(t),s=pn(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(gn(fn(c),s))for(let d of el(l[1]??""))sn.test(d)&&o.push({file:e,line:G(t,l.index),key:d})}return o}a(Rn,"extractArkOrderXiTtlKeysFromSource");function cn(e){let t=[],r=/(['"`])([^'"`\n\\]+)\1/g,n;for(;(n=r.exec(e))!==null;)n[2]&&t.push(n[2]);return t}a(cn,"stringLiterals");function kn(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 cn(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=G(t,o.index);for(let u of cn(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(kn,"extractArkOrderBudgetLeaksFromSource");var Sn={"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 tl(e,t){return!t||t.length===0?!0:t.some(r=>Ct(r).test(e))}a(tl,"matchesArkOrderAppliesTo");function rl(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}a(rl,"isDomainRoleLayer");function M(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Sn[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:ae({ruleId:Sn[t],fromLayer:o?.fromLayer,target:o?.target})}}a(M,"finding");function Ot(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=Be(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||!ce(d))continue;let u=e.layerForFile(c.from);u&&rl(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)||tl(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(Ot,"evaluateArkOrderSensors");function bn(e){if(!e.arkOrder)return[];let t=un(e.file,e.source),r={planeRoots:e.arkOrder.planeRoots??[]},n=hn(e.file,e.source,r),s=e.arkOrder.xiKeys??[],o=e.fromLayer?[{name:e.fromLayer,patterns:[],intentPrefixes:[...e.intentPrefixes??[]]}]:[];return Ot({arkOrder:e.arkOrder,layers:o,planeCalls:t,genericUpdates:n,planeRootHits:[],xiFieldWrites:mn(e.file,e.source,s),ingestWritesXi:yn(e.file,e.source),releaseKeyCounts:An(e.file,e.source),xiTtlKeys:Rn(e.file,e.source,r),budgetLeaks:kn(e.file,e.source),dependencies:dn(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(bn,"evaluateArkOrderEditorSensors");function En(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(En,"violationFor");function nl(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(nl,"lineNode");function In(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length>0&&t.every(r=>r.importKind==="type"||r.exportKind==="type")}a(In,"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:v(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,g)=>{if(typeof u!="string"||!ce(u))return;let p=d.loc?.start?.line??1,{findings:A}=Ot({arkOrder:i.arkOrder,layers:i.layers,planeCalls:[],genericUpdates:[],planeRootHits:[],dependencies:[{from:l,specifier:u,kind:g,typeOnly:f,line:p,resolution:"resolved-external"}],layerForFile:a(S=>S===l?o.fromLayer:v(S,i.layers),"layerForFile")});for(let S of A)S.sensor==="arkorder-kernel-in-domain"&&e.reportAdapterDiagnostic(s,d,"denied",En(S),{message:S.message})},"check");return{ImportDeclaration(d){c(d,d.source?.value,In(d),"import")},ExportNamedDeclaration(d){d.source&&c(d,d.source.value,In(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=le(s)??"",l=bn({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,nl(i,c.line),"denied",En(c),{message:c.message})}}:{}}}}}a(wn,"createArkOrderEslintRules");var cs=D(require("fs"),1),Oe=D(require("path"),1);var $t=require("crypto"),V=D(require("fs"),1),T=D(require("path"),1);var Q={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},vn={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...Q,default:[]},kernelRoots:{...Q},managedLayers:{...Q,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},xn={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...Q,default:[]},managedLayers:{...Q,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...Q,default:[]},appliesTo:{...Q,default:[]}}};function Ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Ie,"isObject");function _n(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)Ie(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}a(_n,"declaredLayerNames");function Cn(e){if(!Ie(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(Cn,"defaultedArkRun");function On(e){if(!Ie(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 Nn(e,t){let r=e.arkRun;if(r===void 0||!Ie(r))return;let n=_n(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}a(Nn,"validateArkRunExtra");function Tn(e,t){let r=e.arkOrder;if(r===void 0||!Ie(r))return;let n=_n(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}a(Tn,"validateArkOrderExtra");var Ze={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Mn={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:{...Ze,minItems:1}}}]},Kn={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:{...Ze,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...Ze,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:{...Ze},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)."},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 alias as an owed move. A build that rejects unknown childSlices fields fails at config load (unknown field). arkgate 4.8.22 and older reject childSlices.",items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}},allowedCrossSlice:{type:"array",minItems:1,description:"Directed child-slice allowances. * matches one whole path segment (features/projects/*). ** and a partial segment are rejected. A bare name is rejected. This list clears only CROSS_SIBLING_SLICE. It cannot clear CROSS_PARENT_SLICE or CROSS_PARENT_VIA_SHARED. The universe allowedCrossSlice still treats * as a literal. A build that rejects unknown childSlices fields fails at config load (unknown field).",items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}}}};function N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(N,"isObject");function Xe(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(Xe,"propertyPath");function Z(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Z,"trimTrailingSlashes");function jn(e,t){ll(e,t),dl(e,t),gl(e,t),_l(e,t)}a(jn,"validateSliceContract");var Ln='must be "deny", "deny-cross-parent", or { "mode": "deny-cross-parent", "stopAt": ["<composition root path or glob>"] }',Dn="must not cover the whole tree. Name the composition root itself (bootstrap file, DI registrations folder).";function sl(e){return e==="*"||e==="**"}a(sl,"isWildcardSegment");function Un(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&&sl(t[r-1]??"");)r-=1;let n=t.slice(0,r);return n.some(s=>s.includes("*"))?null:n}a(Un,"coveredFolder");function ol(e,t){return e.length<=t.length&&e.every((r,n)=>t[n]===r)}a(ol,"isPrefixOf");function il(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(!N(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(g=>g.includes("*")),u=d===-1?c:c.slice(0,d),f=Un(u.join("/"));f&&s.push(f)}}return s}a(il,"ruleLayerFolders");function al(e,t){let r=Z(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 Dn;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=Un(r);return s===null?null:s.length===0?Dn:t.some(o=>ol(s,o))?"must not cover a whole layer root of this rule. Name the composition root itself (bootstrap file, DI registrations folder).":null}a(al,"stopAtEntryIssue");function ll(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!N(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:Ln});return}if(!N(o)){t.push({path:i,message:Ln});return}for(let u of Object.keys(o))u!=="mode"&&u!=="stopAt"&&t.push({path:Xe(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=il(e,n);l.forEach((u,f)=>{let g=`${i}.stopAt[${f}]`;if(typeof u!="string"){t.push({path:g,message:"must be a non-empty path or glob"});return}let p=al(u,d);if(p){t.push({path:g,message:p});return}let A=Z(u.trim().replace(/\\/g,"/")).toLowerCase();if(c.has(A)){t.push({path:g,message:"duplicate stopAt entry"});return}c.add(A)})})}a(ll,"validateSharedImportsSlice");var cl=["deny","advisory"],Fn='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"], "ratchet": true | false }';function dl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!N(n))return;let o=n.childSlices;if(!N(o)||o.siblings===void 0)return;let i=o.siblings,l=`$.rules[${s}].childSlices.siblings`;if(typeof i=="string"){cl.includes(i)||t.push({path:l,message:Fn});return}if(!N(i)){t.push({path:l,message:Fn});return}for(let d of Object.keys(i))d!=="default"&&d!=="enforce"&&d!=="ratchet"&&t.push({path:Xe(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 g=Z(d.trim().replace(/\\/g,"/"));if(g.split("/").some(p=>p.length===0||p==="."||p==="..")){t.push({path:f,message:"must be a child slice id or subtree path without . or .."});return}if(g.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(g)){t.push({path:f,message:"duplicate enforce entry"});return}c.add(g)})})}a(dl,"validateChildSliceSiblings");var ul="must be a slice id with a slash. A bare name is ambiguous across universes.",fl="* matches one whole path segment. ** and a partial segment are not wildcards.";function pl(e){let t=Z(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty slice id";if(!t.includes("/"))return ul;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 fl}return null}a(pl,"childCrossSlicePatternIssue");function Pn(e){return Z(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Pn,"childCrossSlicePatternKey");function gl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!N(n))return;let o=n.childSlices;if(!N(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(!N(d)){t.push({path:f,message:"must be an object with from and to"});return}for(let p of Object.keys(d))p!=="from"&&p!=="to"&&t.push({path:Xe(f,p),message:"unknown field"});for(let p of["from","to"]){let A=d[p],S=`${f}.${p}`;if(typeof A!="string"||A.trim().length===0){t.push({path:S,message:"must be a non-empty slice id"});continue}let m=pl(A);m&&t.push({path:S,message:m})}if(typeof d.from!="string"||typeof d.to!="string")return;let g=`${Pn(d.from)}\0${Pn(d.to)}`;if(!g.startsWith("\0")&&!g.endsWith("\0")){if(c.has(g)){t.push({path:f,message:"duplicate child slice allowance"});return}c.add(g)}})})}a(gl,"validateChildSliceAllowedCrossSlice");var de="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.",hl="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/*).",ml="overlaps a slice folder. An alias covers only files outside the slice trees.",yl="two slice aliases match the same file";function Al(e){return Z(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(Al,"aliasPathSegments");function Rl(e){let t=e[e.length-1];return t===void 0||t.includes("*")?[...e]:[...e,"**"]}a(Rl,"aliasSegmentsWithSubtree");function Gn(e){let t=[];for(let r of e){if(r.includes("*"))break;t.push(r)}return t}a(Gn,"concreteGlobPrefix");function we(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0}a(we,"segmentsArePrefix");function kl(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(kl,"anchoredSlicePrefix");function Sl(e,t){let r=Gn(e),n=r.length<e.length,s=r[0]==="src"||r[0]==="app"?r.slice(1):r;return we(t,r)||we(t,s)?!0:n?we(r,t)&&r.length<t.length||we(r,["src",...t])&&r.length<t.length+1||we(r,["app",...t])&&r.length<t.length+1:!1}a(Sl,"globOverlapsAnchored");function bl(e,t){for(let n=0;n<e.length;n+=1){if(e[n]!==t&&e[n]!=="*")continue;let s=e.slice(n+1);if(s.length>=2||s.some(o=>o==="*"||o==="**"))return!0}let r=Gn(e);return r.length<e.length&&(r.length===0||r.length===1&&(r[0]==="src"||r[0]==="app"))}a(bl,"globOverlapsBare");function El(e,t){let r=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(r.length===1&&r[0]&&!r[0].includes("*"))return bl(e,r[0]);let n=kl(t);return n?Sl(e,n):!1}a(El,"globOverlapsSliceEntry");function Il(e){let t=Z(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(Il,"aliasGlobIssue");function wl(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(wl,"universeShapes");function Ye(e,t){return e.literals.length!==t.length?!1:e.literals.every((r,n)=>r===null||r===t[n])}a(Ye,"shapeMatches");function vl(e,t){let r=Z(e.trim().replace(/\\/g,"/"));if(r.length===0||r.split("/").some(o=>o.length===0||o==="."||o==="..")||r.includes("*")||!r.includes("/"))return de;let n=r.split("/").map(o=>o.toLowerCase());if(t.length===0||t.some(o=>Ye(o,n)))return de;if(t.some(o=>Ye(o,n.slice(0,-1))))return null;let s=new Set(t.filter(o=>o.legacy!==void 0&&!Ye({literals:o.legacy},n)&&Ye({literals:o.legacy},n.slice(0,-1))).map(o=>o.literals.map(i=>i??"*").join("/")));return s.size===1?null:s.size>1?hl:de}a(vl,"aliasTargetIssue");function $n(e){let t=e[0];return(t==="src"||t==="app")&&e.length>1?[e,e.slice(1)]:[e]}a($n,"aliasGlobVariants");function xl(e,t){let r=$n(e),n=$n(t);for(let s of r)if(ee(s,t,0,0,new Map))return!0;for(let s of n)if(ee(e,s,0,0,new Map))return!0;return!1}a(xl,"aliasesCanMatchSameFile");function ee(e,t,r,n,s){let o=`${r}:${n}`,i=s.get(o);if(i!==void 0)return i;let l=!1;if(r===e.length&&n===t.length)l=!0;else if(r<e.length&&e[r]==="**")l=ee(e,t,r+1,n,s)||n<t.length&&ee(e,t,r,n+1,s);else if(n<t.length&&t[n]==="**")l=ee(e,t,r,n+1,s)||r<e.length&&ee(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=ee(e,t,r+1,n+1,s))}return s.set(o,l),l}a(ee,"globsCanMatchSame");function _l(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!N(n))return;let o=n.childSlices;if(!N(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=wl(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,g)=>{let p=`${l}[${g}]`;if(!N(f)){t.push({path:p,message:"must be an object with from and to"});return}for(let m of Object.keys(f))m!=="from"&&m!=="to"&&t.push({path:Xe(p,m),message:"unknown field"});let A=f.from,S=f.to;if(typeof A!="string"||A.trim().length===0)t.push({path:`${p}.from`,message:"must be a non-empty path glob"});else{let m=Il(A);if(m)t.push({path:`${p}.from`,message:m});else{let y=Rl(Al(A));d.some(R=>El(y,R))&&t.push({path:`${p}.from`,message:ml});for(let R of u)if(xl(R,y)){t.push({path:p,message:yl});break}u.push(y)}}if(typeof S!="string"||S.trim().length===0)t.push({path:`${p}.to`,message:de});else{let m=vl(S,c);m&&t.push({path:`${p}.to`,message:m})}})})}a(_l,"validateChildSliceAliases");function Je(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(Je,"normalizeStewardId");function Hn(e){let t=Je(e);return!t||Nt(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(Hn,"isGitHubHandle");function Cl(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(!t.includes("@")||t.includes(" ")||Nt(t))return!1;let r=t.split("@");if(r.length!==2||!r[0]||/\s/.test(t))return!1;let n=r[1].lastIndexOf(".");return n>0&&n<r[1].length-1}a(Cl,"isGitHubEmail");function Ol(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Hn(t[1])?Je(t[1]):null}a(Ol,"githubHandleFromEmail");function Vn(e){let t=Ol(e);if(t)return t;let r=Je(e);return!r||Nt(r)?null:Hn(r)||Cl(r)?r:null}a(Vn,"canonicalStewardId");var Nl=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function Nt(e){let t=Je(e);return!t||Nl.test(t)}a(Nt,"isAutomationAuthor");var P="1.3",Tl=["public","auth","admin","internal"];var Tt="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",Bn=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],Ll=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function Dl(){let e=[];for(let t of Bn)for(let r of Bn)t===r||Ll.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}a(Dl,"createDefaultRules");var Wn=Dl(),Lt=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],C={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},zn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Tt,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:Tt,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:P,default:P},name:{type:"string",minLength:1},include:{...C,minItems:1,default:["src"]},exclude:{...C,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Wn,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...C,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...C,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...C,minItems:1},exclude:C,intentPrefixes:C,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...Tl]},owners:{...C,minItems:1},forbiddenGlobals:C,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:{...C,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:{...C,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:Mn,childSlices:Kn}},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:{...C,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:{...C,minItems:1}}},arkRun:vn,arkOrder:xn}},H=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 qn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(qn,"isObject");function Qe(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(Qe,"propertyPath");function ue(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(ue,"valueType");function Fl(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(Fl,"resolveSchemaRef");function ve(e,t,r,n,s){if(t.$ref){let o=Fl(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}ve(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(!qn(e)){s.push({path:r,message:`must be an object; received ${ue(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:Qe(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Qe(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||ve(e[l],i,Qe(r,l),n,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&ve(e[i],l,Qe(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${ue(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)=>ve(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 ${ue(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 ${ue(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${ue(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}a(ve,"validateNode");function Pl(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"&&(Vn(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}a(Pl,"validateLayerOwners");function $l(e){let t={...e,$schema:e.$schema===void 0?Tt: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?Wn.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Cn(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=On(e.arkOrder)),t}a($l,"defaultedConfig");function Ml(e){return e===P?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(Ml,"migratedFromOf");function Kl(){let e=new Set([P]);for(let t of Lt)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(Kl,"knownInputVersions");function jl(e,t="ark.config.json"){if(!qn(e))throw new H(t,[{path:"$",message:`must be an object; received ${ue(e)}`}]);let r=Kl(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new H(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${P}`}]);if(n!=="unversioned"&&!r.has(n))throw new H(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${P}`}]);let s=n,o={...e},i=0;for(;s!==P&&i<Lt.length+1;){i+=1;let l=Lt.find(c=>c.from===s);if(!l)throw new H(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${P}`}]);s=l.to,o.schemaVersion=s}if(s!==P)throw new H(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${P}`}]);return{candidate:$l(o),migratedFrom:Ml(n)}}a(jl,"migrateArkConfig");function Ul(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=jl(e,t),s=[];if(ve(r,zn,"$",zn,s),Nn(r,s),Tn(r,s),Pl(r,s),jn(r,s),s.length>0)throw new H(t,s);return{config:r,migratedFrom:n}}a(Ul,"loadArkConfigContract");function et(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new H(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return Ul(r,t)}a(et,"parseArkConfigJson");var Dt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",Gl=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],Hl=["no-anemic-model"],Yn={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Zn={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Dt,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:Dt},schemaVersion:{type:"string",const:"1.0",default:"1.0"},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:[...Gl]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:Yn,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:Yn}}}},fe=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 Ce(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Ce,"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 xe(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(xe,"valueType");function Vl(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(Vl,"resolveSchemaRef");function _e(e,t,r,n,s){if(t.$ref){let o=Vl(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}_e(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(!Ce(e)){s.push({path:r,message:`must be an object; received ${xe(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:tt(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:tt(r,i),message:"unknown field"});else if(Ce(t.additionalProperties)){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||_e(e[l],i,tt(r,l),n,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&_e(e[i],l,tt(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${xe(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)=>_e(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 ${xe(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}t.type==="boolean"&&typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${xe(e)}`})}a(_e,"validateNode");function Bl(e){return{...e,$schema:e.$schema===void 0?Dt:e.$schema,schemaVersion:e.schemaVersion===void 0?"1.0":e.schemaVersion,structure:e.structure===void 0?[]:e.structure,invariants:e.invariants===void 0?[]:e.invariants}}a(Bl,"defaultedArkRules");function Xn(e){return e==="enforced"?"enforced":"advisory"}a(Xn,"normalizeMode");function zl(e){return Hl.includes(e)}a(zl,"isTier2Sensor");function Wl(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(!Ce(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"&&zl(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(!Ce(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(Wl,"validateSemantics");function Jn(e,t="arkrules.json",r){if(!Ce(e))throw new fe(t,[{path:"$",message:`must be an object; received ${xe(e)}`}]);let n=Bl(e),s=[];if(_e(n,Zn,"$",Zn,s),Wl(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 fe(t,s);return{config:n}}a(Jn,"loadArkRulesContract");function Qn(e){let t={},r=[],n=[],s=[...e].sort((o,i)=>o.layer.localeCompare(i.layer));for(let o of s){let i=(o.file.structure??[]).map(c=>({...c,mode:Xn(c.mode),provenance:{sourceFile:o.sourceFile,ruleId:c.id,layer:o.layer}})),l=(o.file.invariants??[]).map(c=>({...c,mode:Xn(c.mode),provenance:{sourceFile:o.sourceFile,ruleId:c.id,layer:o.layer}}));t[o.layer]={sourceFile: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:"1.0",byLayer:t,structure:r,invariants:n}}a(Qn,"buildEffectiveArkRules");function te(){return{schemaVersion:"1.0",byLayer:{},structure:[],invariants:[]}}a(te,"emptyEffectiveArkRules");var Ft=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 es(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}a(es,"normalizeRel");function ts(e,t="ark.config.json"){let r=e.config.arkRules,n=[];if(!r||Object.keys(r).length===0){if(e.discoveredArkRulesFiles&&e.discoveredArkRulesFiles.length>0)for(let c of[...e.discoveredArkRulesFiles].sort())n.push({path:c,message:`ArkRules file ${JSON.stringify(c)} is not referenced by arkRules and will not be enforced`,severity:"advisory"});return{config:e.config,arkRules:te(),warnings:n}}let s=new Set(e.config.layers.map(c=>c.name)),o=[],i=[],l=new Set;for(let c of Object.keys(r).sort()){let d=r[c],u=`$.arkRules[${JSON.stringify(c)}]`;if(typeof d!="string"||d.length===0){o.push({path:u,message:"must be a non-empty relative path string"});continue}if(d.startsWith("/")||/^[A-Za-z]:[\\/]/.test(d)){o.push({path:u,message:"must be a project-relative path (absolute paths are not allowed)"});continue}if(!s.has(c)){o.push({path:u,message:`layer ${JSON.stringify(c)} is not declared in layers[]`});continue}let f=es(d);l.add(f);let g=e.fileContents[f]??e.fileContents[d];if(g===void 0){o.push({path:u,message:`referenced ArkRules file ${JSON.stringify(f)} is missing`});continue}try{let p=Jn(JSON.parse(g),f,c);i.push({layer:c,sourceFile:f,file:p.config})}catch(p){if(p instanceof fe)for(let A of p.issues)o.push({path:`${u}${A.path==="$"?"":A.path.replace(/^\$/,"")}`,message:`${f}: ${A.message}`});else p instanceof SyntaxError?o.push({path:u,message:`referenced ArkRules file ${JSON.stringify(f)} is not valid JSON: ${p.message}`}):o.push({path:u,message:`referenced ArkRules file ${JSON.stringify(f)} failed to load: ${p instanceof Error?p.message:String(p)}`})}}if(e.discoveredArkRulesFiles)for(let c of[...e.discoveredArkRulesFiles].sort()){let d=es(c);l.has(d)||n.push({path:d,message:`ArkRules file ${JSON.stringify(d)} is not referenced by arkRules and will not be enforced`,severity:"advisory"})}if(o.length>0)throw new Ft(t,o);return{config:e.config,arkRules:Qn(i),warnings:n}}a(ts,"resolveEffectiveContract");var ql=2e3,rs=new Map;function ns(e){try{return V.default.statSync(e).isFile()}catch{return!1}}a(ns,"isFile");function Mt(e){let t=rs.get(e);if(t){if(t.found!==null&&ns(t.found))return t.found;if(t.found===null&&Date.now()-t.at<ql)return null}let r=T.default.join(e,"ark.config.json"),n;if(ns(r))n=r;else{let s=T.default.dirname(e);n=s===e?null:Mt(s)}return rs.set(e,{found:n,at:Date.now()}),n}a(Mt,"findConfigInDir");function O(e){return!e||e==="<input>"||e.startsWith("stdin")?null:Mt(T.default.dirname(T.default.resolve(e)))}a(O,"findConfigPath");var pe=new Map,Yl=64;function Zl(e){try{let t=V.default.statSync(e,{throwIfNoEntry:!1});return t?.isFile()?`${t.mtimeMs}:${t.size}:${t.ino}`:null}catch{return null}}a(Zl,"configFileStamp");function Xl(e,t){if(!pe.has(e)&&pe.size>=Yl){let r=pe.keys().next().value;r!==void 0&&pe.delete(r)}pe.set(e,t)}a(Xl,"rememberContract");function as(e){let t=e?.arkRules;return!t||typeof t!="object"?[]:Object.entries(t).filter(r=>typeof r[1]=="string")}a(as,"arkRulesRefs");function Jl(e,t){let r=t.replace(/\\/g,"/").replace(/^\.\//,""),n=T.default.resolve(e,r),s=T.default.relative(e,n);if(!(s.startsWith("..")||T.default.isAbsolute(s)))try{return V.default.readFileSync(n,"utf8")}catch{return}}a(Jl,"readReferencedFile");function Pt(e,t){return as(t).map(([,r])=>{try{let n=V.default.statSync(T.default.resolve(e,r));return`${r}:${n.mtimeMs}:${n.size}`}catch{return`${r}:missing`}}).join("|")}a(Pt,"refStampsFor");function ss(e){return e instanceof Error?e.message:String(e)}a(ss,"errorText");function Ql(e,t){let r=T.default.dirname(e),n;try{n=et(t,e).config}catch(l){return{config:null,arkRules:te(),error:ss(l),fingerprint:null}}let s=as(n),o=(0,$t.createHash)("sha256").update(t);if(s.length===0)return{config:n,arkRules:te(),error:null,fingerprint:o.digest("hex")};let i={};for(let[,l]of s){let c=Jl(r,l);if(c===void 0)continue;let d=l.replace(/\\/g,"/").replace(/^\.\//,"");i[d]=c,o.update(`\0${d}\0${c}`)}try{let l=ts({config:n,fileContents:i},e);return{config:n,arkRules:l.arkRules,error:null,fingerprint:o.digest("hex")}}catch(l){return{config:null,arkRules:te(),error:ss(l),fingerprint:null}}}a(Ql,"resolveContract");function ge(e){let t=T.default.dirname(e),r=Zl(e),n=pe.get(e);if(n&&r!==null&&n.stamp===r&&Pt(t,n.refConfig)===n.refStamps)return n.result;let s;try{s=V.default.readFileSync(e,"utf8")}catch{return{config:null,arkRules:te(),error:null,fingerprint:null}}if(n?.source===s&&Pt(t,n.refConfig)===n.refStamps)return n.stamp=r,n.result;let o=Ql(e,s),i=o.config??ec(s,e);return Xl(e,{source:s,stamp:r,refConfig:i,refStamps:Pt(t,i),result:o}),o}a(ge,"loadArkContract");function ec(e,t){try{return et(e,t).config}catch{return null}}a(ec,"safeConfig");function ls(e){if(!V.default.existsSync(e))return null;let t=ge(e);return t.config?t.config:et(V.default.readFileSync(e,"utf8"),e).config}a(ls,"loadArkConfig");function K(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!mr(t,e)}a(K,"sourceIsInAnalysisScope");function B(e){return e?ge(e).config:null}a(B,"configForRule");var os="configInvalid",tc="Ark contract is invalid, so no architecture verdict is possible (fix it; ark-check fails closed the same way): {{detail}}",is=new WeakSet;function Kt(e){let t=O(e);return t?ge(t).error:null}a(Kt,"contractErrorForFile");function L(e){return{meta:{...e.meta,messages:{...e.meta.messages,[os]:tc,[ze]:Zr}},create(t){let r=Kt(x(t));return r?{Program(n){let s=q(t);if(s&&typeof s=="object"){if(is.has(s))return;is.add(s)}t.report({...n?.loc?.start?{node:n}:{loc:{line:1,column:0}},messageId:os,data:{detail:r.replace(/\s*\n\s*/g," ")}})}}:We(e,t,"blocking")}}}a(L,"withContractGuard");function jt(e=process.cwd()){let t=Mt(T.default.resolve(e));if(!t)return null;let r=ge(t);if(r.fingerprint)return r.fingerprint;try{return(0,$t.createHash)("sha256").update(V.default.readFileSync(t,"utf8")).digest("hex")}catch{return null}}a(jt,"contractFingerprint");var rc=256*1024;function nc(e){try{return cs.default.readFileSync(e,"utf8")}catch{return""}}a(nc,"readUtf8");function sc(e,t){if(!/\.(tsx?|mts|cts)$/i.test(e))return[];try{return Ee(e,t)}catch{return[]}}a(sc,"classShapesFor");function oc(e,t){if(!/\.(tsx?|mts|cts|jsx?|mjs|cjs)$/i.test(e)||e.endsWith(".d.ts"))return{};if(t.length>rc)return{};let r=Kr(e,t);return r?{[e]:r}:{}}a(oc,"hintsFor");function ds(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=O(r);if(!n||!r)return{};let s=ge(n),o=s.config;if(!o||s.arkRules.structure.length===0)return{};let i=Oe.default.dirname(n),l=Oe.default.resolve(r),c=Oe.default.relative(i,l).split(Oe.default.sep).join("/");if(!e(o,c))return{};let d=v(c,o.layers);return{Program(u){let f=le(t)??nc(l),g=Mr({arkRules:s.arkRules,classShapes:sc(c,f),files:[c],layerForFile:a(p=>p===c?d:v(p,o.layers),"layerForFile"),fileHints:oc(c,f)}).filter(p=>p.file===c);for(let p of g)_(t,{loc:{start:{line:p.line}},parent:u},"structure",{ruleId:p.ruleId,code:p.code,file:c,line:p.line,fromLayer:p.fromLayer,arkruleId:p.arkruleId,arkruleSource:p.arkruleSource,severity:p.severity,failsStrict:p.failsStrict,message:p.message},{arkruleId:p.arkruleId,sensor:p.sensor,message:p.message})}}}}}a(ds,"createArkRulesStructureRule");function rt(e){return typeof e?.value=="string"?e.value:void 0}a(rt,"stringValue");function Te(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 rt(e)}}a(Te,"staticStringValue");function nt(e){return e?.name??rt(e)}a(nt,"propertyName");function Ut(e,t){return t?Te(e):nt(e)}a(Ut,"staticKeyName");function us(e,t){let r=q(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}a(us,"referenceFor");function z(e,t,r){let n=us(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=q(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}a(z,"isLocallyBound");function fs(e,t){let r=us(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(fs,"isValueIdentifierReference");function Ne(e){if(e?.type==="Identifier"&&e.name)return{root:e,segments:[e.name]};if(!e)return;if(e.type==="ChainExpression"||e.type==="TSNonNullExpression")return Ne(e.expression);if(!(e.type==="MemberExpression"||!!(e.object&&e.property)))return;let r=Ne(e.object),n=Ut(e.property,e.computed);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}a(Ne,"memberExpressionPath");function st(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}a(st,"declarationIsTypeOnly");var j=D(require("path"),1);function ps(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(ps,"longestForbidden");var gs={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),r=e.options?.[0],n=O(t),s=B(n),o=n?j.default.dirname(n):null,i=null,l="this layer";if(s&&o&&t){let m=j.default.isAbsolute(t)?t:j.default.resolve(t),y=j.default.relative(o,m).split(j.default.sep).join("/");if(!K(s,y))return{};let R=s.layers?.find(k=>k.name===v(y,s.layers));R?.forbiddenGlobals?.length?(i=new Set(R.forbiddenGlobals),l=R.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let c=i,d=typeof q(e)?.getScope=="function",u=j.default.isAbsolute(t)?t:j.default.resolve(t),f=o?j.default.relative(o,u).split(j.default.sep).join("/"):t,g=a((m,y)=>{_(e,m,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:y,message:`${l} must not use the ambient global "${y}".`},{name:y,layer:l})},"report"),p=a((m,y,R,k)=>{if(R||typeof y!="string")return;let I=Me(y,c);I&&_(e,m,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:y,edgeKind:k,message:`${l} must not use module "${y}" because it is the import form of forbidden global "${I}".`},{layer:l,name:I,specifier:y,importKind:k})},"reportModule"),A=a((m,y)=>{if(m?.type==="ObjectPattern")for(let R of m.properties??[]){if(R.type==="RestElement")continue;let k=Ut(R.key,R.computed);if(!k)continue;let I=[...y,k],re=ps(c,I,y.length+1);if(re){g(R,re);continue}let ne=R.value,Fe=ne?.type==="AssignmentPattern"?ne.left:ne;A(Fe,I)}},"checkPattern"),S=a((m,y)=>{if(m?.type!=="ObjectPattern")return;let R=Ne(y);if(!R||z(e,R.root,R.segments[0]))return;let k=R.segments[0]==="globalThis"?R.segments.slice(1):R.segments;A(m,k)},"checkDestructure");return{MemberExpression(m){if(m.parent?.type==="MemberExpression"&&m.parent.object===m)return;let y=Ne(m);if(!y||z(e,y.root,y.segments[0]))return;let R=y.segments[0]==="globalThis",k=R?y.segments.slice(1):y.segments,I=ps(c,k,R?1:2);I?g(m,I):!d&&c.has(y.segments[0])&&g(m,y.segments[0])},VariableDeclarator(m){S(m.id,m.init)},AssignmentExpression(m){S(m.left,m.right)},CallExpression(m){let y=m;if(y.callee?.type==="Identifier"&&y.callee.name==="require"&&y.arguments?.[0]?.type==="Literal"&&!z(e,m,"require")&&p(m,y.arguments[0].value,!1,"require"),d)return;let R=y.callee?.type==="Identifier"?y.callee.name:void 0;R&&c.has(R)&&g(m,R)},ImportDeclaration(m){let y=m,R=(y.specifiers??[]).filter(I=>I.type==="ImportSpecifier"),k=R.length>0&&R.length===(y.specifiers??[]).length&&R.every(I=>I.importKind==="type");p(m,y.source?.value,y.importKind==="type"||k,"import")},ImportExpression(m){let y=m;y.source?.type==="Literal"&&p(m,y.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(m){let y=m;p(m,y.moduleReference?.expression?.value,y.importKind==="type"||y.isTypeOnly===!0,"require")},ExportNamedDeclaration(m){let y=m;if(!y.source)return;let R=y.specifiers??[],k=R.length>0&&R.every(I=>I.exportKind==="type");p(m,y.source.value,y.exportKind==="type"||k,"export")},ExportAllDeclaration(m){let y=m;p(m,y.source?.value,y.exportKind==="type","export")},NewExpression(m){if(d)return;let y=m.callee?.type==="Identifier"?m.callee.name:void 0;y&&c.has(y)&&g(m,y)},Identifier(m){!d||!m.name||!c.has(m.name)||!fs(e,m)||z(e,m,m.name)||g(m,m.name)}}}};var Le=D(require("path"),1);function hs(e,t){if(!(e?.type&&e.type!=="ObjectExpression"))return e?.properties?.find(r=>nt(r.key)===t)}a(hs,"objectProperty");function he(e,t){return hs(e,t)!==void 0}a(he,"objectHasProperty");function ic(e){let t=hs(e,"metadata")?.value;return he(t,"source")}a(ic,"objectHasMetadataSource");function ms(e){let t=e.callee;return t?.type==="Identifier"?t.name==="publish":t?.computed!==!0&&nt(t?.property)==="publish"}a(ms,"isPublishCall");function ys(e){return e?e.type==="Identifier"||e.type===void 0&&e.name?/^[A-Z]/.test(e.name??""):e.type==="MemberExpression"&&e.computed!==!0?ys(e.property):!1:!1}a(ys,"looksLikeIntentCreator");function ac(e){let t=Te(e);return t!==void 0&&ke(t)||he(e,"intent")||ys(e)}a(ac,"isArkPublishCandidate");function lc(e){let[t,r,n]=e;return ic(t)||he(r,"source")||he(n,"source")}a(lc,"publishHasSource");function cc(e){let t=x(e),r=O(t),n=B(r);if(!n||!r||!t)return null;let s=Le.default.relative(Le.default.dirname(r),Le.default.resolve(t)).split(Le.default.sep).join("/");return K(n,s)?s:null}a(cc,"scopedFile");var As={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=gt({publishCall:ms(t),rawIntentName:Te(r),objectHasIntent:he(r,"intent"),arkPublishCandidate:!1,hasSource:!0}).find(o=>o.ruleId==="RAW_EVENT_PUBLISH");s&&_(e,t,"rawPublish",{...s,file:x(e)})}}}},Rs={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=cc(e);return t?{CallExpression(r){let n=r.arguments??[],s=n[0],i=gt({publishCall:ms(r),rawIntentName:Te(s),objectHasIntent:he(s,"intent"),arkPublishCandidate:ac(s),hasSource:lc(n)}).find(l=>l.ruleId==="PUBLISH_MISSING_SOURCE");i&&_(e,r,"missingSource",{...i,file:t})}}:{}}};var De=D(require("fs"),1),E=D(require("path"),1);function ks(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(ks,"skipTrivia");function dc(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=ks(t,n);continue}if(o===","){let i=ks(t,n+1);if(t[i]==="}"||t[i]==="]"){n+=1;continue}}r+=o,n+=1}return r}a(dc,"stripJsonc");function Ss(e){return JSON.parse(dc(e))}a(Ss,"parseJsonc");var bs=new Map,me=new Map,uc=64;function Gt(e){try{let t=De.default.statSync(e);return`${t.mtimeMs}:${t.size}`}catch{return"missing"}}a(Gt,"fileStamp");function X(e){try{return De.default.statSync(e).isFile()}catch{return!1}}a(X,"isFile");function Es(e){let t=E.default.resolve(e),r=bs.get(t);if(r!==void 0&&(r===null||X(r)))return r;let n=E.default.join(t,"tsconfig.json"),s;if(X(n))s=n;else{let o=E.default.dirname(t);s=o===t?null:Es(o)}return bs.set(t,s),s}a(Es,"findNearestTsconfig");function fc(e,t){let r=e;for(;;){let n=E.default.join(r,"node_modules",t);for(let i of[n,`${n}.json`])if(X(i))return i;let s=E.default.join(n,"package.json");if(X(s))try{let i=JSON.parse(De.default.readFileSync(s,"utf8"));if(typeof i.tsconfig=="string"&&X(E.default.join(n,i.tsconfig)))return E.default.join(n,i.tsconfig)}catch{}if(X(E.default.join(n,"tsconfig.json")))return E.default.join(n,"tsconfig.json");let o=E.default.dirname(r);if(o===r)return null;r=o}}a(fc,"resolvePackageExtends");function pc(e,t){let r=E.default.dirname(e);if(t.startsWith(".")||E.default.isAbsolute(t)){let n=E.default.resolve(r,t);for(let s of[n,`${n}.json`])if(X(s))return s;return null}return fc(r,t)}a(pc,"resolveExtends");function Ht(e,t){return e.split("${configDir}").join(t)}a(Ht,"substituteConfigDir");function Is(e,t,r,n,s){if(r>8||n.has(e))return{};n.add(e),s.push({file:e,stamp:Gt(e)});let o;try{o=Ss(De.default.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 g=Ht(f,t),p=pc(e,g);if(!p){if(g.startsWith(".")||E.default.isAbsolute(g)){let S=E.default.resolve(E.default.dirname(e),g);for(let m of[S,`${S}.json`])s.push({file:m,stamp:Gt(m)})}continue}let A=Is(p,t,r+1,n,s);A.baseUrl!==void 0&&(i.baseUrl=A.baseUrl),A.paths!==void 0&&(i.paths=A.paths,i.pathsBase=A.pathsBase)}let d=o.compilerOptions??{},u=E.default.dirname(e);return typeof d.baseUrl=="string"&&(i.baseUrl=E.default.resolve(u,Ht(d.baseUrl,t))),d.paths&&typeof d.paths=="object"&&(i.paths=d.paths,i.pathsBase=u),i}a(Is,"loadChain");function gc(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=>Ht(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(gc,"buildAliasSet");function hc(e){let t=me.get(e);if(t&&t.chain.every(i=>Gt(i.file)===i.stamp))return t.result;let r=[],n=E.default.dirname(e),s=Is(e,n,0,new Set,r),o=gc(s,n);if(!me.has(e)&&me.size>=uc){let i=me.keys().next().value;i!==void 0&&me.delete(i)}return me.set(e,{chain:r,result:o}),o}a(hc,"aliasesForTsconfig");function Vt(e){let t=Es(e);return t?hc(t):{baseUrl:E.default.resolve(e),aliases:[]}}a(Vt,"readTsconfigPathAliases");function ws(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,E.default.join(e,"index.ts"),E.default.join(e,"index.tsx"),E.default.join(e,"index.js")];for(let r of t)if(X(r))return r;return null}a(ws,"existingSourceFile");function Bt(e,t){if(!t.startsWith("."))return null;let r=E.default.resolve(E.default.dirname(e),t);return ws(r)}a(Bt,"resolveRelativeImport");function mc(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(mc,"matchAlias");function ot(e,t,r){if(!t)return null;if(t.startsWith("."))return Bt(e,t);let n=e?E.default.dirname(E.default.resolve(e)):r??".",{baseUrl:s,aliases:o}=Vt(n);for(let i of o){let l=mc(i,t);if(l!==null){for(let c of i.targets){let d=i.wildcard?c.split("*").join(l):c,u=ws(E.default.resolve(s,d));if(u)return u}return null}}return null}a(ot,"resolveImportSpecifier");var yc="4.8.24";function Ac(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(Ac,"containingProgram");function Rc(e){let t=Ac(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!st(n))return!1;continue}if(!(n.type==="TSInterfaceDeclaration"||n.type==="TSTypeAliasDeclaration")){if(n.type==="ExportNamedDeclaration"){if(n.declaration){if(n.declaration.type!=="TSInterfaceDeclaration"&&n.declaration.type!=="TSTypeAliasDeclaration")return!1}else if(!st(n))return!1;r=!0;continue}return!1}}return r}a(Rc,"sourceProgramExportsOnlyTypes");var vs={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=O(t),n=B(r),s=r?w.default.dirname(r):null,o=a(i=>{let l=rt(i.source);if(l&&n&&s&&t){let c=w.default.isAbsolute(t)?t:w.default.resolve(t),d=w.default.relative(s,c).split(w.default.sep).join("/");if(!K(n,d))return;let u=v(d,n.layers);if(!u)return;let f=ot(c,l,s);if(!f)return;let g=w.default.relative(s,f).split(w.default.sep).join("/");if(g.startsWith(".."))return;let p=v(g,n.layers);if(!p)return;let A={fromPath:d,toPath:g,layers:n.layers},S=ft(n.rules,u,p,A),m=S?.rule;if(m){let y=i.type?.startsWith("Export")?"export":"import",R=st(i),k=!!m?.peerIsolation,I=R&&!k,re=S?.sliceVerdict,ne=re?pr({surface:"import",verdict:re,fromLayer:u,toLayer:p,kind:y,fromPath:d,toPath:g,ruleMessage:m?.message,childMessage:m?.childSlices?.message}):m?.message??`${u} must not ${y} ${p}.`,Fe=I?`${ne} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:ne;_(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:p,target:g,edgeKind:y,...k?{peerIsolation:!0}:{},...R?{typeOnly:!0}:{},...gr(re),...I?{failsStrict:!1,severity:"warning"}:{},...Rc(i)?{sourcePureTypeModule:!0}:{},message:Fe},{fromLayer:u,toLayer:p,specifier:l,message:Fe})}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),r=O(t),n=B(r),s=r?w.default.dirname(r):null;if(!n||!s||!t)return{};let o=w.default.isAbsolute(t)?t:w.default.resolve(t),i=w.default.relative(s,o).split(w.default.sep).join("/");if(!K(n,i))return{};let l=n.layers?.find(u=>u.name===v(i,n.layers));if(!l)return{};let c=new Set(Rr(l));if(c.size===0)return{};let d=a((u,f,g,p)=>{if(g||typeof f!="string"||Me(f,l.forbiddenGlobals??[]))return;let A=Ar(f);!A||!c.has(A)||_(e,u,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:l.name,target:f,capability:A,edgeKind:p,message:`${l.name} denies the ${A} capability; found import of "${f}".`},{layer:l.name,capability:A,specifier:f})},"check");return{ImportDeclaration(u){let f=u,g=(f.specifiers??[]).filter(A=>A.type==="ImportSpecifier"),p=g.length>0&&g.length===(f.specifiers??[]).length&&g.every(A=>A.importKind==="type");d(u,f.source?.value,f.importKind==="type"||p,"import")},ImportExpression(u){let f=u;f.source?.type==="Literal"&&d(u,f.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let f=u;d(u,f.moduleReference?.expression?.value,f.importKind==="type"||f.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let f=u;if(!f.source)return;let g=f.specifiers??[],p=g.length>0&&g.every(A=>A.exportKind==="type");d(u,f.source.value,f.exportKind==="type"||p,"export")},ExportAllDeclaration(u){let f=u;d(u,f.source?.value,f.exportKind==="type","export")},CallExpression(u){let f=u;f.callee?.type==="Identifier"&&f.callee.name==="require"&&f.arguments?.[0]?.type==="Literal"&&!z(e,u,"require")&&d(u,f.arguments[0].value,!1,"require")}}}},ye=nn({findConfigPath:O,loadArkConfig:B,resolveImportSpecifier:ot,lintedFilename:x,sourceIsInAnalysisScope:K,isLocallyBound:z,reportAdapterDiagnostic:_});function Sc(e,t){let r=w.default.dirname(w.default.resolve(e));return w.default.relative(r,w.default.resolve(t)).split(w.default.sep).join("/")}a(Sc,"toProjectRelative");var it=wn({findConfigPath:O,loadArkConfig:B,lintedFilename:x,sourceIsInAnalysisScope:K,isLocallyBound:z,reportAdapterDiagnostic:_,toProjectRelative:Sc}),xs=ds(K),bc=[vs,ye.noArkRunKernelInDomain,ye.noArkRunDirectNew,ye.noArkRunTransportBypass,it.noArkOrderKernelInDomain,it.noArkOrderGenericUpdate,xs],Ec={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:{[wt]:Yr},schema:[]},create(e){return Kt(x(e))?{}:Qr(bc.map(t=>We(t,e,"advisory")))}},_s=L(vs),Cs=L(As),Os=L(Rs),Ns=L(gs),Ts=L(kc),Ls=L(ye.noArkRunKernelInDomain),Ds=L(ye.noArkRunDirectNew),Fs=L(ye.noArkRunTransportBypass),Ps=L(it.noArkOrderKernelInDomain),$s=L(it.noArkOrderGenericUpdate),Ms=L(xs),Ks=Ec,js={"no-domain-infra-imports":_s,"no-raw-event-publish":Cs,"require-publish-source":Os,"no-forbidden-globals":Ns,"no-denied-capabilities":Ts,"no-arkrun-kernel-in-domain":Ls,"no-arkrun-direct-new":Ds,"no-arkrun-transport-bypass":Fs,"no-arkorder-kernel-in-domain":Ps,"no-arkorder-generic-update":$s,"arkrules-structure":Ms,"architecture-advisory":Ks},Ic={"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"},at={meta:{name:"arkgate",version:yc},rules:js};function wc(){let e=jt();return{plugins:{ark:at},rules:{...Ic},...e?{settings:{ark:{contractHash:e}}}:{}}}a(wc,"recommendedConfig");var zt={};Object.defineProperty(zt,"recommended",{enumerable:!0,configurable:!0,get:wc});at.configs=zt;var vc=at;0&&(module.exports={architectureAdvisory,arkRulesStructureRule,configs,contractFingerprint,findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport,rules});
1
+ "use strict";var eo=Object.create;var Ee=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var no=Object.getOwnPropertyNames;var ro=Object.getPrototypeOf,so=Object.prototype.hasOwnProperty;var a=(e,t)=>Ee(e,"name",{value:t,configurable:!0});var oo=(e,t)=>{for(var n in t)Ee(e,n,{get:t[n],enumerable:!0})},Xt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of no(t))!so.call(e,s)&&s!==n&&Ee(e,s,{get:()=>t[s],enumerable:!(r=to(t,s))||r.enumerable});return e};var P=(e,t,n)=>(n=e!=null?eo(ro(e)):{},Xt(t||!e||!e.__esModule?Ee(n,"default",{value:e,enumerable:!0}):n,e)),io=e=>Xt(Ee({},"__esModule",{value:!0}),e);var Zc={};oo(Zc,{architectureAdvisory:()=>Xs,arkRulesStructureRule:()=>Zs,configs:()=>Zt,contractFingerprint:()=>Vt,default:()=>qc,findConfigPath:()=>D,globToRegExp:()=>T,isEdgeDenied:()=>kn,layerForRelativePath:()=>w,loadArkConfig:()=>bs,noArkOrderGenericUpdate:()=>qs,noArkOrderKernelInDomain:()=>Ys,noArkRunDirectNew:()=>Ws,noArkRunKernelInDomain:()=>Vs,noArkRunTransportBypass:()=>zs,noDeniedCapabilities:()=>Bs,noDomainInfraImports:()=>Us,noForbiddenGlobals:()=>Hs,noRawEventPublish:()=>js,patternSpecificity:()=>pt,plugin:()=>ft,readTsconfigPathAliases:()=>Yt,requirePublishSource:()=>Gs,resolveImportSpecifier:()=>dt,resolveRelativeImport:()=>qt,rules:()=>Js});module.exports=io(Zc);var _=P(require("path"),1);function ao(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(ao,"sharedImportsSliceMode");var Jt=new Map;function Qt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Qt,"escapeLiteral");function Ue(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(Ue,"normalizeGlobSeparators");function lo(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(lo,"bracesBalanced");function T(e){let t=Jt.get(e);if(t)return t;let n=Ue(e),r=lo(n),s="",o=0;for(let l=0;l<n.length;l+=1){let c=n[l];c==="\\"&&l+1<n.length?(s+=Qt(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+=Qt(c)}let i=new RegExp(`^${s}$`);return Jt.set(e,i),i}a(T,"globToRegExp");function co(e){return Ue(String(e)).split("/").filter(Boolean).filter(n=>n!=="**"&&n!=="*"&&!n.includes("*")&&!n.includes("?")&&!n.includes("{")&&!n.includes("["))}a(co,"concreteGlobSegments");function pt(e,t){let n=Ue(String(e)),r=co(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(pt,"patternSpecificity");function w(e,t){let n=String(e).split(/[/\\]/).join("/"),r,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>T(i).test(n))){for(let i of o.patterns??[])if(T(i).test(n)){let l=pt(i,n);l>s&&(s=l,r=o.name)}}return r}a(w,"layerForRelativePath");function je(e,t,n){return fn(e,t,n==="stars"?"stars":"path")}a(je,"sliceIdForPath");function en(e,t){return fn(e,t?[...t]:void 0,un)}a(en,"legacyStarsSliceIdForPath");var un="stars-4.8.23";function fn(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=uo(o);if(i.anchored){let l=go(r,i.anchored,n);if(l)return l;continue}i.bare!==void 0&&s.add(i.bare)}return mo(r,s)}a(fn,"sliceIdWithBinding");var $e=new Map;function uo(e){let t=$e.get(e);if(t)return t;let n={};return fo(e)?n={anchored:po(e)}:!e.includes("/")&&!e.includes("\\")&&!e.includes("*")&&(n={bare:e.toLowerCase()}),$e.size>=1024&&$e.clear(),$e.set(e,n),n}a(uo,"parsedSliceFolder");function fo(e){let t=e.split(/[/\\]/).filter(n=>n.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(n=>n==="*")}a(fo,"isAnchoredSliceEntry");function po(e){return e.split(/[/\\]/).filter(t=>t.length>0).map(t=>t.toLowerCase())}a(po,"anchoredSlicePattern");function go(e,t,n){let r=gn(e,t[0]??"");for(let s of r){let o=ho(e,t,s,n);if(o)return o}}a(go,"anchoredSliceIdFromPattern");function ho(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===un?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(ho,"bindAnchoredSlice");function pn(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(pn,"starsKeptSegmentIndexes");function mo(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(mo,"bareSliceId");function yo(e){let t=new Set;for(let n of e??[]){let s=Ue(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(yo,"inferSliceFoldersFromPatterns");function Ao(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 yo(r?.patterns)}a(Ao,"resolveSliceFolders");function tn(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(tn,"normalizeSegments");function Ie(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Ie,"trimTrailingSlashes");var Ro=["src","app"];function gn(e,t){let n=(e[0]??"").toLowerCase(),r=t.toLowerCase();return Ro.includes(n)&&r!==n?[0,1]:[0]}a(gn,"anchorOffsets");function So(e){let t=Ie(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(So,"isBlanketRoot");function nn(e,t){if(!e||!t?.length)return!1;let n=String(e).split(/[/\\]/).join("/"),r=n.toLowerCase(),s=tn(n);for(let o of t){if(typeof o!="string"||o.length===0||So(o))continue;if(o.includes("*")){let c=Ie(o.toLowerCase());if(T(c).test(r)||T(`${c}/**`).test(r))return!0;continue}let i=tn(o);if(i.length===0)continue;let l=gn(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(nn,"pathUnderSharedRoot");function rn(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(rn,"sliceMatchesDeclaration");function sn(e,t,n){return!e?.length||!t||!n?!1:e.some(r=>r&&typeof r.from=="string"&&typeof r.to=="string"&&rn(r.from,t)&&rn(r.to,n))}a(sn,"crossSliceEdgeAllowed");function ko(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(ko,"peerIsolationDecision");function hn(e){return Ie(e.trim().replace(/\\/g,"/")).toLowerCase()}a(hn,"aliasGlobPattern");function bo(e,t){let n=hn(e);if(!n||n==="*"||n==="**")return!1;let r=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=Ke(r),o=T(n),l=(n.split("/").pop()??"").includes("*")?null:T(`${n}/**`),c=a(d=>o.test(d)||l!==null&&l.test(d),"hit");return c(r)||s!==r&&c(s)}a(bo,"aliasGlobMatches");function mn(e){let t=hn(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(mn,"splitAliasTarget");function yn(e,t){for(let n of t.childSlices?.sliceAliases??[])if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&bo(n.from,e))return n;return null}a(yn,"firstSliceAliasEntry");function Eo(e,t){let n=yn(e,t);return n?mn(n.to):null}a(Eo,"firstSliceAlias");function Io(e,t,n){if(!e)return{};let r=n??t.sliceFolders,s=je(e,r?[...r]:void 0,t.sliceIdentity),o=Me(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=Eo(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(Io,"resolveGovernedSlice");function vo(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=pn(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(vo,"starsUniverseShapes");function on(e,t){return e.length===t.length&&e.every((n,r)=>n===null||t[r]==="*"||n===t[r])}a(on,"literalsMatch");function wo(e,t){let n=t.split("/").filter(Boolean).map(o=>o.toLowerCase()),r=vo(e);if(n.length===0||r.some(o=>on(o.literals,n)))return[];let s=new Set;for(let o of r)if(o.legacy.length!==o.literals.length&&on(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(wo,"legacyStarsIdTargets");function xo(e,t){if(e.sliceIdentity!=="stars")return;let n=mn(t);if(n)return wo(e.sliceFolders,n.universeId).length===1?n.universeId:void 0}a(xo,"legacyAliasUniverse");function an(e,t,n){let r=Io(e,t,n);if(!e||t.sliceIdentity!=="stars")return r;if(r.universeId){let s=yn(e,t);if(!je(e,[...n],t.sliceIdentity)&&s&&xo(t,s.to)!==void 0)return{...r,legacyAlias:!0,legacyUniverse:r.universeId,legacyChild:r.childId};let i=en(e,n),l=t.childSlices,c=l?.sliceIdentity==="stars"?en(e,l.sliceFolders):void 0;return{...r,...i?{legacyUniverse:i}:{},...c&&r.childId?{legacyChild:c}:{}}}return r}a(an,"placeForPair");function Co(e,t,n,r){let s=an(n,e,t),o=an(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=sn(e.allowedCrossSlice,d.universeId,u.universeId)||e.sliceIdentity==="stars"&&(i!==d.universeId||l!==u.universeId)&&sn(e.allowedCrossSlice,i,l),p=e.childSlices?.sliceIdentity==="stars"&&s.legacyChild!==void 0&&o.legacyChild!==void 0&&s.legacyChild!==o.legacyChild&&An(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(Co,"resolveGovernedSlicePair");function _o(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=pn(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(_o,"childPatternDirectory");function Oo(e,t){let n=Ke(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(Oo,"sharedDirectoryPrefix");function To(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(To,"withSourcePrefix");function No(e,t,n){let r=null;for(let s of n.sliceFolders){if(typeof s!="string")continue;let o=_o(s,t,n.sliceIdentity);if(!o)continue;let i=Oo(e,o);(!r||i>r.score||i===r.score&&o.length<r.dir.length)&&(r={dir:o,score:i})}return r?To(e,r.dir):""}a(No,"sliceAliasDestination");var Lo="<Layer>";function Do(e,t){let n=Lo;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(Do,"sliceRuleFileName");function Ge(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?je(c,s.sliceFolders,s.sliceIdentity):void 0,u=Me(c,d,o);if(!u.childId||l.has(u.childId))continue;let f=No(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=Do(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(Ge,"resolveSliceRulePlan");function Fo(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(Fo,"peerIsolationDenyExplanation");function Po(e,t){return`cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(Po,"crossParentExplanation");function $o(e,t,n){return`cross-sibling slice ${e} \u2192 ${t} inside ${n}.`}a($o,"crossSiblingExplanation");function Mo(e){return`universe common imports child ${e}. parentMayImportChild is off.`}a(Mo,"parentImportsChildExplanation");function ln(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(ln,"universePairLabel");function Ko(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(Ko,"isCommonFolderName");function Me(e,t,n){if(!e||!n?.sliceFolders?.length)return{};let r=je(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 Ko(i,n.commonFolders)?{}:{childId:r}}a(Me,"resolveChildSliceId");function Uo(e){return Ie(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Uo,"siblingEntryKey");function Ke(e){return e.replace(/^(?:src|app)\//,"")}a(Ke,"stripSrcOrApp");function jo(e,t){let n=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),r=Ke(t);if(!r)return!1;let s=Ke(n);return n===r||n.startsWith(`${r}/`)||s===r||s.startsWith(`${r}/`)}a(jo,"pathUnderSubtree");function Go(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=Uo(s);if(!(!o||o.includes("*"))&&(r===o||e&&jo(e,o)))return!0}return!1}a(Go,"importerInEnforcedSubtree");function Ho(e,t,n){return e==null||e==="deny"?!1:e==="advisory"?!0:e.default==="deny"?!1:!Go(t,n,e.enforce)}a(Ho,"siblingCrossingAdvisory");function cn(e){if(typeof e!="string")return null;let t=Ie(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(cn,"childSlicePatternSegments");function dn(e,t){let n=cn(e),r=cn(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(dn,"childSlicePatternMatches");function An(e,t,n){if(!e?.length)return!1;for(let r of e)if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&dn(r.from,t)&&dn(r.to,n))return!0;return!1}a(An,"childCrossSliceAllowed");function Bo(e){let t=ko({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:ao(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?Po(e.fromSlice,e.toSlice):Fo(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??Me(e.fromPath,e.fromSlice,n).childId,s=e.toChild??Me(e.toPath,e.toSlice,n).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return r&&s&&r!==s?e.legacyChildAllowed||An(n.allowedCrossSlice,r,s)?o:{crossing:"cross-sibling",decision:Ho(n.siblings,e.fromPath,r)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:$o(r,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!r&&s&&n.parentMayImportChild!==!0?{crossing:"parent-imports-child",decision:"deny",explanation:Mo(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(Bo,"evaluateNestedSliceWall");function Vo(e){return e?.crossing==="cross-sibling"||e?.crossing==="parent-imports-child"}a(Vo,"isChildWallCrossing");function Rn(e){let t=e.verdict.explanation,n=Vo(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(Rn,"composeSliceDenialMessage");function Sn(e){if(!e||e.decision==="allow")return{};let t=ln(e.fromUniverse),n=ln(e.toUniverse);return{...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&n?{universeFrom:t,universeTo:n}:{},...e.decision==="advisory"?{failsStrict:!1,severity:"warning"}:{}}}a(Sn,"sliceFindingExtras");function Wo(e,t,n,r){return gt(e,t,n,r)?.rule}a(Wo,"findDeniedEdgeRule");function gt(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=Ao(s,t,r?.layers),c=Co(s,l,o,i),d=c.from,u=c.to,f=d.universeId,p=u.universeId,g=Bo({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:p,fromChild:d.childId,toChild:u.childId,fromShared:!f&&nn(o,s.sharedRoots),toShared:!p&&nn(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(gt,"findDeniedEdgeDecision");function kn(e,t,n,r){return Wo(e,t,n,r)!==void 0}a(kn,"isEdgeDenied");var zo=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function Yo(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(r=>typeof r=="string"):[];return[...e?.excludeGenerated===!1?[]:zo,...t]}a(Yo,"scanExcludePatterns");function ht(e,t){let n=String(e).split(/[/\\]/).join("/");return Yo(t).some(r=>T(r).test(n))}a(ht,"isScanExcludedRelative");var bn=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),qo=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),ed=Object.freeze(Object.keys(qo).sort()),mt=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"}),Zo=Object.freeze({process:Object.freeze(["process","node:process"])});function En(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=mt[e];if(t)return t;let n=e.indexOf("/");if(n<0)return null;let r=e.slice(0,n),s=mt[r];if(s)return s;let o=e.indexOf("/",n+1);return o<0?null:mt[e.slice(0,o)]??null}a(En,"capabilityForModuleSpecifier");function He(e,t){for(let n of t)if(Zo[n]?.includes(e))return n;return null}a(He,"forbiddenGlobalForModuleSpecifier");function In(e){if(e?.pure===!0)return[...bn].sort();let n=(e?.capabilities?.deny??[]).filter(r=>bn.includes(r));return[...new Set(n)].sort()}a(In,"effectiveCapabilityDeny");var Ot=P(require("fs"),1),q=P(require("path"),1);var vn={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 ve(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(ve,"looksLikeArkIntent");function yt(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&ve(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:vn.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:vn.PUBLISH_MISSING_SOURCE}),t}a(yt,"classifyPublishFacts");var Jo=["createArkKernel","createStrictArkKernel","createLenientArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig","createLenientArkKernelFromConfig"],Qo="ArkModule",ei=["forRoot","forRootAsync"],ti=["ArkKernel","EventBus","EventPublisher","ArkRunPublisher"],Cn=new Set(["eventBus"]),ni=new Set(["publisher","eventBus"]),ri=new Set(ei),si=new Set(ti);var Be=new Set(Jo),oi=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"]),_n=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function te(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")||e==="arkgate/nestjs"||e.startsWith("arkgate/nestjs/")}a(te,"isArkRunKernelModuleSpecifier");var ii=["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"],At=new Set(ii);function On(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(At.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let n=e.slice(0,t);if(At.has(n))return!0;let r=e.indexOf("/",t+1);return r<0?!1:At.has(e.slice(0,r))}a(On,"isArkRunTransportBypassSpecifier");function Rt(e){if(Be.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(Rt,"arkRunKernelCallKind");function Tn(e,t){let n=1;for(let r=0;r<t;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}a(Tn,"lineAt");function St(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,n=>" ".repeat(n.length)))}a(St,"stripCommentsPreservingLines");function ai(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(ai,"firstStringLiteralArg");function wn(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(wn,"keywordBefore");function we(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(we,"parseValueImportClause");function Nn(e,t){we(St(e),t)}a(Nn,"forEachArkRunValueImportClause");function Ln(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(Ln,"bracedValueImportBindings");function li(e){let t=new Map,n=new Set;return we(e,(r,s)=>{if(!te(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 Ln(r))t.set(l,c)}),{named:t,namespaces:n}}a(li,"collectKernelImportBindings");function ci(e,t){let n=new Set(t);return we(e,(r,s)=>{for(let{local:o,original:i}of Ln(r))/^[A-Z]/.test(i)&&(te(s)||t.has(i)||t.has(o))&&(n.add(o),n.add(i))}),n}a(ci,"collectImportedConstructors");function di(e,t){let n;return we(e,(r,s)=>{!n&&new RegExp(`\\b${t}\\b`).test(r)&&(n=s)}),n}a(di,"importedFromForName");function ui(e){let t=new Set,n=/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;){if(!te(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;si.has(c)&&t.add(d)}}return t}a(ui,"collectKernelTypeNames");function fi(e,t){let n=e.split(".");if(n.length===2)return t.namespaces.has(n[0])&&Be.has(n[1]);if(n.length!==1)return!1;let r=t.named.get(n[0]);return r!==void 0&&Be.has(r)}a(fi,"isFactoryCalleeExpression");function pi(e,t,n,r){we(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(pi,"addRootModuleImports");function gi(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])&&(!ni.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(Cn.has(p)){if(n.has(g))continue;n.add(g),d=!0}else Rt(p)&&!Be.has(p)&&r.add(g)}}}a(gi,"addDerivedReceivers");function hi(e,t,n){let r={receivers:new Set,calleeBindings:new Set,rootNamespaces:new Set};n&&pi(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;)fi(o[2].replace(/\s+/g,""),t)&&r.receivers.add(o[1]);let i=ui(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 gi(e,r),r}a(hi,"traceKernelReceivers");function mi(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(mi,"matchingOpenParen");function xn(e){let t=e.split(".").map(n=>n.trim()).filter(n=>n.length>0);return t[0]==="this"?t.slice(1):t}a(xn,"chainParts");function yi(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:xn(r[1].replace(/\?/g,"")),viaPublisherCall:!1}}let s=/\)\s*\??\.\s*$/.exec(n);if(!s)return;let o=t-n.length+s.index,i=mi(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:xn(c[1].replace(/\?/g,"")),viaPublisherCall:!0}:{parts:["<expr>"],viaPublisherCall:!1}}a(yi,"receiverChainBefore");function Ai(e,t,n){let[r,...s]=e.parts;return r?s.length===0&&t.namespaces.has(r)?!0:_n.has(r)||!n.receivers.has(r)?!1:(n.rootNamespaces.has(r)?s.slice(1):s).every(i=>Cn.has(i)):!1}a(Ai,"chainReachesKernel");function Ri(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(Ri,"collectDefinedIntentNames");function Si(e,t){return/^\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(e.slice(t))?.[1]}a(Si,"firstIdentifierArg");function ki(e,t){return ve(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(ki,"carriesIntentPrefix");function bi(e){if(!e)return;if(e.viaPublisherCall)return"publisher";let t=e.parts[e.parts.length-1];return t==="<expr>"?void 0:t}a(bi,"receiverName");function Ei(e,t,n){if(!e||t===void 0||!ki(t,n))return!1;let r=e.parts[0];return r!==void 0&&r!=="<expr>"&&!_n.has(r)}a(Ei,"untracedKernelNameEvidence");function Ve(e,t,n={}){let r=St(t),s=li(r),o=hi(r,s,n.isKernelRootSpecifier),i=Ri(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(wn(r,f,"function")||wn(r,f,"class"))continue;let p=yi(r,f),g=bi(p),m=s.named.get(u)??u,R=Rt(m)??Rt(u),k=s.named.has(u)||o.calleeBindings.has(u)||p?.parts.length===1&&s.namespaces.has(p.parts[0]);if(!R&&ri.has(u)&&p?.parts.length===1&&s.named.get(p.parts[0])===Qo&&(R="factory",k=!0),!R||R==="factory"&&p!==void 0&&!k)continue;let y=f+d[0].length,A=ai(r,y);if(R!=="factory"&&(p===void 0?!k:!Ai(p,s,o))&&!Ei(p,A,n.intentPrefixes))continue;let S=Si(r,y),v=A??(S?i.get(S):void 0);l.push({file:e,line:Tn(t,f),kind:R,callee:u,viaImport:k,...g?{receiver:g}:{},...v?{nameLiteral:v}:{}})}return l}a(Ve,"extractArkRunKernelCallsFromSource");function kt(e,t,n){let r=St(t),s=ci(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(oi.has(c)||!s.has(c))continue;let d=di(r,c);o.push({file:e,line:Tn(t,l.index),typeName:c,...d?{importedFrom:d}:{}})}return o}a(kt,"extractArkRunManagedNewsFromSource");var Ii=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),vi=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),wi=new Set(["return","typeof","case","do","else","in","of","new","delete","void","throw","instanceof","yield","await"]);function xi(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 wi.has(e.slice(s+1,n+1))}return r==="/"&&e[n-1]==="*"?!1:vi.has(r)}a(xi,"slashStartsRegex");function Ci(e,t){if(!xi(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(Ci,"skipRegexLiteral");function le(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 Ci(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(le,"skipStringOrComment");function ie(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=le(e,n);continue}break}return n}a(ie,"skipWsAndComments");function Dn(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(Dn,"readIdent");function ae(e,t,n,r){if(e[t]!==n)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=le(e,o);if(i!==o){o=i;continue}let l=e[o];l===n?s+=1:l===r&&!(r===">"&&e[o-1]==="=")&&(s-=1),o+=1}return s===0?o:null}a(ae,"skipBalanced");function Fn(e){let t=[],n=0,r;for(;n<e.length&&(n=ie(e,n),!(n>=e.length));){if(e[n]===";"){n+=1;continue}let s=[],o=n;for(;;){let u=Dn(e,o);if(!u||!Ii.has(u.ident))break;s.push(u.ident),o=ie(e,u.end)}if(s.length===1&&s[0]==="static"&&e[o]==="{"){let u=ae(e,o,"{","}");if(u==null){r=e.length;break}n=u;continue}let i=Dn(e,o);if(!i){n+=1;continue}if(o=ie(e,i.end),e[o]==="<"){let u=ae(e,o,"<",">");if(u==null){r=e.length;break}o=ie(e,u)}if(e[o]==="("){let u=ae(e,o,"(",")");if(u==null){r=e.length;break}if(o=ie(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let f=le(e,o);if(f!==o){o=f;continue}o+=1}if(e[o]==="{"){let f=ae(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=le(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(Fn,"scanClassMembers");function _i(e,t){let n=t;for(;n<e.length;){let r=ie(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=ae(e,n,s,s==="<"?">":s==="("?")":"]");if(i==null)return null;n=i;continue}if(s==='"'||s==="'"||s==="`"){n=le(e,n);continue}n+=1}return null}a(_i,"findClassBodyBrace");function Pn(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=Oi(e),o;for(;(o=r.exec(s))!==null;){let i=t.exportedOnly?o[1]:o[2],l=t.exportedOnly===!0||o[1]==="export",c=_i(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=ae(e,c,"{","}");n.push({name:i,start:o.index,exported:l,bodyStart:c+1,bodyEnd:d==null?null:d-1})}return n}a(Pn,"findClassDeclarations");function Oi(e){let t="",n=0;for(;n<e.length;){let r=le(e,n);if(r!==n){t+=e.slice(n,r).replace(/[^\n]/g," "),n=r;continue}t+=e[n],n+=1}return t}a(Oi,"maskStringsAndComments");var Ti=/\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)/,Ni=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)/,Li=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]/g,Di=["db","tx","client","prisma","prismaClient","drizzle"],Fi="(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))",Un=/\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,Pi=/^(?: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)$/,$n=/(^|[^\w$])([A-Za-z_$][\w$]*)\s*`((?:[^`\\]|\\[\s\S])*)`/g,$i=/\bINSERT\s+INTO\b[\s\S]*?\bON\s+CONFLICT\b[\s\S]*?\bDO\s+UPDATE\s+SET\b[^;`]*/gi,Mn="\\((?:[^()]|\\([^()]*\\))*\\)",Mi=`\\bnew\\s+PrismaClient\\s*${Mn}|\\bdrizzle\\s*${Mn}`,Ki=/(?<![\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,Ui=/(?<![\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 ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(ji,"escapeRegExp");function xe(e){return Ti.test(e)||Ni.test(e)}a(xe,"sourceImportsPersistenceDriverText");function Kn(e,t,n){let r=new RegExp(e.source,"g"),s;for(;(s=r.exec(t))!==null;)s[1]&&n.add(s[1])}a(Kn,"collectFirstGroup");function Gi(e){let t=new Set;Kn(Ki,e,t),Kn(Ui,e,t);let n=new RegExp(Li.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(Gi,"persistenceClientBindings");function jn(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(jn,"blankPersistenceComments");function Gn(e){let t=jn(e);$n.lastIndex=0;let n;for(;(n=$n.exec(t))!==null;)if(!Pi.test(n[2]??"")&&Un.test((n[3]??"").replace($i," ")))return!0;return!1}a(Gn,"sourceHasTaggedSqlWrite");function We(e){let t=jn(e),n=[...Di,...Gi(t)].map(ji).join("|");return new RegExp(`(?:\\b(?:${n})(?![\\w$])|${Mi})(?:\\s*\\.\\s*[A-Za-z_]\\w*)*\\s*\\.\\s*${Fi}\\s*\\(`,"i").test(t)?!0:Un.test(t)}a(We,"sourceHasPersistenceWrite");var Hi=["no-anemic-model"],Vn=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Bi=new RegExp(`\\b(${Vn.join("|")})\\b`),Wn="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",Vi=new RegExp(`\\bthis\\.${Wn}\\.push\\s*\\(`),Wi=new RegExp(`^this\\.${Wn}\\s*=\\s*\\[\\s*\\]`),zi=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,Yi=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g;function qi(){return`${Vn.join(", ")}, or events-array .push(`}a(qi,"expectedDomainInvariantWordsPhrase");function Zi(e){return Bi.test(e)||Vi.test(e)}a(Zi,"referencesGuardOrPublish");function Xi(e,t,n){let r=e.slice(t);if(Wi.test(r))return!0;if(!zi.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 Ji(e,t){let n=new RegExp(Yi.source,"g"),r;for(;(r=n.exec(t))!==null;)if(!Xi(t,r.index,e))return!0;return!1}a(Ji,"methodAssignsThis");function Hn(e,t){return t==null?e:{...e,truncatedUntil:t}}a(Hn,"attachShapeTruncation");function zn(e){return typeof e.truncatedUntil=="number"?e.truncatedUntil:void 0}a(zn,"shapeTruncatedUntil");function Qi(e){let t=zn(e);return t==null?"":` shape analysed until character ${t}`}a(Qi,"shapeTruncationSuffix");function Bn(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Bn,"escapeGlobLiteral");function ea(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+=Bn(t[r+1]),r+=1):s==="*"?t[r+1]==="*"?t[r+2]==="/"?(n+="(?:.*/)?",r+=2):(n+=".*",r+=1):n+="[^/]*":s==="?"?n+="[^/]":n+=Bn(s)}return new RegExp(`^${n}$`)}a(ea,"globToRegExp");function ze(e,t){return!t||t.length===0?!0:t.some(n=>ea(n).test(e))}a(ze,"matchesAppliesTo");function ta(e){return Hi.includes(e)}a(ta,"isTier2");function na(e){return e.mode==="enforced"&&!ta(e.sensor)?{severity:"error",failsStrict:!0}:{severity:"warning",failsStrict:!1}}a(na,"severityFor");function W(e,t,n,r=1){let{severity:s,failsStrict:o}=na(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(W,"baseViolation");function Ye(e,t,n){if(!n)return!0;let r=n(e);return r?r===t.provenance.layer:!1}a(Ye,"isInRuleLayer");function qe(e,t,n){return t.filter(r=>!(!r.exported||!ze(r.file,e.appliesTo)||!Ye(r.file,e,n)))}a(qe,"shapesForRule");function bt(e,t,n){let r=zn(t);if(r!=null)return W(e,t.file,`Exported class ${t.className} shape analysed until character ${r}; later ${n} may be invisible (sensor ${e.sensor}).`)}a(bt,"truncatedShapeViolation");function ra(e,t,n){let r=[];for(let s of qe(e,t,n)){let o=bt(e,s,"members");o&&r.push(o),(s.hasPublicSetters||s.hasPublicMutableFields)&&r.push(W(e,s.file,`Exported class ${s.className} exposes public mutable state (sensor aggregate-private-state).`))}return r}a(ra,"evaluateAggregatePrivateState");function sa(e,t,n){let r=[];for(let s of qe(e,t,n)){let o=bt(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(W(e,s.file,`Exported class ${s.className} exposes a public constructor without a static factory (sensor always-valid-factory).`))}}return r}a(sa,"evaluateAlwaysValidFactory");function oa(e,t,n){let r=[],s=qi();for(let o of qe(e,t,n)){let i=Qi(o),l=bt(e,o,"methods");l&&r.push(l);for(let c of o.mutatingMethods)c.referencesGuardOrPublish||r.push(W(e,o.file,`Mutating method ${o.className}.${c.name} does not reference ${s} (sensor domain-event-on-mutation).${i}`))}return r}a(oa,"evaluateDomainEventOnMutation");function ia(e,t){let n=[];for(let r of t.files)ze(r,e.appliesTo)&&Ye(r,e,t.layerForFile)&&t.fileHints?.[r]?.orchestrationHeavy&&n.push(W(e,r,"File appears to embed domain branching beyond guard-and-delegate orchestration (sensor orchestration-only)."));return n}a(ia,"evaluateOrchestrationOnly");function aa(e,t){let n=[];for(let r of t.files)ze(r,e.appliesTo)&&Ye(r,e,t.layerForFile)&&t.fileHints?.[r]?.adapterThick&&n.push(W(e,r,"Adapter module mixes domain branching, persistence, and mapping beyond a thin adapter (sensor thin-adapter)."));return n}a(aa,"evaluateThinAdapter");function la(e,t){let n=[];for(let r of t.files)ze(r,e.appliesTo)&&Ye(r,e,t.layerForFile)&&t.fileHints?.[r]?.persistenceWrite&&n.push(W(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(la,"evaluateWritesViaAggregate");function ca(e,t,n){let r=[];for(let s of qe(e,t,n))if(s.dataOnly===!0){let o=W(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(ca,"evaluateNoAnemicModel");function Yn(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(...ra(n,e.classShapes,e.layerForFile));break;case"always-valid-factory":t.push(...sa(n,e.classShapes,e.layerForFile));break;case"domain-event-on-mutation":t.push(...oa(n,e.classShapes,e.layerForFile));break;case"orchestration-only":t.push(...ia(n,e));break;case"thin-adapter":t.push(...aa(n,e));break;case"writes-via-aggregate":t.push(...la(n,e));break;case"no-anemic-model":t.push(...ca(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(Yn,"evaluateArkRuleSensors");function da(e){return e==="PersistenceAdapters"}a(da,"isPersistenceDriverLayer");function ua(e,t){if(xe(e))return!0;if(!t)return!1;for(let n of t){if(da(n.layer))return!0;let r=n.specifier;if(!r)continue;let s=`from '${r}'`;if(xe(s))return!0}return!1}a(ua,"sourceImportsPersistenceDriver");var fa=/\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*=)/,pa=/(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/,ga=/\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*=/,ha=/\bif\s*\(\s*(?:!)?(?:order|invoice|cart|user|account|policy|aggregate|entity|amount|total|balance|status|state)\b/i;function qn(e,t,n){if(!t)return null;let r=ua(t,n),s=r&&We(t)||Gn(t);if(t.length<40)return s?{persistenceWrite:!0}:null;let o=t.match(new RegExp(ga.source,"g"))??[],i=t.match(new RegExp(ha.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=fa.test(t)||pa.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(qn,"deriveArkRuleFileHints");var ma=new Set(["if","match","when"]);function Ce(e,t){let n=[];for(let r of Pn(t,{exportedOnly:!0})){let s=r.name;if(r.bodyStart==null){n.push(Hn({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=Fn(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")||ma.has(S.name)||Ji(S.name,S.body)&&k.push({name:S.name,referencesGuardOrPublish:Zi(S.body)}));let A=c.members.filter(S=>S.kind==="method").length<=1&&u.length>=2&&f;n.push(Hn({file:e,className:s,exported:!0,hasPublicMutableFields:f,hasPublicSetters:p,hasPublicConstructor:m,hasStaticFactory:R,mutatingMethods:[...k],dataOnly:A},d))}return n}a(Ce,"extractClassShapesFromSource");function ya(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(ya,"normalizeExtraMergeTeethClassification");function Ze(e){let t=ya(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(Ze,"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 Zn=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.")]),Rd=new Map(Zn.map(e=>[e.ruleId,e])),Sd=Object.freeze(Zn.map(e=>e.ruleId));var Aa=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."})]),Ra=new Map(Aa.map(e=>[e.reasonId,e]));function Xn(e){if(!(typeof e!="string"||e.length===0))return Ra.get(e)}a(Xn,"sliceReasonHint");var Sa=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,ka=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,ba=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Ea(e,t){let n=String(e??"").replace(/\\/g,"/").trim(),r=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Sa.test(n)?"pure-shared":r==="PersistenceAdapters"&&(ka.test(n)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${n}`))?"kernel-emit":ba.test(n)||(r==="DomainModel"||r==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a(Ea,"classifyLayerImportKind");function Ia(e,t){return t.failsStrict===!1&&e.advisoryNote?`${e.fix} ${e.advisoryNote}`:e.fix}a(Ia,"sliceHintAction");function va(e){let t=Xn(typeof e.reasonId=="string"?e.reasonId:void 0);if(t)return`${Ia(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=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 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(va,"layerImportNextAction");function wa(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a(wa,"arkRunCallSiteName");function xa(e){let t=wa(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(xa,"arkRunNextAction");function ce(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return va(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 xa(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(ce,"deterministicNextAction");var Ca=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],_a=new Set(Ca);function Oa(e){return _a.has(e)}a(Oa,"isArkRunEditorSensor");var Jn={"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"},Ta="ARKRUN_INTERACTION_NAME_INCOMPLETE";function tr(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(tr,"isDomainRoleLayer");function Na(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(Na,"compareFindings");function j(e,t,n,r,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Jn[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:ce({ruleId:Jn[t],fromLayer:o?.fromLayer,target:o?.target})}}a(j,"finding");function La(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(La,"bagForFile");function Qn(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Qn,"emitKinds");function er(e){return e==="subscribe"||e==="register-handler"}a(er,"handleKinds");function Da(e){return e==="resolve"||e==="resolve-singleton"}a(Da,"dependKinds");function Fa(e,t,n){let r=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return r.push(j(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(j(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(j(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(Fa,"evaluateMissingRoot");function Pa(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||!te(c))continue;let d=r(l.from);d&&tr(d,o.get(d)??[])&&i.push(j(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 $a(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)||tr(p,l.get(p)??[])||d.push(j(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($a,"evaluateDirectNew");function Ma(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(!Qn(c.kind)&&!er(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:Ta,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=La(n,c.file);if(Qn(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(j(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(er(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(j(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(j(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(Ma,"evaluateUndeclared");function Ka(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||!On(l))continue;let c=n(i.from);!c||!s.has(c)||o.push(j(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(Ka,"evaluateTransportBypass");function Ua(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let n=Ze(e.classification),r=Ma(t,e.kernelCalls,e.declarations,e.layerForFile,n),s=[...Fa(t,e.compositionRootHits,n),...Pa(t,e.layers,e.dependencies,e.layerForFile,n),...$a(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,n),...r.findings,...Ka(t,e.dependencies,e.layerForFile,n)].sort(Na),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(Ua,"evaluateArkRunSensors");function Et(e){return{findings:Ua(e).findings.filter(n=>Oa(n.sensor)),completenessReasons:[]}}a(Et,"evaluateArkRunEditorSensors");var It="docs/diagnostics.md";function vt(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(vt,"adapterFindingTargetKey");function wt(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(wt,"adapterFindingRefFromTargetKey");function xt(e){return`${It}#${e}`}a(xt,"adapterDocsCodePath");function b(e){return typeof e=="string"&&e.length>0?e:void 0}a(b,"text");function nr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(nr,"positiveInteger");function Ha(e,t,n){return ce({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(Ha,"nextActionForDiagnostic");var Ba=new Set(["CROSS_PARENT_SLICE","CROSS_SIBLING_SLICE","CROSS_PARENT_VIA_SHARED"]);function Va(e){let t=e.details,n=t!==null&&typeof t=="object"?t.reasonId:void 0,r=b(e.reasonId)??b(n);return r&&Ba.has(r)?r:void 0}a(Va,"sliceReasonOf");function rr(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=Va(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??vt(e),c=wt(l);return{ruleId:r,severity:s,message:b(e.message)??r,location:{file:b(e.file)??"<unknown>",line:nr(e.line,1),column:nr(e.column,1)},evidence:i,nextAction:b(e.nextAction)??Ha(r,i,e),findingRef:c,targetKey:l,docsCodePath:xt(r)}}a(rr,"toAdapterDiagnostic");var Ct="advisory",or="{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check]",Xe="advisoryFallback",ir='{{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.]',sr=new WeakMap,ar=new WeakMap;function Wa(e){return Object.prototype.hasOwnProperty.call(e,"sourceCode")||Object.prototype.hasOwnProperty.call(e,"getSourceCode")}a(Wa,"ownsSourceCode");function za(e){let t=e;for(let n=0;t&&t!==Object.prototype&&n<8;n+=1){if(Wa(t))return t===e?null:t;t=Object.getPrototypeOf(t)}return null}a(za,"runKey");function Ya(e,t){let n=Object.create(e,{report:{value(r){t.sinks.blocking?.report(r)}}});return ar.set(n,t),n}a(Ya,"routedContext");function Je(e,t,n){let r=za(t),s;if(r){let o=sr.get(r);o||(o=new Map,sr.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(Ya(t,s)))}a(Je,"createChannelListeners");function lr(e,t){let n=ar.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:Xe,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:Ct,data:t.advisoryData,diagnostic:s});return}n.sinks.blocking?.report({...r,messageId:Xe,data:t.advisoryData,diagnostic:s})}a(lr,"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 z(e){try{return e.sourceCode??e.getSourceCode?.()}catch{return}}a(z,"sourceCodeFor");function de(e){let t=z(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(de,"editorSourceText");function qa(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(qa,"reportLocation");function N(e,t,n,r,s){let o=rr({...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 lr(e,{nonBlocking:o.severity==="warning",location:qa(t,o.location.line),messageId:n,...s?{data:s}:{},advisoryData:{message:o.message,ruleId:o.ruleId},diagnostic:o}),o}a(N,"reportAdapterDiagnostic");function cr(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(cr,"mergeListeners");function Qe(e){return typeof e?.value=="string"?e.value:void 0}a(Qe,"stringValue");function Oe(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(Oe,"staticStringValue");function et(e){return e?.name??Qe(e)}a(et,"propertyName");function _t(e,t){return t?Oe(e):et(e)}a(_t,"staticKeyName");function dr(e,t){let n=z(e)?.getScope?.(t);for(;n;){let r=n.references?.find(s=>s.identifier===t);if(r)return r;n=n.upper??void 0}}a(dr,"referenceFor");function Y(e,t,n){let r=dr(e,t);if(r?.resolved)return(r.resolved.defs?.length??0)>0;let s=z(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(Y,"isLocallyBound");function ur(e,t){let n=dr(e,t);return n?n.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(ur,"isValueIdentifierReference");function _e(e){if(e?.type==="Identifier"&&e.name)return{root:e,segments:[e.name]};if(!e)return;if(e.type==="ChainExpression"||e.type==="TSNonNullExpression")return _e(e.expression);if(!(e.type==="MemberExpression"||!!(e.object&&e.property)))return;let n=_e(e.object),r=_t(e.property,e.computed);if(!(!n||!r))return{root:n.root,segments:[...n.segments,r]}}a(_e,"memberExpressionPath");function tt(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(tt,"declarationIsTypeOnly");function ue(e,t,n=Y){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(ue,"moduleSourceListeners");function pr(e){try{return Ot.default.existsSync(e)?Ot.default.readFileSync(e,"utf8"):null}catch{return null}}a(pr,"readUtf8");function fr(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=q.default.dirname(r),i=q.default.isAbsolute(n)?n:q.default.resolve(n),l=q.default.relative(o,i).split(q.default.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(fr,"loadEditorFile");function Za(e,t,n){let r=Ve(t,n).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:r})}return s}a(Za,"compositionRootHitsForFile");function Xa(e,t,n){let r=new Set(Ce(t.relFile,n).map(s=>s.className));return Nn(n,(s,o)=>{if(te(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=q.default.relative(t.root,i).split(q.default.sep).join("/");if(l.startsWith(".."))return;let c=pr(i);if(c!==null)for(let d of Ce(l,c))r.add(d.className)}),r}a(Xa,"admittedTypeNamesForEditor");function gr(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(gr,"reportFinding");function Ja(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(Ja,"constructedTypeName");function Qa(e,t,n,r,s){return ue(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}=Et({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&&gr(e,t,i,s,g,{fromLayer:g.fromLayer??n.fromLayer,specifier:l,target:g.target??l})},"check"),e.isLocallyBound)}a(Qa,"importListeners");function el(e,t,n){let r=de(t)??pr(n.absFile)??"",s=Xa(e,n,r),o=kt(n.relFile,r,s),{findings:i}=Et({arkRun:n.extra,layers:n.config.layers,kernelCalls:Ve(n.relFile,r),managedNews:o,compositionRootHits:Za(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=Ja(c);if(!d)return;let u=c.loc?.start?.line,f=l.find(p=>p.target===d&&(u===void 0||p.line===u));f&&gr(e,t,c,"directNew",f,{fromLayer:f.fromLayer??n.fromLayer,typeName:d,target:f.target??d})}}}a(el,"directNewListener");function hr(e){let t=a((n,r,s,o)=>({meta:{type:"problem",docs:{description:r},messages:{[s]:o},schema:[]},create(i){let l=fr(e,i);return l?Qa(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=fr(e,n);return r?el(e,n,r):{}}}}}a(hr,"createArkRunEslintRules");var mr=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var Nt="createOrderPlane";function Lt(e){return T(e)}a(Lt,"arkOrderGlobToRegExp");function nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(nt,"escapeRegExp");function fe(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(fe,"isArkOrderModuleSpecifier");function G(e,t){let n=1;for(let r=0;r<t&&r<e.length;r+=1)e[r]===`
4
+ `&&(n+=1);return n}a(G,"lineAt");function M(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,n=>" ".repeat(n.length)))}a(M,"stripCommentsPreservingLines");function Rr(e,t){let n=M(t),r=[],s=/\b(import|export)(\s+type)?\s+(?:[^;]*?\s+from\s*)?['"]([^'"]+)['"]/g,o;for(;(o=s.exec(n))!==null;){let l=o[3]??"";fe(l)&&r.push({from:e,specifier:l,kind:o[1]==="export"?"export":"import",typeOnly:!!o[2],line:G(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]??"";fe(l)&&r.push({from:e,specifier:l,kind:o[1]==="import"?"dynamic-import":"require",typeOnly:!1,line:G(t,o.index),resolution:"resolved-external"})}return r}a(Rr,"extractArkOrderModuleImportsFromSource");function Sr(e,t){let n=M(t),r=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(n))!==null;)r.push({file:e,line:G(t,o.index),callee:Nt});return r}a(Sr,"extractArkOrderPlaneCallsFromSource");var tl=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;\n]+)?=\s*createOrderPlane\s*(?:<[^>]*>)?\s*\(/g,Tt=/^(?:plane|[A-Za-z_$][\w$]*Plane)$/,nl=/\b([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?OrderPlane\b/g,rl=/\bfrom\s+['"]arkgate\/order(?:\/[^'"]*)?['"]|\brequire\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]|\bimport\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]/,sl=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g,yr=["",".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],ol=/([A-Za-z_$][\w$]*)\s*!?\s*\??\s*$/,il=/^\s*(?:<[^<>]*>\s*)?([A-Za-z_$][\w$]*)\s*!?\s*(?:\b(?:as|satisfies)\b[\s\S]*)?$/;function al(e){let t=M(e),n=new Set,r=new RegExp(tl.source,"g"),s;for(;(s=r.exec(t))!==null;)s[1]&&n.add(s[1]);return[...n].sort()}a(al,"arkOrderPlaneBindings");function ll(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(ll,"normalizeRelativePath");function cl(e,t){if(!t.startsWith("./")&&!t.startsWith("../"))return[];let n=e.replace(/\\/g,"/").split("/").slice(0,-1),r=ll([...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 yr)o.add(`${i}${l}`);for(let l of yr.slice(1))o.add(`${i}/index${l}`)}return[...o]}a(cl,"relativeModuleCandidates");function dl(e,t,n){let r=cl(e,t);return r.length===0?!1:n.some(s=>{let o;try{o=Lt(s)}catch{return!1}return r.some(i=>o.test(i))})}a(dl,"specifierResolvesToPlaneRoot");function ul(e,t,n={}){let r=M(t),s=new Set(al(t)),o=new RegExp(nl.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(sl.source,"g");for(;(i=c.exec(r))!==null;)if(dl(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)||(Tt.test(f)||Tt.test(p))&&s.add(p)}}return s.delete(Nt),{names:[...s].sort(),isArkOrderFile:rl.test(r)}}a(ul,"arkOrderPlaneReceivers");var fl=new Set(["return","await","void","typeof","yield","in","of","case","else","do","throw","delete"]);function pl(e){let t=e.replace(/\s+$/,"");if(/[)\]]$/.test(t))return!0;let n=/([A-Za-z_$][\w$]*)$/.exec(t);return n!==null&&!fl.has(n[1])}a(pl,"isCallBefore");function kr(e){let t=e.replace(/\s*!?\s*\??\s*$/,"");if(!t.endsWith(")")){let r=ol.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(pl(t.slice(0,r)))return null;let o=t.slice(r+1,t.length-1),i=il.exec(o);return i?i[1]??null:null}}return null}a(kr,"receiverBefore");function br(e,t,n){let r=ul(e,t,n);return{names:new Set(r.names),isArkOrderFile:r.isArkOrderFile}}a(br,"planeReceiverContext");function Er(e,t){return!e||e===Nt?!1:t.names.has(e)?!0:t.isArkOrderFile&&Tt.test(e)}a(Er,"isPlaneReceiver");function Ir(e,t,n={}){let r=M(t),s=br(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);Er(kr(d),s)&&o.push({file:e,line:G(t,l.index),method:c})}return o}a(Ir,"extractArkOrderGenericUpdatesFromSource");function vr(e,t,n){if(n.length===0)return[];let r=M(t);if(!xe(r)||!We(r))return[];let s=[],o=new Set;for(let i of n){if(!i)continue;let l=new RegExp(`(?:\\b${nt(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${nt(i)}['"]\\s*:|[{\\,]\\s*${nt(i)}\\s*[\\,}]|\\.${nt(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:G(t,c.index),key:i});break}}}return s}a(vr,"extractArkOrderXiFieldWritesFromSource");var gl="(?:xi(?:[A-Z][\\w$]*)?|release|pattern|house|current|[A-Za-z_$][\\w$]*?(?:Xi|Release|Pattern))(?![\\w$])";function wr(e,t){let n=M(t),r=[],s=new RegExp(`(?:(?<![\\w$])|\\.)${gl}(?:\\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:G(t,o.index)});return r}a(wr,"extractArkOrderIngestWritesXiFromSource");function xr(e,t){let n=M(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:G(t,o.index),keyCount:l.length})}return r}a(xr,"extractArkOrderReleaseKeyCountsFromSource");function hl(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(hl,"literalKeys");function Cr(e,t,n={}){let r=M(t),s=br(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(Er(kr(c),s))for(let d of hl(l[1]??""))mr.test(d)&&o.push({file:e,line:G(t,l.index),key:d})}return o}a(Cr,"extractArkOrderXiTtlKeysFromSource");function Ar(e){let t=[],n=/(['"`])([^'"`\n\\]+)\1/g,r;for(;(r=n.exec(e))!==null;)r[2]&&t.push(r[2]);return t}a(Ar,"stringLiterals");function _r(e,t){let n=M(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 Ar(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=G(t,o.index);for(let u of Ar(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(_r,"extractArkOrderBudgetLeaksFromSource");var Or={"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 ml(e,t){return!t||t.length===0?!0:t.some(n=>Lt(n).test(e))}a(ml,"matchesArkOrderAppliesTo");function yl(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(yl,"isDomainRoleLayer");function K(e,t,n,r,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Or[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:ce({ruleId:Or[t],fromLayer:o?.fromLayer,target:o?.target})}}a(K,"finding");function Dt(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let n=Ze(e.classification),r=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)r.push(K(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(K(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(K(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||!fe(d))continue;let u=e.layerForFile(c.from);u&&yl(u,o.get(u)??[])&&r.push(K(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(K(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(K(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(K(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(K(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(K(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)||ml(c.file,t.appliesTo)&&r.push(K(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(Dt,"evaluateArkOrderSensors");function Tr(e){if(!e.arkOrder)return[];let t=Sr(e.file,e.source),n={planeRoots:e.arkOrder.planeRoots??[]},r=Ir(e.file,e.source,n),s=e.arkOrder.xiKeys??[],o=e.fromLayer?[{name:e.fromLayer,patterns:[],intentPrefixes:[...e.intentPrefixes??[]]}]:[];return Dt({arkOrder:e.arkOrder,layers:o,planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:vr(e.file,e.source,s),ingestWritesXi:wr(e.file,e.source),releaseKeyCounts:xr(e.file,e.source),xiTtlKeys:Cr(e.file,e.source,n),budgetLeaks:_r(e.file,e.source),dependencies:Rr(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(Tr,"evaluateArkOrderEditorSensors");function Nr(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(Nr,"violationFor");function Al(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(Al,"lineNode");function Lr(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(Lr,"isTypeOnlyDeclaration");function Dr(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"||!fe(u))return;let g=d.loc?.start?.line??1,{findings:m}=Dt({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",Nr(R),{message:R.message})},"check");return{ImportDeclaration(d){c(d,d.source?.value,Lr(d),"import")},ExportNamedDeclaration(d){d.source&&c(d,d.source.value,Lr(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=de(s)??"",l=Tr({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,Al(i,c.line),"denied",Nr(c),{message:c.message})}}:{}}}}}a(Dr,"createArkOrderEslintRules");var Es=P(require("fs"),1),De=P(require("path"),1);var Gt=require("crypto"),U=P(require("fs"),1),I=P(require("path"),1);var ne={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Fr={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...ne,default:[]},kernelRoots:{...ne},managedLayers:{...ne,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Pr={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...ne,default:[]},managedLayers:{...ne,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...ne,default:[]},appliesTo:{...ne,default:[]}}};function Te(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Te,"isObject");function Rl(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let n of e.layers)Te(n)&&typeof n.name=="string"&&n.name.length>0&&t.add(n.name);return t}a(Rl,"declaredLayerNames");function $r(e){if(!Te(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($r,"defaultedArkRun");function Mr(e){if(!Te(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(Mr,"defaultedArkOrder");function Kr(e,t,n,r){if(!Array.isArray(t))return;let s=Rl(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(Kr,"validateManagedLayersDeclared");function Ur(e,t){let n=e.arkRun;if(n===void 0||!Te(n))return;let r=n.managedLayers;if(Kr(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(Ur,"validateArkRunExtra");function jr(e,t){let n=e.arkOrder;if(n===void 0||!Te(n))return;let r=n.managedLayers;if(Kr(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(jr,"validateArkOrderExtra");var st={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Yr={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:{...st,minItems:1}}}]},qr={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:{...st,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...st,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:{...st},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 ot(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(ot,"propertyPath");function Z(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(Z,"trimTrailingSlashes");function Zr(e,t){Il(e,t),wl(e,t),Ol(e,t),Vl(e,t),Bl(e,t)}a(Zr,"validateSliceContract");var Gr='must be "deny", "deny-cross-parent", or { "mode": "deny-cross-parent", "stopAt": ["<composition root path or glob>"] }',Hr="must not cover the whole tree. Name the composition root itself (bootstrap file, DI registrations folder).";function Sl(e){return e==="*"||e==="**"}a(Sl,"isWildcardSegment");function Xr(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&&Sl(t[n-1]??"");)n-=1;let r=t.slice(0,n);return r.some(s=>s.includes("*"))?null:r}a(Xr,"coveredFolder");function kl(e,t){return e.length<=t.length&&e.every((n,r)=>t[r]===n)}a(kl,"isPrefixOf");function bl(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=Xr(u.join("/"));f&&s.push(f)}}return s}a(bl,"ruleLayerFolders");function El(e,t){let n=Z(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 Hr;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=Xr(n);return s===null?null:s.length===0?Hr:t.some(o=>kl(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 Il(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:Gr});return}if(!C(o)){t.push({path:i,message:Gr});return}for(let u of Object.keys(o))u!=="mode"&&u!=="stopAt"&&t.push({path:ot(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=bl(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=El(u,d);if(g){t.push({path:p,message:g});return}let m=Z(u.trim().replace(/\\/g,"/")).toLowerCase();if(c.has(m)){t.push({path:p,message:"duplicate stopAt entry"});return}c.add(m)})})}a(Il,"validateSharedImportsSlice");var vl=["deny","advisory"],Br='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"], "ratchet": true | false }';function wl(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"){vl.includes(i)||t.push({path:l,message:Br});return}if(!C(i)){t.push({path:l,message:Br});return}for(let d of Object.keys(i))d!=="default"&&d!=="enforce"&&d!=="ratchet"&&t.push({path:ot(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=Z(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(wl,"validateChildSliceSiblings");var xl="must be a slice id with a slash. A bare name is ambiguous across universes.",Cl="* matches one whole path segment. ** and a partial segment are not wildcards.";function _l(e){let t=Z(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty slice id";if(!t.includes("/"))return xl;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 Cl}return null}a(_l,"childCrossSlicePatternIssue");function Vr(e){return Z(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Vr,"childCrossSlicePatternKey");function Ol(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:ot(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=_l(m);k&&t.push({path:R,message:k})}if(typeof d.from!="string"||typeof d.to!="string")return;let p=`${Vr(d.from)}\0${Vr(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(Ol,"validateChildSliceAllowedCrossSlice");var pe="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.",Tl="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/*).",Nl="overlaps a slice folder. An alias covers only files outside the slice trees.",Ll="two slice aliases match the same file";function Dl(e){return Z(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(Dl,"aliasPathSegments");function Fl(e){let t=e[e.length-1];return t===void 0||t.includes("*")?[...e]:[...e,"**"]}a(Fl,"aliasSegmentsWithSubtree");function Jr(e){let t=[];for(let n of e){if(n.includes("*"))break;t.push(n)}return t}a(Jr,"concreteGlobPrefix");function Ne(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(Ne,"segmentsArePrefix");function Pl(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(Pl,"anchoredSlicePrefix");function $l(e,t){let n=Jr(e),r=n.length<e.length,s=n[0]==="src"||n[0]==="app"?n.slice(1):n;return Ne(t,n)||Ne(t,s)?!0:r?Ne(n,t)&&n.length<t.length||Ne(n,["src",...t])&&n.length<t.length+1||Ne(n,["app",...t])&&n.length<t.length+1:!1}a($l,"globOverlapsAnchored");function Ml(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=Jr(e);return n.length<e.length&&(n.length===0||n.length===1&&(n[0]==="src"||n[0]==="app"))}a(Ml,"globOverlapsBare");function Kl(e,t){let n=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(n.length===1&&n[0]&&!n[0].includes("*"))return Ml(e,n[0]);let r=Pl(t);return r?$l(e,r):!1}a(Kl,"globOverlapsSliceEntry");function Ul(e){let t=Z(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(Ul,"aliasGlobIssue");function jl(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(jl,"universeShapes");function rt(e,t){return e.literals.length!==t.length?!1:e.literals.every((n,r)=>n===null||n===t[r])}a(rt,"shapeMatches");function Gl(e,t){let n=Z(e.trim().replace(/\\/g,"/"));if(n.length===0||n.split("/").some(o=>o.length===0||o==="."||o==="..")||n.includes("*")||!n.includes("/"))return pe;let r=n.split("/").map(o=>o.toLowerCase());if(t.length===0||t.some(o=>rt(o,r)))return pe;if(t.some(o=>rt(o,r.slice(0,-1))))return null;let s=new Set(t.filter(o=>o.legacy!==void 0&&!rt({literals:o.legacy},r)&&rt({literals:o.legacy},r.slice(0,-1))).map(o=>o.literals.map(i=>i??"*").join("/")));return s.size===1?null:s.size>1?Tl:pe}a(Gl,"aliasTargetIssue");function Wr(e){let t=e[0];return(t==="src"||t==="app")&&e.length>1?[e,e.slice(1)]:[e]}a(Wr,"aliasGlobVariants");function Hl(e,t){let n=Wr(e),r=Wr(t);for(let s of n)if(re(s,t,0,0,new Map))return!0;for(let s of r)if(re(e,s,0,0,new Map))return!0;return!1}a(Hl,"aliasesCanMatchSameFile");function re(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=re(e,t,n+1,r,s)||r<t.length&&re(e,t,n,r+1,s);else if(r<t.length&&t[r]==="**")l=re(e,t,n,r+1,s)||n<e.length&&re(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=re(e,t,n+1,r+1,s))}return s.set(o,l),l}a(re,"globsCanMatchSame");var zr="must be a filename with exactly one <Layer> token and no slash or wildcard (arkrules.<Layer>.json)";function Bl(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:zr});return}(l.split("<Layer>").length!==2||/[*\\/]/.test(l)||l.includes(".."))&&t.push({path:i,message:zr})})}a(Bl,"validateChildSliceArkRulesFile");function Vl(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=jl(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:ot(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=Ul(m);if(k)t.push({path:`${g}.from`,message:k});else{let y=Fl(Dl(m));d.some(A=>Kl(y,A))&&t.push({path:`${g}.from`,message:Nl});for(let A of u)if(Hl(A,y)){t.push({path:g,message:Ll});break}u.push(y)}}if(typeof R!="string"||R.trim().length===0)t.push({path:`${g}.to`,message:pe});else{let k=Gl(R,c);k&&t.push({path:`${g}.to`,message:k})}})})}a(Vl,"validateChildSliceAliases");function J(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(J,"isObject");function ge(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(ge,"propertyPath");function H(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(H,"valueType");function Wl(e,t){let n="#/$defs/";if(e.startsWith(n))return t.$defs[e.slice(n.length)]}a(Wl,"resolveSchemaRef");function X(e,t,n,r,s){if(t.$ref){let o=Wl(t.$ref,r);if(!o){s.push({path:n,message:`schema reference ${t.$ref} cannot be resolved`});return}X(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(!J(e)){s.push({path:n,message:`must be an object; received ${H(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:ge(n,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:ge(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||X(e[l],i,ge(n,l),r,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&X(e[i],l,ge(n,i),r,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:n,message:`must be an array; received ${H(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)=>X(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 ${H(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 ${H(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:n,message:`must be an integer; received ${H(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:n,message:`must be at least ${t.minimum}`})}}a(X,"validateSchemaNode");function it(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(it,"normalizeStewardId");function Qr(e){let t=it(e);return!t||Ft(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(Qr,"isGitHubHandle");function zl(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(!t.includes("@")||t.includes(" ")||Ft(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(zl,"isGitHubEmail");function Yl(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Qr(t[1])?it(t[1]):null}a(Yl,"githubHandleFromEmail");function es(e){let t=Yl(e);if(t)return t;let n=it(e);return!n||Ft(n)?null:Qr(n)||zl(n)?n:null}a(es,"canonicalStewardId");var ql=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function Ft(e){let t=it(e);return!t||ql.test(t)}a(Ft,"isAutomationAuthor");var $="1.3",Zl=["public","auth","admin","internal"];var Pt="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",ts=["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 Jl(){let e=[];for(let t of ts)for(let n of ts)t===n||Xl.has(`${t}->${n}`)||e.push({from:t,to:n,allowed:!1});return e}a(Jl,"createDefaultRules");var rs=Jl(),$t=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],L={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ns={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Pt,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:Pt,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:$,default:$},name:{type:"string",minLength:1},include:{...L,minItems:1,default:["src"]},exclude:{...L,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:rs,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...L,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:{...L,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...L,minItems:1},exclude:L,intentPrefixes:L,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...Zl]},owners:{...L,minItems:1},forbiddenGlobals:L,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:{...L,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:{...L,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:Yr,childSlices:qr}},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:{...L,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:{...L,minItems:1}}},arkRun:Fr,arkOrder:Pr}},B=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 Ql(e,t){let n=e.arkRules;if(!(n===void 0||!J(n)))for(let[r,s]of Object.entries(n)){let o=ge("$.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(Ql,"validateArkRulesRefs");function ec(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"&&(es(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}a(ec,"validateLayerOwners");function tc(e){let t={...e,$schema:e.$schema===void 0?Pt:e.$schema,schemaVersion:e.schemaVersion===void 0?$:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?rs.map(n=>({...n})):e.rules};return e.arkRun!==void 0&&(t.arkRun=$r(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Mr(e.arkOrder)),t}a(tc,"defaultedConfig");function nc(e){return e===$?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(nc,"migratedFromOf");function rc(){let e=new Set([$]);for(let t of $t)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(rc,"knownInputVersions");function sc(e,t="ark.config.json"){if(!J(e))throw new B(t,[{path:"$",message:`must be an object; received ${H(e)}`}]);let n=rc(),r=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(r===null)throw new B(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${$}`}]);if(r!=="unversioned"&&!n.has(r))throw new B(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${$}`}]);let s=r,o={...e},i=0;for(;s!==$&&i<$t.length+1;){i+=1;let l=$t.find(c=>c.from===s);if(!l)throw new B(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${$}`}]);s=l.to,o.schemaVersion=s}if(s!==$)throw new B(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(r)}; expected ${$}`}]);return{candidate:tc(o),migratedFrom:nc(r)}}a(sc,"migrateArkConfig");function oc(e,t="ark.config.json"){let{candidate:n,migratedFrom:r}=sc(e,t),s=[];if(X(n,ns,"$",ns,s),Ur(n,s),jr(n,s),ec(n,s),Zr(n,s),Ql(n,s),s.length>0)throw new B(t,s);return{config:n,migratedFrom:r}}a(oc,"loadArkConfigContract");function at(e,t="ark.config.json"){let n;try{n=JSON.parse(e)}catch(r){throw new B(t,[{path:"$",message:`invalid JSON: ${r instanceof Error?r.message:String(r)}`}])}return oc(n,t)}a(at,"parseArkConfigJson");var Le="1.0",Mt="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",ic=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],ac=["no-anemic-model"],ss={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},os={$schema:"https://json-schema.org/draft/2020-12/schema",$id:Mt,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:Mt},schemaVersion:{type:"string",const:Le,default:Le},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:[...ic]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:ss,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:ss}}}},he=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 lc(e){return{...e,$schema:e.$schema===void 0?Mt:e.$schema,schemaVersion:e.schemaVersion===void 0?Le:e.schemaVersion,structure:e.structure===void 0?[]:e.structure,invariants:e.invariants===void 0?[]:e.invariants}}a(lc,"defaultedArkRules");function is(e){return e==="enforced"?"enforced":"advisory"}a(is,"normalizeMode");function cc(e){return ac.includes(e)}a(cc,"isTier2Sensor");function dc(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(!J(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"&&cc(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(!J(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(dc,"validateSemantics");function Kt(e,t="arkrules.json",n){if(!J(e))throw new he(t,[{path:"$",message:`must be an object; received ${H(e)}`}]);let r=lc(e),s=[];if(X(r,os,"$",os,s),dc(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 he(t,s);return{config:r}}a(Kt,"loadArkRulesContract");function lt(e,t){return e.childId?`${e.childId}#${t}`:t}a(lt,"effectiveRuleId");function as(e,t){if(t&&t.length>0)return[...t];if(e.childId&&e.defaultAppliesTo&&e.defaultAppliesTo.length>0)return[...e.defaultAppliesTo]}a(as,"effectiveAppliesTo");function ls(e,t){return{sourceFile:e.sourceFile,ruleId:lt(e,t),layer:e.layer,...e.childId?{childId:e.childId}:{}}}a(ls,"provenanceFor");function cs(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?cs(o,s):!1}a(cs,"appliesToPatternInsideSlice");function ds(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??[])cs(o,t)||n.push({id:s.id,pattern:o});return n}a(ds,"sliceScopeEscapes");function us(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=lt(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(us,"duplicateArkRuleIds");function fs(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=as(o,d.appliesTo);return{...d,id:lt(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:is(d.mode),provenance:ls(o,d.id)}}),l=(o.file.invariants??[]).map(d=>{let u=as(o,d.appliesTo);return{...d,id:lt(o,d.id),...u?{appliesTo:u}:{appliesTo:void 0},mode:is(d.mode),provenance:ls(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:Le,byLayer:t,structure:n,invariants:r}}a(fs,"buildEffectiveArkRules");function se(){return{schemaVersion:Le,byLayer:{},structure:[],invariants:[]}}a(se,"emptyEffectiveArkRules");var Ut=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 ps(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}a(ps,"normalizeRel");function gs(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:se(),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 he){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=ps(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 v=Kt(JSON.parse(S),A,f);c.push({layer:f,sourceFile:A,file:v.config})}catch(v){u(y,A,v)}})}if(e.governedFiles&&e.governedFiles.length>0){let f=Ge({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=Kt(JSON.parse(g),p.path,p.layer),R={layer:p.layer,sourceFile:p.path,file:m.config,childId:p.childId,defaultAppliesTo:p.defaultAppliesTo},k=ds(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 us(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=ps(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 Ut(t,l);return{config:e.config,arkRules:fs(c),warnings:r}}a(gs,"resolveEffectiveContract");var uc=2e3,hs=new Map;function ms(e){try{return U.default.statSync(e).isFile()}catch{return!1}}a(ms,"isFile");function Ht(e){let t=hs.get(e);if(t){if(t.found!==null&&ms(t.found))return t.found;if(t.found===null&&Date.now()-t.at<uc)return null}let n=I.default.join(e,"ark.config.json"),r;if(ms(n))r=n;else{let s=I.default.dirname(e);r=s===e?null:Ht(s)}return hs.set(e,{found:r,at:Date.now()}),r}a(Ht,"findConfigInDir");function D(e){return!e||e==="<input>"||e.startsWith("stdin")?null:Ht(I.default.dirname(I.default.resolve(e)))}a(D,"findConfigPath");var me=new Map,fc=64;function pc(e){try{let t=U.default.statSync(e,{throwIfNoEntry:!1});return t?.isFile()?`${t.mtimeMs}:${t.size}:${t.ino}`:null}catch{return null}}a(pc,"configFileStamp");function gc(e,t){if(!me.has(e)&&me.size>=fc){let n=me.keys().next().value;n!==void 0&&me.delete(n)}me.set(e,t)}a(gc,"rememberContract");var hc=/\.[cm]?[tj]sx?$/,mc=/(^test(?:[-_.]).*|\.(spec|test)(?:-d)?\.)(tsx?|jsx?|mjsx?|cjsx?|mts|cts)$/i,yc=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 Ac(e){return hc.test(e)&&!e.endsWith(".d.ts")&&!mc.test(e)}a(Ac,"isGovernableSourceName");function Rc(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(Rc,"arkRulesRefs");function Ss(e,t){let n=t.include&&t.include.length>0?t.include:["src"],r=[],s=a(o=>{let i;try{i=U.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of i){if(l.name.startsWith("."))continue;let c=I.default.join(o,l.name);if(l.isDirectory()){if(yc.has(l.name))continue;s(c);continue}if(!l.isFile()||!Ac(l.name))continue;let d=I.default.relative(e,c).split(I.default.sep).join("/");!d||d.startsWith("..")||ht(d,t)||r.push(d)}},"walk");for(let o of n){let i=String(o).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");s(I.default.resolve(e,i==="."?"":i))}return r}a(Ss,"governedRelativeFiles");function Sc(e,t){return Ge({files:t,rules:e.rules,layers:e.layers.map(n=>n.name)}).map(n=>n.path)}a(Sc,"plannedSlicePaths");function kc(e,t){let n=t.replace(/\\/g,"/").replace(/^\.\//,""),r=I.default.resolve(e,n),s=I.default.relative(e,r);if(!(s.startsWith("..")||I.default.isAbsolute(s)))try{return U.default.readFileSync(r,"utf8")}catch{return}}a(kc,"readReferencedFile");function ks(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 Rc(e))s(o);for(let o of Sc(e,t))s(o);return r}a(ks,"contractSourcePaths");function jt(e,t){let n=t?Ss(e,t):[];return ks(t,n).map(r=>{try{let s=U.default.statSync(I.default.resolve(e,r));return`${r}:${s.mtimeMs}:${s.size}`}catch{return`${r}:missing`}}).join("|")}a(jt,"refStampsFor");function ys(e){return e instanceof Error?e.message:String(e)}a(ys,"errorText");function bc(e,t){let n=I.default.dirname(e),r;try{r=at(t,e).config}catch(c){return{config:null,arkRules:se(),error:ys(c),fingerprint:null}}let s=Ss(n,r),o=ks(r,s),i=(0,Gt.createHash)("sha256").update(t);if(o.length===0)return{config:r,arkRules:se(),error:null,fingerprint:i.digest("hex")};let l={};for(let c of o){let d=kc(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=gs({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:se(),error:ys(c),fingerprint:null}}}a(bc,"resolveContract");function ye(e){let t=I.default.dirname(e),n=pc(e),r=me.get(e);if(r&&n!==null&&r.stamp===n&&jt(t,r.refConfig)===r.refStamps)return r.result;let s;try{s=U.default.readFileSync(e,"utf8")}catch{return{config:null,arkRules:se(),error:null,fingerprint:null}}if(r?.source===s&&jt(t,r.refConfig)===r.refStamps)return r.stamp=n,r.result;let o=bc(e,s),i=o.config??Ec(s,e);return gc(e,{source:s,stamp:n,refConfig:i,refStamps:jt(t,i),result:o}),o}a(ye,"loadArkContract");function Ec(e,t){try{return at(e,t).config}catch{return null}}a(Ec,"safeConfig");function bs(e){if(!U.default.existsSync(e))return null;let t=ye(e);return t.config?t.config:at(U.default.readFileSync(e,"utf8"),e).config}a(bs,"loadArkConfig");function Q(e,t){return(e.include??[]).some(r=>{let s=String(r).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!ht(t,e)}a(Q,"sourceIsInAnalysisScope");function ct(e,t,n){let r=I.default.isAbsolute(n)?n:I.default.resolve(n),s=I.default.relative(t,r).split(I.default.sep).join("/");if(!Q(e,s))return null;let o=e.layers?.find(i=>i.name===w(s,e.layers));return{relFile:s,layer:o}}a(ct,"lintedFileInScope");function V(e){return e?ye(e).config:null}a(V,"configForRule");var As="configInvalid",Ic="Ark contract is invalid, so no architecture verdict is possible (fix it; ark-check fails closed the same way): {{detail}}",Rs=new WeakSet;function Bt(e){let t=D(e);return t?ye(t).error:null}a(Bt,"contractErrorForFile");function F(e){return{meta:{...e.meta,messages:{...e.meta.messages,[As]:Ic,[Xe]:ir}},create(t){let n=Bt(x(t));return n?{Program(r){let s=z(t);if(s&&typeof s=="object"){if(Rs.has(s))return;Rs.add(s)}t.report({...r?.loc?.start?{node:r}:{loc:{line:1,column:0}},messageId:As,data:{detail:n.replace(/\s*\n\s*/g," ")}})}}:Je(e,t,"blocking")}}}a(F,"withContractGuard");function Vt(e=process.cwd()){let t=Ht(I.default.resolve(e));if(!t)return null;let n=ye(t);if(n.fingerprint)return n.fingerprint;try{return(0,Gt.createHash)("sha256").update(U.default.readFileSync(t,"utf8")).digest("hex")}catch{return null}}a(Vt,"contractFingerprint");var vc=256*1024;function wc(e){try{return Es.default.readFileSync(e,"utf8")}catch{return""}}a(wc,"readUtf8");function xc(e,t){if(!/\.(tsx?|mts|cts)$/i.test(e))return[];try{return Ce(e,t)}catch{return[]}}a(xc,"classShapesFor");function Cc(e,t){if(!/\.(tsx?|mts|cts|jsx?|mjs|cjs)$/i.test(e)||e.endsWith(".d.ts"))return{};if(t.length>vc)return{};let n=qn(e,t);return n?{[e]:n}:{}}a(Cc,"hintsFor");function Is(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=ye(r),o=s.config;if(!o||s.arkRules.structure.length===0)return{};let i=De.default.dirname(r),l=De.default.resolve(n),c=De.default.relative(i,l).split(De.default.sep).join("/");if(!e(o,c))return{};let d=w(c,o.layers);return{Program(u){let f=de(t)??wc(l),p=Yn({arkRules:s.arkRules,classShapes:xc(c,f),files:[c],layerForFile:a(g=>g===c?d:w(g,o.layers),"layerForFile"),fileHints:Cc(c,f)}).filter(g=>g.file===c);for(let g of p)N(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(Is,"createArkRulesStructureRule");var Ae=P(require("path"),1);function vs(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(vs,"longestForbidden");var ws={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=V(r),o=r?Ae.default.dirname(r):null,i=null,l="this layer";if(s&&o&&t){let y=ct(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 z(e)?.getScope=="function",u=Ae.default.isAbsolute(t)?t:Ae.default.resolve(t),f=o?Ae.default.relative(o,u).split(Ae.default.sep).join("/"):t,p=a((y,A)=>{N(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,v)=>{if(S||typeof A!="string")return;let O=He(A,c);O&&N(e,y,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:f,fromLayer:l,target:A,edgeKind:v,message:`${l} must not use module "${A}" because it is the import form of forbidden global "${O}".`},{layer:l,name:O,specifier:A,importKind:v})},"reportModule"),m=a((y,A)=>{if(y?.type==="ObjectPattern")for(let S of y.properties??[]){if(S.type==="RestElement")continue;let v=_t(S.key,S.computed);if(!v)continue;let O=[...A,v],be=vs(c,O,A.length+1);if(be){p(S,be);continue}let oe=S.value,Qs=oe?.type==="AssignmentPattern"?oe.left:oe;m(Qs,O)}},"checkPattern"),R=a((y,A)=>{if(y?.type!=="ObjectPattern")return;let S=_e(A);if(!S||Y(e,S.root,S.segments[0]))return;let v=S.segments[0]==="globalThis"?S.segments.slice(1):S.segments;m(y,v)},"checkDestructure"),k=ue(e,g);return{MemberExpression(y){if(y.parent?.type==="MemberExpression"&&y.parent.object===y)return;let A=_e(y);if(!A||Y(e,A.root,A.segments[0]))return;let S=A.segments[0]==="globalThis",v=S?A.segments.slice(1):A.segments,O=vs(c,v,S?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(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)||!ur(e,y)||Y(e,y,y.name)||p(y,y.name)}}}};var Fe=P(require("path"),1);function xs(e,t){if(!(e?.type&&e.type!=="ObjectExpression"))return e?.properties?.find(n=>et(n.key)===t)}a(xs,"objectProperty");function Re(e,t){return xs(e,t)!==void 0}a(Re,"objectHasProperty");function _c(e){let t=xs(e,"metadata")?.value;return Re(t,"source")}a(_c,"objectHasMetadataSource");function Cs(e){let t=e.callee;return t?.type==="Identifier"?t.name==="publish":t?.computed!==!0&&et(t?.property)==="publish"}a(Cs,"isPublishCall");function _s(e){return e?e.type==="Identifier"||e.type===void 0&&e.name?/^[A-Z]/.test(e.name??""):e.type==="MemberExpression"&&e.computed!==!0?_s(e.property):!1:!1}a(_s,"looksLikeIntentCreator");function Oc(e){let t=Oe(e);return t!==void 0&&ve(t)||Re(e,"intent")||_s(e)}a(Oc,"isArkPublishCandidate");function Tc(e){let[t,n,r]=e;return _c(t)||Re(n,"source")||Re(r,"source")}a(Tc,"publishHasSource");function Nc(e){let t=x(e),n=D(t),r=V(n);if(!r||!n||!t)return null;let s=Fe.default.relative(Fe.default.dirname(n),Fe.default.resolve(t)).split(Fe.default.sep).join("/");return Q(r,s)?s:null}a(Nc,"scopedFile");var Os={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=yt({publishCall:Cs(t),rawIntentName:Oe(n),objectHasIntent:Re(n,"intent"),arkPublishCandidate:!1,hasSource:!0}).find(o=>o.ruleId==="RAW_EVENT_PUBLISH");s&&N(e,t,"rawPublish",{...s,file:x(e)})}}}},Ts={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=Nc(e);return t?{CallExpression(n){let r=n.arguments??[],s=r[0],i=yt({publishCall:Cs(n),rawIntentName:Oe(s),objectHasIntent:Re(s,"intent"),arkPublishCandidate:Oc(s),hasSource:Tc(r)}).find(l=>l.ruleId==="PUBLISH_MISSING_SOURCE");i&&N(e,n,"missingSource",{...i,file:t})}}:{}}};var Pe=P(require("fs"),1),E=P(require("path"),1);function Ns(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(Ns,"skipTrivia");function Lc(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=Ns(t,r);continue}if(o===","){let i=Ns(t,r+1);if(t[i]==="}"||t[i]==="]"){r+=1;continue}}n+=o,r+=1}return n}a(Lc,"stripJsonc");function Ls(e){return JSON.parse(Lc(e))}a(Ls,"parseJsonc");var Ds=new Map,Se=new Map,Dc=64;function Wt(e){try{let t=Pe.default.statSync(e);return`${t.mtimeMs}:${t.size}`}catch{return"missing"}}a(Wt,"fileStamp");function ee(e){try{return Pe.default.statSync(e).isFile()}catch{return!1}}a(ee,"isFile");function Fs(e){let t=E.default.resolve(e),n=Ds.get(t);if(n!==void 0&&(n===null||ee(n)))return n;let r=E.default.join(t,"tsconfig.json"),s;if(ee(r))s=r;else{let o=E.default.dirname(t);s=o===t?null:Fs(o)}return Ds.set(t,s),s}a(Fs,"findNearestTsconfig");function Fc(e,t){let n=e;for(;;){let r=E.default.join(n,"node_modules",t);for(let i of[r,`${r}.json`])if(ee(i))return i;let s=E.default.join(r,"package.json");if(ee(s))try{let i=JSON.parse(Pe.default.readFileSync(s,"utf8"));if(typeof i.tsconfig=="string"&&ee(E.default.join(r,i.tsconfig)))return E.default.join(r,i.tsconfig)}catch{}if(ee(E.default.join(r,"tsconfig.json")))return E.default.join(r,"tsconfig.json");let o=E.default.dirname(n);if(o===n)return null;n=o}}a(Fc,"resolvePackageExtends");function Pc(e,t){let n=E.default.dirname(e);if(t.startsWith(".")||E.default.isAbsolute(t)){let r=E.default.resolve(n,t);for(let s of[r,`${r}.json`])if(ee(s))return s;return null}return Fc(n,t)}a(Pc,"resolveExtends");function zt(e,t){return e.split("${configDir}").join(t)}a(zt,"substituteConfigDir");function Ps(e,t,n,r,s){if(n>8||r.has(e))return{};r.add(e),s.push({file:e,stamp:Wt(e)});let o;try{o=Ls(Pe.default.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=zt(f,t),g=Pc(e,p);if(!g){if(p.startsWith(".")||E.default.isAbsolute(p)){let R=E.default.resolve(E.default.dirname(e),p);for(let k of[R,`${R}.json`])s.push({file:k,stamp:Wt(k)})}continue}let m=Ps(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.default.dirname(e);return typeof d.baseUrl=="string"&&(i.baseUrl=E.default.resolve(u,zt(d.baseUrl,t))),d.paths&&typeof d.paths=="object"&&(i.paths=d.paths,i.pathsBase=u),i}a(Ps,"loadChain");function $c(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=>zt(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($c,"buildAliasSet");function Mc(e){let t=Se.get(e);if(t&&t.chain.every(i=>Wt(i.file)===i.stamp))return t.result;let n=[],r=E.default.dirname(e),s=Ps(e,r,0,new Set,n),o=$c(s,r);if(!Se.has(e)&&Se.size>=Dc){let i=Se.keys().next().value;i!==void 0&&Se.delete(i)}return Se.set(e,{chain:n,result:o}),o}a(Mc,"aliasesForTsconfig");function Yt(e){let t=Fs(e);return t?Mc(t):{baseUrl:E.default.resolve(e),aliases:[]}}a(Yt,"readTsconfigPathAliases");function $s(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,E.default.join(e,"index.ts"),E.default.join(e,"index.tsx"),E.default.join(e,"index.js")];for(let n of t)if(ee(n))return n;return null}a($s,"existingSourceFile");function qt(e,t){if(!t.startsWith("."))return null;let n=E.default.resolve(E.default.dirname(e),t);return $s(n)}a(qt,"resolveRelativeImport");function Kc(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(Kc,"matchAlias");function dt(e,t,n){if(!t)return null;if(t.startsWith("."))return qt(e,t);let r=e?E.default.dirname(E.default.resolve(e)):n??".",{baseUrl:s,aliases:o}=Yt(r);for(let i of o){let l=Kc(i,t);if(l!==null){for(let c of i.targets){let d=i.wildcard?c.split("*").join(l):c,u=$s(E.default.resolve(s,d));if(u)return u}return null}}return null}a(dt,"resolveImportSpecifier");var Uc="4.8.25";function jc(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(jc,"containingProgram");function Gc(e){let t=jc(e)?.body;if(!t)return!1;let n=!1;for(let r of t){if(r.type==="ImportDeclaration"){if(!tt(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(!tt(r))return!1;n=!0;continue}return!1}}return n}a(Gc,"sourceProgramExportsOnlyTypes");var Ms={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=V(n),s=n?_.default.dirname(n):null,o=a(i=>{let l=Qe(i.source);if(l&&r&&s&&t){let c=_.default.isAbsolute(t)?t:_.default.resolve(t),d=_.default.relative(s,c).split(_.default.sep).join("/");if(!Q(r,d))return;let u=w(d,r.layers);if(!u)return;let f=dt(c,l,s);if(!f)return;let p=_.default.relative(s,f).split(_.default.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=gt(r.rules,u,g,m),k=R?.rule;if(k){let y=i.type?.startsWith("Export")?"export":"import",A=tt(i),S=!!k?.peerIsolation,v=A&&!S,O=R?.sliceVerdict,be=O?Rn({surface:"import",verdict:O,fromLayer:u,toLayer:g,kind:y,fromPath:d,toPath:p,ruleMessage:k?.message,childMessage:k?.childSlices?.message}):k?.message??`${u} must not ${y} ${g}.`,oe=v?`${be} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:be;N(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:g,target:p,edgeKind:y,...S?{peerIsolation:!0}:{},...A?{typeOnly:!0}:{},...Sn(O),...v?{failsStrict:!1,severity:"warning"}:{},...Gc(i)?{sourcePureTypeModule:!0}:{},message:oe},{fromLayer:u,toLayer:g,specifier:l,message:oe})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},Hc={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=V(n),s=n?_.default.dirname(n):null;if(!r||!s||!t)return{};let o=ct(r,s,t);if(!o?.layer)return{};let{relFile:i,layer:l}=o,c=new Set(In(l));return c.size===0?{}:ue(e,a((u,f,p,g)=>{if(p||typeof f!="string"||He(f,l.forbiddenGlobals??[]))return;let m=En(f);!m||!c.has(m)||N(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"))}},ke=hr({findConfigPath:D,loadArkConfig:V,resolveImportSpecifier:dt,lintedFilename:x,sourceIsInAnalysisScope:Q,isLocallyBound:Y,reportAdapterDiagnostic:N});function Bc(e,t){let n=_.default.dirname(_.default.resolve(e));return _.default.relative(n,_.default.resolve(t)).split(_.default.sep).join("/")}a(Bc,"toProjectRelative");var ut=Dr({findConfigPath:D,loadArkConfig:V,lintedFilename:x,sourceIsInAnalysisScope:Q,isLocallyBound:Y,reportAdapterDiagnostic:N,toProjectRelative:Bc}),Ks=Is(Q),Vc=[Ms,ke.noArkRunKernelInDomain,ke.noArkRunDirectNew,ke.noArkRunTransportBypass,ut.noArkOrderKernelInDomain,ut.noArkOrderGenericUpdate,Ks],Wc={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:{[Ct]:or},schema:[]},create(e){return Bt(x(e))?{}:cr(Vc.map(t=>Je(t,e,"advisory")))}},Us=F(Ms),js=F(Os),Gs=F(Ts),Hs=F(ws),Bs=F(Hc),Vs=F(ke.noArkRunKernelInDomain),Ws=F(ke.noArkRunDirectNew),zs=F(ke.noArkRunTransportBypass),Ys=F(ut.noArkOrderKernelInDomain),qs=F(ut.noArkOrderGenericUpdate),Zs=F(Ks),Xs=Wc,Js={"no-domain-infra-imports":Us,"no-raw-event-publish":js,"require-publish-source":Gs,"no-forbidden-globals":Hs,"no-denied-capabilities":Bs,"no-arkrun-kernel-in-domain":Vs,"no-arkrun-direct-new":Ws,"no-arkrun-transport-bypass":zs,"no-arkorder-kernel-in-domain":Ys,"no-arkorder-generic-update":qs,"arkrules-structure":Zs,"architecture-advisory":Xs},zc={"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"},ft={meta:{name:"arkgate",version:Uc},rules:Js};function Yc(){let e=Vt();return{plugins:{ark:ft},rules:{...zc},...e?{settings:{ark:{contractHash:e}}}:{}}}a(Yc,"recommendedConfig");var Zt={};Object.defineProperty(Zt,"recommended",{enumerable:!0,configurable:!0,get:Yc});ft.configs=Zt;var qc=ft;0&&(module.exports={architectureAdvisory,arkRulesStructureRule,configs,contractFingerprint,findConfigPath,globToRegExp,isEdgeDenied,layerForRelativePath,loadArkConfig,noArkOrderGenericUpdate,noArkOrderKernelInDomain,noArkRunDirectNew,noArkRunKernelInDomain,noArkRunTransportBypass,noDeniedCapabilities,noDomainInfraImports,noForbiddenGlobals,noRawEventPublish,patternSpecificity,plugin,readTsconfigPathAliases,requirePublishSource,resolveImportSpecifier,resolveRelativeImport,rules});
12
12
 
13
13
  /* arkgate:eslint-cjs-plugin-shape */
14
14
  ;(function(){var m=module.exports,p=m&&m.default;if(!p||typeof p!=="object")return;