arkgate 4.8.22 → 4.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/README.md +7 -5
- package/bin/ark-check-runtime.mjs +27 -78
- package/bin/ark-dashboard.mjs +56 -53
- package/bin/ark-layer-match.mjs +1117 -38
- package/bin/ark-mcp-runtime.mjs +412 -138
- package/bin/ark-mcp.mjs +68 -4
- package/bin/ark-shared.mjs +39 -0
- package/bin/ark.mjs +65 -97
- package/bin/lib/adapter-contract-types.mjs +5 -0
- package/bin/lib/adapter-contract.mjs +15 -0
- package/bin/lib/agent-projection-command.mjs +5 -1
- package/bin/lib/analysis-engine.mjs +15 -11
- package/bin/lib/architecture-scan.mjs +50 -6
- package/bin/lib/ark-order-doctor.mjs +1 -1
- package/bin/lib/ark-order-facts.mjs +410 -15
- package/bin/lib/ark-order-invariants.mjs +51 -9
- package/bin/lib/ark-order-sensors.mjs +28 -101
- package/bin/lib/ark-order-types.mjs +2 -0
- package/bin/lib/ark-run-doctor.mjs +14 -0
- package/bin/lib/ark-run-facts.mjs +434 -11
- package/bin/lib/ark-run-sensors.mjs +5 -3
- package/bin/lib/arkgate-pins.mjs +91 -0
- package/bin/lib/arkrules-sensors.mjs +50 -249
- package/bin/lib/check-args.mjs +23 -1
- package/bin/lib/ci-and-commands.mjs +16 -6
- package/bin/lib/class-source-scan.mjs +479 -0
- package/bin/lib/codex-home.mjs +4 -2
- package/bin/lib/config-contract-slices.mjs +701 -0
- package/bin/lib/config-contract.mjs +5 -2
- package/bin/lib/config-warnings.mjs +32 -0
- package/bin/lib/dashboard-cli.mjs +62 -0
- package/bin/lib/design-delta.mjs +1 -1
- package/bin/lib/diagnostic-catalog.mjs +45 -6
- package/bin/lib/doctor-advisories.mjs +84 -1
- package/bin/lib/doctor-next-actions.mjs +17 -2
- package/bin/lib/doctor-plan.mjs +7 -9
- package/bin/lib/effective-contract-load.mjs +121 -59
- package/bin/lib/enforcement-honesty.mjs +22 -0
- package/bin/lib/enforcement-profiles.mjs +40 -4
- package/bin/lib/first-run-help.mjs +3 -2
- package/bin/lib/flat-parent-importers.mjs +137 -0
- package/bin/lib/flat-parent-pilot.mjs +192 -0
- package/bin/lib/gate-files.mjs +29 -2
- package/bin/lib/git-change-scope.mjs +109 -0
- package/bin/lib/github-enforcement.mjs +1 -1
- package/bin/lib/hook-templates.mjs +18 -16
- package/bin/lib/host-support-matrix.mjs +3 -1
- package/bin/lib/html-report-advisories.mjs +2 -0
- package/bin/lib/html-report-depth.mjs +3 -1
- package/bin/lib/import-resolve.mjs +13 -1
- package/bin/lib/install-migrate.mjs +50 -73
- package/bin/lib/invariant-coverage.mjs +59 -11
- package/bin/lib/mcp-adoption.mjs +9 -1
- package/bin/lib/mcp-hook-payload.mjs +401 -61
- package/bin/lib/package-manager.mjs +59 -1
- package/bin/lib/passthrough-commands.mjs +83 -0
- package/bin/lib/persistence-write-hint.mjs +81 -0
- package/bin/lib/physical-cohesion.mjs +16 -18
- package/bin/lib/pilot-loop.mjs +21 -8
- package/bin/lib/pin-dependent-gates.mjs +117 -0
- package/bin/lib/policy-delta-io.mjs +168 -10
- package/bin/lib/prepare-change.mjs +120 -6
- package/bin/lib/prepare-write.mjs +1 -0
- package/bin/lib/presets.mjs +3 -5
- package/bin/lib/remediation.mjs +23 -4
- package/bin/lib/resolved-candidate-facts.mjs +315 -55
- package/bin/lib/rules-inventory.mjs +22 -3
- package/bin/lib/rules-under-contract.mjs +179 -5
- package/bin/lib/scan-files.mjs +32 -0
- package/bin/lib/snippet-analysis.mjs +140 -6
- package/bin/lib/source-policy.mjs +34 -0
- package/bin/lib/stable-hash.mjs +90 -0
- package/bin/lib/start-install-recovery.mjs +71 -1
- package/bin/lib/start-preview.mjs +30 -0
- package/bin/lib/status-command.mjs +33 -4
- package/bin/lib/status-manifest.mjs +32 -4
- package/bin/lib/team-parliament-io.mjs +79 -75
- package/bin/lib/team-parliament.mjs +6 -1
- package/bin/lib/write-path-capabilities.mjs +4 -2
- package/dist/chunk-A5EIY3HI.cjs +5 -0
- package/dist/chunk-MBXCFLO4.js +16 -0
- package/dist/chunk-RNQHRDCQ.cjs +16 -0
- package/dist/chunk-SVSQVGFJ.js +5 -0
- package/dist/{configTypes-CTELo87-.d.ts → configTypes-BJbaeoj4.d.cts} +53 -4
- package/dist/configTypes-BJbaeoj4.d.ts +246 -0
- package/dist/eslint/index.cjs +17 -4
- package/dist/eslint/index.d.cts +359 -0
- package/dist/eslint/index.d.ts +178 -158
- package/dist/eslint/index.js +10 -4
- package/dist/index.cjs +38 -37
- package/dist/index.d.cts +5475 -0
- package/dist/index.d.ts +3408 -296
- package/dist/index.js +38 -37
- package/dist/inspectorListen-6DQVJ4DC.js +1 -0
- package/dist/inspectorListen-KGMIQ2TF.cjs +1 -0
- package/dist/nestjs/index.cjs +1 -18
- package/dist/nestjs/index.d.cts +22 -0
- package/dist/nestjs/index.d.ts +1 -3
- package/dist/nestjs/index.js +1 -18
- package/dist/order/index.cjs +1 -1
- package/dist/order/index.d.cts +155 -0
- package/dist/order/index.d.ts +15 -3
- package/dist/order/index.js +1 -1
- package/dist/runtime/index.cjs +13 -30
- package/dist/{diagnosticCatalog-WD2TPSwZ.d.ts → runtime/index.d.cts} +814 -290
- package/dist/runtime/index.d.ts +2678 -108
- package/dist/runtime/index.js +13 -30
- package/dist/{types-yDNEQ603.d.ts → types-DRinG-vT.d.cts} +576 -140
- package/dist/types-DRinG-vT.d.ts +1792 -0
- package/docs/README.md +3 -1
- package/docs/agent-guide.md +92 -15
- package/docs/ai-gates.md +160 -26
- package/docs/arkorder.md +32 -15
- package/docs/brownfield-adoption.md +5 -1
- package/docs/configuration.md +273 -12
- package/docs/develop.md +2 -1
- package/docs/diagnostics.md +122 -13
- package/docs/package-surface.md +31 -8
- package/docs/product-voice.md +1 -1
- package/package.json +59 -18
- package/schemas/ark.analysis-result.schema.json +15 -0
- package/schemas/ark.config.schema.json +163 -4
- package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
- package/schemas/ark.status-manifest.schema.json +22 -0
- package/server.json +3 -9
- package/templates/agent-skills/README.md +1 -1
- package/templates/agent-skills/ark-adopt/SKILL.md +4 -1
- package/templates/agent-skills/ark-order/SKILL.md +4 -2
- package/templates/agent-skills/ark-runtime/SKILL.md +6 -1
- package/templates/arkrules/PersistenceAdapters.json +1 -1
- package/templates/arkrules/PresentationAdapters.json +1 -1
- package/templates/skills/ark-adopt.md +4 -1
- package/templates/skills/ark-order.md +4 -2
- package/templates/skills/ark-runtime.md +6 -1
- package/dist/types-fQ9-KrBj.d.ts +0 -183
package/dist/eslint/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
var $t=Object.defineProperty;var l=(e,t)=>$t(e,"name",{value:t,configurable:!0});import C from"fs";import m from"path";var Ne=new Map;function Ce(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(Ce,"escapeLiteral");function Z(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l(Z,"normalizeGlobSeparators");function Mt(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}l(Mt,"bracesBalanced");function _(e){let t=Ne.get(e);if(t)return t;let r=Z(e),n=Mt(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=Ce(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=Ce(c)}let i=new RegExp(`^${s}$`);return Ne.set(e,i),i}l(_,"globToRegExp");function Ut(e){return Z(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}l(Ut,"concreteGlobSegments");function De(e,t){let r=Z(String(e)),n=Ut(r),s=r.replace(/\*/g,"").length,o=n.length*1e4+s;if(t==null||t==="")return o;let i=String(t).split(/[/\\]/).filter(Boolean);if(n.length===0)return s;let a=0,c=-1;for(let f of n){let d=-1;for(let u=a;u<i.length;u+=1)if(i[u]===f){d=u;break}if(d<0)return o;c=d,a=d+1}return(c+1)*1e6+n.length*1e4+s}l(De,"patternSpecificity");function S(e,t){let r=String(e).split(/[/\\]/).join("/"),n,s=-1;for(let o of t??[])if(!(o.exclude??[]).some(i=>_(i).test(r))){for(let i of o.patterns??[])if(_(i).test(r)){let a=De(i,r);a>s&&(s=a,n=o.name)}}return n}l(S,"layerForRelativePath");function Oe(e,t,r){if(!t?.length)return;let n=r==="stars"?"stars":"path",s=String(e).split(/[/\\]/).filter(Boolean);if(s.length===0)return;let o=new Set;for(let i of t)if(!(typeof i!="string"||i.length===0)){if(jt(i)){let a=Ht(s,i,n);if(a)return a;continue}!i.includes("/")&&!i.includes("\\")&&!i.includes("*")&&o.add(i.toLowerCase())}return Gt(s,o)}l(Oe,"sliceIdForPath");function jt(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(r=>r==="*")}l(jt,"isAnchoredSliceEntry");function Ht(e,t,r){let n=t.split(/[/\\]/).filter(o=>o.length>0).map(o=>o.toLowerCase()),s=Pe(e,n[0]??"");for(let o of s){let i=Vt(e,n,o,r);if(i)return i}}l(Ht,"anchoredSliceId");function Vt(e,t,r,n="path"){let s=[],o=-1,i=r;for(let a=0;a<t.length;a+=1){let c=t[a];if(c==="*"){if(i>=e.length-1){for(let f=a;f<t.length;f+=1)if(t[f]!=="*")return;break}s.push(e[i].toLowerCase()),i+=1;continue}if(c==="**"||i>=e.length||e[i].toLowerCase()!==c)return;s.push(e[i].toLowerCase()),o=s.length-1,i+=1}if(s.length!==0)return n==="stars"?o<0?void 0:s.slice(o).join("/"):s.join("/")}l(Vt,"bindAnchoredSlice");function Gt(e,t){if(t.size!==0){for(let r=0;r<e.length-1;r+=1)if(t.has(e[r].toLowerCase())&&!(r+1>=e.length-1))return`${e[r].toLowerCase()}/${e[r+1].toLowerCase()}`}}l(Gt,"bareSliceId");function Bt(e){let t=new Set;for(let r of e??[]){let s=Z(String(r)).split("/").filter(Boolean);for(let o=0;o<s.length;o+=1){let i=s[o];if((i==="**"||i==="*")&&o>0){let a=s[o-1];a&&!a.includes("*")&&!a.includes("{")&&!a.includes("}")&&t.add(a)}}}return[...t]}l(Bt,"inferSliceFoldersFromPatterns");function Wt(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 Bt(n?.patterns)}l(Wt,"resolveSliceFolders");function ve(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}l(ve,"normalizeSegments");function Fe(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}l(Fe,"trimTrailingSlashes");var zt=["src","app"];function Pe(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return zt.includes(r)&&n!==r?[0,1]:[0]}l(Pe,"anchorOffsets");function qt(e){let t=Fe(e.replace(/^[./]+/,""));return t==="*"||t==="**"}l(qt,"isBlanketRoot");function Te(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=ve(r);for(let o of t){if(typeof o!="string"||o.length===0||qt(o))continue;if(o.includes("*")){let c=Fe(o.toLowerCase());if(_(c).test(n)||_(`${c}/**`).test(n))return!0;continue}let i=ve(o);if(i.length===0)continue;let a=Pe(s,i[0]??"");for(let c of a){if(c+i.length>s.length)continue;let f=!0;for(let d=0;d<i.length;d+=1)if(s[c+d]!==i[d]){f=!1;break}if(f)return!0}}return!1}l(Te,"pathUnderSharedRoot");function Le(e,t){let r=String(e).split(/[/\\]/).filter(Boolean).join("/").toLowerCase();if(!r)return!1;let n=t.toLowerCase();return r===n?!0:!r.includes("/")&&n.endsWith(`/${r}`)}l(Le,"sliceMatchesDeclaration");function Zt(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Le(n.from,t)&&Le(n.to,r))}l(Zt,"crossSliceEdgeAllowed");function Yt(e){if(!e.fromPath)return{denied:!0,reason:"missing-path"};if(e.folderCount<=0)return{denied:!0,reason:"no-slice-folders"};let t=!!e.fromSlice||e.fromShared===!0;if(!e.toPath)return t?e.fromSlice?{denied:!0,reason:"missing-path"}:{denied:!1}:{denied:!0,reason:"unclassifiable-path"};let r=!!e.toSlice||e.toShared===!0;return!t||!r?{denied:!0,reason:"unclassifiable-path"}:e.sharedImportsSlice==="deny"&&e.fromShared===!0&&e.toSlice&&!e.fromSlice?{denied:!0,reason:"shared-imports-slice"}:!e.fromSlice||!e.toSlice?{denied:!1}:e.fromSlice===e.toSlice?{denied:!1}:e.crossSliceAllowed?{denied:!1}:{denied:!0,reason:"cross-slice"}}l(Yt,"peerIsolationDecision");function Ke(e,t){switch(e){case"cross-slice":return`cross-slice edge ${t.fromSlice??"?"} \u2192 ${t.toSlice??"?"}. Extract the shared code, use events/ports across slices, or declare the edge in the rule's allowedCrossSlice.`;case"shared-imports-slice":return`shared root imports slice ${t.toSlice??"?"} (${t.fromPath??"?"} \u2192 ${t.toPath??"?"}). The wall is direct-only.`;case"unclassifiable-path":{let r=[t.fromSlice?void 0:t.fromPath,t.toSlice?void 0:t.toPath].filter(s=>!!s);return`unclassifiable path${r.length>0?` (${r.join(", ")})`:""} \u2014 ArkGate cannot place it in a slice, so it cannot prove this is not a cross-slice edge. Move it into a slice, or declare its root in the rule's sharedRoots.`}case"no-slice-folders":return"no slice folders \u2014 peerIsolation is on but no slice folder resolves from the rule or the layer patterns. Set sliceFolders on the rule.";default:return"no path evidence for this edge \u2014 peerIsolation needs the importer and importee paths."}}l(Ke,"peerIsolationDenyExplanation");function Xt(e,t,r,n){return ae(e,t,r,n)?.rule}l(Xt,"findDeniedEdgeRule");function ae(e,t,r,n){for(let s of e??[])if(!(s.from!==t||s.to!==r)&&s.allowed===!1){if(s.peerIsolation){let o=n?.fromPath,i=n?.toPath,a=Wt(s,t,n?.layers),c=o?Oe(o,a,s.sliceIdentity):void 0,f=i?Oe(i,a,s.sliceIdentity):void 0,d=Yt({fromPath:o,toPath:i,folderCount:a.length,fromSlice:c,toSlice:f,fromShared:!c&&Te(o,s.sharedRoots),toShared:!f&&Te(i,s.sharedRoots),crossSliceAllowed:Zt(s.allowedCrossSlice,c,f),sharedImportsSlice:s.sharedImportsSlice});if(d.denied)return{rule:s,peerIsolationReason:d.reason,fromSlice:c,toSlice:f};continue}if(t!==r)return{rule:s}}}l(ae,"findDeniedEdgeDecision");function Jt(e,t,r,n){return Xt(e,t,r,n)!==void 0}l(Jt,"isEdgeDenied");var Qt=["**/*.gen.ts","**/*.gen.tsx","**/*.generated.ts","**/*.generated.tsx"];function er(e){let t=Array.isArray(e?.exclude)?e.exclude.filter(n=>typeof n=="string"):[];return[...e?.excludeGenerated===!1?[]:Qt,...t]}l(er,"scanExcludePatterns");function $e(e,t){let r=String(e).split(/[/\\]/).join("/");return er(t).some(n=>_(n).test(r))}l($e,"isScanExcludedRelative");var Me=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),tr=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),Jn=Object.freeze(Object.keys(tr).sort()),le=Object.freeze({fs:"filesystem","node:fs":"filesystem","fs/promises":"filesystem","node:fs/promises":"filesystem","fs-extra":"filesystem","graceful-fs":"filesystem",memfs:"filesystem",chokidar:"filesystem",http:"network",https:"network",http2:"network",net:"network",tls:"network",dgram:"network",dns:"network","node:http":"network","node:https":"network","node:http2":"network","node:net":"network","node:tls":"network","node:dgram":"network","node:dns":"network",axios:"network",undici:"network","node-fetch":"network",got:"network",ky:"network",superagent:"network",ws:"network",process:"process","node:process":"process",child_process:"process","node:child_process":"process","@prisma/client":"persistence",prisma:"persistence",pg:"persistence",mysql:"persistence",mysql2:"persistence",mongodb:"persistence",mongoose:"persistence",sqlite3:"persistence","better-sqlite3":"persistence",redis:"persistence",ioredis:"persistence",typeorm:"persistence",knex:"persistence","drizzle-orm":"persistence",sequelize:"persistence",kysely:"persistence","@supabase/supabase-js":"persistence"}),rr=Object.freeze({process:Object.freeze(["process","node:process"])});function Ue(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=le[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=le[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:le[e.slice(0,o)]??null}l(Ue,"capabilityForModuleSpecifier");function ce(e,t){for(let r of t)if(rr[r]?.includes(e))return r;return null}l(ce,"forbiddenGlobalForModuleSpecifier");function je(e){if(e?.pure===!0)return[...Me].sort();let r=(e?.capabilities?.deny??[]).filter(n=>Me.includes(n));return[...new Set(r)].sort()}l(je,"effectiveCapabilityDeny");var v={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},He={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...v,default:[]},kernelRoots:{...v},managedLayers:{...v,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},Ve={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...v,default:[]},managedLayers:{...v,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...v,default:[]},appliesTo:{...v,default:[]}}};function M(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(M,"isObject");function Ge(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)M(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}l(Ge,"declaredLayerNames");function Be(e){if(!M(e))return e;let t={mode:e.mode===void 0?"advisory":e.mode,compositionRoots:e.compositionRoots===void 0?[]:e.compositionRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,requireDeclarations:e.requireDeclarations===void 0?!0:e.requireDeclarations};return e.kernelRoots!==void 0&&(t.kernelRoots=e.kernelRoots),e.ignoreDirectNewForErrors!==void 0&&(t.ignoreDirectNewForErrors=e.ignoreDirectNewForErrors),{...e,...t}}l(Be,"defaultedArkRun");function We(e){if(!M(e))return e;let t=typeof e.maxXiKeys=="number"&&e.maxXiKeys>0?e.maxXiKeys:7;return{...e,mode:e.mode===void 0?"advisory":e.mode,planeRoots:e.planeRoots===void 0?[]:e.planeRoots,managedLayers:e.managedLayers===void 0?[]:e.managedLayers,maxXiKeys:t,xiKeys:e.xiKeys===void 0?[]:e.xiKeys}}l(We,"defaultedArkOrder");function ze(e,t){let r=e.arkRun;if(r===void 0||!M(r))return;let n=Ge(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkRun.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.kernelRoots??r.compositionRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:r.kernelRoots!==void 0?"$.arkRun.kernelRoots":"$.arkRun.compositionRoots",message:"ARKRUN_MISSING_ROOT: enforced mode requires at least one kernel root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkRun.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(ze,"validateArkRunExtra");function qe(e,t){let r=e.arkOrder;if(r===void 0||!M(r))return;let n=Ge(e),s=r.managedLayers;if(Array.isArray(s)&&s.forEach((o,i)=>{typeof o=="string"&&o.length>0&&!n.has(o)&&t.push({path:`$.arkOrder.managedLayers[${i}]`,message:`layer ${JSON.stringify(o)} is not declared in layers[]`})}),r.mode==="enforced"){let o=r.planeRoots;(!Array.isArray(o)||o.length===0)&&t.push({path:"$.arkOrder.planeRoots",message:"ARKORDER_MISSING_PLANE: enforced mode requires at least one plane root"}),(!Array.isArray(s)||s.length===0)&&t.push({path:"$.arkOrder.managedLayers",message:"enforced mode requires at least one managed layer"})}}l(qe,"validateArkOrderExtra");function Y(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}l(Y,"normalizeStewardId");function Ze(e){let t=Y(e);return!t||de(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}l(Ze,"isGitHubHandle");function nr(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return!t.includes("@")||t.includes(" ")||de(t)?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}l(nr,"isGitHubEmail");function sr(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Ze(t[1])?Y(t[1]):null}l(sr,"githubHandleFromEmail");function Ye(e){let t=sr(e);if(t)return t;let r=Y(e);return!r||de(r)?null:Ze(r)||nr(r)?r:null}l(Ye,"canonicalStewardId");var or=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function de(e){let t=Y(e);return!t||or.test(t)}l(de,"isAutomationAuthor");var I="1.3",ir=["public","auth","admin","internal"];var ue="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",Xe=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],ar=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function lr(){let e=[];for(let t of Xe)for(let r of Xe)t===r||ar.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}l(lr,"createDefaultRules");var Qe=lr(),fe=[{from:"unversioned",to:"1.0"},{from:"1.0",to:"1.1"},{from:"1.1",to:"1.2"},{from:"1.2",to:"1.3"}],E={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Je={$schema:"https://json-schema.org/draft/2020-12/schema",$id:ue,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:ue,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:I,default:I},name:{type:"string",minLength:1},include:{...E,minItems:1,default:["src"]},exclude:{...E,default:[]},excludeGenerated:{type:"boolean",default:!0},frameworkOverlay:{type:"string",minLength:1},layers:{type:"array",default:[],items:{$ref:"#/$defs/layer"}},rules:{type:"array",default:Qe,items:{$ref:"#/$defs/rule"}},cyclePolicy:{type:"string",enum:["strict","soft","framework-soft","off"],default:"strict"},dynamicImportAllowlist:{...E,default:[]},safety:{$ref:"#/$defs/safety",default:{maxTsSuppressions:0,maxAnyCasts:0,allowInMemory:!1,allowDisabledPeerIsolation:!1}},coverage:{$ref:"#/$defs/coverage"},arkRules:{type:"object",additionalProperties:{type:"string",minLength:1},default:{}},arkRun:{$ref:"#/$defs/arkRun"},arkOrder:{$ref:"#/$defs/arkOrder"},stewards:{...E,default:[]},requireLayerOwners:{type:"boolean"}},$defs:{layer:{type:"object",additionalProperties:!1,required:["name","patterns"],properties:{name:{type:"string",minLength:1},patterns:{...E,minItems:1},exclude:E,intentPrefixes:E,description:{type:"string",minLength:1},trustBoundary:{type:"string",enum:[...ir]},owners:{...E,minItems:1},forbiddenGlobals:E,capabilities:{type:"object",additionalProperties:!1,properties:{deny:{type:"array",uniqueItems:!0,items:{type:"string",enum:["network","filesystem","clock","randomness","environment","process","persistence"]}}}},pure:{type:"boolean"},mayImportInfrastructure:{type:"boolean"},optional:{type:"boolean"},reserved:{type:"boolean"},allowEmpty:{type:"boolean"}}},rule:{type:"object",additionalProperties:!1,required:["from","to","allowed"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1},allowed:{type:"boolean"},message:{type:"string",minLength:1},peerIsolation:{type:"boolean"},sliceFolders:{...E,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"],description:"How a starred sliceFolders prefix is named. Absent and path keep today's ids (every literal and star binding). stars keeps the last literal plus the star bindings, so parallel trees share one feature id. Bare names are unchanged."},sharedRoots:{...E,minItems:1},allowedCrossSlice:{type:"array",minItems:1,items:{type:"object",additionalProperties:!1,required:["from","to"],properties:{from:{type:"string",minLength:1},to:{type:"string",minLength:1}}}},sharedImportsSlice:{type:"string",enum:["deny"]}}},safety:{type:"object",additionalProperties:!1,properties:{maxTsSuppressions:{type:"integer",minimum:0,default:0},maxAnyCasts:{type:"integer",minimum:0,default:0},allowInMemory:{type:"boolean",default:!1},allowDisabledPeerIsolation:{type:"boolean",default:!1}}},coverage:{type:"object",additionalProperties:!1,description:"Invariant coverage scan controls. testGlobs replaces the built-in test-name heuristic; maxFiles raises or lowers the evidence file budget and also bounds structural-hint preload for orchestration-only, thin-adapter, and writes-via-aggregate (default 400; there is no arkrules.hintBudget); coverageRoots declares where the project runs its tests, so a covering test found outside them is reported instead of silently certifying an invariant. When any invariant is enforced, missing coverageRoots fails closed.",properties:{testGlobs:{...E,minItems:1},maxFiles:{type:"integer",minimum:1,description:"Evidence file budget (default 400) and structural-hint preload cap for orchestration-only, thin-adapter, and writes-via-aggregate. Raise this when hinted/governed counts show truncated sensors. There is no separate arkrules.hintBudget."},coverageRoots:{...E,minItems:1}}},arkRun:He,arkOrder:Ve}},x=class extends Error{static{l(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
|
|
1
|
+
var bs=Object.defineProperty;var a=(e,t)=>bs(e,"name",{value:t,configurable:!0});import w from"path";function Es(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(Es,"sharedImportsSliceMode");var Mt=new Map;function Kt(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Kt,"escapeLiteral");function Te(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(Te,"normalizeGlobSeparators");function Is(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(Is,"bracesBalanced");function F(e){let t=Mt.get(e);if(t)return t;let r=Te(e),n=Is(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Kt(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+=Kt(c)}let i=new RegExp(`^${s}$`);return Mt.set(e,i),i}a(F,"globToRegExp");function ws(e){return Te(String(e)).split("/").filter(Boolean).filter(r=>r!=="**"&&r!=="*"&&!r.includes("*")&&!r.includes("?")&&!r.includes("{")&&!r.includes("["))}a(ws,"concreteGlobSegments");function Zt(e,t){let r=Te(String(e)),n=ws(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(Zt,"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=Zt(i,r);l>s&&(s=l,n=o.name)}}return n}a(v,"layerForRelativePath");function it(e,t,r){return Jt(e,t,r==="stars"?"stars":"path")}a(it,"sliceIdForPath");function jt(e,t){return Jt(e,t?[...t]:void 0,Xt)}a(jt,"legacyStarsSliceIdForPath");var Xt="stars-4.8.23";function Jt(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=vs(o);if(i.anchored){let l=Cs(n,i.anchored,r);if(l)return l;continue}i.bare!==void 0&&s.add(i.bare)}return Ts(n,s)}a(Jt,"sliceIdWithBinding");var Ne=new Map;function vs(e){let t=Ne.get(e);if(t)return t;let r={};return xs(e)?r={anchored:_s(e)}:!e.includes("/")&&!e.includes("\\")&&!e.includes("*")&&(r={bare:e.toLowerCase()}),Ne.size>=1024&&Ne.clear(),Ne.set(e,r),r}a(vs,"parsedSliceFolder");function xs(e){let t=e.split(/[/\\]/).filter(r=>r.length>0);return t.length<2||t[0]==="*"||t[0]==="**"?!1:t.some(r=>r==="*")}a(xs,"isAnchoredSliceEntry");function _s(e){return e.split(/[/\\]/).filter(t=>t.length>0).map(t=>t.toLowerCase())}a(_s,"anchoredSlicePattern");function Cs(e,t,r){let n=Qt(e,t[0]??"");for(let s of n){let o=Os(e,t,s,r);if(o)return o}}a(Cs,"anchoredSliceIdFromPattern");function Os(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===Xt?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(Os,"bindAnchoredSlice");function Ns(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(Ns,"starsKeptSegmentIndexes");function Ts(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(Ts,"bareSliceId");function Ls(e){let t=new Set;for(let r of e??[]){let s=Te(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(Ls,"inferSliceFoldersFromPatterns");function Ds(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 Ls(n?.patterns)}a(Ds,"resolveSliceFolders");function Ut(e){return String(e).split(/[/\\]/).filter(t=>!!t&&t!==".").map(t=>t.toLowerCase())}a(Ut,"normalizeSegments");function ye(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(ye,"trimTrailingSlashes");var Fs=["src","app"];function Qt(e,t){let r=(e[0]??"").toLowerCase(),n=t.toLowerCase();return Fs.includes(r)&&n!==r?[0,1]:[0]}a(Qt,"anchorOffsets");function Ps(e){let t=ye(e.replace(/^[./]+/,""));return t==="*"||t==="**"}a(Ps,"isBlanketRoot");function Gt(e,t){if(!e||!t?.length)return!1;let r=String(e).split(/[/\\]/).join("/"),n=r.toLowerCase(),s=Ut(r);for(let o of t){if(typeof o!="string"||o.length===0||Ps(o))continue;if(o.includes("*")){let c=ye(o.toLowerCase());if(F(c).test(n)||F(`${c}/**`).test(n))return!0;continue}let i=Ut(o);if(i.length===0)continue;let l=Qt(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(Gt,"pathUnderSharedRoot");function Ht(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(Ht,"sliceMatchesDeclaration");function Vt(e,t,r){return!e?.length||!t||!r?!1:e.some(n=>n&&typeof n.from=="string"&&typeof n.to=="string"&&Ht(n.from,t)&&Ht(n.to,r))}a(Vt,"crossSliceEdgeAllowed");function $s(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($s,"peerIsolationDecision");function er(e){return ye(e.trim().replace(/\\/g,"/")).toLowerCase()}a(er,"aliasGlobPattern");function Ms(e,t){let r=er(e);if(!r||r==="*"||r==="**")return!1;let n=String(t).replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),s=ot(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(Ms,"aliasGlobMatches");function tr(e){let t=er(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(tr,"splitAliasTarget");function rr(e,t){for(let r of t.childSlices?.sliceAliases??[])if(!(!r||typeof r.from!="string"||typeof r.to!="string")&&Ms(r.from,e))return r;return null}a(rr,"firstSliceAliasEntry");function Ks(e,t){let r=rr(e,t);return r?tr(r.to):null}a(Ks,"firstSliceAlias");function js(e,t,r){if(!e)return{};let n=r??t.sliceFolders,s=it(e,n?[...n]:void 0,t.sliceIdentity),o=st(e,s,t.childSlices);if(s||o.childId||o.mismatched)return o.childId?{universeId:s,childId:o.childId}:{universeId:s};let i=Ks(e,t);return i?{universeId:i.universeId,childId:i.childId}:{}}a(js,"resolveGovernedSlice");function Us(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=Ns(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(Us,"starsUniverseShapes");function Bt(e,t){return e.length===t.length&&e.every((r,n)=>r===null||t[n]==="*"||r===t[n])}a(Bt,"literalsMatch");function Gs(e,t){let r=t.split("/").filter(Boolean).map(o=>o.toLowerCase()),n=Us(e);if(r.length===0||n.some(o=>Bt(o.literals,r)))return[];let s=new Set;for(let o of n)if(o.legacy.length!==o.literals.length&&Bt(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(Gs,"legacyStarsIdTargets");function Hs(e,t){if(e.sliceIdentity!=="stars")return;let r=tr(t);if(r)return Gs(e.sliceFolders,r.universeId).length===1?r.universeId:void 0}a(Hs,"legacyAliasUniverse");function zt(e,t,r){let n=js(e,t,r);if(!e||t.sliceIdentity!=="stars")return n;if(n.universeId){let s=rr(e,t);if(!it(e,[...r],t.sliceIdentity)&&s&&Hs(t,s.to)!==void 0)return{...n,legacyAlias:!0,legacyUniverse:n.universeId,legacyChild:n.childId};let i=jt(e,r),l=t.childSlices,c=l?.sliceIdentity==="stars"?jt(e,l.sliceFolders):void 0;return{...n,...i?{legacyUniverse:i}:{},...c&&n.childId?{legacyChild:c}:{}}}return n}a(zt,"placeForPair");function Vs(e,t,r,n){let s=zt(r,e,t),o=zt(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=Vt(e.allowedCrossSlice,d.universeId,u.universeId)||e.sliceIdentity==="stars"&&(i!==d.universeId||l!==u.universeId)&&Vt(e.allowedCrossSlice,i,l),g=e.childSlices?.sliceIdentity==="stars"&&s.legacyChild!==void 0&&o.legacyChild!==void 0&&s.legacyChild!==o.legacyChild&&nr(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(Vs,"resolveGovernedSlicePair");function Bs(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(Bs,"peerIsolationDenyExplanation");function zs(e,t){return`cross-parent slice ${e??"?"} \u2192 ${t??"?"}. The child wall cannot allow another universe.`}a(zs,"crossParentExplanation");function Ws(e,t,r){return`cross-sibling slice ${e} \u2192 ${t} inside ${r}.`}a(Ws,"crossSiblingExplanation");function qs(e){return`universe common imports child ${e}. parentMayImportChild is off.`}a(qs,"parentImportsChildExplanation");function Wt(e){if(!e)return;let t=e.split("/").filter(Boolean);return t.length>0?t[t.length-1]:void 0}a(Wt,"universePairLabel");function Ys(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(Ys,"isCommonFolderName");function st(e,t,r){if(!e||!r?.sliceFolders?.length)return{};let n=it(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 Ys(i,r.commonFolders)?{}:{childId:n}}a(st,"resolveChildSliceId");function Zs(e){return ye(e.trim().replace(/\\/g,"/")).toLowerCase()}a(Zs,"siblingEntryKey");function ot(e){return e.replace(/^(?:src|app)\//,"")}a(ot,"stripSrcOrApp");function Xs(e,t){let r=e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase(),n=ot(t);if(!n)return!1;let s=ot(r);return r===n||r.startsWith(`${n}/`)||s===n||s.startsWith(`${n}/`)}a(Xs,"pathUnderSubtree");function Js(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=Zs(s);if(!(!o||o.includes("*"))&&(n===o||e&&Xs(e,o)))return!0}return!1}a(Js,"importerInEnforcedSubtree");function Qs(e,t,r){return e==null||e==="deny"?!1:e==="advisory"?!0:e.default==="deny"?!1:!Js(t,r,e.enforce)}a(Qs,"siblingCrossingAdvisory");function qt(e){if(typeof e!="string")return null;let t=ye(e.trim().replace(/\\/g,"/")).toLowerCase();if(!t.includes("/"))return null;let r=t.split("/");for(let n of r)if(n.length===0||n==="."||n===".."||n.includes("*")&&n!=="*")return null;return r}a(qt,"childSlicePatternSegments");function Yt(e,t){let r=qt(e),n=qt(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(Yt,"childSlicePatternMatches");function nr(e,t,r){if(!e?.length)return!1;for(let n of e)if(!(!n||typeof n.from!="string"||typeof n.to!="string")&&Yt(n.from,t)&&Yt(n.to,r))return!0;return!1}a(nr,"childCrossSliceAllowed");function eo(e){let t=$s({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:Es(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?zs(e.fromSlice,e.toSlice):Bs(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??st(e.fromPath,e.fromSlice,r).childId,s=e.toChild??st(e.toPath,e.toSlice,r).childId,o={crossing:"none",decision:"allow",fromUniverse:e.fromSlice,toUniverse:e.toSlice};return n&&s&&n!==s?e.legacyChildAllowed||nr(r.allowedCrossSlice,n,s)?o:{crossing:"cross-sibling",decision:Qs(r.siblings,e.fromPath,n)?"advisory":"deny",reasonId:"CROSS_SIBLING_SLICE",explanation:Ws(n,s,e.fromSlice),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:!n&&s&&r.parentMayImportChild!==!0?{crossing:"parent-imports-child",decision:"deny",explanation:qs(s),fromUniverse:e.fromSlice,toUniverse:e.toSlice}:o}a(eo,"evaluateNestedSliceWall");function to(e){return e?.crossing==="cross-sibling"||e?.crossing==="parent-imports-child"}a(to,"isChildWallCrossing");function sr(e){let t=e.verdict.explanation,r=to(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(sr,"composeSliceDenialMessage");function or(e){if(!e||e.decision==="allow")return{};let t=Wt(e.fromUniverse),r=Wt(e.toUniverse);return{...e.reasonId?{reasonId:e.reasonId}:{},...e.reasonId&&t&&r?{universeFrom:t,universeTo:r}:{},...e.decision==="advisory"?{failsStrict:!1,severity:"warning"}:{}}}a(or,"sliceFindingExtras");function ro(e,t,r,n){return at(e,t,r,n)?.rule}a(ro,"findDeniedEdgeRule");function at(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=Ds(s,t,n?.layers),c=Vs(s,l,o,i),d=c.from,u=c.to,f=d.universeId,g=u.universeId,p=eo({rule:s,fromPath:o,toPath:i,folderCount:l.length,fromSlice:f,toSlice:g,fromChild:d.childId,toChild:u.childId,fromShared:!f&&Gt(o,s.sharedRoots),toShared:!g&&Gt(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(at,"findDeniedEdgeDecision");function no(e,t,r,n){return ro(e,t,r,n)!==void 0}a(no,"isEdgeDenied");var so=["**/*.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?[]:so,...t]}a(oo,"scanExcludePatterns");function ir(e,t){let r=String(e).split(/[/\\]/).join("/");return oo(t).some(n=>F(n).test(r))}a(ir,"isScanExcludedRelative");var ar=Object.freeze(["network","filesystem","clock","randomness","environment","process","persistence"]),io=Object.freeze({fetch:"network",XMLHttpRequest:"network",Date:"clock","Date.now":"clock","Math.random":"randomness","process.env":"environment",process:"process"}),kc=Object.freeze(Object.keys(io).sort()),lt=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"}),ao=Object.freeze({process:Object.freeze(["process","node:process"])});function lr(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=lt[e];if(t)return t;let r=e.indexOf("/");if(r<0)return null;let n=e.slice(0,r),s=lt[n];if(s)return s;let o=e.indexOf("/",r+1);return o<0?null:lt[e.slice(0,o)]??null}a(lr,"capabilityForModuleSpecifier");function Le(e,t){for(let r of t)if(ao[r]?.includes(e))return r;return null}a(Le,"forbiddenGlobalForModuleSpecifier");function cr(e){if(e?.pure===!0)return[...ar].sort();let r=(e?.capabilities?.deny??[]).filter(n=>ar.includes(n));return[...new Set(r)].sort()}a(cr,"effectiveCapabilityDeny");import Vr from"fs";import X from"path";var dr={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 Ae(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}a(Ae,"looksLikeArkIntent");function ct(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&Ae(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:dr.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:dr.PUBLISH_MISSING_SOURCE}),t}a(ct,"classifyPublishFacts");var co=["createArkKernel","createStrictArkKernel","createLenientArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig","createLenientArkKernelFromConfig"],uo="ArkModule",fo=["forRoot","forRootAsync"],po=["ArkKernel","EventBus","EventPublisher","ArkRunPublisher"],pr=new Set(["eventBus"]),go=new Set(["publisher","eventBus"]),ho=new Set(fo),mo=new Set(po);var De=new Set(co),yo=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"]),gr=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function Z(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")||e==="arkgate/nestjs"||e.startsWith("arkgate/nestjs/")}a(Z,"isArkRunKernelModuleSpecifier");var Ao=["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"],dt=new Set(Ao);function hr(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(dt.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(dt.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:dt.has(e.slice(0,n))}a(hr,"isArkRunTransportBypassSpecifier");function ut(e){if(De.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(ut,"arkRunKernelCallKind");function mr(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}a(mr,"lineAt");function ft(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(ft,"stripCommentsPreservingLines");function Ro(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(Ro,"firstStringLiteralArg");function ur(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(ur,"keywordBefore");function Re(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(Re,"parseValueImportClause");function yr(e,t){Re(ft(e),t)}a(yr,"forEachArkRunValueImportClause");function ko(e){let t=new Map,r=new Set;return Re(e,(n,s)=>{if(!Z(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(ko,"collectKernelImportBindings");function So(e,t){let r=new Set(t);return Re(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)||(Z(s)||t.has(u)||t.has(d))&&(r.add(d),r.add(u))}}),r}a(So,"collectImportedConstructors");function bo(e,t){let r;return Re(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}a(bo,"importedFromForName");function Eo(e){let t=new Set,r=/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;){if(!Z(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;mo.has(c)&&t.add(d)}}return t}a(Eo,"collectKernelTypeNames");function Io(e,t){let r=e.split(".");if(r.length===2)return t.namespaces.has(r[0])&&De.has(r[1]);if(r.length!==1)return!1;let n=t.named.get(r[0]);return n!==void 0&&De.has(n)}a(Io,"isFactoryCalleeExpression");function wo(e,t,r,n){Re(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(wo,"addRootModuleImports");function vo(e,t){let{receivers:r,calleeBindings:n}=t,s=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*(?:await\s+)?(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*\.\s*([A-Za-z_$][\w$]*)\b/g,o=/\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*[;\n)]/g,i=/(?:\b(?:const|let|var)\s+|\bthis\s*\.\s*|(?:^|[;{}\n])\s*)([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?(?<![=!<>])=(?![=>])\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*)\s*(?:as\s+[A-Za-z_$][\w$.<>]*\s*)?(?=[;\n,)])/g,l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*typeof\s+([A-Za-z_$][\w$]*)\b/g,c;for(let d=!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])&&(!go.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(pr.has(g)){if(r.has(p))continue;r.add(p),d=!0}else ut(g)&&!De.has(g)&&n.add(p)}}}a(vo,"addDerivedReceivers");function xo(e,t,r){let n={receivers:new Set,calleeBindings:new Set,rootNamespaces:new Set};r&&wo(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;)Io(o[2].replace(/\s+/g,""),t)&&n.receivers.add(o[1]);let i=Eo(e);if(i.size>0){let l=/([A-Za-z_$][\w$]*)\s*\??\s*:\s*(?:Readonly\s*<\s*)?([A-Za-z_$][\w$]*)\b/g;for(;(o=l.exec(e))!==null;)i.has(o[2])&&n.receivers.add(o[1])}return vo(e,n),n}a(xo,"traceKernelReceivers");function _o(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(_o,"matchingOpenParen");function fr(e){let t=e.split(".").map(r=>r.trim()).filter(r=>r.length>0);return t[0]==="this"?t.slice(1):t}a(fr,"chainParts");function Co(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:fr(n[1].replace(/\?/g,"")),viaPublisherCall:!1}}let s=/\)\s*\??\.\s*$/.exec(r);if(!s)return;let o=t-r.length+s.index,i=_o(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:fr(c[1].replace(/\?/g,"")),viaPublisherCall:!0}:{parts:["<expr>"],viaPublisherCall:!1}}a(Co,"receiverChainBefore");function Oo(e,t,r){let[n,...s]=e.parts;return n?s.length===0&&t.namespaces.has(n)?!0:gr.has(n)||!r.receivers.has(n)?!1:(r.rootNamespaces.has(n)?s.slice(1):s).every(i=>pr.has(i)):!1}a(Oo,"chainReachesKernel");function No(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(No,"collectDefinedIntentNames");function To(e,t){return/^\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(e.slice(t))?.[1]}a(To,"firstIdentifierArg");function Lo(e,t){return Ae(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(Lo,"carriesIntentPrefix");function Do(e){if(!e)return;if(e.viaPublisherCall)return"publisher";let t=e.parts[e.parts.length-1];return t==="<expr>"?void 0:t}a(Do,"receiverName");function Fo(e,t,r){if(!e||t===void 0||!Lo(t,r))return!1;let n=e.parts[0];return n!==void 0&&n!=="<expr>"&&!gr.has(n)}a(Fo,"untracedKernelNameEvidence");function Fe(e,t,r={}){let n=ft(t),s=ko(n),o=xo(n,s,r.isKernelRootSpecifier),i=No(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(ur(n,f,"function")||ur(n,f,"class"))continue;let g=Co(n,f),p=Do(g),A=s.named.get(u)??u,S=ut(A)??ut(u),m=s.named.has(u)||o.calleeBindings.has(u)||g?.parts.length===1&&s.namespaces.has(g.parts[0]);if(!S&&ho.has(u)&&g?.parts.length===1&&s.named.get(g.parts[0])===uo&&(S="factory",m=!0),!S||S==="factory"&&g!==void 0&&!m)continue;let y=f+d[0].length,R=Ro(n,y);if(S!=="factory"&&(g===void 0?!m:!Oo(g,s,o))&&!Fo(g,R,r.intentPrefixes))continue;let k=To(n,y),I=R??(k?i.get(k):void 0);l.push({file:e,line:mr(t,f),kind:S,callee:u,viaImport:m,...p?{receiver:p}:{},...I?{nameLiteral:I}:{}})}return l}a(Fe,"extractArkRunKernelCallsFromSource");function pt(e,t,r){let n=ft(t),s=So(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(yo.has(c)||!s.has(c))continue;let d=bo(n,c);o.push({file:e,line:mr(t,l.index),typeName:c,...d?{importedFrom:d}:{}})}return o}a(pt,"extractArkRunManagedNewsFromSource");var Po=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),$o=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),Mo=new Set(["return","typeof","case","do","else","in","of","new","delete","void","throw","instanceof","yield","await"]);function Ko(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 Mo.has(e.slice(s+1,r+1))}return n==="/"&&e[r-1]==="*"?!1:$o.has(n)}a(Ko,"slashStartsRegex");function jo(e,t){if(!Ko(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(jo,"skipRegexLiteral");function oe(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 jo(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(oe,"skipStringOrComment");function ne(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=oe(e,r);continue}break}return r}a(ne,"skipWsAndComments");function Ar(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(Ar,"readIdent");function se(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=oe(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(se,"skipBalanced");function Rr(e){let t=[],r=0,n;for(;r<e.length&&(r=ne(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let u=Ar(e,o);if(!u||!Po.has(u.ident))break;s.push(u.ident),o=ne(e,u.end)}if(s.length===1&&s[0]==="static"&&e[o]==="{"){let u=se(e,o,"{","}");if(u==null){n=e.length;break}r=u;continue}let i=Ar(e,o);if(!i){r+=1;continue}if(o=ne(e,i.end),e[o]==="<"){let u=se(e,o,"<",">");if(u==null){n=e.length;break}o=ne(e,u)}if(e[o]==="("){let u=se(e,o,"(",")");if(u==null){n=e.length;break}if(o=ne(e,u),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let f=oe(e,o);if(f!==o){o=f;continue}o+=1}if(e[o]==="{"){let f=se(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=oe(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(Rr,"scanClassMembers");function Uo(e,t){let r=t;for(;r<e.length;){let n=ne(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=se(e,r,s,s==="<"?">":s==="("?")":"]");if(i==null)return null;r=i;continue}if(s==='"'||s==="'"||s==="`"){r=oe(e,r);continue}r+=1}return null}a(Uo,"findClassBodyBrace");function kr(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=Go(e),o;for(;(o=n.exec(s))!==null;){let i=t.exportedOnly?o[1]:o[2],l=t.exportedOnly===!0||o[1]==="export",c=Uo(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=se(e,c,"{","}");r.push({name:i,start:o.index,exported:l,bodyStart:c+1,bodyEnd:d==null?null:d-1})}return r}a(kr,"findClassDeclarations");function Go(e){let t="",r=0;for(;r<e.length;){let n=oe(e,r);if(n!==r){t+=e.slice(r,n).replace(/[^\n]/g," "),r=n;continue}t+=e[r],r+=1}return t}a(Go,"maskStringsAndComments");var Ho=/\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)/,Vo=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)/,Bo=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle|orm)(?:\.[cm]?[jt]sx?)?['"]/g,zo=["db","tx","client","prisma","prismaClient","drizzle"],Wo="(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))",qo="\\bINSERT\\s+INTO\\b|\\bUPDATE\\s+[A-Za-z_][\\w.]*\\s+SET\\b|\\bDELETE\\s+FROM\\b",Sr="\\((?:[^()]|\\([^()]*\\))*\\)",Yo=`\\bnew\\s+PrismaClient\\s*${Sr}|\\bdrizzle\\s*${Sr}`,Zo=/(?<![\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,Xo=/(?<![\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 Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(Jo,"escapeRegExp");function ke(e){return Ho.test(e)||Vo.test(e)}a(ke,"sourceImportsPersistenceDriverText");function br(e,t,r){let n=new RegExp(e.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1])}a(br,"collectFirstGroup");function Qo(e){let t=new Set;br(Zo,e,t),br(Xo,e,t);let r=new RegExp(Bo.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(Qo,"persistenceClientBindings");function Pe(e){let t=[...zo,...Qo(e)].map(Jo).join("|");return new RegExp(`(?:\\b(?:${t})(?![\\w$])|${Yo})(?:\\s*\\.\\s*[A-Za-z_]\\w*)*\\s*\\.\\s*${Wo}\\s*\\(|${qo}`,"i").test(e)}a(Pe,"sourceHasPersistenceWrite");var ei=["no-anemic-model"],wr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],ti=new RegExp(`\\b(${wr.join("|")})\\b`),vr="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",ri=new RegExp(`\\bthis\\.${vr}\\.push\\s*\\(`),ni=new RegExp(`^this\\.${vr}\\s*=\\s*\\[\\s*\\]`),si=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,oi=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g;function ii(){return`${wr.join(", ")}, or events-array .push(`}a(ii,"expectedDomainInvariantWordsPhrase");function ai(e){return ti.test(e)||ri.test(e)}a(ai,"referencesGuardOrPublish");function li(e,t,r){let n=e.slice(t);if(ni.test(n))return!0;if(!si.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(li,"isIdiomaticEventsReset");function ci(e,t){let r=new RegExp(oi.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!li(t,n.index,e))return!0;return!1}a(ci,"methodAssignsThis");function Er(e,t){return t==null?e:{...e,truncatedUntil:t}}a(Er,"attachShapeTruncation");function xr(e){return typeof e.truncatedUntil=="number"?e.truncatedUntil:void 0}a(xr,"shapeTruncatedUntil");function di(e){let t=xr(e);return t==null?"":` shape analysed until character ${t}`}a(di,"shapeTruncationSuffix");function Ir(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Ir,"escapeGlobLiteral");function ui(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+=Ir(t[n+1]),n+=1):s==="*"?t[n+1]==="*"?t[n+2]==="/"?(r+="(?:.*/)?",n+=2):(r+=".*",n+=1):r+="[^/]*":s==="?"?r+="[^/]":r+=Ir(s)}return new RegExp(`^${r}$`)}a(ui,"globToRegExp");function $e(e,t){return!t||t.length===0?!0:t.some(r=>ui(r).test(e))}a($e,"matchesAppliesTo");function fi(e){return ei.includes(e)}a(fi,"isTier2");function pi(e){return e.mode==="enforced"&&!fi(e.sensor)?{severity:"error",failsStrict:!0}:{severity:"warning",failsStrict:!1}}a(pi,"severityFor");function B(e,t,r,n=1){let{severity:s,failsStrict:o}=pi(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(B,"baseViolation");function Me(e,t,r){if(!r)return!0;let n=r(e);return n?n===t.provenance.layer:!1}a(Me,"isInRuleLayer");function Ke(e,t,r){return t.filter(n=>!(!n.exported||!$e(n.file,e.appliesTo)||!Me(n.file,e,r)))}a(Ke,"shapesForRule");function gt(e,t,r){let n=xr(t);if(n!=null)return B(e,t.file,`Exported class ${t.className} shape analysed until character ${n}; later ${r} may be invisible (sensor ${e.sensor}).`)}a(gt,"truncatedShapeViolation");function gi(e,t,r){let n=[];for(let s of Ke(e,t,r)){let o=gt(e,s,"members");o&&n.push(o),(s.hasPublicSetters||s.hasPublicMutableFields)&&n.push(B(e,s.file,`Exported class ${s.className} exposes public mutable state (sensor aggregate-private-state).`))}return n}a(gi,"evaluateAggregatePrivateState");function hi(e,t,r){let n=[];for(let s of Ke(e,t,r)){let o=gt(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(B(e,s.file,`Exported class ${s.className} exposes a public constructor without a static factory (sensor always-valid-factory).`))}}return n}a(hi,"evaluateAlwaysValidFactory");function mi(e,t,r){let n=[],s=ii();for(let o of Ke(e,t,r)){let i=di(o),l=gt(e,o,"methods");l&&n.push(l);for(let c of o.mutatingMethods)c.referencesGuardOrPublish||n.push(B(e,o.file,`Mutating method ${o.className}.${c.name} does not reference ${s} (sensor domain-event-on-mutation).${i}`))}return n}a(mi,"evaluateDomainEventOnMutation");function yi(e,t){let r=[];for(let n of t.files)$e(n,e.appliesTo)&&Me(n,e,t.layerForFile)&&t.fileHints?.[n]?.orchestrationHeavy&&r.push(B(e,n,"File appears to embed domain branching beyond guard-and-delegate orchestration (sensor orchestration-only)."));return r}a(yi,"evaluateOrchestrationOnly");function Ai(e,t){let r=[];for(let n of t.files)$e(n,e.appliesTo)&&Me(n,e,t.layerForFile)&&t.fileHints?.[n]?.adapterThick&&r.push(B(e,n,"Adapter module mixes domain branching, persistence, and mapping beyond a thin adapter (sensor thin-adapter)."));return r}a(Ai,"evaluateThinAdapter");function Ri(e,t){let r=[];for(let n of t.files)$e(n,e.appliesTo)&&Me(n,e,t.layerForFile)&&t.fileHints?.[n]?.persistenceWrite&&r.push(B(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(Ri,"evaluateWritesViaAggregate");function ki(e,t,r){let n=[];for(let s of Ke(e,t,r))if(s.dataOnly===!0){let o=B(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(ki,"evaluateNoAnemicModel");function _r(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(...gi(r,e.classShapes,e.layerForFile));break;case"always-valid-factory":t.push(...hi(r,e.classShapes,e.layerForFile));break;case"domain-event-on-mutation":t.push(...mi(r,e.classShapes,e.layerForFile));break;case"orchestration-only":t.push(...yi(r,e));break;case"thin-adapter":t.push(...Ai(r,e));break;case"writes-via-aggregate":t.push(...Ri(r,e));break;case"no-anemic-model":t.push(...ki(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(_r,"evaluateArkRuleSensors");function Si(e){return e==="PersistenceAdapters"}a(Si,"isPersistenceDriverLayer");function bi(e,t){if(ke(e))return!0;if(!t)return!1;for(let r of t){if(Si(r.layer))return!0;let n=r.specifier;if(!n)continue;let s=`from '${n}'`;if(ke(s))return!0}return!1}a(bi,"sourceImportsPersistenceDriver");var Ei=/\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*=)/,Ii=/(?:^|[;\n])\s*(?:import\s+(?:type\s+)?(?:[^;]{0,512}?\s+from\s+)?|export\s+(?:type\s+)?[^;]{0,512}?\s+from\s+)['"]next\/server(?:\.js)?['"]/,wi=/\b(?:export\s+)?(?:async\s+)?function\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*|\b(?:export\s+)?const\s+(?:can|calculate|compute|should|ensure|validate|is|has)[A-Z]\w*\s*=/,vi=/\bif\s*\(\s*(?:!)?(?:order|invoice|cart|user|account|policy|aggregate|entity|amount|total|balance|status|state)\b/i;function Cr(e,t,r){if(!t)return null;let n=bi(t,r),s=n&&Pe(t);if(t.length<40)return s?{persistenceWrite:!0}:null;let o=t.match(new RegExp(wi.source,"g"))??[],i=t.match(new RegExp(vi.source,"g"))??[],l=(t.match(/\bif\s*\(/g)??[]).length,c=(t.match(/\bswitch\s*\(/g)??[]).length,d=o.length>=2||o.length>=1&&i.length>=2||i.length>=3&&l+c>=6,u=Ei.test(t)||Ii.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(Cr,"deriveArkRuleFileHints");var xi=new Set(["if","match","when"]);function Se(e,t){let r=[];for(let n of kr(t,{exportedOnly:!0})){let s=n.name;if(n.bodyStart==null){r.push(Er({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=Rr(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)||ci(k.name,k.body)&&m.push({name:k.name,referencesGuardOrPublish:ai(k.body)}));let R=c.members.filter(k=>k.kind==="method").length<=1&&u.length>=2&&f;r.push(Er({file:e,className:s,exported:!0,hasPublicMutableFields:f,hasPublicSetters:g,hasPublicConstructor:A,hasStaticFactory:S,mutatingMethods:[...m],dataOnly:R},d))}return r}a(Se,"extractClassShapesFromSource");function _i(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(_i,"normalizeExtraMergeTeethClassification");function je(e){let t=_i(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(je,"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 Or=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.")]),Kc=new Map(Or.map(e=>[e.ruleId,e])),jc=Object.freeze(Or.map(e=>e.ruleId));var Ci=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."})]),Oi=new Map(Ci.map(e=>[e.reasonId,e]));function Nr(e){if(!(typeof e!="string"||e.length===0))return Oi.get(e)}a(Nr,"sliceReasonHint");var Ni=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,Ti=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Li=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Di(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return Ni.test(r)?"pure-shared":n==="PersistenceAdapters"&&(Ti.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Li.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}a(Di,"classifyLayerImportKind");function Fi(e,t){return t.failsStrict===!1&&e.advisoryNote?`${e.fix} ${e.advisoryNote}`:e.fix}a(Fi,"sliceHintAction");function Pi(e){let t=Nr(typeof e.reasonId=="string"?e.reasonId:void 0);if(t)return`${Fi(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=Di(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(Pi,"layerImportNextAction");function $i(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}a($i,"arkRunCallSiteName");function Mi(e){let t=$i(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(Mi,"arkRunNextAction");function ie(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return Pi(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 Mi(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(ie,"deterministicNextAction");var Ki=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],ji=new Set(Ki);function Ui(e){return ji.has(e)}a(Ui,"isArkRunEditorSensor");var Tr={"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"},Gi="ARKRUN_INTERACTION_NAME_INCOMPLETE";function Fr(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(Fr,"isDomainRoleLayer");function Hi(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}a(Hi,"compareFindings");function K(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:Tr[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:ie({ruleId:Tr[t],fromLayer:o?.fromLayer,target:o?.target})}}a(K,"finding");function Vi(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(Vi,"bagForFile");function Lr(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}a(Lr,"emitKinds");function Dr(e){return e==="subscribe"||e==="register-handler"}a(Dr,"handleKinds");function Bi(e){return e==="resolve"||e==="resolve-singleton"}a(Bi,"dependKinds");function zi(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(K(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let l=o.get(i.matchedRoot)??[];l.push(i),o.set(i.matchedRoot,l)}for(let i of s){let l=[...o.get(i)??[]].sort((d,u)=>d.file.localeCompare(u.file));if(l.length===0){n.push(K(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(l.some(d=>d.hasKernelFactory))continue;let c=l[0];n.push(K(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no kernel factory (createArkKernel / createStrictArkKernel / createLenientArkKernel / *FromConfig, or ArkModule.forRoot / forRootAsync from arkgate/nestjs).`,{target:i},r))}return n}a(zi,"evaluateMissingRoot");function Wi(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||!Z(c))continue;let d=n(l.from);d&&Fr(d,o.get(d)??[])&&i.push(K(e,"arkrun-kernel-in-domain",l.from,l.line,`${d} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:d,target:c},s))}return i}a(Wi,"evaluateKernelInDomain");function qi(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)||Fr(g,l.get(g)??[])||d.push(K(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(qi,"evaluateDirectNew");function Yi(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(!Lr(c.kind)&&!Dr(c.kind)&&!Bi(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:Gi,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=Vi(r,c.file);if(Lr(c.kind)){if(u.raises.has(c.nameLiteral)||u.sends.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:d,target:c.nameLiteral},s));continue}if(Dr(c.kind)){if(u.reactsTo.has(c.nameLiteral))continue;o.push(K(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:d,target:c.nameLiteral},s));continue}u.uses.has(c.nameLiteral)||o.push(K(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:d,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}a(Yi,"evaluateUndeclared");function Zi(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||!hr(l))continue;let c=r(i.from);!c||!s.has(c)||o.push(K(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(l)}; use the ArkRun kernel transport.`,{fromLayer:c,target:l},n))}return o}a(Zi,"evaluateTransportBypass");function Xi(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=je(e.classification),n=Yi(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...zi(t,e.compositionRootHits,r),...Wi(t,e.layers,e.dependencies,e.layerForFile,r),...qi(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...Zi(t,e.dependencies,e.layerForFile,r)].sort(Hi),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(Xi,"evaluateArkRunSensors");function ht(e){return{findings:Xi(e).findings.filter(r=>Ui(r.sensor)),completenessReasons:[]}}a(ht,"evaluateArkRunEditorSensors");var mt="docs/diagnostics.md";function yt(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(yt,"adapterFindingTargetKey");function At(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(At,"adapterFindingRefFromTargetKey");function Rt(e){return`${mt}#${e}`}a(Rt,"adapterDocsCodePath");function b(e){return typeof e=="string"&&e.length>0?e:void 0}a(b,"text");function Pr(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}a(Pr,"positiveInteger");function ea(e,t,r){return ie({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(ea,"nextActionForDiagnostic");var ta=new Set(["CROSS_PARENT_SLICE","CROSS_SIBLING_SLICE","CROSS_PARENT_VIA_SHARED"]);function ra(e){let t=e.details,r=t!==null&&typeof t=="object"?t.reasonId:void 0,n=b(e.reasonId)??b(r);return n&&ta.has(n)?n:void 0}a(ra,"sliceReasonOf");function $r(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=ra(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??yt(e),c=At(l);return{ruleId:n,severity:s,message:b(e.message)??n,location:{file:b(e.file)??"<unknown>",line:Pr(e.line,1),column:Pr(e.column,1)},evidence:i,nextAction:b(e.nextAction)??ea(n,i,e),findingRef:c,targetKey:l,docsCodePath:Rt(n)}}a($r,"toAdapterDiagnostic");var kt="advisory",Kr="{{message}} [{{ruleId}}; advisory \u2014 does not fail ark-check]",Ue="advisoryFallback",jr='{{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.]',Mr=new WeakMap,Ur=new WeakMap;function na(e){return Object.prototype.hasOwnProperty.call(e,"sourceCode")||Object.prototype.hasOwnProperty.call(e,"getSourceCode")}a(na,"ownsSourceCode");function sa(e){let t=e;for(let r=0;t&&t!==Object.prototype&&r<8;r+=1){if(na(t))return t===e?null:t;t=Object.getPrototypeOf(t)}return null}a(sa,"runKey");function oa(e,t){let r=Object.create(e,{report:{value(n){t.sinks.blocking?.report(n)}}});return Ur.set(r,t),r}a(oa,"routedContext");function Ge(e,t,r){let n=sa(t),s;if(n){let o=Mr.get(n);o||(o=new Map,Mr.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(oa(t,s)))}a(Ge,"createChannelListeners");function Gr(e,t){let r=Ur.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:Ue,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:kt,data:t.advisoryData,diagnostic:s});return}r.sinks.blocking?.report({...n,messageId:Ue,data:t.advisoryData,diagnostic:s})}a(Gr,"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 ae(e){let t=z(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(ae,"editorSourceText");function ia(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(ia,"reportLocation");function _(e,t,r,n,s){let o=$r({...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 Gr(e,{nonBlocking:o.severity==="warning",location:ia(t,o.location.line),messageId:r,...s?{data:s}:{},advisoryData:{message:o.message,ruleId:o.ruleId},diagnostic:o}),o}a(_,"reportAdapterDiagnostic");function Hr(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(Hr,"mergeListeners");function aa(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(aa,"declarationIsTypeOnly");function zr(e){try{return Vr.existsSync(e)?Vr.readFileSync(e,"utf8"):null}catch{return null}}a(zr,"readUtf8");function Br(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=X.dirname(n),i=X.isAbsolute(r)?r:X.resolve(r),l=X.relative(o,i).split(X.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(Br,"loadEditorFile");function la(e,t,r){let n=Fe(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(la,"compositionRootHitsForFile");function ca(e,t,r){let n=new Set(Se(t.relFile,r).map(s=>s.className));return yr(r,(s,o)=>{if(Z(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let l=X.relative(t.root,i).split(X.sep).join("/");if(l.startsWith(".."))return;let c=zr(i);if(c!==null)for(let d of Se(l,c))n.add(d.className)}),n}a(ca,"admittedTypeNamesForEditor");function Wr(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(Wr,"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 ua(e,t){return e.type?.startsWith("Export")?"export":t}a(ua,"specifierEdgeKind");function fa(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}=ht({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&&Wr(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||aa(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,ua(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(fa,"importListeners");function pa(e,t,r){let n=ae(t)??zr(r.absFile)??"",s=ca(e,r,n),o=pt(r.relFile,n,s),{findings:i}=ht({arkRun:r.extra,layers:r.config.layers,kernelCalls:Fe(r.relFile,n),managedNews:o,compositionRootHits:la(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&&Wr(e,t,c,"directNew",f,{fromLayer:f.fromLayer??r.fromLayer,typeName:d,target:f.target??d})}}}a(pa,"directNewListener");function qr(e){let t=a((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let l=Br(e,i);return l?fa(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=Br(e,r);return n?pa(e,r,n):{}}}}}a(qr,"createArkRunEslintRules");var Yr=/^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;var bt="createOrderPlane";var Zr=new Map;function Xr(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}a(Xr,"escapeAppliesToLiteral");function ga(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(ga,"normalizeAppliesToGlob");function ha(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(ha,"appliesToBracesBalanced");function Et(e){let t=Zr.get(e);if(t)return t;let r=ga(e),n=ha(r),s="",o=0;for(let l=0;l<r.length;l+=1){let c=r[l];c==="\\"&&l+1<r.length?(s+=Xr(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+=Xr(c)}let i=new RegExp(`^${s}$`);return Zr.set(e,i),i}a(Et,"arkOrderGlobToRegExp");function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(He,"escapeRegExp");function le(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}a(le,"isArkOrderModuleSpecifier");function j(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
|
|
4
|
+
`&&(r+=1);return r}a(j,"lineAt");function P(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}a(P,"stripCommentsPreservingLines");function en(e,t){let r=P(t),n=[],s=/\b(import|export)(\s+type)?\s+(?:[^;]*?\s+from\s*)?['"]([^'"]+)['"]/g,o;for(;(o=s.exec(r))!==null;){let l=o[3]??"";le(l)&&n.push({from:e,specifier:l,kind:o[1]==="export"?"export":"import",typeOnly:!!o[2],line:j(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]??"";le(l)&&n.push({from:e,specifier:l,kind:o[1]==="import"?"dynamic-import":"require",typeOnly:!1,line:j(t,o.index),resolution:"resolved-external"})}return n}a(en,"extractArkOrderModuleImportsFromSource");function tn(e,t){let r=P(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:j(t,o.index),callee:bt});return n}a(tn,"extractArkOrderPlaneCallsFromSource");var ma=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;\n]+)?=\s*createOrderPlane\s*(?:<[^>]*>)?\s*\(/g,St=/^(?:plane|[A-Za-z_$][\w$]*Plane)$/,ya=/\b([A-Za-z_$][\w$]*)\s*[?!]?\s*:\s*(?:Readonly\s*<\s*)?OrderPlane\b/g,Aa=/\bfrom\s+['"]arkgate\/order(?:\/[^'"]*)?['"]|\brequire\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]|\bimport\s*\(\s*['"]arkgate\/order(?:\/[^'"]*)?['"]/,Ra=/\bimport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g,Jr=["",".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],ka=/([A-Za-z_$][\w$]*)\s*!?\s*\??\s*$/,Sa=/^\s*(?:<[^<>]*>\s*)?([A-Za-z_$][\w$]*)\s*!?\s*(?:\b(?:as|satisfies)\b[\s\S]*)?$/;function ba(e){let t=P(e),r=new Set,n=new RegExp(ma.source,"g"),s;for(;(s=n.exec(t))!==null;)s[1]&&r.add(s[1]);return[...r].sort()}a(ba,"arkOrderPlaneBindings");function Ea(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(Ea,"normalizeRelativePath");function Ia(e,t){if(!t.startsWith("./")&&!t.startsWith("../"))return[];let r=e.replace(/\\/g,"/").split("/").slice(0,-1),n=Ea([...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 Jr)o.add(`${i}${l}`);for(let l of Jr.slice(1))o.add(`${i}/index${l}`)}return[...o]}a(Ia,"relativeModuleCandidates");function wa(e,t,r){let n=Ia(e,t);return n.length===0?!1:r.some(s=>{let o;try{o=Et(s)}catch{return!1}return n.some(i=>o.test(i))})}a(wa,"specifierResolvesToPlaneRoot");function va(e,t,r={}){let n=P(t),s=new Set(ba(t)),o=new RegExp(ya.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(Ra.source,"g");for(;(i=c.exec(n))!==null;)if(wa(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)||(St.test(f)||St.test(g))&&s.add(g)}}return s.delete(bt),{names:[...s].sort(),isArkOrderFile:Aa.test(n)}}a(va,"arkOrderPlaneReceivers");var xa=new Set(["return","await","void","typeof","yield","in","of","case","else","do","throw","delete"]);function _a(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(_a,"isCallBefore");function rn(e){let t=e.replace(/\s*!?\s*\??\s*$/,"");if(!t.endsWith(")")){let n=ka.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(_a(t.slice(0,n)))return null;let o=t.slice(n+1,t.length-1),i=Sa.exec(o);return i?i[1]??null:null}}return null}a(rn,"receiverBefore");function nn(e,t,r){let n=va(e,t,r);return{names:new Set(n.names),isArkOrderFile:n.isArkOrderFile}}a(nn,"planeReceiverContext");function sn(e,t){return!e||e===bt?!1:t.names.has(e)?!0:t.isArkOrderFile&&St.test(e)}a(sn,"isPlaneReceiver");function on(e,t,r={}){let n=P(t),s=nn(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);sn(rn(d),s)&&o.push({file:e,line:j(t,l.index),method:c})}return o}a(on,"extractArkOrderGenericUpdatesFromSource");function an(e,t,r){if(r.length===0)return[];let n=P(t);if(!ke(n)||!Pe(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let l=new RegExp(`(?:\\b${He(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${He(i)}['"]\\s*:|[{\\,]\\s*${He(i)}\\s*[\\,}]|\\.${He(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:j(t,c.index),key:i});break}}}return s}a(an,"extractArkOrderXiFieldWritesFromSource");var Ca="(?:xi(?:[A-Z][\\w$]*)?|release|pattern|house|current|[A-Za-z_$][\\w$]*?(?:Xi|Release|Pattern))(?![\\w$])";function ln(e,t){let r=P(t),n=[],s=new RegExp(`(?:(?<![\\w$])|\\.)${Ca}(?:\\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:j(t,o.index)});return n}a(ln,"extractArkOrderIngestWritesXiFromSource");function cn(e,t){let r=P(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:j(t,o.index),keyCount:l.length})}return n}a(cn,"extractArkOrderReleaseKeyCountsFromSource");function Oa(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(Oa,"literalKeys");function dn(e,t,r={}){let n=P(t),s=nn(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(sn(rn(c),s))for(let d of Oa(l[1]??""))Yr.test(d)&&o.push({file:e,line:j(t,l.index),key:d})}return o}a(dn,"extractArkOrderXiTtlKeysFromSource");function Qr(e){let t=[],r=/(['"`])([^'"`\n\\]+)\1/g,n;for(;(n=r.exec(e))!==null;)n[2]&&t.push(n[2]);return t}a(Qr,"stringLiterals");function un(e,t){let r=P(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 Qr(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=j(t,o.index);for(let u of Qr(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(un,"extractArkOrderBudgetLeaksFromSource");var fn={"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 Na(e,t){return!t||t.length===0?!0:t.some(r=>Et(r).test(e))}a(Na,"matchesArkOrderAppliesTo");function Ta(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(Ta,"isDomainRoleLayer");function $(e,t,r,n,s,o,i){let l=e.mode==="enforced"&&i;return{ruleId:fn[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:ie({ruleId:fn[t],fromLayer:o?.fromLayer,target:o?.target})}}a($,"finding");function It(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=je(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push($(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($(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($(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||!le(d))continue;let u=e.layerForFile(c.from);u&&Ta(u,o.get(u)??[])&&n.push($(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($(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($(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($(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($(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($(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)||Na(c.file,t.appliesTo)&&n.push($(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(It,"evaluateArkOrderSensors");function pn(e){if(!e.arkOrder)return[];let t=tn(e.file,e.source),r={planeRoots:e.arkOrder.planeRoots??[]},n=on(e.file,e.source,r),s=e.arkOrder.xiKeys??[],o=e.fromLayer?[{name:e.fromLayer,patterns:[],intentPrefixes:[...e.intentPrefixes??[]]}]:[];return It({arkOrder:e.arkOrder,layers:o,planeCalls:t,genericUpdates:n,planeRootHits:[],xiFieldWrites:an(e.file,e.source,s),ingestWritesXi:ln(e.file,e.source),releaseKeyCounts:cn(e.file,e.source),xiTtlKeys:dn(e.file,e.source,r),budgetLeaks:un(e.file,e.source),dependencies:en(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(pn,"evaluateArkOrderEditorSensors");function gn(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(gn,"violationFor");function La(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(La,"lineNode");function hn(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(hn,"isTypeOnlyDeclaration");function mn(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"||!le(u))return;let p=d.loc?.start?.line??1,{findings:A}=It({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",gn(S),{message:S.message})},"check");return{ImportDeclaration(d){c(d,d.source?.value,hn(d),"import")},ExportNamedDeclaration(d){d.source&&c(d,d.source.value,hn(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=ae(s)??"",l=pn({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,La(i,c.line),"denied",gn(c),{message:c.message})}}:{}}}}}a(mn,"createArkOrderEslintRules");import Ll from"fs";import Xe from"path";import{createHash as Jn}from"crypto";import q from"fs";import D from"path";var J={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},yn={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},compositionRoots:{...J,default:[]},kernelRoots:{...J},managedLayers:{...J,default:[]},requireDeclarations:{type:"boolean",default:!0},ignoreDirectNewForErrors:{type:"boolean",default:!0}}},An={type:"object",additionalProperties:!1,properties:{mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},planeRoots:{...J,default:[]},managedLayers:{...J,default:[]},maxXiKeys:{type:"integer",minimum:1,default:7},xiKeys:{...J,default:[]},appliesTo:{...J,default:[]}}};function be(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(be,"isObject");function Rn(e){let t=new Set;if(!Array.isArray(e.layers))return t;for(let r of e.layers)be(r)&&typeof r.name=="string"&&r.name.length>0&&t.add(r.name);return t}a(Rn,"declaredLayerNames");function kn(e){if(!be(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(kn,"defaultedArkRun");function Sn(e){if(!be(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(Sn,"defaultedArkOrder");function bn(e,t){let r=e.arkRun;if(r===void 0||!be(r))return;let n=Rn(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(bn,"validateArkRunExtra");function En(e,t){let r=e.arkOrder;if(r===void 0||!be(r))return;let n=Rn(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(En,"validateArkOrderExtra");var Be={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Cn={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:{...Be,minItems:1}}}]},On={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:{...Be,minItems:1},sliceIdentity:{type:"string",enum:["path","stars"]},commonFolders:{...Be,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:{...Be},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 O(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(O,"isObject");function ze(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(ze,"propertyPath");function W(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}a(W,"trimTrailingSlashes");function Nn(e,t){Ma(e,t),ja(e,t),Va(e,t),sl(e,t)}a(Nn,"validateSliceContract");var In='must be "deny", "deny-cross-parent", or { "mode": "deny-cross-parent", "stopAt": ["<composition root path or glob>"] }',wn="must not cover the whole tree. Name the composition root itself (bootstrap file, DI registrations folder).";function Da(e){return e==="*"||e==="**"}a(Da,"isWildcardSegment");function Tn(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&&Da(t[r-1]??"");)r-=1;let n=t.slice(0,r);return n.some(s=>s.includes("*"))?null:n}a(Tn,"coveredFolder");function Fa(e,t){return e.length<=t.length&&e.every((r,n)=>t[n]===r)}a(Fa,"isPrefixOf");function Pa(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(!O(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=Tn(u.join("/"));f&&s.push(f)}}return s}a(Pa,"ruleLayerFolders");function $a(e,t){let r=W(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 wn;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=Tn(r);return s===null?null:s.length===0?wn:t.some(o=>Fa(s,o))?"must not cover a whole layer root of this rule. Name the composition root itself (bootstrap file, DI registrations folder).":null}a($a,"stopAtEntryIssue");function Ma(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!O(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:In});return}if(!O(o)){t.push({path:i,message:In});return}for(let u of Object.keys(o))u!=="mode"&&u!=="stopAt"&&t.push({path:ze(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=Pa(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=$a(u,d);if(p){t.push({path:g,message:p});return}let A=W(u.trim().replace(/\\/g,"/")).toLowerCase();if(c.has(A)){t.push({path:g,message:"duplicate stopAt entry"});return}c.add(A)})})}a(Ma,"validateSharedImportsSlice");var Ka=["deny","advisory"],vn='must be "deny", "advisory", or { "default": "deny" | "advisory", "enforce": ["<child id or subtree path>"], "ratchet": true | false }';function ja(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!O(n))return;let o=n.childSlices;if(!O(o)||o.siblings===void 0)return;let i=o.siblings,l=`$.rules[${s}].childSlices.siblings`;if(typeof i=="string"){Ka.includes(i)||t.push({path:l,message:vn});return}if(!O(i)){t.push({path:l,message:vn});return}for(let d of Object.keys(i))d!=="default"&&d!=="enforce"&&d!=="ratchet"&&t.push({path:ze(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=W(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(ja,"validateChildSliceSiblings");var Ua="must be a slice id with a slash. A bare name is ambiguous across universes.",Ga="* matches one whole path segment. ** and a partial segment are not wildcards.";function Ha(e){let t=W(e.trim().replace(/\\/g,"/"));if(t.length===0)return"must be a non-empty slice id";if(!t.includes("/"))return Ua;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 Ga}return null}a(Ha,"childCrossSlicePatternIssue");function xn(e){return W(e.trim().replace(/\\/g,"/")).toLowerCase()}a(xn,"childCrossSlicePatternKey");function Va(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!O(n))return;let o=n.childSlices;if(!O(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(!O(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:ze(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=Ha(A);m&&t.push({path:S,message:m})}if(typeof d.from!="string"||typeof d.to!="string")return;let g=`${xn(d.from)}\0${xn(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(Va,"validateChildSliceAllowedCrossSlice");var ce="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.",Ba="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/*).",za="overlaps a slice folder. An alias covers only files outside the slice trees.",Wa="two slice aliases match the same file";function qa(e){return W(e.trim().replace(/\\/g,"/")).toLowerCase().split("/").filter(t=>t.length>0)}a(qa,"aliasPathSegments");function Ya(e){let t=e[e.length-1];return t===void 0||t.includes("*")?[...e]:[...e,"**"]}a(Ya,"aliasSegmentsWithSubtree");function Ln(e){let t=[];for(let r of e){if(r.includes("*"))break;t.push(r)}return t}a(Ln,"concreteGlobPrefix");function Ee(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(Ee,"segmentsArePrefix");function Za(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(Za,"anchoredSlicePrefix");function Xa(e,t){let r=Ln(e),n=r.length<e.length,s=r[0]==="src"||r[0]==="app"?r.slice(1):r;return Ee(t,r)||Ee(t,s)?!0:n?Ee(r,t)&&r.length<t.length||Ee(r,["src",...t])&&r.length<t.length+1||Ee(r,["app",...t])&&r.length<t.length+1:!1}a(Xa,"globOverlapsAnchored");function Ja(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=Ln(e);return r.length<e.length&&(r.length===0||r.length===1&&(r[0]==="src"||r[0]==="app"))}a(Ja,"globOverlapsBare");function Qa(e,t){let r=t.split(/[/\\]/).filter(Boolean).map(s=>s.toLowerCase());if(r.length===1&&r[0]&&!r[0].includes("*"))return Ja(e,r[0]);let n=Za(t);return n?Xa(e,n):!1}a(Qa,"globOverlapsSliceEntry");function el(e){let t=W(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(el,"aliasGlobIssue");function tl(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(tl,"universeShapes");function Ve(e,t){return e.literals.length!==t.length?!1:e.literals.every((r,n)=>r===null||r===t[n])}a(Ve,"shapeMatches");function rl(e,t){let r=W(e.trim().replace(/\\/g,"/"));if(r.length===0||r.split("/").some(o=>o.length===0||o==="."||o==="..")||r.includes("*")||!r.includes("/"))return ce;let n=r.split("/").map(o=>o.toLowerCase());if(t.length===0||t.some(o=>Ve(o,n)))return ce;if(t.some(o=>Ve(o,n.slice(0,-1))))return null;let s=new Set(t.filter(o=>o.legacy!==void 0&&!Ve({literals:o.legacy},n)&&Ve({literals:o.legacy},n.slice(0,-1))).map(o=>o.literals.map(i=>i??"*").join("/")));return s.size===1?null:s.size>1?Ba:ce}a(rl,"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 nl(e,t){let r=_n(e),n=_n(t);for(let s of r)if(Q(s,t,0,0,new Map))return!0;for(let s of n)if(Q(e,s,0,0,new Map))return!0;return!1}a(nl,"aliasesCanMatchSameFile");function Q(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=Q(e,t,r+1,n,s)||n<t.length&&Q(e,t,r,n+1,s);else if(n<t.length&&t[n]==="**")l=Q(e,t,r,n+1,s)||r<e.length&&Q(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=Q(e,t,r+1,n+1,s))}return s.set(o,l),l}a(Q,"globsCanMatchSame");function sl(e,t){let r=e.rules;Array.isArray(r)&&r.forEach((n,s)=>{if(!O(n))return;let o=n.childSlices;if(!O(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=tl(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(!O(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:ze(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=el(A);if(m)t.push({path:`${p}.from`,message:m});else{let y=Ya(qa(A));d.some(R=>Qa(y,R))&&t.push({path:`${p}.from`,message:za});for(let R of u)if(nl(R,y)){t.push({path:p,message:Wa});break}u.push(y)}}if(typeof S!="string"||S.trim().length===0)t.push({path:`${p}.to`,message:ce});else{let m=rl(S,c);m&&t.push({path:`${p}.to`,message:m})}})})}a(sl,"validateChildSliceAliases");function We(e){if(typeof e!="string")return null;let t=e.trim().replace(/^@/,"").toLowerCase();return t.length>0?t:null}a(We,"normalizeStewardId");function Dn(e){let t=We(e);return!t||wt(t)||t.includes(" ")||t.includes("@")?!1:/^(?!-)[a-z0-9-]{1,39}(?<!-)$/.test(t)}a(Dn,"isGitHubHandle");function ol(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(!t.includes("@")||t.includes(" ")||wt(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(ol,"isGitHubEmail");function il(e){if(typeof e!="string")return null;let t=e.trim().match(/^(?:\d+\+)?([^@]+)@users\.noreply\.github\.com$/i);return t&&Dn(t[1])?We(t[1]):null}a(il,"githubHandleFromEmail");function Fn(e){let t=il(e);if(t)return t;let r=We(e);return!r||wt(r)?null:Dn(r)||ol(r)?r:null}a(Fn,"canonicalStewardId");var al=/bot\b|\[bot\]|dependabot|renovate|github-actions|imgbot|codecov/i;function wt(e){let t=We(e);return!t||al.test(t)}a(wt,"isAutomationAuthor");var L="1.3",ll=["public","auth","admin","internal"];var vt="https://unpkg.com/arkgate@4/schemas/ark.config.schema.json",Pn=["DomainModel","ApplicationOrchestration","PersistenceAdapters","IntegrationAdapters","WorkflowSagaEngine","BackgroundJobsScheduling","PresentationAdapters","ReportingReadModels","ExtensibilityMetadata","SecurityAuditObservability","Kernel"],cl=new Set(["PresentationAdapters->ApplicationOrchestration","ApplicationOrchestration->DomainModel","WorkflowSagaEngine->ApplicationOrchestration","WorkflowSagaEngine->DomainModel","BackgroundJobsScheduling->ApplicationOrchestration"]);function dl(){let e=[];for(let t of Pn)for(let r of Pn)t===r||cl.has(`${t}->${r}`)||e.push({from:t,to:r,allowed:!1});return e}a(dl,"createDefaultRules");var Mn=dl(),xt=[{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},$n={$schema:"https://json-schema.org/draft/2020-12/schema",$id:vt,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:vt,description:"Editor-facing URL or local path for this JSON Schema."},schemaVersion:{type:"string",const:L,default:L},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:Mn,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:[...ll]},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:Cn,childSlices:On}},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:yn,arkOrder:An}},U=class extends Error{static{a(this,"ArkConfigValidationError")}issues;source;constructor(t,r){super(`Invalid ArkGate config (${t}):
|
|
2
5
|
${r.map(n=>`- ${n.path}: ${n.message}`).join(`
|
|
3
|
-
`)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function et(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}l(et,"isObject");function X(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}l(X,"propertyPath");function P(e){return e===null?"null":Array.isArray(e)?"array":typeof e}l(P,"valueType");function cr(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}l(cr,"resolveSchemaRef");function U(e,t,r,n,s){if(t.$ref){let o=cr(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}U(e,o,r,n,s);return}if(t.const!==void 0&&!Object.is(e,t.const)){s.push({path:r,message:`must equal ${JSON.stringify(t.const)}`});return}if(t.enum&&!t.enum.some(o=>Object.is(o,e))){s.push({path:r,message:`must be one of ${t.enum.map(String).join(", ")}`});return}if(t.type==="object"){if(!et(e)){s.push({path:r,message:`must be an object; received ${P(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:X(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:X(r,i),message:"unknown field"});else if(t.additionalProperties!==void 0&&t.additionalProperties!==!0&&typeof t.additionalProperties=="object"){let i=t.additionalProperties;for(let a of Object.keys(e))a in o||U(e[a],i,X(r,a),n,s)}for(let[i,a]of Object.entries(o))e[i]!==void 0&&U(e[i],a,X(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${P(e)}`});return}if(t.minItems!==void 0&&e.length<t.minItems&&s.push({path:r,message:`must contain at least ${t.minItems} item(s)`}),t.uniqueItems){let o=e.map(i=>JSON.stringify(i));new Set(o).size!==o.length&&s.push({path:r,message:"must not contain duplicate items"})}t.items&&e.forEach((o,i)=>U(o,t.items,`${r}[${i}]`,n,s));return}if(t.type==="string"){if(typeof e!="string"){s.push({path:r,message:`must be a string; received ${P(e)}`});return}t.minLength!==void 0&&e.length<t.minLength&&s.push({path:r,message:`must contain at least ${t.minLength} character(s)`});return}if(t.type==="boolean"){typeof e!="boolean"&&s.push({path:r,message:`must be a boolean; received ${P(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${P(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}l(U,"validateNode");function dr(e,t){let r=e.layers;Array.isArray(r)&&r.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n)||!("owners"in n))return;let o=n.owners;Array.isArray(o)&&o.forEach((i,a)=>{typeof i=="string"&&(Ye(i)||t.push({path:`$.layers[${s}].owners[${a}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}l(dr,"validateLayerOwners");function ur(e){let t={...e,$schema:e.$schema===void 0?ue:e.$schema,schemaVersion:e.schemaVersion===void 0?I:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Qe.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=Be(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=We(e.arkOrder)),t}l(ur,"defaultedConfig");function fr(e){return e===I?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}l(fr,"migratedFromOf");function pr(){let e=new Set([I]);for(let t of fe)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}l(pr,"knownInputVersions");function gr(e,t="ark.config.json"){if(!et(e))throw new x(t,[{path:"$",message:`must be an object; received ${P(e)}`}]);let r=pr(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${I}`}]);if(n!=="unversioned"&&!r.has(n))throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);let s=n,o={...e},i=0;for(;s!==I&&i<fe.length+1;){i+=1;let a=fe.find(c=>c.from===s);if(!a)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${I}`}]);s=a.to,o.schemaVersion=s}if(s!==I)throw new x(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${I}`}]);return{candidate:ur(o),migratedFrom:fr(n)}}l(gr,"migrateArkConfig");function mr(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=gr(e,t),s=[];if(U(r,Je,"$",Je,s),ze(r,s),qe(r,s),dr(r,s),s.length>0)throw new x(t,s);return{config:r,migratedFrom:n}}l(mr,"loadArkConfigContract");function tt(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new x(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return mr(r,t)}l(tt,"parseArkConfigJson");var yr=/(^|\/)(constants|types|enums|shared-types|shared\/(?:types|constants)|test-projects)(\/|\.|$)|(?:^|\/)[^/]*(?:constants|types)(?:\.[cm]?[jt]sx?)?$/i,hr=/(^|\/)(?:kernel(?:\/|$)|events?(?:\/|\.|$)|bootstrap(?:\.[cm]?[jt]sx?)?$|emitter(?:\.[cm]?[jt]sx?)?$)|(?:^|\/)(?:intents?|publish)(?:\/|\.|$)/i,Rr=/(use-?cases?|usecases?|application|orchestrat|services?|handlers?)(\/|\.|$)/i;function Ar(e,t){let r=String(e??"").replace(/\\/g,"/").trim(),n=String(t?.fromLayer??""),s=String(t?.toLayer??"");return yr.test(r)?"pure-shared":n==="PersistenceAdapters"&&(hr.test(r)||/events?|intents?|kernel|bootstrap/i.test(`${s} ${r}`))?"kernel-emit":Rr.test(r)||(n==="DomainModel"||n==="ApplicationOrchestration")&&s==="PersistenceAdapters"?"use-case":"unknown"}l(Ar,"classifyLayerImportKind");function kr(e){if(e.typeOnly||e.targetTypeOnlyExports||e.namedBindingsTypeOnly)return"Move the referenced type to a mutually allowed layer, use `import type`, then preflight again.";if(e.peerIsolation)return"Extract the shared dependency to a shared layer, test at the public interface, then preflight again.";let t=Ar(typeof e.target=="string"?e.target:"",{fromLayer:typeof e.fromLayer=="string"?e.fromLayer:void 0,toLayer:typeof e.toLayer=="string"?e.toLayer:void 0});return t==="pure-shared"?"Adopt the imported constants/types/pure module into DomainModel or SharedKernel (do not inject a port). Then preflight again.":t==="kernel-emit"?"Persistence must not emit. Inject a port or move the event map to SharedTypes; do not import kernel/events/bootstrap from a repository. Then preflight again.":t==="use-case"||e.portProofEligible?`Define a port in ${e.fromLayer??"the source layer"}, inject the ${e.toLayer??"outer-layer"} implementation, test at the public interface, then preflight again.`:"Classify the import: if it is constants/types/pure, adopt into DomainModel or SharedKernel; define a port only if the target is a real use-case. Then preflight again."}l(kr,"layerImportNextAction");function br(e){return typeof e.target=="string"&&e.target.trim().length>0?e.target.trim():void 0}l(br,"arkRunCallSiteName");function Er(e){let t=br(e),r=typeof e.fromLayer=="string"&&e.fromLayer.length>0?e.fromLayer:void 0;switch(e.ruleId){case"ARKRUN_MISSING_ROOT":return t?`Import createStrictArkKernel from arkgate/runtime and call it in composition root ${t} listed in arkRun.compositionRoots, then preflight again.`:"Import createStrictArkKernel from arkgate/runtime (same npm package; @arkgate/runtime is deprecated) and call it in a composition root listed in arkRun.compositionRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKRUN_KERNEL_IN_DOMAIN":return t?`Move the kernel import of ${t} out of ${r??"the Domain-role layer"} into a composition root or adapter. Import from arkgate/runtime, then preflight again.`:"Move the kernel import out of the Domain-role layer into a composition root or adapter. Import from arkgate/runtime (same npm package; @arkgate/runtime is deprecated), then preflight again. Never mechanical-safe.";case"ARKRUN_DIRECT_NEW":return t?`Resolve ${t} from the kernel instead of constructing it with new, then preflight again.`:"Resolve the type from the kernel instead of constructing it with new, then preflight again. Never mechanical-safe \u2014 rewiring construction is a design decision.";case"ARKRUN_UNDECLARED_EMIT":return t?`Add ${t} to raises or sends on the managed component, then preflight again.`:"Add the existing call-site name to raises or sends on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new emit stays judgment.";case"ARKRUN_UNDECLARED_HANDLE":return t?`Add ${t} to reactsTo on the managed component, then preflight again.`:"Add the existing call-site name to reactsTo on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new handle stays judgment.";case"ARKRUN_UNDECLARED_DEPEND":return t?`Add ${t} to uses on the managed component, then preflight again.`:"Add the existing call-site name to uses on the managed component, then preflight again. Mechanical-safe only when that literal already exists and the edit is the declaration list; inventing a new depend stays judgment.";case"ARKRUN_TRANSPORT_BYPASS":return t?`Send through the ArkRun kernel transport instead of importing ${t}, then preflight again.`:"Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe \u2014 homemade buses stay judgment.";default:return`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(Er,"arkRunNextAction");function K(e){switch(e.ruleId){case"LAYER_IMPORT_VIOLATION":return kr(e);case"FORBIDDEN_GLOBAL":return`Inject ${e.target??"the capability"} through a port, test at the public interface, then preflight again.`;case"CAPABILITY_VIOLATION":return`Define a ${String(e.capability??"capability")} port in ${e.fromLayer??"the walled layer"}, bind the implementation outside it, test at the public interface, then preflight again.`;case"CIRCULAR_DEPENDENCY":return"Extract the shared dependency into a third module, test at the public interface, then preflight again.";case"RAW_EVENT_PUBLISH":return"Publish through a registered intent creator, then run Ark again.";case"LITERAL_PATH_DRIFT":return typeof e.target=="string"&&e.target.length>0?`Rewrite the literal to ${e.target}, or run \`arkgate-check --path-drift --base-ref <ref> --write\` to apply every anchored replacement.`:"Rewrite the literal to the rename destination, or run `arkgate-check --path-drift --base-ref <ref> --write` to apply every anchored replacement.";case"LITERAL_PATH_UNRESOLVED":return"Read the candidate and decide: fix the path, or leave it. Advisory \u2014 with no rename to anchor it there is no destination to propose, so --write never touches it.";case"PUBLISH_MISSING_SOURCE":return"Add metadata.source to the publish call, then run Ark again.";case"INVARIANT_COVERAGE_OUTSIDE_ROOTS":return"Move the covering test under a declared coverage root, or add its root to coverage.coverageRoots in ark.config.json, then run Ark again.";case"INVARIANT_CATALOG_EMPTY":return typeof e.file=="string"&&e.file.length>0?`Add 1\u20132 short phrases to invariants[] in ${e.file}, then run ark-check --doctor. Starters show the shape.`:"Add 1\u20132 short phrases to invariants[] in arkrules/<Domain>.json, then run ark-check --doctor. Starters show the shape.";case"INVARIANT_TESTS_PATH_MISSING":return"Add coverage.testGlobs or coverage.coverageRoots in ark.config.json pointing at a real tests folder, then re-run. Adopted mode fails closed until that path is present.";case"INVARIANT_COVERAGE_ROOTS_MISSING":return"Add coverage.coverageRoots in ark.config.json pointing at the folder the test runner uses, then re-run. An enforced invariant fails closed until that path is present.";case"ARKRULE_STRUCTURE":case"ARKRULE_INVARIANT":case"INVARIANT_UNCOVERED":return`Fix the structure or invariant for ${typeof e.arkruleId=="string"&&e.arkruleId.length>0?e.arkruleId:"the ArkRule"} (declared in ${typeof e.arkruleSource=="string"&&e.arkruleSource.length>0?e.arkruleSource:"arkrules/<Layer>.json"}), then preflight again. Do not demote the rule without a hash-bound policy acknowledgement.`;case"ARKRUN_MISSING_ROOT":case"ARKRUN_KERNEL_IN_DOMAIN":case"ARKRUN_DIRECT_NEW":case"ARKRUN_UNDECLARED_EMIT":case"ARKRUN_UNDECLARED_HANDLE":case"ARKRUN_UNDECLARED_DEPEND":case"ARKRUN_TRANSPORT_BYPASS":return Er(e);case"ARKORDER_MISSING_PLANE":return typeof e.target=="string"&&e.target.length>0?`Import createOrderPlane from arkgate/order and call it in plane root ${e.target} listed in arkOrder.planeRoots, then preflight again.`:"Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe \u2014 factory placement is a design decision.";case"ARKORDER_KERNEL_IN_DOMAIN":return"Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.";case"ARKORDER_GENERIC_UPDATE":return"Don't use a generic update. First freeze with release(). Later, propose the change, then apply it.";case"ARKORDER_TOO_MANY_PARAMS":return"Cut \u03BE to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.";case"ARKORDER_INGEST_WRITES_XI":return"Keep ingest results as absorb/escalate_up/hold only. Change \u03BE with proposeRelease then apply(ProposeResult). Never mechanical-safe.";case"ARKORDER_XI_FIELD_WRITE":return typeof e.target=="string"&&e.target.length>0?`Don't write ${e.target} from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.`:"Don't write a named product choice from a use-case. Take the event in, or change that choice through the valve (proposeRelease then apply), not a generic update.";case"ARKORDER_UNVALVED_RELEASE":return"Change the choice with proposeRelease then apply. release() is only the first freeze. Never mechanical-safe.";default:return typeof e.ruleId=="string"&&e.ruleId.startsWith("ARKRULE_")?`Fix the ArkRule ${typeof e.arkruleId=="string"?e.arkruleId:e.ruleId}, then preflight again.`:`Resolve ${typeof e.ruleId=="string"&&e.ruleId.length>0?e.ruleId:"ARK_UNKNOWN"} without weakening ark.config.json, then run Ark again.`}}l(K,"deterministicNextAction");var pe="docs/diagnostics.md";function ge(e){let t=typeof e.ruleId=="string"?e.ruleId:typeof e.code=="string"?e.code:void 0,r=typeof e.file=="string"?e.file:void 0,n=typeof e.fromLayer=="string"?e.fromLayer:void 0,s=typeof e.toLayer=="string"?e.toLayer:void 0,o=typeof e.target=="string"?e.target:void 0;return[t,r,n??"",s??"",o??""].join("|")}l(ge,"adapterFindingTargetKey");function me(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return`fnv1a-${(t>>>0).toString(16).padStart(8,"0")}`}l(me,"adapterFindingRefFromTargetKey");function ye(e){return`${pe}#${e}`}l(ye,"adapterDocsCodePath");function h(e){return typeof e=="string"&&e.length>0?e:void 0}l(h,"text");function rt(e,t){return Number.isInteger(e)&&Number(e)>0?Number(e):t}l(rt,"positiveInteger");function xr(e,t,r){return K({ruleId:e,target:h(t.target)??h(r.target)??void 0,fromLayer:h(t.fromLayer)??void 0,toLayer:h(t.toLayer)??void 0,typeOnly:t.typeOnly===!0,targetTypeOnlyExports:t.targetTypeOnlyExports===!0,namedBindingsTypeOnly:t.namedBindingsTypeOnly===!0,portProofEligible:t.portProofEligible===!0,peerIsolation:t.peerIsolation===!0,sourcePureTypeModule:t.sourcePureTypeModule===!0,edgeKind:h(t.edgeKind)??void 0,capability:h(t.capability)??h(r.capability)??void 0,arkruleId:h(t.arkruleId)??void 0,arkruleSource:h(t.arkruleSource)??void 0})}l(xr,"nextActionForDiagnostic");function nt(e,t="error",r){let n=h(e.ruleId)??h(e.code)??"ARK_UNKNOWN",s=e.severity==="warning"||e.failsStrict===!1||e.typeOnly===!0&&e.peerIsolation!==!0?"warning":t,o={...h(e.target)?{target:h(e.target)}:{},...h(e.fromLayer)?{fromLayer:h(e.fromLayer)}:{},...h(e.toLayer)?{toLayer:h(e.toLayer)}:{},...typeof e.typeOnly=="boolean"?{typeOnly:e.typeOnly}:{},...typeof e.targetTypeOnlyExports=="boolean"?{targetTypeOnlyExports:e.targetTypeOnlyExports}:{},...typeof e.sourcePureTypeModule=="boolean"?{sourcePureTypeModule:e.sourcePureTypeModule}:{},...typeof e.namedBindingsTypeOnly=="boolean"?{namedBindingsTypeOnly:e.namedBindingsTypeOnly}:{},...typeof e.portProofEligible=="boolean"?{portProofEligible:e.portProofEligible}:{},...typeof e.peerIsolation=="boolean"?{peerIsolation:e.peerIsolation}:{},...h(e.capability)?{capability:h(e.capability)}:{},...h(e.edgeKind)?{edgeKind:h(e.edgeKind)}:{},...h(e.arkruleId)?{arkruleId:h(e.arkruleId)}:{},...h(e.arkruleSource)?{arkruleSource:h(e.arkruleSource)}:{}},i=r??ge(e),a=me(i);return{ruleId:n,severity:s,message:h(e.message)??n,location:{file:h(e.file)??"<unknown>",line:rt(e.line,1),column:rt(e.column,1)},evidence:o,nextAction:h(e.nextAction)??xr(n,o,e),findingRef:a,targetKey:i,docsCodePath:ye(n)}}l(nt,"toAdapterDiagnostic");var st={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."},Ss=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 wr(e){return/^(Domain|Application|Adapter|Workflow|Job|Presentation|Reporting|Metadata|Security|Audit|Observability|Kernel)\.[A-Za-z0-9_.]+$/.test(e)}l(wr,"looksLikeArkIntent");function he(e){if(!e.publishCall)return[];let t=[];return(e.rawIntentName!==void 0&&wr(e.rawIntentName)||e.objectHasIntent)&&t.push({ruleId:"RAW_EVENT_PUBLISH",message:st.RAW_EVENT_PUBLISH}),e.arkPublishCandidate&&!e.hasSource&&t.push({ruleId:"PUBLISH_MISSING_SOURCE",message:st.PUBLISH_MISSING_SOURCE}),t}l(he,"classifyPublishFacts");import yt from"fs";import T from"path";var _r=["createArkKernel","createStrictArkKernel","createArkKernelFromConfig","createStrictArkKernelFromConfig"];var Nr=new Set(_r),Cr=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"]),Or=new Set(["Array","Atomics","Buffer","JSON","Math","Number","Object","Promise","Reflect","String","console","fs","path","url","util"]);function $(e){return e==="@arkgate/runtime"||e.startsWith("@arkgate/runtime/")||e==="arkgate/runtime"||e.startsWith("arkgate/runtime/")}l($,"isArkRunKernelModuleSpecifier");var vr=["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"],Re=new Set(vr);function at(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;if(Re.has(e))return!0;let t=e.indexOf("/");if(t<0)return!1;let r=e.slice(0,t);if(Re.has(r))return!0;let n=e.indexOf("/",t+1);return n<0?!1:Re.has(e.slice(0,n))}l(at,"isArkRunTransportBypassSpecifier");function ot(e){if(Nr.has(e))return"factory";switch(e){case"publisher":return"publisher";case"publish":return"publish";case"raise":case"raiseAsync":return"raise";case"send":case"sendTo":return"send";case"subscribe":return"subscribe";case"registerHandler":return"register-handler";case"resolve":return"resolve";case"resolveSingleton":return"resolve-singleton";default:return}}l(ot,"arkRunKernelCallKind");function lt(e,t){let r=1;for(let n=0;n<t;n+=1)e.charCodeAt(n)===10&&(r+=1);return r}l(lt,"lineAt");function Ae(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:\\])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(Ae,"stripCommentsPreservingLines");function Tr(e,t){let r=e.slice(t),n=/^\s*(['"])((?:\\.|[^\\])*?)\1/.exec(r);if(!n)return;let s=n[2]??"";return s.length>0?s:void 0}l(Tr,"firstStringLiteralArg");function it(e,t,r){let n=Math.max(0,t-r.length-8),s=e.slice(n,t);return new RegExp(`\\b${r}\\s+$`).test(s)}l(it,"keywordBefore");function J(e,t){let r=/\b(?:import|export)(\s+type)?\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g,n;for(;(n=r.exec(e))!==null;)n[1]||t(n[2]??"",n[3]??"")}l(J,"parseValueImportClause");function ct(e,t){J(Ae(e),t)}l(ct,"forEachArkRunValueImportClause");function Lr(e){let t=new Map,r=new Set;return J(e,(n,s)=>{if(!$(s))return;let o=/\*\s+as\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(n);o?.[1]&&r.add(o[1]);let i=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:,|$)/.exec(n.trim());i?.[1]&&t.set(i[1],i[1]);let a=/\{([^}]*)\}/.exec(n);if(a?.[1])for(let c of a[1].split(",")){let f=c.trim();if(!f||f.startsWith("type "))continue;let d=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(f);if(d){t.set(d[2],d[1]);continue}let u=/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(f);u?.[1]&&t.set(u[1],u[1])}}),{named:t,namespaces:r}}l(Lr,"collectKernelImportBindings");function Dr(e,t){let r=new Set(t);return J(e,(n,s)=>{let o=/\{([^}]*)\}/.exec(n);if(o?.[1])for(let i of o[1].split(",")){let a=i.trim();if(!a||a.startsWith("type "))continue;let c=/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/.exec(a),f=c?.[2]??/^([A-Za-z_][A-Za-z0-9_]*)$/.exec(a)?.[1],d=c?.[1]??f;!f||!d||!/^[A-Z]/.test(d)||($(s)||t.has(d)||t.has(f))&&(r.add(f),r.add(d))}}),r}l(Dr,"collectImportedConstructors");function Fr(e,t){let r;return J(e,(n,s)=>{!r&&new RegExp(`\\b${t}\\b`).test(n)&&(r=s)}),r}l(Fr,"importedFromForName");function Q(e,t){let r=Ae(t),n=Lr(r),s=[],o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,i;for(;(i=o.exec(r))!==null;){let a=i[1],c=i.index;if(it(r,c,"function")||it(r,c,"class"))continue;let d=r.slice(0,c).match(/([A-Za-z_][A-Za-z0-9_]*)\s*\.\s*$/)?.[1],u=n.named.get(a)??a,p=ot(u)??ot(a);if(!p)continue;let g=n.named.has(a)||d!==void 0&&n.namespaces.has(d);if(p!=="factory"&&(!g&&d===void 0||d&&Or.has(d)&&!g))continue;let y=Tr(r,c+i[0].length);s.push({file:e,line:lt(t,c),kind:p,callee:a,viaImport:g,...d?{receiver:d}:{},...y?{nameLiteral:y}:{}})}return s}l(Q,"extractArkRunKernelCallsFromSource");function ke(e,t,r){let n=Ae(t),s=Dr(n,r),o=[],i=/\bnew\s+(?:[A-Za-z_][A-Za-z0-9_]*\s*\.\s*)*([A-Z][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/g,a;for(;(a=i.exec(n))!==null;){let c=a[1];if(Cr.has(c)||!s.has(c))continue;let f=Fr(n,c);o.push({file:e,line:lt(t,a.index),typeName:c,...f?{importedFrom:f}:{}})}return o}l(ke,"extractArkRunManagedNewsFromSource");var Pr=["ensureInvariants","assertInvariants","validate","publish","emit","raise","record"],Kr=new RegExp(`\\b(${Pr.join("|")})\\b`),ut="(?:_?pendingEvents|domainEvents|uncommittedEvents|recordedEvents)",$r=new RegExp(`\\bthis\\.${ut}\\.push\\s*\\(`),Mr=new RegExp(`^this\\.${ut}\\s*=\\s*\\[\\s*\\]`),Ur=/^this\.[A-Za-z_][A-Za-z0-9_]*\s*=\s*\[\s*\]/,jr=/\bthis\.[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)/g,Hr="truncatedUntil";function Vr(e){return Kr.test(e)||$r.test(e)}l(Vr,"referencesGuardOrPublish");function Gr(e,t,r){let n=e.slice(t);if(Mr.test(n))return!0;if(!Ur.test(n))return!1;if(r&&/^pullEvents$/i.test(r))return!0;let s=t>200?t-200:0;return/\bpullEvents\b/.test(e.slice(s,t+200))}l(Gr,"isIdiomaticEventsReset");function Br(e,t){let r=new RegExp(jr.source,"g"),n;for(;(n=r.exec(t))!==null;)if(!Gr(t,n.index,e))return!0;return!1}l(Br,"methodAssignsThis");function Wr(e,t){return t==null||Object.defineProperty(e,Hr,{value:t,enumerable:!1,configurable:!0}),e}l(Wr,"attachShapeTruncation");var zr=new Set(["public","private","protected","static","async","readonly","abstract","override","declare","get","set"]),qr=new Set(["if","match","when"]);function ee(e,t){let r=e[t];if(r==="/"&&e[t+1]==="/"){let n=e.indexOf(`
|
|
4
|
-
`,t);return n===-1?e.length:n}if(r==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2}if(r==="'"||r==='"'||r==="`"){let n=t+1;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]===r)return n+1;n+=1}return e.length}return t}l(ee,"skipStringOrComment");function j(e,t){let r=t;for(;r<e.length;){if(/\s/.test(e[r])){r+=1;continue}if(e[r]==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ee(e,r);continue}break}return r}l(j,"skipWsAndComments");function dt(e,t){let r=e[t];if(!r||!/[A-Za-z_]/.test(r))return null;let n=t+1;for(;n<e.length&&/[A-Za-z0-9_]/.test(e[n]);)n+=1;return{ident:e.slice(t,n),end:n}}l(dt,"readIdent");function be(e,t,r,n){if(e[t]!==r)return null;let s=1,o=t+1;for(;o<e.length&&s>0;){let i=ee(e,o);if(i!==o){o=i;continue}let a=e[o];a===r?s+=1:a===n&&(s-=1),o+=1}return s===0?o:null}l(be,"skipBalanced");function Zr(e){let t=[],r=0,n;for(;r<e.length&&(r=j(e,r),!(r>=e.length));){if(e[r]===";"){r+=1;continue}let s=[],o=r;for(;;){let d=dt(e,o);if(!d||!zr.has(d.ident))break;s.push(d.ident),o=j(e,d.end)}let i=dt(e,o);if(!i){r+=1;continue}if(o=j(e,i.end),e[o]==="<"){let d=be(e,o,"<",">");if(d==null){n=e.length;break}o=j(e,d)}if(e[o]==="("){let d=be(e,o,"(",")");if(d==null){n=e.length;break}if(o=j(e,d),e[o]===":")for(o+=1;o<e.length&&e[o]!=="{"&&e[o]!==";";){let u=ee(e,o);if(u!==o){o=u;continue}o+=1}if(e[o]==="{"){let u=be(e,o,"{","}");if(u==null){n=e.length;break}t.push({name:i.ident,modifiers:s,kind:"method",body:e.slice(o+1,u-1)}),r=u;continue}if(e[o]===";"){r=o+1;continue}r=o+1;continue}let a=0,c=0,f=0;for(;o<e.length;){let d=ee(e,o);if(d!==o){o=d;continue}let u=e[o];if(u==="{")a+=1;else if(u==="}"){if(a===0)break;a-=1}else if(u==="(")c+=1;else if(u===")")c-=1;else if(u==="[")f+=1;else if(u==="]")f-=1;else if(u===";"&&a===0&&c===0&&f===0){o+=1;break}o+=1}t.push({name:i.ident,modifiers:s,kind:"field",body:""}),r=o}return{members:t,truncatedAt:n}}l(Zr,"scanClassMembers");function Ee(e,t){let r=[],n=/export\s+(?:abstract\s+)?class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:extends\s+[^{]+)?(?:implements\s+[^{]+)?\{/g,s;for(;(s=n.exec(t))!==null;){let o=s[1],i=s.index+s[0].length,a=1,c=i;for(;c<t.length&&a>0;){let A=t[c];A==="{"?a+=1:A==="}"&&(a-=1),c+=1}let f=t.slice(i,c-1),d=a>0,u=Zr(f),p=d?t.length:u.truncatedAt==null?void 0:i+u.truncatedAt,g=u.members.filter(A=>!(A.kind!=="field"||A.name==="constructor"||A.modifiers.includes("private")||A.modifiers.includes("protected")||A.modifiers.includes("readonly")||A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set"))),y=g.length>0,R=/(?:^|[\n;{])\s*(?:public\s+)?set\s+[a-zA-Z_]/.test(f),k=/(?:^|[\n;{])\s*private\s+constructor\s*\(/.test(f),b=/(?:^|[\n;{])\s*(?:public\s+)?constructor\s*\(/.test(f)&&!k,q=/(?:^|[\n;{])\s*static\s+(?:async\s+)?(?:create|of|from|parse|build|make|new)\s*[<(]/.test(f)||/(?:^|[\n;{])\s*static\s+(?:async\s+)?[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)\s*:\s*[A-Za-z_]/.test(f),D=[];for(let A of u.members)A.kind==="method"&&A.name!=="constructor"&&(A.modifiers.includes("static")||A.modifiers.includes("get")||A.modifiers.includes("set")||qr.has(A.name)||Br(A.name,A.body)&&D.push({name:A.name,referencesGuardOrPublish:Vr(A.body)}));let F=u.members.filter(A=>A.kind==="method").length<=1&&g.length>=2&&y;r.push(Wr({file:e,className:o,exported:!0,hasPublicMutableFields:y,hasPublicSetters:R,hasPublicConstructor:b,hasStaticFactory:q,mutatingMethods:[...D],dataOnly:F},p))}return r}l(Ee,"extractClassShapesFromSource");function Yr(e){if(!e)return{};let t=typeof e.governedPercent=="number"?e.governedPercent:null,r=typeof e.populatedLayerCount=="number"?e.populatedLayerCount:null;return r==null&&typeof e.classifiedFiles=="number"&&(r=e.classifiedFiles>0?1:0),{governedPercent:t,populatedLayerCount:r}}l(Yr,"normalizeExtraMergeTeethClassification");function te(e){let t=Yr(e),r=typeof t.governedPercent=="number"?t.governedPercent:null,n=typeof t.populatedLayerCount=="number"?t.populatedLayerCount:null;return r==null&&n==null?!0:(r??0)>=50&&(n??0)>=1}l(te,"extraMergeTeethAllowed");var Xr=["arkrun-kernel-in-domain","arkrun-direct-new","arkrun-transport-bypass"],Jr=new Set(Xr);function Qr(e){return Jr.has(e)}l(Qr,"isArkRunEditorSensor");var ft={"arkrun-missing-root":"ARKRUN_MISSING_ROOT","arkrun-kernel-in-domain":"ARKRUN_KERNEL_IN_DOMAIN","arkrun-direct-new":"ARKRUN_DIRECT_NEW","arkrun-undeclared-emit":"ARKRUN_UNDECLARED_EMIT","arkrun-undeclared-handle":"ARKRUN_UNDECLARED_HANDLE","arkrun-undeclared-depend":"ARKRUN_UNDECLARED_DEPEND","arkrun-transport-bypass":"ARKRUN_TRANSPORT_BYPASS"},en="ARKRUN_INTERACTION_NAME_INCOMPLETE";function mt(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)||/^(?:entit(?:y|ies)|aggregates?)(?:$|(?=[A-Z_\-\s]))/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(mt,"isDomainRoleLayer");function tn(e,t){return e.file.localeCompare(t.file)||e.ruleId.localeCompare(t.ruleId)||e.line-t.line||e.message.localeCompare(t.message)}l(tn,"compareFindings");function w(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:ft[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:ft[t],fromLayer:o?.fromLayer,target:o?.target})}}l(w,"finding");function rn(e,t){let r=[],n=[],s=[],o=[];for(let i of e)i.file===t&&(r.push(...i.uses),n.push(...i.reactsTo),s.push(...i.raises),o.push(...i.sends));return{uses:new Set(r),reactsTo:new Set(n),raises:new Set(s),sends:new Set(o)}}l(rn,"bagForFile");function pt(e){return e==="publisher"||e==="publish"||e==="raise"||e==="send"}l(pt,"emitKinds");function gt(e){return e==="subscribe"||e==="register-handler"}l(gt,"handleKinds");function nn(e){return e==="resolve"||e==="resolve-singleton"}l(nn,"dependKinds");function sn(e,t,r){let n=[],s=e.kernelRoots??e.compositionRoots;if(s.length===0)return n.push(w(e,"arkrun-missing-root","ark.config.json",1,"ArkRun kernelRoots is empty; no createArkKernel factory site is declared.",void 0,r)),n;let o=new Map;for(let i of t){let a=o.get(i.matchedRoot)??[];a.push(i),o.set(i.matchedRoot,a)}for(let i of s){let a=[...o.get(i)??[]].sort((f,d)=>f.file.localeCompare(d.file));if(a.length===0){n.push(w(e,"arkrun-missing-root","ark.config.json",1,`ArkRun kernel root ${JSON.stringify(i)} matched no governed files and has no createArkKernel factory.`,{target:i},r));continue}if(a.some(f=>f.hasKernelFactory))continue;let c=a[0];n.push(w(e,"arkrun-missing-root",c.file,1,`ArkRun kernel root ${JSON.stringify(i)} has no createArkKernel / createStrictArkKernel factory.`,{target:i},r))}return n}l(sn,"evaluateMissingRoot");function on(e,t,r,n,s){let o=new Map(t.map(a=>[a.name,a.intentPrefixes??[]])),i=[];for(let a of r){let c=a.specifier;if(!c||!$(c))continue;let f=n(a.from);f&&mt(f,o.get(f)??[])&&i.push(w(e,"arkrun-kernel-in-domain",a.from,a.line,`${f} must not import kernel module ${JSON.stringify(c)}.`,{fromLayer:f,target:c},s))}return i}l(on,"evaluateKernelInDomain");function an(e,t,r,n,s,o){let i=new Set(e.managedLayers);if(i.size===0)return[];let a=new Map(t.map(d=>[d.name,d.intentPrefixes??[]])),c=new Set(n.filter(d=>d.hasKernelFactory).map(d=>d.file)),f=[];for(let d of r){if(c.has(d.file))continue;let u=d.typeName;if(e.ignoreDirectNewForErrors!==!1&&(u.endsWith("Error")||u==="Error")||u.endsWith("DTO")||u.endsWith("VO"))continue;let p=s(d.file);!p||!i.has(p)||mt(p,a.get(p)??[])||f.push(w(e,"arkrun-direct-new",d.file,d.line,`${p} must not construct ${d.typeName} with new outside an ArkRun composition-root factory.`,{fromLayer:p,target:d.typeName},o))}return f}l(an,"evaluateDirectNew");function ln(e,t,r,n,s){let o=[],i=[];if(e.requireDeclarations!==!0)return{findings:o,completenessReasons:i};let a=new Set(e.managedLayers);if(a.size===0)return{findings:o,completenessReasons:i};for(let c of t){if(!pt(c.kind)&&!gt(c.kind)&&!nn(c.kind))continue;let f=n(c.file);if(!f||!a.has(f))continue;if(!c.nameLiteral){e.mode==="enforced"&&i.push({code:en,file:c.file,message:`ArkRun ${c.kind} call in ${c.file} has no string-literal name; enforced extra cannot prove the declaration.`});continue}let d=rn(r,c.file);if(pt(c.kind)){if(d.raises.has(c.nameLiteral)||d.sends.has(c.nameLiteral))continue;o.push(w(e,"arkrun-undeclared-emit",c.file,c.line,`Emit ${JSON.stringify(c.nameLiteral)} is not declared in raises or sends.`,{fromLayer:f,target:c.nameLiteral},s));continue}if(gt(c.kind)){if(d.reactsTo.has(c.nameLiteral))continue;o.push(w(e,"arkrun-undeclared-handle",c.file,c.line,`Handle ${JSON.stringify(c.nameLiteral)} is not declared in reactsTo.`,{fromLayer:f,target:c.nameLiteral},s));continue}d.uses.has(c.nameLiteral)||o.push(w(e,"arkrun-undeclared-depend",c.file,c.line,`Depend ${JSON.stringify(c.nameLiteral)} is not declared in uses.`,{fromLayer:f,target:c.nameLiteral},s))}return{findings:o,completenessReasons:i}}l(ln,"evaluateUndeclared");function cn(e,t,r,n){let s=new Set(e.managedLayers);if(s.size===0)return[];let o=[];for(let i of t){if(i.typeOnly)continue;let a=i.specifier;if(!a||!at(a))continue;let c=r(i.from);!c||!s.has(c)||o.push(w(e,"arkrun-transport-bypass",i.from,i.line,`${c} must not import broker/queue/emitter ${JSON.stringify(a)}; use the ArkRun kernel transport.`,{fromLayer:c,target:a},n))}return o}l(cn,"evaluateTransportBypass");function dn(e){let t=e.arkRun;if(!t)return{findings:[],completenessReasons:[]};let r=te(e.classification),n=ln(t,e.kernelCalls,e.declarations,e.layerForFile,r),s=[...sn(t,e.compositionRootHits,r),...on(t,e.layers,e.dependencies,e.layerForFile,r),...an(t,e.layers,e.managedNews,e.compositionRootHits,e.layerForFile,r),...n.findings,...cn(t,e.dependencies,e.layerForFile,r)].sort(tn),o=[...n.completenessReasons].sort((i,a)=>{let c=`${i.code}\0${i.file??""}\0${i.message}`,f=`${a.code}\0${a.file??""}\0${a.message}`;return c<f?-1:c>f?1:0});return{findings:s,completenessReasons:o}}l(dn,"evaluateArkRunSensors");function Se(e){return{findings:dn(e).findings.filter(r=>Qr(r.sensor)),completenessReasons:[]}}l(Se,"evaluateArkRunEditorSensors");function un(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(un,"declarationIsTypeOnly");function Rt(e){try{return yt.existsSync(e)?yt.readFileSync(e,"utf8"):null}catch{return null}}l(Rt,"readUtf8");function ht(e,t){let r=e.lintedFilename(t),n=e.findConfigPath(r),s=n?e.loadArkConfig(n):null;if(!s?.arkRun||!n||!r)return null;let o=T.dirname(n),i=T.isAbsolute(r)?r:T.resolve(r),a=T.relative(o,i).split(T.sep).join("/");if(!e.sourceIsInAnalysisScope(s,a))return null;let c=S(a,s.layers);return c?{extra:s.arkRun,config:s,root:o,absFile:i,relFile:a,fromLayer:c}:null}l(ht,"loadEditorFile");function fn(e,t,r){let n=Q(t,r).some(o=>o.kind==="factory"),s=[];for(let o of e.compositionRoots){try{if(!_(o).test(t))continue}catch{continue}s.push({file:t,matchedRoot:o,hasKernelFactory:n})}return s}l(fn,"compositionRootHitsForFile");function pn(e,t,r){let n=new Set(Ee(t.relFile,r).map(s=>s.className));return ct(r,(s,o)=>{if($(o))return;let i=e.resolveImportSpecifier(t.absFile,o,t.root);if(!i)return;let a=T.relative(t.root,i).split(T.sep).join("/");if(a.startsWith(".."))return;let c=Rt(i);if(c!==null)for(let f of Ee(a,c))n.add(f.className)}),n}l(pn,"admittedTypeNamesForEditor");function At(e,t,r,n,s,o){e.reportAdapterDiagnostic(t,r,n,{ruleId:s.ruleId,file:s.file,fromLayer:s.fromLayer,target:s.target,message:s.message,line:s.line,severity:s.severity,failsStrict:s.failsStrict,nextAction:s.nextAction},o)}l(At,"reportFinding");function gn(e){let t=e.callee;if(t?.type==="Identifier"&&t.name&&/^[A-Z]/.test(t.name))return t.name;let r=t?.property?.name;if(r&&/^[A-Z]/.test(r)&&t?.computed!==!0)return r}l(gn,"constructedTypeName");function mn(e,t){return e.type?.startsWith("Export")?"export":t}l(mn,"specifierEdgeKind");function yn(e,t,r,n,s){let o=l((i,a,c,f)=>{if(typeof a!="string"||a.length===0)return;let d=i.loc?.start?.line??1,u={from:r.relFile,specifier:a,kind:f,typeOnly:c,line:d,resolution:"resolved-external"},{findings:p}=Se({arkRun:r.extra,layers:r.config.layers,kernelCalls:[],managedNews:[],compositionRootHits:[],declarations:[],dependencies:[u],layerForFile:l(g=>g===r.relFile?r.fromLayer:S(g,r.config.layers),"layerForFile")});for(let g of p)g.sensor===n&&At(e,t,i,s,g,{fromLayer:g.fromLayer??r.fromLayer,specifier:a,target:g.target??a})},"check");return{ImportDeclaration(i){let a=i,c=(a.specifiers??[]).filter(d=>d.type==="ImportSpecifier"),f=c.length>0&&c.length===(a.specifiers??[]).length&&c.every(d=>d.importKind==="type");o(i,a.source?.value,a.importKind==="type"||f||un(i),"import")},ImportExpression(i){let a=i;a.source?.type==="Literal"&&o(i,a.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(i){let a=i;o(i,a.moduleReference?.expression?.value,a.importKind==="type"||a.isTypeOnly===!0,"require")},ExportNamedDeclaration(i){let a=i;if(!a.source)return;let c=a.specifiers??[],f=c.length>0&&c.every(d=>d.exportKind==="type");o(i,a.source.value,a.exportKind==="type"||f,mn(i,"export"))},ExportAllDeclaration(i){let a=i;o(i,a.source?.value,a.exportKind==="type","export")},CallExpression(i){let a=i;a.callee?.type==="Identifier"&&a.callee.name==="require"&&a.arguments?.[0]?.type==="Literal"&&!e.isLocallyBound(t,i,"require")&&o(i,a.arguments[0].value,!1,"require")}}}l(yn,"importListeners");function hn(e,t,r){let n=Rt(r.absFile)??"",s=pn(e,r,n),o=ke(r.relFile,n,s),{findings:i}=Se({arkRun:r.extra,layers:r.config.layers,kernelCalls:Q(r.relFile,n),managedNews:o,compositionRootHits:fn(r.extra,r.relFile,n),declarations:[],dependencies:[],layerForFile:l(c=>c===r.relFile?r.fromLayer:S(c,r.config.layers),"layerForFile")}),a=i.filter(c=>c.sensor==="arkrun-direct-new");return{NewExpression(c){let f=gn(c);if(!f)return;let d=c.loc?.start?.line,u=a.find(p=>p.target===f&&(d===void 0||p.line===d))??a.find(p=>p.target===f);u&&At(e,t,c,"directNew",u,{fromLayer:u.fromLayer??r.fromLayer,typeName:f,target:u.target??f})}}}l(hn,"directNewListener");function kt(e){let t=l((r,n,s,o)=>({meta:{type:"problem",docs:{description:n},messages:{[s]:o},schema:[]},create(i){let a=ht(e,i);return a?yn(e,i,a,r,s):{}}}),"createImportRule");return{noArkRunKernelInDomain:t("arkrun-kernel-in-domain","Disallow Domain-role imports of arkgate/runtime when arkRun is on (same sensor as ark-check).","kernelInDomain",'{{fromLayer}} must not import kernel module "{{specifier}}".'),noArkRunTransportBypass:t("arkrun-transport-bypass","Disallow homemade broker/queue/emitter imports in arkRun managed layers (same sensor as ark-check).","transportBypass",'{{fromLayer}} must not import broker/queue/emitter "{{specifier}}"; use the ArkRun kernel transport.'),noArkRunDirectNew:{meta:{type:"problem",docs:{description:"Disallow `new` of ArkRun-admitted types outside a composition-root factory (on-disk import/`new` envelope)."},messages:{directNew:"{{fromLayer}} must not construct {{typeName}} with new outside an ArkRun composition-root factory."},schema:[]},create(r){let n=ht(e,r);return n?hn(e,r,n):{}}}}}l(kt,"createArkRunEslintRules");var Rn="createOrderPlane";var An=/\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)/,kn=/\bfrom\s+['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)(?:\.[cm]?[jt]sx?)?['"]|require\(\s*['"](?:@\/|~\/)?(?:[\w.-]+\/)*(?:db|database|prisma|drizzle)/,bn=/\b(?:db|tx|client|prisma(?:Client)?|drizzle)\b(?:\s*\.\s*[A-Za-z_]\w*)*\s*\.\s*(?:insert(?:One|Many)?|update(?:One|Many)?|upsert|delete(?:One|Many)?|createMany|create|replaceOne|findOneAnd(?:Update|Delete|Replace))\s*\(|\bINSERT\s+INTO\b|\bUPDATE\s+[A-Za-z_][\w.]*\s+SET\b|\bDELETE\s+FROM\b/i;function En(e){return An.test(e)||kn.test(e)}l(En,"sourceImportsPersistenceDriver");function re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(re,"escapeRegExp");function ne(e){return e==="arkgate/order"||e.startsWith("arkgate/order/")}l(ne,"isArkOrderModuleSpecifier");function H(e,t){let r=1;for(let n=0;n<t&&n<e.length;n+=1)e[n]===`
|
|
5
|
-
`&&(r+=1);return r}l(H,"lineAt");function V(e){return e.replace(/\/\*[\s\S]*?\*\//g,t=>t.replace(/[^\n]/g," ")).replace(/(^|[^:])\/\/.*$/gm,t=>t.replace(/\/\/.*$/,r=>" ".repeat(r.length)))}l(V,"stripCommentsPreservingLines");function bt(e,t){let r=V(t),n=[],s=/\bcreateOrderPlane\s*(?:<[^>]*>)?\s*\(/g,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:H(t,o.index),callee:Rn});return n}l(bt,"extractArkOrderPlaneCallsFromSource");function Et(e,t){let r=V(t),n=[],s=/\.((?:update|patch|set|mutate))\s*\(/g,o;for(;(o=s.exec(r))!==null;){let i=o[1],a=r.slice(Math.max(0,o.index-80),o.index);!/\b(?:plane|orderPlane)\s*(?:\?|!)?$/.test(a)&&!/\bcreateOrderPlane\b/.test(r)||n.push({file:e,line:H(t,o.index),method:i})}return n}l(Et,"extractArkOrderGenericUpdatesFromSource");function St(e,t,r){if(r.length===0)return[];let n=V(t);if(!En(n)||!bn.test(n))return[];let s=[],o=new Set;for(let i of r){if(!i)continue;let a=new RegExp(`(?:\\b${re(i)}\\s*:\\s*(?!string\\b|number\\b|boolean\\b|null\\b|[A-Z])|['"]${re(i)}['"]\\s*:|[{\\,]\\s*${re(i)}\\s*[\\,}]|\\.${re(i)}\\s*=)`,"g"),c;for(;(c=a.exec(n))!==null;){let f=`${i}:${c.index}`;if(!o.has(f)){o.add(f),s.push({file:e,line:H(t,c.index),key:i});break}}}return s}l(St,"extractArkOrderXiFieldWritesFromSource");function It(e,t){let r=V(t),n=[],s=/(?:\b(?:xi|release|current|pattern|house)\w*|\.xi)\s*=\s*[^\n;]{0,160}?\bingest\s*\(/gi,o;for(;(o=s.exec(r))!==null;)n.push({file:e,line:H(t,o.index)});return n}l(It,"extractArkOrderIngestWritesXiFromSource");function xt(e,t){let r=V(t),n=[],s=/\.release\s*\(\s*\{([^}]*)\}/g,o;for(;(o=s.exec(r))!==null;){let a=(o[1]??"").match(/\b[A-Za-z_][\w]*\s*:/g)??[];a.length!==0&&n.push({file:e,line:H(t,o.index),keyCount:a.length})}return n}l(xt,"extractArkOrderReleaseKeyCountsFromSource");var wt=new Map;function _t(e){return/[.*+?^${}()|[\]\\]/.test(e)?`\\${e}`:e}l(_t,"escapeAppliesToLiteral");function Sn(e){let t="";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"&&r+1<e.length){let s=e[r+1];if("*?{}[],".includes(s)||s==="\\"){t+="\\"+s,r+=1;continue}t+="/";continue}t+=n}return t}l(Sn,"normalizeAppliesToGlob");function In(e){let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="\\"){r+=1;continue}if(n==="{")t+=1;else if(n==="}"&&(t-=1,t<0))return!1}return t===0}l(In,"appliesToBracesBalanced");function xn(e){let t=wt.get(e);if(t)return t;let r=Sn(e),n=In(r),s="",o=0;for(let a=0;a<r.length;a+=1){let c=r[a];c==="\\"&&a+1<r.length?(s+=_t(r[a+1]),a+=1):c==="*"?r[a+1]==="*"?r[a+2]==="/"?(s+="(?:.*/)?",a+=2):(s+=".*",a+=1):s+="[^/]*":c==="?"?s+="[^/]":c==="{"&&n?(s+="(?:",o+=1):c==="}"&&n&&o>0?(s+=")",o-=1):c===","&&n&&o>0?s+="|":s+=_t(c)}let i=new RegExp(`^${s}$`);return wt.set(e,i),i}l(xn,"globToRegExp");var Nt={"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 wn(e,t){return!t||t.length===0?!0:t.some(r=>xn(r).test(e))}l(wn,"matchesArkOrderAppliesTo");function _n(e,t=[]){let r=e.trim();return/^domain(?:model)?$/i.test(r)||/^domain(?=[A-Z_\-\s])/i.test(r)?!0:t.some(n=>{let s=n.trim().replace(/\.+$/,"");return s==="Domain"||s.startsWith("Domain.")})}l(_n,"isDomainRoleLayer");function N(e,t,r,n,s,o,i){let a=e.mode==="enforced"&&i;return{ruleId:Nt[t],sensor:t,message:s,file:r,line:n,...o?.fromLayer?{fromLayer:o.fromLayer}:{},...o?.target?{target:o.target}:{},severity:a?"error":"warning",failsStrict:a,nextAction:K({ruleId:Nt[t],fromLayer:o?.fromLayer,target:o?.target})}}l(N,"finding");function Nn(e){let t=e.arkOrder;if(!t)return{findings:[],completenessReasons:[]};let r=te(e.classification),n=[],s=t.planeRoots;if(t.mode==="enforced"&&s.length===0)n.push(N(t,"arkorder-missing-plane","ark.config.json",1,"ArkOrder planeRoots is empty; no createOrderPlane site is declared.",void 0,r));else{let c=new Map;for(let f of e.planeRootHits){let d=c.get(f.matchedRoot)??[];d.push(f),c.set(f.matchedRoot,d)}for(let f of s){let d=c.get(f)??[];if(d.length===0){n.push(N(t,"arkorder-missing-plane","ark.config.json",1,`ArkOrder plane root ${JSON.stringify(f)} matched no governed files and has no createOrderPlane factory.`,{target:f},r));continue}d.some(u=>u.hasPlaneFactory)||n.push(N(t,"arkorder-missing-plane",d[0].file,1,`ArkOrder plane root ${JSON.stringify(f)} has no createOrderPlane factory.`,{target:f},r))}}let o=new Map(e.layers.map(c=>[c.name,c.intentPrefixes??[]]));for(let c of e.dependencies){let f=c.specifier;if(!f||!ne(f))continue;let d=e.layerForFile(c.from);d&&_n(d,o.get(d)??[])&&n.push(N(t,"arkorder-kernel-in-domain",c.from,c.line,"Domain-role layer imports arkgate/order; Domain stays plane-free.",{fromLayer:d,target:f},r))}for(let c of e.genericUpdates)n.push(N(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(N(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(N(t,"arkorder-ingest-writes-xi",c.file,c.line,"ingest() result is assigned into a Release or \u03BE store; ingest may absorb or escalate, never mint a pattern.",void 0,r));let a=new Set(t.managedLayers);for(let c of i.length===0?[]:e.xiFieldWrites??[]){let f=e.layerForFile(c.file);!f||!a.has(f)||wn(c.file,t.appliesTo)&&n.push(N(t,"arkorder-xi-field-write",c.file,c.line,`This file writes ${JSON.stringify(c.key)} the same way it would write a seat count. Take the event in, or change that choice through the valve (propose, then apply).`,{fromLayer:f,target:c.key},r))}return n.sort((c,f)=>c.file.localeCompare(f.file)||c.ruleId.localeCompare(f.ruleId)||c.line-f.line),{findings:n,completenessReasons:[]}}l(Nn,"evaluateArkOrderSensors");function Ct(e){if(!e.arkOrder)return[];let t=bt(e.file,e.source),r=Et(e.file,e.source),n=e.arkOrder.xiKeys??[];return Nn({arkOrder:e.arkOrder,layers:[],planeCalls:t,genericUpdates:r,planeRootHits:[],xiFieldWrites:St(e.file,e.source,n),ingestWritesXi:It(e.file,e.source),releaseKeyCounts:xt(e.file,e.source),dependencies:[],layerForFile:l(()=>e.fromLayer,"layerForFile")}).findings.filter(s=>s.sensor==="arkorder-generic-update"||s.sensor==="arkorder-kernel-in-domain"||s.sensor==="arkorder-xi-field-write"||s.sensor==="arkorder-ingest-writes-xi"||s.sensor==="arkorder-too-many-params")}l(Ct,"evaluateArkOrderEditorSensors");function Cn(e){let t=e;return t.sourceCode?.getText?.()??t.getSourceCode?.()?.getText?.()??""}l(Cn,"eslintSourceText");function Ot(e){function t(r){return{meta:{type:"problem",docs:{description:r},messages:{denied:"{{message}}"},schema:[]},create(n){let s=e.lintedFilename(n),o=e.findConfigPath(s),i=o?e.loadArkConfig(o):null;if(!i?.arkOrder)return{};let a=e.toProjectRelative(o,s);if(!e.sourceIsInAnalysisScope(i,a))return{};let c=S(a,i.layers);return{ImportDeclaration(f){let d=typeof f.source?.value=="string"?f.source.value:"";if(r==="ARKORDER_KERNEL_IN_DOMAIN"){if(!ne(d)||c!=="DomainModel"&&!/^domain/i.test(c??""))return;e.reportAdapterDiagnostic(n,f,"denied",{ruleId:r,file:a,line:f.loc?.start?.line??1,message:"Domain-role layer imports arkgate/order; Domain stays plane-free."})}},Program(){if(r!=="ARKORDER_GENERIC_UPDATE")return;let f=Cn(n),d=Ct({arkOrder:i.arkOrder,file:a,source:f,fromLayer:c}).filter(u=>u.ruleId!=="ARKORDER_KERNEL_IN_DOMAIN");for(let u of d)e.reportAdapterDiagnostic(n,{loc:{start:{line:u.line}}},"denied",{ruleId:u.ruleId,file:u.file,line:u.line,message:u.message})}}}}}return l(t,"createImportRule"),{noArkOrderKernelInDomain:t("ARKORDER_KERNEL_IN_DOMAIN"),noArkOrderGenericUpdate:t("ARKORDER_GENERIC_UPDATE")}}l(Ot,"createArkOrderEslintRules");function L(e){if(typeof e.physicalFilename=="string"&&e.physicalFilename.length>0)return e.physicalFilename;if(typeof e.filename=="string"&&e.filename.length>0)return e.filename;if(typeof e.getFilename=="function")try{let t=e.getFilename();if(typeof t=="string"&&t.length>0)return t}catch{}return""}l(L,"lintedFilename");function O(e,t,r,n,s){let o=nt({...n,line:n.line??t.loc?.start?.line,column:n.column??(typeof t.loc?.start?.column=="number"?t.loc.start.column+1:void 0)});return e.report({node:t,messageId:r,...s?{data:s}:{},diagnostic:o}),o}l(O,"reportAdapterDiagnostic");function B(e){if(!e||e==="<input>"||e.startsWith("stdin"))return null;let t=m.dirname(m.resolve(e));for(;;){let r=m.join(t,"ark.config.json");if(C.existsSync(r))return r;let n=m.dirname(t);if(n===t)return null;t=n}}l(B,"findConfigPath");var vt=new Map;function W(e){if(!C.existsSync(e))return null;let t=C.readFileSync(e,"utf8"),r=vt.get(e);if(r?.source===t)return r.config;let n=tt(t,e).config;return vt.set(e,{source:t,config:n}),n}l(W,"loadArkConfig");function z(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!$e(t,e)}l(z,"sourceIsInAnalysisScope");function Tt(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,m.join(e,"index.ts"),m.join(e,"index.tsx"),m.join(e,"index.js")];for(let r of t)try{if(C.existsSync(r)&&C.statSync(r).isFile())return r}catch{}return null}l(Tt,"existingSourceFile");function On(e){let t=m.resolve(e),r=null;for(;;){let f=m.join(t,"tsconfig.json");if(C.existsSync(f)){r=f;break}let d=m.dirname(t);if(d===t)break;t=d}if(!r)return{baseUrl:e,aliases:[]};let n=l(f=>{try{let d=C.readFileSync(f,"utf8");return d=d.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),JSON.parse(d)}catch{return null}},"loadJsonc"),s=l((f,d)=>{if(d>4)return{};let u=n(f);if(!u)return{};let p=u.compilerOptions??{},g=p.baseUrl,y=p.paths,R=u.extends;if(typeof R=="string"&&!R.startsWith("@")){let k=m.resolve(m.dirname(f),R.endsWith(".json")?R:`${R}.json`);if(C.existsSync(k)){let b=s(k,d+1);g=g??b.baseUrl,y={...b.paths??{},...y??{}}}}return{baseUrl:g,paths:y}},"mergePaths"),o=s(r,0),i=m.dirname(r),a=m.resolve(i,o.baseUrl||"."),c=[];for(let[f,d]of Object.entries(o.paths||{})){if(!Array.isArray(d)||d.length===0)continue;let u=f.replace(/\*$/,"");u&&c.push({from:u,to:String(d[0]).replace(/\*$/,"")})}return c.sort((f,d)=>d.from.length-f.from.length),{baseUrl:a,aliases:c}}l(On,"readTsconfigPathAliases");function vn(e,t){if(!t.startsWith("."))return null;let r=m.resolve(m.dirname(e),t);return Tt(r)}l(vn,"resolveRelativeImport");function Lt(e,t,r){if(!t)return null;if(t.startsWith("."))return vn(e,t);let n=r||m.dirname(e),{baseUrl:s,aliases:o}=On(n),i=o.find(c=>t.startsWith(c.from));if(!i)return null;let a=m.resolve(s,`${i.to}${t.slice(i.from.length)}`);return Tt(a)}l(Lt,"resolveImportSpecifier");function oe(e){return typeof e?.value=="string"?e.value:void 0}l(oe,"stringValue");function we(e){return e?.name??oe(e)}l(we,"propertyName");function _e(e){return e.sourceCode??e.getSourceCode?.()}l(_e,"sourceCodeFor");function Dt(e,t){let r=_e(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}l(Dt,"referenceFor");function G(e,t,r){let n=Dt(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=_e(e)?.getScope?.(t);for(;s;){let o=s.set?.get(r);if(o)return(o.defs?.length??0)>0;s=s.upper??void 0}return!1}l(G,"isLocallyBound");function Tn(e,t){let r=Dt(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}l(Tn,"isValueIdentifierReference");function Ft(e){if(e?.type==="Identifier"&&e.name)return{root:e,segments:[e.name]};if(!e||!(e.type==="MemberExpression"||!!(e.object&&e.property))||e.computed===!0)return;let r=Ft(e.object),n=we(e.property);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}l(Ft,"memberExpressionPath");function Ln(e){return we(e.callee?.property)}l(Ln,"calleePropertyName");function Pt(e,t){return e?.properties?.find(r=>we(r.key)===t)}l(Pt,"objectProperty");function se(e,t){return Pt(e,t)!==void 0}l(se,"objectHasProperty");function Dn(e){let t=Pt(e,"metadata")?.value;return se(t,"source")}l(Dn,"objectHasMetadataSource");function Kt(e){return Ln(e)==="publish"}l(Kt,"isPublishCall");function Ie(e){if(e.importKind==="type"||e.exportKind==="type")return!0;let t=e.specifiers??[];return t.length===0?!1:t.every(r=>r.type==="ImportSpecifier")?t.every(r=>r.importKind==="type"):t.every(r=>r.exportKind==="type")}l(Ie,"declarationIsTypeOnly");function Fn(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}l(Fn,"containingProgram");function Pn(e){let t=Fn(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!Ie(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(!Ie(n))return!1;r=!0;continue}return!1}}return r}l(Pn,"sourceProgramExportsOnlyTypes");var Kn={meta:{type:"problem",docs:{description:"Disallow imports that violate ark.config.json layer rules (same contract as arkgate-check)."},messages:{forbiddenImport:"Architecture: {{fromLayer}} must not import {{toLayer}} (ark.config.json). Specifier: {{specifier}}",forbiddenImportHeuristic:"Domain code must not import infrastructure, adapters, repositories, or database modules."},schema:[]},create(e){let t=L(e),r=B(t),n=r?W(r):null,s=r?m.dirname(r):null,o=l(i=>{let a=oe(i.source);if(a&&n&&s&&t){let c=m.isAbsolute(t)?t:m.resolve(t),f=m.relative(s,c).split(m.sep).join("/");if(!z(n,f))return;let d=S(f,n.layers);if(!d)return;let u=Lt(c,a,s);if(!u)return;let p=m.relative(s,u).split(m.sep).join("/");if(p.startsWith(".."))return;let g=S(p,n.layers);if(!g)return;let y={fromPath:f,toPath:p,layers:n.layers},R=ae(n.rules,d,g,y),k=R?.rule;if(k){let b=i.type?.startsWith("Export")?"export":"import",q=Ie(i),D=!!k?.peerIsolation,ie=q&&!D,F=D&&R?Ke(R.peerIsolationReason??"cross-slice",{fromPath:f,toPath:p,fromSlice:R.fromSlice,toSlice:R.toSlice}):void 0,A=k?.message?F?`${k.message} (${F})`:k.message:F?`${d} must not ${b} another slice of ${g} (${f} \u2192 ${p}): ${F}`:`${d} must not ${b} ${g}.`;O(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:f,fromLayer:d,toLayer:g,target:p,edgeKind:b,...D?{peerIsolation:!0}:{},...q?{typeOnly:!0}:{},...ie?{severity:"warning"}:{},...Pn(i)?{sourcePureTypeModule:!0}:{},message:ie?`${A} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:A},{fromLayer:d,toLayer:g,specifier:a})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},$n={meta:{type:"problem",docs:{description:"Require event bus publish calls to use registered intent creators instead of raw event objects or intent strings."},messages:{rawPublish:"Publish through a registered intent creator; raw event objects or intent strings bypass Ark contracts."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=oe(r),s=he({publishCall:Kt(t),rawIntentName:n,objectHasIntent:se(r,"intent"),arkPublishCandidate:!1,hasSource:!0});if(s.some(o=>o.ruleId==="RAW_EVENT_PUBLISH")){let o=s.find(i=>i.ruleId==="RAW_EVENT_PUBLISH");O(e,t,"rawPublish",{...o,file:L(e)})}}}}},Mn={meta:{type:"problem",docs:{description:"Require event bus publish calls to include source metadata."},messages:{missingSource:"Strict Ark publish calls must include metadata.source."},schema:[]},create(e){return{CallExpression(t){let r=t.arguments?.[0],n=t.arguments?.[2],o=he({publishCall:Kt(t),rawIntentName:oe(r),objectHasIntent:se(r,"intent"),arkPublishCandidate:!0,hasSource:Dn(r)||se(n,"source")}).find(i=>i.ruleId==="PUBLISH_MISSING_SOURCE");o&&O(e,t,"missingSource",{...o,file:L(e)})}}}},Un={meta:{type:"problem",docs:{description:"Disallow ambient globals from the layer\u2019s forbiddenGlobals in ark.config.json (same purity surface as ark-check). Option `globals` is a standalone fallback when no project config applies."},messages:{forbiddenGlobal:'Ambient global "{{name}}" is forbidden in {{layer}} (ark.config.json); inject the capability through a port instead.',forbiddenGlobalDefault:'Ambient global "{{name}}" is forbidden here; inject the capability through a port instead.',forbiddenModule:'{{layer}} must not use module "{{specifier}}" because it is the import form of forbidden global "{{name}}".'},schema:[{type:"object",properties:{globals:{type:"array",items:{type:"string"}}},additionalProperties:!1}]},create(e){let t=L(e),r=e.options?.[0],n=B(t),s=n?W(n):null,o=n?m.dirname(n):null,i=null,a="this layer";if(s&&o&&t){let u=m.isAbsolute(t)?t:m.resolve(t),p=m.relative(o,u).split(m.sep).join("/");if(!z(s,p))return{};let g=s.layers?.find(y=>y.name===S(p,s.layers));g?.forbiddenGlobals?.length?(i=new Set(g.forbiddenGlobals),a=g.name):i=null}else r?.globals&&(i=new Set(r.globals));if(!i)return{};let c=typeof _e(e)?.getScope=="function",f=l((u,p)=>{let g=m.isAbsolute(t)?t:m.resolve(t),y=o?m.relative(o,g).split(m.sep).join("/"):t;O(e,u,s?"forbiddenGlobal":"forbiddenGlobalDefault",{ruleId:"FORBIDDEN_GLOBAL",file:y,fromLayer:a,target:p,message:`${a} must not use the ambient global "${p}".`},{name:p,layer:a})},"report"),d=l((u,p,g,y)=>{if(g||typeof p!="string")return;let R=ce(p,i);if(!R)return;let k=m.isAbsolute(t)?t:m.resolve(t),b=o?m.relative(o,k).split(m.sep).join("/"):t;O(e,u,"forbiddenModule",{ruleId:"FORBIDDEN_GLOBAL",file:b,fromLayer:a,target:p,edgeKind:y,message:`${a} must not use module "${p}" because it is the import form of forbidden global "${R}".`},{layer:a,name:R,specifier:p,importKind:y})},"reportModule");return{MemberExpression(u){if(u.parent?.type==="MemberExpression"&&u.parent.object===u)return;let p=Ft(u);if(!p||G(e,p.root,p.segments[0]))return;let g=p.segments[0]==="globalThis",y=g?p.segments.slice(1):p.segments,R;for(let k=y.length;k>=(g?1:2);k-=1){let b=y.slice(0,k).join(".");if(i.has(b)){R=b;break}}R?f(u,R):!c&&i.has(p.segments[0])&&f(u,p.segments[0])},CallExpression(u){let p=u;if(p.callee?.type==="Identifier"&&p.callee.name==="require"&&p.arguments?.[0]?.type==="Literal"&&!G(e,u,"require")&&d(u,p.arguments[0].value,!1,"require"),c)return;let g=p.callee?.type==="Identifier"?p.callee.name:void 0;g&&i.has(g)&&f(u,g)},ImportDeclaration(u){let p=u,g=(p.specifiers??[]).filter(R=>R.type==="ImportSpecifier"),y=g.length>0&&g.length===(p.specifiers??[]).length&&g.every(R=>R.importKind==="type");d(u,p.source?.value,p.importKind==="type"||y,"import")},ImportExpression(u){let p=u;p.source?.type==="Literal"&&d(u,p.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(u){let p=u;d(u,p.moduleReference?.expression?.value,p.importKind==="type"||p.isTypeOnly===!0,"require")},ExportNamedDeclaration(u){let p=u;if(!p.source)return;let g=p.specifiers??[],y=g.length>0&&g.every(R=>R.exportKind==="type");d(u,p.source.value,p.exportKind==="type"||y,"export")},ExportAllDeclaration(u){let p=u;d(u,p.source?.value,p.exportKind==="type","export")},NewExpression(u){if(c)return;let p=u.callee?.type==="Identifier"?u.callee.name:void 0;p&&i.has(p)&&f(u,p)},Identifier(u){!c||!u.name||!i.has(u.name)||!Tn(e,u)||G(e,u,u.name)||f(u,u.name)}}}},jn={meta:{type:"problem",docs:{description:"Disallow importing modules whose effect capability the layer denies (ark.config.json capabilities.deny / pure \u2014 same wall surface as ark-check). Import dimension only: ambient globals stay with no-forbidden-globals and the CLI/hook symbol path."},messages:{deniedCapability:'{{layer}} denies the {{capability}} capability (ark.config.json); "{{specifier}}" imports it. Define a port and bind the implementation in an adapter layer.'},schema:[]},create(e){let t=L(e),r=B(t),n=r?W(r):null,s=r?m.dirname(r):null;if(!n||!s||!t)return{};let o=m.isAbsolute(t)?t:m.resolve(t),i=m.relative(s,o).split(m.sep).join("/");if(!z(n,i))return{};let a=n.layers?.find(d=>d.name===S(i,n.layers));if(!a)return{};let c=new Set(je(a));if(c.size===0)return{};let f=l((d,u,p,g)=>{if(p||typeof u!="string"||ce(u,a.forbiddenGlobals??[]))return;let y=Ue(u);!y||!c.has(y)||O(e,d,"deniedCapability",{ruleId:"CAPABILITY_VIOLATION",file:i,fromLayer:a.name,target:u,capability:y,edgeKind:g,message:`${a.name} denies the ${y} capability; found import of "${u}".`},{layer:a.name,capability:y,specifier:u})},"check");return{ImportDeclaration(d){let u=d,p=(u.specifiers??[]).filter(y=>y.type==="ImportSpecifier"),g=p.length>0&&p.length===(u.specifiers??[]).length&&p.every(y=>y.importKind==="type");f(d,u.source?.value,u.importKind==="type"||g,"import")},ImportExpression(d){let u=d;u.source?.type==="Literal"&&f(d,u.source.value,!1,"dynamic-import")},TSImportEqualsDeclaration(d){let u=d;f(d,u.moduleReference?.expression?.value,u.importKind==="type"||u.isTypeOnly===!0,"require")},ExportNamedDeclaration(d){let u=d;if(!u.source)return;let p=u.specifiers??[],g=p.length>0&&p.every(y=>y.exportKind==="type");f(d,u.source.value,u.exportKind==="type"||g,"export")},ExportAllDeclaration(d){let u=d;f(d,u.source?.value,u.exportKind==="type","export")},CallExpression(d){let u=d;u.callee?.type==="Identifier"&&u.callee.name==="require"&&u.arguments?.[0]?.type==="Literal"&&!G(e,d,"require")&&f(d,u.arguments[0].value,!1,"require")}}}},{noArkRunKernelInDomain:Hn,noArkRunDirectNew:Vn,noArkRunTransportBypass:Gn}=kt({findConfigPath:B,loadArkConfig:W,resolveImportSpecifier:Lt,lintedFilename:L,sourceIsInAnalysisScope:z,isLocallyBound:G,reportAdapterDiagnostic:O});function Bn(e,t){let r=m.dirname(m.resolve(e));return m.relative(r,m.resolve(t)).split(m.sep).join("/")}l(Bn,"toProjectRelative");var{noArkOrderKernelInDomain:Wn,noArkOrderGenericUpdate:zn}=Ot({findConfigPath:B,loadArkConfig:W,lintedFilename:L,sourceIsInAnalysisScope:z,reportAdapterDiagnostic:O,toProjectRelative:Bn});var qn={"no-domain-infra-imports":Kn,"no-raw-event-publish":$n,"require-publish-source":Mn,"no-forbidden-globals":Un,"no-denied-capabilities":jn,"no-arkrun-kernel-in-domain":Hn,"no-arkrun-direct-new":Vn,"no-arkrun-transport-bypass":Gn,"no-arkorder-kernel-in-domain":Wn,"no-arkorder-generic-update":zn},xe={rules:qn};xe.configs={recommended:{plugins:{ark:xe},rules:{"ark/no-domain-infra-imports":"error","ark/no-raw-event-publish":"error","ark/require-publish-source":"error","ark/no-forbidden-globals":"error","ark/no-denied-capabilities":"error","ark/no-arkrun-kernel-in-domain":"error","ark/no-arkrun-direct-new":"error","ark/no-arkrun-transport-bypass":"error","ark/no-arkorder-kernel-in-domain":"error","ark/no-arkorder-generic-update":"error"}}};var yo=xe;export{yo as default,B as findConfigPath,_ as globToRegExp,Jt as isEdgeDenied,S as layerForRelativePath,W as loadArkConfig,zn as noArkOrderGenericUpdate,Wn as noArkOrderKernelInDomain,Vn as noArkRunDirectNew,Hn as noArkRunKernelInDomain,Gn as noArkRunTransportBypass,jn as noDeniedCapabilities,Kn as noDomainInfraImports,Un as noForbiddenGlobals,$n as noRawEventPublish,De as patternSpecificity,xe as plugin,On as readTsconfigPathAliases,Mn as requirePublishSource,Lt as resolveImportSpecifier,vn as resolveRelativeImport};
|
|
6
|
+
`)}`),this.name="ArkConfigValidationError",this.source=t,this.issues=r}};function Kn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(Kn,"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 de(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(de,"valueType");function ul(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(ul,"resolveSchemaRef");function Ie(e,t,r,n,s){if(t.$ref){let o=ul(t.$ref,n);if(!o){s.push({path:r,message:`schema reference ${t.$ref} cannot be resolved`});return}Ie(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(!Kn(e)){s.push({path:r,message:`must be an object; received ${de(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||Ie(e[l],i,qe(r,l),n,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&Ie(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 ${de(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)=>Ie(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 ${de(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 ${de(e)}`});return}if(t.type==="integer"){if(!Number.isInteger(e)){s.push({path:r,message:`must be an integer; received ${de(e)}`});return}t.minimum!==void 0&&e<t.minimum&&s.push({path:r,message:`must be at least ${t.minimum}`})}}a(Ie,"validateNode");function fl(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"&&(Fn(i)||t.push({path:`$.layers[${s}].owners[${l}]`,message:"must be a GitHub handle or email (not a display name)"}))})})}a(fl,"validateLayerOwners");function pl(e){let t={...e,$schema:e.$schema===void 0?vt:e.$schema,schemaVersion:e.schemaVersion===void 0?L:e.schemaVersion,include:e.include===void 0?["src"]:e.include,layers:e.layers===void 0?[]:e.layers,rules:e.rules===void 0?Mn.map(r=>({...r})):e.rules};return e.arkRun!==void 0&&(t.arkRun=kn(e.arkRun)),e.arkOrder!==void 0&&(t.arkOrder=Sn(e.arkOrder)),t}a(pl,"defaultedConfig");function gl(e){return e===L?null:e==="unversioned"?"unversioned":e==="1.0"||e==="1.1"||e==="1.2"?e:null}a(gl,"migratedFromOf");function hl(){let e=new Set([L]);for(let t of xt)t.from!=="unversioned"&&e.add(t.from),e.add(t.to);return e}a(hl,"knownInputVersions");function ml(e,t="ark.config.json"){if(!Kn(e))throw new U(t,[{path:"$",message:`must be an object; received ${de(e)}`}]);let r=hl(),n=e.schemaVersion===void 0?"unversioned":typeof e.schemaVersion=="string"?e.schemaVersion:null;if(n===null)throw new U(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(e.schemaVersion)}; expected ${L}`}]);if(n!=="unversioned"&&!r.has(n))throw new U(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${L}`}]);let s=n,o={...e},i=0;for(;s!==L&&i<xt.length+1;){i+=1;let l=xt.find(c=>c.from===s);if(!l)throw new U(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(s)}; expected ${L}`}]);s=l.to,o.schemaVersion=s}if(s!==L)throw new U(t,[{path:"$.schemaVersion",message:`unsupported version ${JSON.stringify(n)}; expected ${L}`}]);return{candidate:pl(o),migratedFrom:gl(n)}}a(ml,"migrateArkConfig");function yl(e,t="ark.config.json"){let{candidate:r,migratedFrom:n}=ml(e,t),s=[];if(Ie(r,$n,"$",$n,s),bn(r,s),En(r,s),fl(r,s),Nn(r,s),s.length>0)throw new U(t,s);return{config:r,migratedFrom:n}}a(yl,"loadArkConfigContract");function Ye(e,t="ark.config.json"){let r;try{r=JSON.parse(e)}catch(n){throw new U(t,[{path:"$",message:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}])}return yl(r,t)}a(Ye,"parseArkConfigJson");var _t="https://unpkg.com/arkgate/schemas/ark.arkrules.schema.json",Al=["aggregate-private-state","always-valid-factory","domain-event-on-mutation","orchestration-only","thin-adapter","writes-via-aggregate","no-anemic-model","invariant-coverage"],Rl=["no-anemic-model"],jn={type:"array",items:{type:"string",minLength:1},uniqueItems:!0},Un={$schema:"https://json-schema.org/draft/2020-12/schema",$id:_t,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:_t},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:[...Al]},mode:{type:"string",enum:["advisory","enforced"],default:"advisory"},appliesTo:jn,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:jn}}}},ue=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 xe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(xe,"isObject");function Ze(e,t){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}a(Ze,"propertyPath");function we(e){return e===null?"null":Array.isArray(e)?"array":typeof e}a(we,"valueType");function kl(e,t){let r="#/$defs/";if(e.startsWith(r))return t.$defs[e.slice(r.length)]}a(kl,"resolveSchemaRef");function ve(e,t,r,n,s){if(t.$ref){let o=kl(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(!xe(e)){s.push({path:r,message:`must be an object; received ${we(e)}`});return}let o=t.properties??{};for(let i of t.required??[])e[i]===void 0&&s.push({path:Ze(r,i),message:"is required"});if(t.additionalProperties===!1)for(let i of Object.keys(e))i in o||s.push({path:Ze(r,i),message:"unknown field"});else if(xe(t.additionalProperties)){let i=t.additionalProperties;for(let l of Object.keys(e))l in o||ve(e[l],i,Ze(r,l),n,s)}for(let[i,l]of Object.entries(o))e[i]!==void 0&&ve(e[i],l,Ze(r,i),n,s);return}if(t.type==="array"){if(!Array.isArray(e)){s.push({path:r,message:`must be an array; received ${we(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 ${we(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 ${we(e)}`})}a(ve,"validateNode");function Sl(e){return{...e,$schema:e.$schema===void 0?_t: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(Sl,"defaultedArkRules");function Gn(e){return e==="enforced"?"enforced":"advisory"}a(Gn,"normalizeMode");function bl(e){return Rl.includes(e)}a(bl,"isTier2Sensor");function El(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(!xe(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"&&bl(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(!xe(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(El,"validateSemantics");function Hn(e,t="arkrules.json",r){if(!xe(e))throw new ue(t,[{path:"$",message:`must be an object; received ${we(e)}`}]);let n=Sl(e),s=[];if(ve(n,Un,"$",Un,s),El(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 ue(t,s);return{config:n}}a(Hn,"loadArkRulesContract");function Vn(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:Gn(c.mode),provenance:{sourceFile:o.sourceFile,ruleId:c.id,layer:o.layer}})),l=(o.file.invariants??[]).map(c=>({...c,mode:Gn(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(Vn,"buildEffectiveArkRules");function ee(){return{schemaVersion:"1.0",byLayer:{},structure:[],invariants:[]}}a(ee,"emptyEffectiveArkRules");var Ct=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 Bn(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}a(Bn,"normalizeRel");function zn(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:ee(),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=Bn(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=Hn(JSON.parse(g),f,c);i.push({layer:c,sourceFile:f,file:p.config})}catch(p){if(p instanceof ue)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=Bn(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 Ct(t,o);return{config:e.config,arkRules:Vn(i),warnings:n}}a(zn,"resolveEffectiveContract");var Il=2e3,Wn=new Map;function qn(e){try{return q.statSync(e).isFile()}catch{return!1}}a(qn,"isFile");function Nt(e){let t=Wn.get(e);if(t){if(t.found!==null&&qn(t.found))return t.found;if(t.found===null&&Date.now()-t.at<Il)return null}let r=D.join(e,"ark.config.json"),n;if(qn(r))n=r;else{let s=D.dirname(e);n=s===e?null:Nt(s)}return Wn.set(e,{found:n,at:Date.now()}),n}a(Nt,"findConfigInDir");function N(e){return!e||e==="<input>"||e.startsWith("stdin")?null:Nt(D.dirname(D.resolve(e)))}a(N,"findConfigPath");var fe=new Map,wl=64;function vl(e){try{let t=q.statSync(e,{throwIfNoEntry:!1});return t?.isFile()?`${t.mtimeMs}:${t.size}:${t.ino}`:null}catch{return null}}a(vl,"configFileStamp");function xl(e,t){if(!fe.has(e)&&fe.size>=wl){let r=fe.keys().next().value;r!==void 0&&fe.delete(r)}fe.set(e,t)}a(xl,"rememberContract");function Qn(e){let t=e?.arkRules;return!t||typeof t!="object"?[]:Object.entries(t).filter(r=>typeof r[1]=="string")}a(Qn,"arkRulesRefs");function _l(e,t){let r=t.replace(/\\/g,"/").replace(/^\.\//,""),n=D.resolve(e,r),s=D.relative(e,n);if(!(s.startsWith("..")||D.isAbsolute(s)))try{return q.readFileSync(n,"utf8")}catch{return}}a(_l,"readReferencedFile");function Ot(e,t){return Qn(t).map(([,r])=>{try{let n=q.statSync(D.resolve(e,r));return`${r}:${n.mtimeMs}:${n.size}`}catch{return`${r}:missing`}}).join("|")}a(Ot,"refStampsFor");function Yn(e){return e instanceof Error?e.message:String(e)}a(Yn,"errorText");function Cl(e,t){let r=D.dirname(e),n;try{n=Ye(t,e).config}catch(l){return{config:null,arkRules:ee(),error:Yn(l),fingerprint:null}}let s=Qn(n),o=Jn("sha256").update(t);if(s.length===0)return{config:n,arkRules:ee(),error:null,fingerprint:o.digest("hex")};let i={};for(let[,l]of s){let c=_l(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=zn({config:n,fileContents:i},e);return{config:n,arkRules:l.arkRules,error:null,fingerprint:o.digest("hex")}}catch(l){return{config:null,arkRules:ee(),error:Yn(l),fingerprint:null}}}a(Cl,"resolveContract");function pe(e){let t=D.dirname(e),r=vl(e),n=fe.get(e);if(n&&r!==null&&n.stamp===r&&Ot(t,n.refConfig)===n.refStamps)return n.result;let s;try{s=q.readFileSync(e,"utf8")}catch{return{config:null,arkRules:ee(),error:null,fingerprint:null}}if(n?.source===s&&Ot(t,n.refConfig)===n.refStamps)return n.stamp=r,n.result;let o=Cl(e,s),i=o.config??Ol(s,e);return xl(e,{source:s,stamp:r,refConfig:i,refStamps:Ot(t,i),result:o}),o}a(pe,"loadArkContract");function Ol(e,t){try{return Ye(e,t).config}catch{return null}}a(Ol,"safeConfig");function Nl(e){if(!q.existsSync(e))return null;let t=pe(e);return t.config?t.config:Ye(q.readFileSync(e,"utf8"),e).config}a(Nl,"loadArkConfig");function M(e,t){return(e.include??[]).some(n=>{let s=String(n).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"");return s==="."||t===s||t.startsWith(`${s}/`)})&&!ir(t,e)}a(M,"sourceIsInAnalysisScope");function G(e){return e?pe(e).config:null}a(G,"configForRule");var Zn="configInvalid",Tl="Ark contract is invalid, so no architecture verdict is possible (fix it; ark-check fails closed the same way): {{detail}}",Xn=new WeakSet;function Tt(e){let t=N(e);return t?pe(t).error:null}a(Tt,"contractErrorForFile");function T(e){return{meta:{...e.meta,messages:{...e.meta.messages,[Zn]:Tl,[Ue]:jr}},create(t){let r=Tt(x(t));return r?{Program(n){let s=z(t);if(s&&typeof s=="object"){if(Xn.has(s))return;Xn.add(s)}t.report({...n?.loc?.start?{node:n}:{loc:{line:1,column:0}},messageId:Zn,data:{detail:r.replace(/\s*\n\s*/g," ")}})}}:Ge(e,t,"blocking")}}}a(T,"withContractGuard");function es(e=process.cwd()){let t=Nt(D.resolve(e));if(!t)return null;let r=pe(t);if(r.fingerprint)return r.fingerprint;try{return Jn("sha256").update(q.readFileSync(t,"utf8")).digest("hex")}catch{return null}}a(es,"contractFingerprint");var Dl=256*1024;function Fl(e){try{return Ll.readFileSync(e,"utf8")}catch{return""}}a(Fl,"readUtf8");function Pl(e,t){if(!/\.(tsx?|mts|cts)$/i.test(e))return[];try{return Se(e,t)}catch{return[]}}a(Pl,"classShapesFor");function $l(e,t){if(!/\.(tsx?|mts|cts|jsx?|mjs|cjs)$/i.test(e)||e.endsWith(".d.ts"))return{};if(t.length>Dl)return{};let r=Cr(e,t);return r?{[e]:r}:{}}a($l,"hintsFor");function ts(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=N(r);if(!n||!r)return{};let s=pe(n),o=s.config;if(!o||s.arkRules.structure.length===0)return{};let i=Xe.dirname(n),l=Xe.resolve(r),c=Xe.relative(i,l).split(Xe.sep).join("/");if(!e(o,c))return{};let d=v(c,o.layers);return{Program(u){let f=ae(t)??Fl(l),g=_r({arkRules:s.arkRules,classShapes:Pl(c,f),files:[c],layerForFile:a(p=>p===c?d:v(p,o.layers),"layerForFile"),fileHints:$l(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(ts,"createArkRulesStructureRule");function Je(e){return typeof e?.value=="string"?e.value:void 0}a(Je,"stringValue");function Ce(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 Je(e)}}a(Ce,"staticStringValue");function Qe(e){return e?.name??Je(e)}a(Qe,"propertyName");function Lt(e,t){return t?Ce(e):Qe(e)}a(Lt,"staticKeyName");function rs(e,t){let r=z(e)?.getScope?.(t);for(;r;){let n=r.references?.find(s=>s.identifier===t);if(n)return n;r=r.upper??void 0}}a(rs,"referenceFor");function H(e,t,r){let n=rs(e,t);if(n?.resolved)return(n.resolved.defs?.length??0)>0;let s=z(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(H,"isLocallyBound");function ns(e,t){let r=rs(e,t);return r?r.isValueReference!==!1:t.parent?.type==="VariableDeclarator"&&t.parent.init===t}a(ns,"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 r=_e(e.object),n=Lt(e.property,e.computed);if(!(!r||!n))return{root:r.root,segments:[...r.segments,n]}}a(_e,"memberExpressionPath");function et(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(et,"declarationIsTypeOnly");import V from"path";function ss(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(ss,"longestForbidden");var os={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=N(t),s=G(n),o=n?V.dirname(n):null,i=null,l="this layer";if(s&&o&&t){let m=V.isAbsolute(t)?t:V.resolve(t),y=V.relative(o,m).split(V.sep).join("/");if(!M(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 z(e)?.getScope=="function",u=V.isAbsolute(t)?t:V.resolve(t),f=o?V.relative(o,u).split(V.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=Le(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=Lt(R.key,R.computed);if(!k)continue;let I=[...y,k],te=ss(c,I,y.length+1);if(te){g(R,te);continue}let re=R.value,Oe=re?.type==="AssignmentPattern"?re.left:re;A(Oe,I)}},"checkPattern"),S=a((m,y)=>{if(m?.type!=="ObjectPattern")return;let R=_e(y);if(!R||H(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=_e(m);if(!y||H(e,y.root,y.segments[0]))return;let R=y.segments[0]==="globalThis",k=R?y.segments.slice(1):y.segments,I=ss(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"&&!H(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)||!ns(e,m)||H(e,m,m.name)||g(m,m.name)}}}};import tt from"path";function is(e,t){if(!(e?.type&&e.type!=="ObjectExpression"))return e?.properties?.find(r=>Qe(r.key)===t)}a(is,"objectProperty");function ge(e,t){return is(e,t)!==void 0}a(ge,"objectHasProperty");function Ml(e){let t=is(e,"metadata")?.value;return ge(t,"source")}a(Ml,"objectHasMetadataSource");function as(e){let t=e.callee;return t?.type==="Identifier"?t.name==="publish":t?.computed!==!0&&Qe(t?.property)==="publish"}a(as,"isPublishCall");function ls(e){return e?e.type==="Identifier"||e.type===void 0&&e.name?/^[A-Z]/.test(e.name??""):e.type==="MemberExpression"&&e.computed!==!0?ls(e.property):!1:!1}a(ls,"looksLikeIntentCreator");function Kl(e){let t=Ce(e);return t!==void 0&&Ae(t)||ge(e,"intent")||ls(e)}a(Kl,"isArkPublishCandidate");function jl(e){let[t,r,n]=e;return Ml(t)||ge(r,"source")||ge(n,"source")}a(jl,"publishHasSource");function Ul(e){let t=x(e),r=N(t),n=G(r);if(!n||!r||!t)return null;let s=tt.relative(tt.dirname(r),tt.resolve(t)).split(tt.sep).join("/");return M(n,s)?s:null}a(Ul,"scopedFile");var cs={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=ct({publishCall:as(t),rawIntentName:Ce(r),objectHasIntent:ge(r,"intent"),arkPublishCandidate:!1,hasSource:!0}).find(o=>o.ruleId==="RAW_EVENT_PUBLISH");s&&_(e,t,"rawPublish",{...s,file:x(e)})}}}},ds={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=Ul(e);return t?{CallExpression(r){let n=r.arguments??[],s=n[0],i=ct({publishCall:as(r),rawIntentName:Ce(s),objectHasIntent:ge(s,"intent"),arkPublishCandidate:Kl(s),hasSource:jl(n)}).find(l=>l.ruleId==="PUBLISH_MISSING_SOURCE");i&&_(e,r,"missingSource",{...i,file:t})}}:{}}};import rt from"fs";import E from"path";function us(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(us,"skipTrivia");function Gl(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=us(t,n);continue}if(o===","){let i=us(t,n+1);if(t[i]==="}"||t[i]==="]"){n+=1;continue}}r+=o,n+=1}return r}a(Gl,"stripJsonc");function fs(e){return JSON.parse(Gl(e))}a(fs,"parseJsonc");var ps=new Map,he=new Map,Hl=64;function Dt(e){try{let t=rt.statSync(e);return`${t.mtimeMs}:${t.size}`}catch{return"missing"}}a(Dt,"fileStamp");function Y(e){try{return rt.statSync(e).isFile()}catch{return!1}}a(Y,"isFile");function gs(e){let t=E.resolve(e),r=ps.get(t);if(r!==void 0&&(r===null||Y(r)))return r;let n=E.join(t,"tsconfig.json"),s;if(Y(n))s=n;else{let o=E.dirname(t);s=o===t?null:gs(o)}return ps.set(t,s),s}a(gs,"findNearestTsconfig");function Vl(e,t){let r=e;for(;;){let n=E.join(r,"node_modules",t);for(let i of[n,`${n}.json`])if(Y(i))return i;let s=E.join(n,"package.json");if(Y(s))try{let i=JSON.parse(rt.readFileSync(s,"utf8"));if(typeof i.tsconfig=="string"&&Y(E.join(n,i.tsconfig)))return E.join(n,i.tsconfig)}catch{}if(Y(E.join(n,"tsconfig.json")))return E.join(n,"tsconfig.json");let o=E.dirname(r);if(o===r)return null;r=o}}a(Vl,"resolvePackageExtends");function Bl(e,t){let r=E.dirname(e);if(t.startsWith(".")||E.isAbsolute(t)){let n=E.resolve(r,t);for(let s of[n,`${n}.json`])if(Y(s))return s;return null}return Vl(r,t)}a(Bl,"resolveExtends");function Ft(e,t){return e.split("${configDir}").join(t)}a(Ft,"substituteConfigDir");function hs(e,t,r,n,s){if(r>8||n.has(e))return{};n.add(e),s.push({file:e,stamp:Dt(e)});let o;try{o=fs(rt.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=Ft(f,t),p=Bl(e,g);if(!p){if(g.startsWith(".")||E.isAbsolute(g)){let S=E.resolve(E.dirname(e),g);for(let m of[S,`${S}.json`])s.push({file:m,stamp:Dt(m)})}continue}let A=hs(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.dirname(e);return typeof d.baseUrl=="string"&&(i.baseUrl=E.resolve(u,Ft(d.baseUrl,t))),d.paths&&typeof d.paths=="object"&&(i.paths=d.paths,i.pathsBase=u),i}a(hs,"loadChain");function zl(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=>Ft(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(zl,"buildAliasSet");function Wl(e){let t=he.get(e);if(t&&t.chain.every(i=>Dt(i.file)===i.stamp))return t.result;let r=[],n=E.dirname(e),s=hs(e,n,0,new Set,r),o=zl(s,n);if(!he.has(e)&&he.size>=Hl){let i=he.keys().next().value;i!==void 0&&he.delete(i)}return he.set(e,{chain:r,result:o}),o}a(Wl,"aliasesForTsconfig");function ms(e){let t=gs(e);return t?Wl(t):{baseUrl:E.resolve(e),aliases:[]}}a(ms,"readTsconfigPathAliases");function ys(e){let t=[e,`${e}.ts`,`${e}.tsx`,`${e}.mts`,`${e}.cts`,`${e}.js`,`${e}.jsx`,E.join(e,"index.ts"),E.join(e,"index.tsx"),E.join(e,"index.js")];for(let r of t)if(Y(r))return r;return null}a(ys,"existingSourceFile");function As(e,t){if(!t.startsWith("."))return null;let r=E.resolve(E.dirname(e),t);return ys(r)}a(As,"resolveRelativeImport");function ql(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(ql,"matchAlias");function Pt(e,t,r){if(!t)return null;if(t.startsWith("."))return As(e,t);let n=e?E.dirname(E.resolve(e)):r??".",{baseUrl:s,aliases:o}=ms(n);for(let i of o){let l=ql(i,t);if(l!==null){for(let c of i.targets){let d=i.wildcard?c.split("*").join(l):c,u=ys(E.resolve(s,d));if(u)return u}return null}}return null}a(Pt,"resolveImportSpecifier");var Yl="4.8.24";function Zl(e){let t=e;for(;t?.parent;)t=t.parent;return t?.type==="Program"?t:void 0}a(Zl,"containingProgram");function Xl(e){let t=Zl(e)?.body;if(!t)return!1;let r=!1;for(let n of t){if(n.type==="ImportDeclaration"){if(!et(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(!et(n))return!1;r=!0;continue}return!1}}return r}a(Xl,"sourceProgramExportsOnlyTypes");var Rs={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=N(t),n=G(r),s=r?w.dirname(r):null,o=a(i=>{let l=Je(i.source);if(l&&n&&s&&t){let c=w.isAbsolute(t)?t:w.resolve(t),d=w.relative(s,c).split(w.sep).join("/");if(!M(n,d))return;let u=v(d,n.layers);if(!u)return;let f=Pt(c,l,s);if(!f)return;let g=w.relative(s,f).split(w.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=at(n.rules,u,p,A),m=S?.rule;if(m){let y=i.type?.startsWith("Export")?"export":"import",R=et(i),k=!!m?.peerIsolation,I=R&&!k,te=S?.sliceVerdict,re=te?sr({surface:"import",verdict:te,fromLayer:u,toLayer:p,kind:y,fromPath:d,toPath:g,ruleMessage:m?.message,childMessage:m?.childSlices?.message}):m?.message??`${u} must not ${y} ${p}.`,Oe=I?`${re} (type-only \u2014 type placement debt; prefer SharedTypes / owning layer; not runtime coupling)`:re;_(e,i,"forbiddenImport",{ruleId:"LAYER_IMPORT_VIOLATION",file:d,fromLayer:u,toLayer:p,target:g,edgeKind:y,...k?{peerIsolation:!0}:{},...R?{typeOnly:!0}:{},...or(te),...I?{failsStrict:!1,severity:"warning"}:{},...Xl(i)?{sourcePureTypeModule:!0}:{},message:Oe},{fromLayer:u,toLayer:p,specifier:l,message:Oe})}return}},"check");return{ImportDeclaration:o,ExportNamedDeclaration:o,ExportAllDeclaration:o}}},Jl={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=N(t),n=G(r),s=r?w.dirname(r):null;if(!n||!s||!t)return{};let o=w.isAbsolute(t)?t:w.resolve(t),i=w.relative(s,o).split(w.sep).join("/");if(!M(n,i))return{};let l=n.layers?.find(u=>u.name===v(i,n.layers));if(!l)return{};let c=new Set(cr(l));if(c.size===0)return{};let d=a((u,f,g,p)=>{if(g||typeof f!="string"||Le(f,l.forbiddenGlobals??[]))return;let A=lr(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"&&!H(e,u,"require")&&d(u,f.arguments[0].value,!1,"require")}}}},me=qr({findConfigPath:N,loadArkConfig:G,resolveImportSpecifier:Pt,lintedFilename:x,sourceIsInAnalysisScope:M,isLocallyBound:H,reportAdapterDiagnostic:_});function Ql(e,t){let r=w.dirname(w.resolve(e));return w.relative(r,w.resolve(t)).split(w.sep).join("/")}a(Ql,"toProjectRelative");var nt=mn({findConfigPath:N,loadArkConfig:G,lintedFilename:x,sourceIsInAnalysisScope:M,isLocallyBound:H,reportAdapterDiagnostic:_,toProjectRelative:Ql}),ks=ts(M),ec=[Rs,me.noArkRunKernelInDomain,me.noArkRunDirectNew,me.noArkRunTransportBypass,nt.noArkOrderKernelInDomain,nt.noArkOrderGenericUpdate,ks],tc={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:{[kt]:Kr},schema:[]},create(e){return Tt(x(e))?{}:Hr(ec.map(t=>Ge(t,e,"advisory")))}},rc=T(Rs),nc=T(cs),sc=T(ds),oc=T(os),ic=T(Jl),ac=T(me.noArkRunKernelInDomain),lc=T(me.noArkRunDirectNew),cc=T(me.noArkRunTransportBypass),dc=T(nt.noArkOrderKernelInDomain),uc=T(nt.noArkOrderGenericUpdate),fc=T(ks),pc=tc,gc={"no-domain-infra-imports":rc,"no-raw-event-publish":nc,"require-publish-source":sc,"no-forbidden-globals":oc,"no-denied-capabilities":ic,"no-arkrun-kernel-in-domain":ac,"no-arkrun-direct-new":lc,"no-arkrun-transport-bypass":cc,"no-arkorder-kernel-in-domain":dc,"no-arkorder-generic-update":uc,"arkrules-structure":fc,"architecture-advisory":pc},hc={"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"},$t={meta:{name:"arkgate",version:Yl},rules:gc};function mc(){let e=es();return{plugins:{ark:$t},rules:{...hc},...e?{settings:{ark:{contractHash:e}}}:{}}}a(mc,"recommendedConfig");var Ss={};Object.defineProperty(Ss,"recommended",{enumerable:!0,configurable:!0,get:mc});$t.configs=Ss;var cf=$t;export{pc as architectureAdvisory,fc as arkRulesStructureRule,Ss as configs,es as contractFingerprint,cf as default,N as findConfigPath,F as globToRegExp,no as isEdgeDenied,v as layerForRelativePath,Nl as loadArkConfig,uc as noArkOrderGenericUpdate,dc as noArkOrderKernelInDomain,lc as noArkRunDirectNew,ac as noArkRunKernelInDomain,cc as noArkRunTransportBypass,ic as noDeniedCapabilities,rc as noDomainInfraImports,oc as noForbiddenGlobals,nc as noRawEventPublish,Zt as patternSpecificity,$t as plugin,ms as readTsconfigPathAliases,sc as requirePublishSource,Pt as resolveImportSpecifier,As as resolveRelativeImport,gc as rules};
|